/* ─── FAQ Chatbot Wizard v4 — Full-Screen Sheet (all devices) ────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent:         #4F46E5;
  --accent-hover:   #4338CA;
  --accent-light:   #EEF2FF;
  --accent-text:    #4338CA;

  --bg:             #ffffff;
  --bg-secondary:   #F8F8F7;
  --bg-hover:       #F0EFFF;
  --bg-warning:     #FFFBEB;

  --text-primary:   #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-muted:     #9B9B9B;
  --text-warning:   #92400E;

  --border:         rgba(0,0,0,0.09);
  --border-strong:  rgba(0,0,0,0.16);
  --border-warning: rgba(217,119,6,0.40);

  --shadow-launcher: 0 4px 18px rgba(79,70,229,0.50);
  --shadow-widget:   0 -4px 40px rgba(0,0,0,0.13), 0 -1px 6px rgba(0,0,0,0.06);

  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font: 'DM Sans', system-ui, sans-serif;

  /* Sheet height — leaves a gap at top so the page peeks through */
  --sheet-height: 88vh;
  --launcher-size: 60px;
  --launcher-bottom: 24px;
  --launcher-right: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:             #1C1C1C;
    --bg-secondary:   #252525;
    --bg-hover:       #2A2952;
    --bg-warning:     #2D2000;
    --text-primary:   #F0F0F0;
    --text-secondary: #A0A0A0;
    --text-muted:     #666666;
    --text-warning:   #FCD34D;
    --border:         rgba(255,255,255,0.09);
    --border-strong:  rgba(255,255,255,0.16);
    --border-warning: rgba(217,119,6,0.50);
    --accent-light:   #2D2B5A;
    --accent-text:    #818CF8;
    --shadow-widget:  0 -4px 40px rgba(0,0,0,0.40);
  }
}

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text-primary);
}

/* ── Demo page ── */
.demo-page {
  max-width: 720px;
  margin: 80px auto;
  padding: 0 24px;
}
.demo-page h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 16px;
}
.demo-page p {
  font-size: 16px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 10px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FLOATING LAUNCHER BUTTON (round, all screen sizes)
───────────────────────────────────────────────────────────────────────────── */

#chat-launcher {
  position: fixed;
  bottom: var(--launcher-bottom);
  right: var(--launcher-right);
  z-index: 9999;

  width: var(--launcher-size);
  height: var(--launcher-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: var(--shadow-launcher);
  transition: background 0.2s, transform 0.25s cubic-bezier(.34,1.56,.64,1);
}

#chat-launcher:hover {
  background: var(--accent-hover);
  transform: scale(1.08);
}

#chat-launcher:active {
  transform: scale(0.96);
}

/* Icon swap */
.open-icon, .close-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
}
.close-icon            { opacity: 0; transform: rotate(-90deg) scale(0.7); }
.chat-open .open-icon  { opacity: 0; transform: rotate(90deg)  scale(0.7); }
.chat-open .close-icon { opacity: 1; transform: rotate(0deg)   scale(1);   }

/* Unread badge */
#unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #EF4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  pointer-events: none;
  transition: transform 0.2s, opacity 0.2s;
}

#unread-badge.hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CHAT WIDGET — BOTTOM SHEET (all screen sizes)
───────────────────────────────────────────────────────────────────────────── */

#chat-widget {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9998;

  height: var(--sheet-height);
  max-width: 640px;       /* cap width on large screens, centered */
  margin: 0 auto;

  background: transparent;
  pointer-events: none;

  /* Slide up animation */
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(.32,.72,0,1);
}

#chat-widget.open {
  pointer-events: all;
  transform: translateY(0);
}

/* Backdrop overlay (dims the page behind the sheet) */
#chat-widget::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: -1;
}

#chat-widget.open::before {
  opacity: 1;
  pointer-events: all;
}

/* Inner card — the actual white sheet */
#chat-inner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  box-shadow: var(--shadow-widget);
  overflow: hidden;
}

/* Drag handle pill at top of sheet */
#chat-inner::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CHAT HEADER
───────────────────────────────────────────────────────────────────────────── */

#chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 14px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#chat-header-info { flex: 1; min-width: 0; }

#chat-header-info h1 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#chat-header-info p {
  font-size: 12px;
  color: var(--text-secondary);
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.22);
}

#close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 0.5px solid var(--border-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

#close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   FAQ HORIZONTAL SCROLL BAR (replaces sidebar)
───────────────────────────────────────────────────────────────────────────── */

#faq-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.faq-bar-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

#faq-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
}

#faq-scroll::-webkit-scrollbar { display: none; }

.faq-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 0.5px solid var(--border-strong);
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-primary);
  font-family: var(--font);
  transition: all 0.15s;
  flex-shrink: 0;
}

.faq-pill:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.faq-pill-count {
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.faq-pill:hover .faq-pill-count {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

.faq-pill-count.zero {
  background: var(--border-strong);
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────────────────────
   MESSAGES
───────────────────────────────────────────────────────────────────────────── */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}

#messages::-webkit-scrollbar { width: 3px; }
#messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.msg {
  display: flex;
  gap: 9px;
  max-width: 86%;
  animation: fadeUp 0.22s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
}

.msg-avatar.user-av {
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 500;
}

.msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 0.5px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 18px;
}

.msg-bubble strong, .msg-bubble b { font-weight: 500; }
.msg-bubble a { color: var(--accent-text); }
.msg.user .msg-bubble a { color: rgba(255,255,255,0.85); }

.answer-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 7px;
}

/* Sorry box */
.sorry-box {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border-warning);
  background: var(--bg-warning);
  font-size: 13px;
  color: var(--text-warning);
  line-height: 1.6;
}

.sorry-box a {
  color: var(--text-warning);
  font-weight: 500;
  text-decoration: underline;
}

/* Wizard chips */
.wizard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  padding: 6px 13px;
  border-radius: 20px;
  border: 0.5px solid var(--border-strong);
  background: var(--bg);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Typing indicator */
.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
  padding: 0 2px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 0.9s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ─────────────────────────────────────────────────────────────────────────────
   INPUT AREA
───────────────────────────────────────────────────────────────────────────── */

#input-area {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--bg);
}

#user-input {
  flex: 1;
  border: 0.5px solid var(--border-strong);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 0.15s, background 0.15s;
}

#user-input::placeholder { color: var(--text-muted); }
#user-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}

#send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

#send-btn:hover  { background: var(--accent-hover); }
#send-btn:active { transform: scale(0.93); }
