/* S7 Digital Chat Widget */
#cw-root {
  --cw-purple: #7C3AED;
  --cw-white: #ffffff;
  --cw-black: #111827;
  --cw-gray-600: #6B7280;
  --cw-gray-500: #9CA3AF;
  --cw-gray-300: #E5E7EB;
  --cw-gray-200: #F3F4F6;
  font-family: "Inter", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#cw-root *, #cw-root *::before, #cw-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
}

/* ── Trigger/FAB ──────────────────────────────────────────────────────────── */
#cw-root .widget-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--cw-purple);
  color: var(--cw-white);
  box-shadow: 0 12px 30px rgba(124,58,237,0.35);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 9999;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#cw-root .widget-trigger:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(124,58,237,0.42);
}
#cw-root .widget-trigger svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
#cw-root .chat-widget {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: var(--cw-white);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9998;
}
#cw-root .chat-widget.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
#cw-root .screen {
  display: none;
  flex-direction: column;
  background: var(--cw-white);
}
#cw-root .screen.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Scrollable areas ─────────────────────────────────────────────────────── */
#cw-root .home-main,
#cw-root .help-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}
#cw-root .home-main::-webkit-scrollbar,
#cw-root .messages-main::-webkit-scrollbar,
#cw-root .help-main::-webkit-scrollbar { width: 4px; }
#cw-root .home-main::-webkit-scrollbar-thumb,
#cw-root .messages-main::-webkit-scrollbar-thumb,
#cw-root .help-main::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }

/* ── Messages ─────────────────────────────────────────────────────────────── */
#cw-root .messages-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
}
#cw-root .home-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
#cw-root .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#cw-root .logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #1f2937;
}
#cw-root .icon-btn {
  border: 0;
  background: transparent;
  color: var(--cw-gray-500);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
#cw-root .icon-btn:hover { background: #f5f6f8; color: #6b7280; }

/* ── Home text ────────────────────────────────────────────────────────────── */
#cw-root .greeting {
  margin-top: 20px;
  font-size: 16px;
  font-weight: 500;
  color: var(--cw-gray-600);
}
#cw-root .headline {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--cw-black);
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
#cw-root .cards { display: grid; gap: 8px; }
#cw-root .card {
  width: 100%;
  border: 1px solid var(--cw-gray-300);
  background: var(--cw-white);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
#cw-root .card.small { padding: 12px; }
#cw-root .card:hover { border-color: #d8dbe1; background: #fcfcfd; }
#cw-root .card-icon,
#cw-root .arrow-icon { flex-shrink: 0; color: #6b7280; }
#cw-root .card-copy { flex: 1; min-width: 0; }
#cw-root .card-title {
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.25;
  display: block;
}
#cw-root .card-desc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--cw-gray-600);
  line-height: 1.35;
  display: block;
}
#cw-root .section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--cw-gray-500);
}
#cw-root .question-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

/* ── Bottom nav ───────────────────────────────────────────────────────────── */
#cw-root .bottom-nav {
  position: relative;
  height: 56px;
  border-top: 1px solid var(--cw-gray-200);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--cw-white);
  padding: 0 6px;
  flex: none;
}
#cw-root .nav-item {
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--cw-gray-500);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: color 0.15s;
}
#cw-root .nav-item svg { width: 18px; height: 18px; }
#cw-root .nav-item.active { color: var(--cw-purple); }

#cw-root .message {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}
#cw-root .message.bot {
  align-self: flex-start;
  background: var(--cw-gray-200);
  color: #1f2937;
  border-bottom-left-radius: 8px;
}
#cw-root .message.user {
  align-self: flex-end;
  background: var(--cw-purple);
  color: #fff;
  border-bottom-right-radius: 8px;
}

/* ── Typing dots ──────────────────────────────────────────────────────────── */
#cw-root .typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 2px 0;
}
#cw-root .typing-dots span {
  width: 7px; height: 7px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: cw-bounce 1.1s ease-in-out infinite;
}
#cw-root .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
#cw-root .typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes cw-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Input bar ────────────────────────────────────────────────────────────── */
#cw-root .input-bar {
  border-top: 1px solid var(--cw-gray-200);
  display: flex;
  align-items: center;
  padding: 10px 12px;
  gap: 8px;
  flex: none;
}
#cw-root .input-bar input {
  flex: 1;
  border: 1px solid #e6e8ec;
  border-radius: 999px;
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
}
#cw-root .input-bar input::placeholder { color: #9CA3AF; }
#cw-root .input-bar input:focus {
  border-color: #d3c2fb;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
#cw-root .input-bar input:disabled { opacity: 0.5; }
#cw-root .send-btn {
  width: 36px; height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cw-purple);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
#cw-root .send-btn:hover:not(:disabled) { background: #6D28D9; }
#cw-root .send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Help screen ──────────────────────────────────────────────────────────── */
#cw-root .help-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#cw-root .help-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--cw-black);
  margin-top: 8px;
}

/* ── FAQ accordion ────────────────────────────────────────────────────────── */
#cw-root .faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#cw-root .faq-item {
  border: 1px solid var(--cw-gray-300);
  border-radius: 10px;
  overflow: hidden;
}
#cw-root .faq-q {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  transition: background 0.12s;
}
#cw-root .faq-q:hover { background: #f9fafb; }
#cw-root .faq-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--cw-gray-500);
  transition: transform 0.2s ease;
}
#cw-root .faq-item.open .faq-chevron { transform: rotate(180deg); }
#cw-root .faq-a {
  display: none;
  padding: 0 16px 14px;
  font-size: 13px;
  color: var(--cw-gray-600);
  line-height: 1.55;
}
#cw-root .faq-item.open .faq-a { display: block; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 460px) {
  #cw-root .chat-widget {
    width: calc(100vw - 28px);
    height: calc(100svh - 110px);
    right: 14px;
  }
}
