/* ══════════════════════════════════════════════════════════
   TYPE 19 SPECIALISTS — AI CHATBOT
   Agentic Concierge · Slide-Out Panel · 2026
   ══════════════════════════════════════════════════════════ */

/* ── Chat Tab (Right Edge) ── */
.t19-chat-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  z-index: 9999;
  background: var(--color-primary);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-right: none;
  padding: 16px 12px;
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.3);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 8px 0 0 8px;
  transition: background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1;
}

.t19-chat-tab:hover {
  background: var(--color-primary-hover);
}

.t19-chat-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.t19-chat-tab.hidden {
  display: none;
}

/* ── Nudge Pulse ── */
@keyframes t19-nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(113, 24, 24, 0); }
  50% { box-shadow: 0 0 0 10px rgba(113, 24, 24, 0.4); }
}

.t19-chat-tab.nudge {
  animation: t19-nudge 1.2s ease-in-out 2;
}

/* ── Panel Overlay ── */
.t19-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-medium) var(--ease-out),
              visibility var(--duration-medium);
  touch-action: none;
}

.t19-chat-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* ── Panel Container ──
   100dvh fallback covers iOS Safari's dynamic viewport (URL bar / keyboard).
   The visualViewport JS pin in chatbot.js then refines top/height on mobile. */
.t19-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  height: 100dvh;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
  border-left: 1px solid var(--color-border-strong);
  transform: translateX(100%);
  transition: transform var(--duration-medium) var(--ease-out);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.t19-chat-panel.open {
  transform: translateX(0);
}

/* ── Header ── */
.t19-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--color-surface-elevated);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.t19-chat-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t19-chat-header-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.t19-chat-header-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.t19-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.t19-chat-human-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border: 1px solid var(--color-primary-muted);
  border-radius: 4px;
  transition: background var(--duration-fast), color var(--duration-fast);
  cursor: pointer;
  background: transparent;
  white-space: nowrap;
}

.t19-chat-human-link:hover {
  background: var(--color-primary);
  color: #fff;
}

.t19-chat-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  font-size: 20px;
  transition: color var(--duration-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.t19-chat-close:hover {
  color: var(--color-text);
}

/* ── Messages Area ──
   iOS momentum scroll + contain prevents the page beneath being rubber-banded
   when the user reaches the top/bottom of the chat history. */
.t19-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--color-surface-elevated) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  min-height: 0;
}

.t19-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.t19-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.t19-chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-surface-elevated);
  border-radius: 2px;
}

/* ── Message Bubbles ── */
.t19-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text);
  word-wrap: break-word;
  flex-shrink: 0;
}

.t19-msg--bot {
  align-self: flex-start;
  background: var(--color-surface);
  border-bottom-left-radius: 2px;
}

.t19-msg--user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.t19-msg--system {
  align-self: center;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

/* ── Message Content Formatting ── */
.t19-msg strong {
  font-weight: 600;
  color: inherit;
}

.t19-msg ul {
  margin: 8px 0 0 0;
  padding-left: 18px;
  list-style: disc;
}

.t19-msg ul li {
  margin-bottom: 4px;
}

.t19-msg ul li:last-child {
  margin-bottom: 0;
}

/* ── CTA Buttons (inline in messages) ── */
.t19-msg-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast);
}

.t19-msg-cta:hover {
  background: var(--color-primary-hover);
}

.t19-msg-cta--outline {
  background: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
}

.t19-msg-cta--outline:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Suggestion Chips ── */
.t19-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin-top: 8px;
  flex-shrink: 0;
}

.t19-chat-chip {
  background: var(--color-surface-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--duration-fast),
              color var(--duration-fast),
              background var(--duration-fast);
  white-space: nowrap;
}

.t19-chat-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
  background: var(--color-primary-muted);
}

/* ── Rich Product Card ── */
.t19-product-card {
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
  max-width: 100%;
  transition: border-color var(--duration-fast);
  flex-shrink: 0;
}

.t19-product-card:hover {
  border-color: var(--color-border-strong);
}

.t19-product-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--color-surface);
}

.t19-product-card-body {
  padding: 14px 16px;
}

.t19-product-card-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 4px;
  line-height: 1.3;
}

.t19-product-card-desc {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--color-text-secondary);
  margin: 0 0 10px;
  line-height: 1.5;
}

.t19-product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.t19-product-card-price {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
}

.t19-product-card-link {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--duration-fast);
}

.t19-product-card-link:hover {
  color: var(--color-primary-hover);
}

.t19-product-card-link::after {
  content: '\2192';
}

/* ── Typing Indicator ── */
.t19-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: var(--color-surface);
  border-radius: 8px;
  border-bottom-left-radius: 2px;
  flex-shrink: 0;
}

.t19-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: t19-typing-bounce 1.4s infinite ease-in-out;
}

.t19-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.t19-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes t19-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Lead Capture Form ── */
.t19-lead-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
  align-self: flex-start;
  max-width: 85%;
  flex-shrink: 0;
}

.t19-lead-form-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 12px;
}

.t19-lead-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.t19-lead-form-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.t19-lead-form-input {
  background: var(--color-background);
  border: 1px solid var(--color-border-strong);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  outline: none;
  transition: border-color var(--duration-fast);
  width: 100%;
  box-sizing: border-box;
}

textarea.t19-lead-form-input {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

.t19-lead-form-input:focus {
  border-color: var(--color-primary);
}

.t19-lead-form-input::placeholder {
  color: var(--color-text-muted);
}

.t19-lead-form-submit {
  width: 100%;
  padding: 10px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast);
  margin-top: 4px;
}

.t19-lead-form-submit:hover {
  background: var(--color-primary-hover);
}

.t19-lead-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Input Area ── */
.t19-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.t19-chat-input {
  flex: 1;
  background: var(--color-background);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  outline: none;
  transition: border-color var(--duration-fast);
  resize: none;
}

.t19-chat-input:focus {
  border-color: var(--color-primary);
}

.t19-chat-input::placeholder {
  color: var(--color-text-muted);
}

.t19-chat-send {
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--duration-fast);
  flex-shrink: 0;
}

.t19-chat-send:hover {
  background: var(--color-primary-hover);
}

.t19-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.t19-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── Powered By ── */
.t19-chat-powered {
  text-align: center;
  padding: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

/* Multilingual note — shown once below the initial greeting */
.t19-chat-lang-note {
  margin: 4px 14px 10px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: 4px;
  letter-spacing: 0.01em;
}
.t19-chat-lang-note span {
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* ── Mobile Responsive ── */
@media (max-width: 520px) {
  .t19-chat-panel {
    width: 100%;
    max-width: 100%;
    border-left: none;
  }

  .t19-chat-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .t19-chat-tab {
    top: auto;
    bottom: 20px;
    transform: rotate(-90deg) translateX(50%);
  }
}

@media (min-width: 521px) and (max-width: 768px) {
  .t19-chat-panel {
    width: 100%;
    max-width: 400px;
  }
}
