/* ============================================================
   WEBCHAT V2 — Two-Column AI Chat Layout
   Column 1: AI Chat | Column 2: FAQs, Knowledge Base, Quick Tools
   Mobile-first responsive design
   ============================================================ */

/* ── LAYOUT SHELL ─────────────────────────────────────── */
.wc-v2-shell {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #F0F4F8 0%, #FAFAFA 100%);
}

/* ── COLUMN 1: CHAT ───────────────────────────────────── */
.wc-v2-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid rgba(0,0,0,0.06);
}

/* ── COLUMN 2: SIDEBAR ────────────────────────────────── */
.wc-v2-sidebar {
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  overflow: hidden;
}

.wc-v2-sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: linear-gradient(135deg, rgba(124,58,237,0.03), rgba(20,184,166,0.03));
}

.wc-v2-sidebar-title {
  font-size: 15px;
  font-weight: 900;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.wc-v2-sidebar-title i {
  color: #7C3AED;
  font-size: 14px;
}

.wc-v2-sidebar-sub {
  font-size: 11px;
  color: #9CA3AF;
  font-weight: 600;
}

/* Sidebar Search */
.wc-v2-kb-search {
  position: relative;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.wc-v2-kb-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,0.07);
  background: #F8FAFC;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: #111827;
  outline: none;
  transition: all 0.2s;
}

.wc-v2-kb-search input:focus {
  border-color: rgba(124,58,237,0.3);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.06);
}

.wc-v2-kb-search input::placeholder { color: #9CA3AF; }

.wc-v2-kb-search i {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  font-size: 12px;
}

/* Sidebar Tabs */
.wc-v2-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: #FAFAFA;
}

.wc-v2-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #9CA3AF;
  text-align: center;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.wc-v2-tab:hover { color: #7C3AED; }

.wc-v2-tab.active {
  color: #7C3AED;
  border-bottom-color: #7C3AED;
  background: rgba(124,58,237,0.03);
}

.wc-v2-tab i { font-size: 12px; }

/* Sidebar Scroll Content */
.wc-v2-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.wc-v2-sidebar-content::-webkit-scrollbar { width: 4px; }
.wc-v2-sidebar-content::-webkit-scrollbar-track { background: transparent; }
.wc-v2-sidebar-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

/* Tab Panels */
.wc-v2-panel { display: none; padding: 16px 20px; }
.wc-v2-panel.active { display: block; }

/* ── FAQ ACCORDION ────────────────────────────────────── */
.wc-v2-faq-group { margin-bottom: 20px; }

.wc-v2-faq-group-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9CA3AF;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wc-v2-faq-item {
  background: #F8FAFC;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px;
  margin-bottom: 6px;
  overflow: hidden;
  transition: all 0.2s;
}

.wc-v2-faq-item:hover {
  border-color: rgba(124,58,237,0.15);
}

.wc-v2-faq-item summary {
  padding: 12px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: #111827;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
}

.wc-v2-faq-item summary::-webkit-details-marker { display: none; }

.wc-v2-faq-item summary .faq-q-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(124,58,237,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #7C3AED;
  flex-shrink: 0;
}

.wc-v2-faq-item summary .faq-chevron {
  margin-left: auto;
  font-size: 10px;
  color: #9CA3AF;
  transition: transform 0.2s;
}

.wc-v2-faq-item[open] summary .faq-chevron {
  transform: rotate(180deg);
}

.wc-v2-faq-item[open] {
  background: rgba(124,58,237,0.02);
  border-color: rgba(124,58,237,0.12);
}

.wc-v2-faq-answer {
  padding: 0 14px 14px 48px;
  font-size: 12px;
  color: #4B5563;
  line-height: 1.7;
}

.wc-v2-faq-answer a {
  color: #7C3AED;
  font-weight: 700;
}

.wc-v2-faq-ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.wc-v2-faq-ask-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
}

/* ── KNOWLEDGE BASE CARDS ─────────────────────────────── */
.wc-v2-kb-cards { display: flex; flex-direction: column; gap: 10px; }

.wc-v2-kb-card {
  background: #F8FAFC;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  gap: 12px;
}

.wc-v2-kb-card:hover {
  border-color: rgba(20,184,166,0.25);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.wc-v2-kb-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.wc-v2-kb-card-body { flex: 1; min-width: 0; }

.wc-v2-kb-card-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 3px;
  line-height: 1.3;
}

.wc-v2-kb-card-desc {
  font-size: 11px;
  color: #6B7280;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wc-v2-kb-card-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 10px;
  color: #9CA3AF;
  font-weight: 600;
}

/* ── QUICK TOOLS PANEL ────────────────────────────────── */
.wc-v2-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wc-v2-tool-card {
  background: #F8FAFC;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: block;
}

