/* ============================================================
   FinAcc lead-capture chatbot widget
   Include before </body>:
     <link rel="stylesheet" href="/assets/css/finacc-chatbot.css">
     <script src="/assets/js/finacc-chatbot.js" defer></script>
   ============================================================ */

:root {
  --fa-cb-gold: #E8930A;
  --fa-cb-gold-dark: #9C5A09;
  --fa-cb-action: #A8620A;
  --fa-cb-action-dark: #8E5208;
  --fa-cb-soft: #FDF4E3;
  --fa-cb-ink: #1B1A17;
  --fa-cb-body: #44403A;
  --fa-cb-muted: #6E6961;
  --fa-cb-line: #E4E0D8;
  --fa-cb-surface: #FFFFFF;
  --fa-cb-surface-2: #F8F6F2;
  --fa-cb-green: #1E7A4F;
  --fa-cb-red: #A8321E;
  --fa-cb-radius: 14px;
  --fa-cb-shadow: 0 8px 28px -10px rgba(27, 26, 23, 0.45), 0 2px 6px rgba(27, 26, 23, 0.08);
}

/* Floating launcher — above desktop WhatsApp (.fa-wafloat 56px @ bottom:18px)
   and above mobile sticky Call/WA bar (handled in the max-width:820px block). */
.fa-cb-launcher {
  position: fixed;
  right: 18px;
  bottom: 90px;
  z-index: 9500;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border: none;
  border-radius: 999px;
  background: var(--fa-cb-action);
  color: #fff;
  font: 600 0.95rem/1.2 Roboto, system-ui, sans-serif;
  cursor: pointer;
  box-shadow: var(--fa-cb-shadow);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.fa-cb-launcher:hover,
.fa-cb-launcher:focus-visible {
  background: var(--fa-cb-action-dark);
  outline: none;
  transform: translateY(-1px);
}
.fa-cb-launcher:active { transform: translateY(0); }
.fa-cb-launcher[aria-expanded="true"] { background: var(--fa-cb-ink); }
.fa-cb-launcher__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.fa-cb-launcher__icon svg { width: 16px; height: 16px; fill: currentColor; }
.fa-cb-launcher__label { white-space: nowrap; }

/* Panel */
.fa-cb-panel {
  position: fixed;
  right: 18px;
  bottom: 156px;
  z-index: 9501;
  width: min(360px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 110px));
  display: none;
  flex-direction: column;
  background: var(--fa-cb-surface);
  border: 1px solid var(--fa-cb-line);
  border-radius: var(--fa-cb-radius);
  box-shadow: var(--fa-cb-shadow);
  overflow: hidden;
  font: 400 0.95rem/1.45 Roboto, system-ui, sans-serif;
  color: var(--fa-cb-body);
}
.fa-cb-panel[data-open="1"] { display: flex; }

.fa-cb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, var(--fa-cb-soft) 0%, #fff 70%);
  border-bottom: 1px solid var(--fa-cb-line);
}
.fa-cb-head__avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--fa-cb-gold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  flex: none;
}
.fa-cb-head__meta { flex: 1; min-width: 0; }
.fa-cb-head__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--fa-cb-ink);
  line-height: 1.25;
}
.fa-cb-head__sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--fa-cb-muted);
}
.fa-cb-head__close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fa-cb-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  flex: none;
}
.fa-cb-head__close:hover,
.fa-cb-head__close:focus-visible {
  background: var(--fa-cb-surface-2);
  color: var(--fa-cb-ink);
  outline: none;
}

.fa-cb-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--fa-cb-surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.fa-cb-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.fa-cb-bubble--bot {
  align-self: flex-start;
  background: var(--fa-cb-surface);
  border: 1px solid var(--fa-cb-line);
  color: var(--fa-cb-ink);
  border-bottom-left-radius: 4px;
}
.fa-cb-bubble--user {
  align-self: flex-end;
  background: var(--fa-cb-action);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.fa-cb-bubble--ok {
  align-self: stretch;
  max-width: 100%;
  background: #E4F1EA;
  border: 1px solid #B9D9C8;
  color: var(--fa-cb-green);
  text-align: center;
  font-weight: 600;
  border-radius: 10px;
}
.fa-cb-bubble--err {
  align-self: stretch;
  max-width: 100%;
  background: #FBE9E6;
  border: 1px solid #EFC4BC;
  color: var(--fa-cb-red);
  font-size: 0.86rem;
  border-radius: 10px;
}

.fa-cb-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--fa-cb-surface);
  border: 1px solid var(--fa-cb-line);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.fa-cb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fa-cb-muted);
  opacity: 0.45;
  animation: fa-cb-dot 1.2s infinite ease-in-out;
}
.fa-cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.fa-cb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes fa-cb-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.fa-cb-foot {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--fa-cb-line);
  background: var(--fa-cb-surface);
}
.fa-cb-inputrow {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.fa-cb-input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--fa-cb-line);
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  color: var(--fa-cb-ink);
  background: var(--fa-cb-surface);
}
.fa-cb-input:focus {
  outline: none;
  border-color: var(--fa-cb-gold);
  box-shadow: 0 0 0 3px rgba(232, 147, 10, 0.18);
}
.fa-cb-input:disabled {
  background: var(--fa-cb-surface-2);
  color: var(--fa-cb-muted);
}
.fa-cb-send {
  flex: none;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: var(--fa-cb-action);
  color: #fff;
  font: 600 0.9rem/1 Roboto, system-ui, sans-serif;
  cursor: pointer;
}
.fa-cb-send:hover:not(:disabled),
.fa-cb-send:focus-visible:not(:disabled) {
  background: var(--fa-cb-action-dark);
  outline: none;
}
.fa-cb-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.fa-cb-hint {
  margin: 8px 2px 0;
  font-size: 0.75rem;
  color: var(--fa-cb-muted);
  line-height: 1.35;
}
.fa-cb-skip {
  margin-top: 8px;
  border: none;
  background: none;
  color: var(--fa-cb-gold-dark);
  font: 600 0.82rem/1.3 Roboto, system-ui, sans-serif;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.fa-cb-skip:hover { color: var(--fa-cb-action-dark); }

.fa-cb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Mobile: clear sticky Call/WA bar (fa-stickybar ~56px) */
@media (max-width: 720px) {
  .fa-cb-launcher {
    right: 12px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 11px 15px 11px 12px;
    font-size: 0.9rem;
  }
  .fa-cb-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - 140px - env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .fa-cb-launcher,
  .fa-cb-typing span { transition: none; animation: none; }
}
