/* ==========================================================================
   FOSTER ASSISTANT — guided conversion helper widget
   Built on Foster --fc-* tokens. Uses a FIXED dark surface for the panel
   header/launcher (not the theme-flipping --fc-navy-ink) so it stays
   legible in light AND dark mode. Respects prefers-reduced-motion.
   ========================================================================== */
#fca-root {
  --fca-navy: #0B1A35;         /* fixed dark — never flips with theme */
  --fca-navy-2: #13294d;
  --fca-accent: #1F6FB2;       /* Foster oval blue */
  --fca-surface: var(--fc-paper, #fff);
  --fca-ink: var(--fc-navy-ink, #0B1A35);
  --fca-muted: var(--fc-steel-500, #5C6473);
  --fca-line: var(--fc-steel-100, #E5E7EB);
  --fca-bot-bg: var(--fc-mist, #F4F6F8);
  position: fixed;
  right: clamp(14px, 3vw, 26px);
  bottom: clamp(14px, 3vw, 26px);
  z-index: 2147483000;         /* above nav/modals */
  font-family: var(--fc-font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

/* ── Launcher ── */
.fca-launcher {
  width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--fca-navy); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(11, 26, 53, .28);
  transition: transform .18s ease, box-shadow .18s ease;
  margin-left: auto;
}
.fca-launcher::after {                     /* small orange status dot */
  content: ""; position: absolute; margin: -22px 0 0 22px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--fca-accent); border: 2px solid var(--fca-navy);
}
.fca-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(11, 26, 53, .34); }
.fca-launcher:focus-visible { outline: 3px solid var(--fca-accent); outline-offset: 3px; }
#fca-root.is-open .fca-launcher { transform: scale(.9); opacity: .85; }

/* ── Nudge bubble ── */
.fca-bubble {
  max-width: 260px; margin: 0 0 12px auto;
  background: var(--fca-surface); color: var(--fca-ink);
  border: 1px solid var(--fca-line); border-radius: 14px 14px 4px 14px;
  padding: 12px 15px; font-size: 14px; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(11, 26, 53, .18);
  cursor: pointer;
  animation: fca-pop .28s ease both;
}
.fca-bubble[hidden] { display: none; }

/* ── Panel ── */
.fca-panel {
  position: absolute; right: 0; bottom: 74px;
  width: min(370px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  background: var(--fca-surface);
  border: 1px solid var(--fca-line);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(11, 26, 53, .34);
  animation: fca-pop .22s ease both;
}
.fca-panel[hidden] { display: none; }

.fca-head {
  background: var(--fca-navy); color: #fff;
  padding: 15px 16px; display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto;
}
.fca-head-id { display: flex; align-items: center; gap: 11px; }
.fca-dot { width: 9px; height: 9px; border-radius: 50%; background: #37d67a; box-shadow: 0 0 0 3px rgba(55,214,122,.25); flex: 0 0 auto; }
.fca-head strong { display: block; font-size: 15px; font-weight: 700; }
.fca-sub { display: block; font-size: 11px; color: rgba(255,255,255,.6); letter-spacing: .02em; margin-top: 1px; }
.fca-close {
  background: transparent; border: none; color: rgba(255,255,255,.7);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.fca-close:hover { color: #fff; }
.fca-close:focus-visible { outline: 2px solid var(--fca-accent); outline-offset: 2px; border-radius: 4px; }

.fca-body {
  flex: 1 1 auto; overflow-y: auto;
  padding: 18px 16px; display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}

/* messages */
.fca-msg {
  max-width: 88%; padding: 11px 14px; font-size: 14px; line-height: 1.5;
  border-radius: 14px; word-wrap: break-word;
}
.fca-msg-bot { align-self: flex-start; background: var(--fca-bot-bg); color: var(--fca-ink); border-bottom-left-radius: 4px; }
.fca-msg-user { align-self: flex-end; background: var(--fca-accent); color: #fff; border-bottom-right-radius: 4px; }

/* option chips (buttons + links look identical) */
.fca-opts { display: flex; flex-direction: column; gap: 8px; align-self: stretch; margin-top: 2px; }
.fca-opt {
  display: block; width: 100%; text-align: left;
  background: var(--fca-surface); color: var(--fca-accent);
  border: 1px solid var(--fca-accent); border-radius: 12px;
  padding: 11px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  text-decoration: none; font-family: inherit;
  transition: background .14s ease, color .14s ease;
}
.fca-opt:hover { background: var(--fca-accent); color: #fff; }
.fca-opt:focus-visible { outline: 2px solid var(--fca-navy); outline-offset: 2px; }

/* lead capture */
.fca-lead { display: flex; gap: 8px; align-self: stretch; margin-top: 2px; }
.fca-input {
  flex: 1 1 auto; min-width: 0;
  border: 1px solid var(--fca-line); border-radius: 12px;
  padding: 11px 13px; font-size: 14px; font-family: inherit;
  background: var(--fca-surface); color: var(--fca-ink);
}
.fca-input:focus-visible { outline: 2px solid var(--fca-accent); outline-offset: 1px; }
.fca-send {
  flex: 0 0 auto; background: var(--fca-navy); color: #fff;
  border: none; border-radius: 12px; padding: 0 16px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.fca-send:hover { background: var(--fca-navy-2); }
.fca-send:focus-visible { outline: 2px solid var(--fca-accent); outline-offset: 2px; }

.fca-foot {
  flex: 0 0 auto; border-top: 1px solid var(--fca-line);
  padding: 10px 16px; display: flex; gap: 16px; justify-content: center;
  font-size: 12px;
}
.fca-foot a { color: var(--fca-muted); text-decoration: none; font-weight: 600; }
.fca-foot a:hover { color: var(--fca-accent); }

@keyframes fca-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Dark mode: panel body/surface go dark, header stays fixed navy (already dark). */
:root[data-theme="dark"] #fca-root,
:root:not([data-theme="light"]) #fca-root {
  --fca-surface: #0F1A2E;
  --fca-ink: #EAF0F8;
  --fca-line: #22324E;
  --fca-bot-bg: #16233b;
  --fca-muted: #9AA7BC;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #fca-root {
    --fca-surface: #0F1A2E; --fca-ink: #EAF0F8; --fca-line: #22324E;
    --fca-bot-bg: #16233b; --fca-muted: #9AA7BC;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fca-launcher, .fca-bubble, .fca-panel, .fca-opt, .fca-body { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

/* keep clear of very small screens */
@media (max-width: 380px) {
  .fca-panel { height: calc(100vh - 96px); bottom: 70px; }
}