.wc-v2-tool-card:hover {
  border-color: rgba(124,58,237,0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.wc-v2-tool-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}

.wc-v2-tool-name {
  font-size: 11px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 2px;
}

.wc-v2-tool-desc {
  font-size: 10px;
  color: #9CA3AF;
  font-weight: 600;
}

/* ── EMERGENCY CARD ───────────────────────────────────── */
.wc-v2-emergency {
  margin-top: 16px;
  background: rgba(239,68,68,0.04);
  border: 1px solid rgba(239,68,68,0.12);
  border-radius: 14px;
  padding: 14px;
}

.wc-v2-emergency-title {
  font-size: 12px;
  font-weight: 800;
  color: #DC2626;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wc-v2-emergency-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wc-v2-sos-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.wc-v2-sos-btn.crisis {
  background: rgba(239,68,68,0.08);
  color: #DC2626;
  border: 1px solid rgba(239,68,68,0.15);
}

.wc-v2-sos-btn.police {
  background: rgba(59,130,246,0.06);
  color: #2563EB;
  border: 1px solid rgba(59,130,246,0.12);
}

.wc-v2-sos-btn.child {
  background: rgba(245,158,11,0.06);
  color: #D97706;
  border: 1px solid rgba(245,158,11,0.12);
}

.wc-v2-sos-btn:hover { transform: translateX(2px); }

/* ── AI SUGGESTIONS ───────────────────────────────────── */
.wc-v2-ai-suggestions {
  padding: 12px 20px;
  border-top: 1px solid rgba(0,0,0,0.04);
  background: rgba(124,58,237,0.02);
}

.wc-v2-ai-suggestions-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9CA3AF;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wc-v2-ai-suggestions-label i { color: #7C3AED; }

.wc-v2-suggestion-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.wc-v2-suggestion-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  background: #fff;
  border: 1px solid rgba(124,58,237,0.15);
  color: #7C3AED;
  cursor: pointer;
  transition: all 0.2s;
}

.wc-v2-suggestion-chip:hover {
  background: rgba(124,58,237,0.06);
  border-color: rgba(124,58,237,0.3);
}

/* ── MOBILE TOGGLE ────────────────────────────────────── */
.wc-v2-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 16px;
  z-index: 200;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #A855F7);
  color: #fff;
  font-size: 18px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.wc-v2-mobile-toggle:hover {
  transform: scale(1.1);
}

/* ── MOBILE SIDEBAR OVERLAY ───────────────────────────── */
.wc-v2-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.wc-v2-sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0,0,0,0.05);
  border: none;
  color: #4B5563;
  font-size: 14px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* ── RESPONSIVE ───────────────────────────────────── */
@media (max-width: 1024px) {
  .wc-v2-shell {
    grid-template-columns: 1fr;
  }

  .wc-v2-chat {
    border-right: none;
  }

  .wc-v2-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    bottom: 0;
    width: 85%;
    max-width: 400px;
    z-index: 400;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 40px rgba(0,0,0,0.15);
  }

  .wc-v2-sidebar.open {
    right: 0;
  }

  .wc-v2-sidebar-overlay.open {
    display: block;
  }

  .wc-v2-mobile-toggle {
    display: flex;
  }

  .wc-v2-sidebar-close {
    display: flex;
  }
}

@media (max-width: 768px) {
  /* Webchat header compact */
  .webchat-header {
    padding: 10px 12px !important;
    gap: 10px !important;
  }

  .webchat-header .back-btn {
    width: 34px;
    height: 34px;
    min-height: auto;
  }

  .webchat-header .chat-avatar,
  .webchat-header .chat-avatar img {
    width: 36px !important;
    height: 36px !important;
  }

  .privacy-pill {
    padding: 4px 8px;
    font-size: 9px;
    gap: 4px;
  }

  .privacy-pill i { font-size: 9px; }

  /* TTS + dark toggle smaller */
  #ttsToggle, #darkToggle {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
  }

  /* Webchat body */
  .webchat-body {
    padding: 12px !important;
    gap: 8px !important;
  }

  /* Message bubbles */
  .msg-text {
    font-size: 13px !important;
    padding: 10px 13px !important;
    max-width: 88% !important;
  }

  /* Input area */
  .wc-input-area {
    padding: 8px 10px !important;
  }

  .wc-input-row {
    gap: 6px !important;
    padding: 0 !important;
  }

  .wc-input {
    font-size: 16px !important; /* Prevent iOS zoom */
    padding: 10px 14px !important;
    min-height: 42px !important;
    border-radius: 12px !important;
  }

  .wc-send {
    width: 42px !important;
    height: 42px !important;
    min-height: auto !important;
    border-radius: 12px !important;
    font-size: 15px !important;
  }

  .wc-mic {
    width: 38px !important;
    height: 38px !important;
    font-size: 13px !important;
  }

  .wc-footer-note {
    font-size: 9px !important;
    margin-top: 4px !important;
  }

  /* Language switcher */
  .lang-switcher {
    padding: 6px 10px !important;
    gap: 4px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    flex-wrap: nowrap !important;
  }
  .lang-switcher::-webkit-scrollbar { display: none !important; }

  .lang-btn {
    flex-shrink: 0 !important;
    padding: 5px 10px !important;
    font-size: 11px !important;
    min-height: 32px !important;
  }

  /* Quick replies */
  .wc-quick-replies {
    padding: 6px 10px !important;
    gap: 5px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .wc-quick-replies::-webkit-scrollbar { display: none !important; }

  .qr-chip {
    flex-shrink: 0 !important;
    font-size: 11px !important;
    padding: 6px 12px !important;
    min-height: auto !important;
  }

  /* Trending chips */
  .wc-trending {
    padding: 6px 10px 0 !important;
  }

  .wc-trending-chip {
    font-size: 10px !important;
    padding: 4px 10px !important;
  }

  /* Crisis banner */
  .crisis-banner-v2 {
    padding: 10px 12px !important;
  }

  .cb-call-btns {
    flex-direction: column !important;
    gap: 6px !important;
  }

  .cb-call-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px !important;
    font-size: 12px !important;
  }

  /* Mobile sidebar toggle */
  .wc-v2-mobile-toggle {
    bottom: 80px;
    right: 12px;
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  /* Disclaimer modal */
  .wc-disclaimer {
    margin: 12px !important;
    padding: 16px !important;
  }

  .wc-disclaimer h3 { font-size: 14px !important; }
  .wc-disclaimer p { font-size: 11px !important; }

  .btn-accept {
    padding: 10px 20px !important;
    font-size: 12px !important;
  }
}

@media (max-width: 480px) {
  .wc-v2-sidebar {
    width: 100%;
    max-width: none;
  }

  .wc-v2-tools-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .wc-v2-tool-card {
    padding: 10px;
  }

  .wc-v2-tool-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    margin-bottom: 6px;
  }

  .wc-v2-tool-name { font-size: 10px; }
  .wc-v2-tool-desc { font-size: 9px; }

  .webchat-header {
    padding: 8px 10px !important;
  }

  /* Hide "Zero Footprint" text, keep lock icon */
  .privacy-pill span:not(.fa-lock) { display: none; }

  /* AI mode label */
  #aiModeLabel { display: none !important; }

  /* Sidebar panels compact */
  .wc-v2-panel { padding: 12px 14px; }

  .wc-v2-faq-item summary {
    padding: 10px 12px;
    font-size: 12px;
  }

  .wc-v2-faq-answer {
    padding: 0 12px 12px 36px;
    font-size: 11px;
  }

  .wc-v2-kb-card {
    padding: 10px;
    gap: 10px;
  }

  .wc-v2-kb-card-title { font-size: 11.5px; }
  .wc-v2-kb-card-desc { font-size: 10px; }

  /* Emergency card */
  .wc-v2-emergency { padding: 10px; }
  .wc-v2-sos-btn { padding: 8px 10px; font-size: 10px; }

  /* AI suggestions compact */
  .wc-v2-ai-suggestions { padding: 10px 14px; }
  .wc-v2-suggestion-chip { padding: 4px 10px; font-size: 9px; }
}

/* ── SAFE AREA (notched phones) ───────────────────── */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .wc-input-area {
      padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }
    .crisis-banner-v2 {
      padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    }
  }
}

/* ── CONTEXT-AWARE AI BADGE ───────────────────────────── */
.wc-v2-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(168,85,247,0.06));
  border: 1px solid rgba(124,58,237,0.15);
  color: #7C3AED;
}

.wc-v2-ai-badge .ai-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10B981;
  animation: pulse 2s infinite;
}

/* ── SIDEBAR TOPIC TAGS ───────────────────────────────── */
.wc-v2-topic-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.wc-v2-topic-tag {
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 10px;
  font-weight: 700;
  background: #F3F4F6;
  border: 1px solid rgba(0,0,0,0.05);
  color: #4B5563;
  cursor: pointer;
  transition: all 0.2s;
}

.wc-v2-topic-tag:hover,
.wc-v2-topic-tag.active {
  background: rgba(124,58,237,0.08);
  border-color: rgba(124,58,237,0.2);
  color: #7C3AED;
}

/* ── RELATED ARTICLES (shown contextually) ────────────── */
.wc-v2-related {
  padding: 14px 20px;
  border-top: 1px solid rgba(0,0,0,0.04);
  background: rgba(20,184,166,0.02);
}

.wc-v2-related-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #0D9488;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wc-v2-related-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 700;
  color: #111827;
  cursor: pointer;
  transition: color 0.2s;
}

.wc-v2-related-item:hover { color: #7C3AED; }

.wc-v2-related-item i {
  color: #14B8A6;
  font-size: 10px;
}
