/* FCT Core — built-in live chat widget.
 * Bottom offset: set --fct-chat-bottom on :root or body to move the launcher
 * (default 88px under 768px to clear the sticky mobile call bar, 24px otherwise). */
html { --fct-chat-bottom: 24px; }
@media (max-width: 767.98px) { html { --fct-chat-bottom: 88px; } }

/* The theme's fallback chat button/panel is replaced by this widget. */
body.fct-chat-builtin .chat-fab,
body.fct-chat-builtin #fct-chat.chat-panel { display: none !important; }

.fct-lc {
  --lc-teal: var(--teal-700, #0E6E64);
  --lc-teal-d: var(--teal-900, #0A4F48);
  --lc-coral: var(--coral-700, #C2410C);
  --lc-cream: var(--cream-50, #FBF7EF);
  --lc-ink: #17302C;
  --lc-muted: #4A5B58;
  --lc-line: #6B7C79;
  --lc-soft: #D9E2E0;
  --lc-focus: var(--focus, #0B57D0);
  font: inherit;
  color: var(--lc-ink);
  line-height: 1.45;
}
.fct-lc *, .fct-lc *::before, .fct-lc *::after { box-sizing: border-box; }
.fct-lc [hidden] { display: none !important; }
.fct-lc-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Neutralise theme button/input styles; colours are set per component below. */
.fct-lc button, .fct-lc input, .fct-lc textarea { font: inherit; letter-spacing: normal; text-transform: none; }
.fct-lc button { cursor: pointer; }
.fct-lc :focus { outline: none; }
.fct-lc :focus-visible { outline: 3px solid var(--lc-focus); outline-offset: 2px; }
.fct-lc-ic { display: inline-flex; flex-shrink: 0; }
.fct-lc-ic svg { width: 20px; height: 20px; display: block; }

/* ---------- Launcher ---------- */
.fct-lc-launcher {
  position: fixed; right: 24px; bottom: var(--fct-chat-bottom, 24px); z-index: 9990;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 56px; min-width: 56px; margin: 0; padding: 0 22px 0 16px;
  border: 2px solid transparent; border-radius: 999px;
  background: var(--lc-teal); color: #fff;
  font-weight: 700; font-size: 1rem; line-height: 1.2;
  box-shadow: 0 10px 28px rgba(10, 79, 72, .35);
  transition: background-color .15s ease, transform .15s ease;
}
.fct-lc-launcher:hover { background: var(--lc-teal-d); }
.fct-lc-launcher:focus-visible { outline-offset: 4px; }
.fct-lc-launcher .fct-lc-ic svg { width: 26px; height: 26px; }
.fct-lc-launcher > .fct-lc-dot { position: absolute; left: 34px; top: 9px; }
.fct-lc-dot { display: inline-block; flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; background: #A8B3B1; border: 2px solid #fff; }
.fct-lc.is-online .fct-lc-dot { background: #22C55E; }
.fct-lc-badge {
  position: absolute; top: -8px; right: -6px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; border: 2px solid #fff; background: var(--lc-coral); color: #fff;
  font-size: .8125rem; font-weight: 700; line-height: 20px; text-align: center;
}

/* ---------- Panel ---------- */
.fct-lc-panel {
  position: fixed; right: 24px; bottom: calc(var(--fct-chat-bottom, 24px) + 72px); z-index: 9991;
  display: flex; flex-direction: column;
  width: 384px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - var(--fct-chat-bottom, 24px) - 96px);
  max-height: calc(100dvh - var(--fct-chat-bottom, 24px) - 96px);
  background: #fff; border: 1px solid var(--lc-soft); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(10, 40, 36, .28); overflow: hidden;
  animation: fct-lc-in .18s ease-out;
}
@keyframes fct-lc-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.fct-lc-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 10px 14px 18px; background: var(--lc-teal-d); color: #fff; }
.fct-lc-head-txt { flex: 1; min-width: 0; }
.fct-lc-title { margin: 0; padding: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; color: #fff; }
.fct-lc-status { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: .875rem; color: #DCEFEB; }
.fct-lc-status .fct-lc-dot { width: 10px; height: 10px; border-width: 1px; }
.fct-lc-x {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 10px;
  background: transparent; color: #fff;
}
.fct-lc-x:hover { background: rgba(255, 255, 255, .14); }
.fct-lc-head :focus-visible { outline-color: #fff; }

.fct-lc-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--lc-cream); }

/* ---------- Pre-chat form ---------- */
.fct-lc-pre { flex: 1; overflow-y: auto; padding: 16px 18px 18px; display: grid; gap: 12px; align-content: start; }
.fct-lc-intro { margin: 0; font-size: 1rem; }
.fct-lc-note { display: flex; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 10px; background: #FFF4DB; border: 1px solid #E8D29C; font-size: .875rem; color: #3D3417; }
.fct-lc-note .fct-lc-ic { margin-top: 1px; }
.fct-lc-field { display: grid; gap: 4px; }
.fct-lc-field label { font-weight: 600; font-size: .9375rem; }
.fct-lc-req { font-weight: 400; color: var(--lc-muted); }
.fct-lc-field input, .fct-lc-field textarea, .fct-lc-compose textarea {
  width: 100%; min-height: 44px; margin: 0; padding: 10px 12px;
  border: 2px solid var(--lc-line); border-radius: 10px; background: #fff; color: var(--lc-ink);
  font-size: 1rem; line-height: 1.4; box-shadow: none;
}
.fct-lc-field textarea { resize: vertical; min-height: 84px; }
.fct-lc-field input:focus-visible, .fct-lc textarea:focus-visible { outline-offset: 0; border-color: var(--lc-focus); }
.fct-lc [aria-invalid="true"] { border-color: #B42318; }
.fct-lc-check { display: flex; align-items: flex-start; gap: 10px; font-size: .9375rem; }
.fct-lc-check input { flex-shrink: 0; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--lc-teal); }
.fct-lc-check label { padding: 2px 0; }
.fct-lc-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fct-lc-err:empty { display: none; }
.fct-lc-err { margin: 0; padding: 10px 12px; border-radius: 10px; background: #FEF3F2; border: 2px solid #B42318; color: #7A1A12; font-size: .9375rem; }
.fct-lc-conv .fct-lc-err { margin: 0 12px 8px; }

.fct-lc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; margin: 0; padding: 10px 20px; border: 2px solid transparent; border-radius: 12px;
  background: var(--lc-coral); color: #fff; font-weight: 700; font-size: 1rem; line-height: 1.2;
}
.fct-lc-btn:hover { background: #9A3412; }
.fct-lc-btn[disabled] { opacity: .7; cursor: progress; }
.fct-lc-call { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; justify-self: center; color: var(--lc-teal); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.fct-lc-call:hover { color: var(--lc-teal-d); }

/* ---------- Conversation ---------- */
.fct-lc-conv { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fct-lc-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.fct-lc-msg { display: flex; flex-direction: column; max-width: 86%; }
.fct-lc-bubble { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: .9688rem; }
.fct-lc-meta { margin-top: 3px; padding: 0 4px; font-size: .75rem; color: var(--lc-muted); }
.fct-lc-msg.is-visitor { align-self: flex-end; align-items: flex-end; }
.fct-lc-msg.is-visitor .fct-lc-bubble { background: var(--lc-teal); color: #fff; border-bottom-right-radius: 4px; }
.fct-lc-msg.is-staff { align-self: flex-start; }
.fct-lc-msg.is-staff .fct-lc-bubble { background: #fff; color: var(--lc-ink); border: 1px solid var(--lc-soft); border-bottom-left-radius: 4px; }
.fct-lc-msg.is-system { align-self: center; max-width: 94%; }
.fct-lc-msg.is-system .fct-lc-bubble { background: transparent; color: var(--lc-muted); font-size: .875rem; text-align: center; padding: 4px 8px; }
.fct-lc-msg.is-pending { opacity: .7; }

.fct-lc-typing { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 16px 8px; font-size: .8125rem; color: var(--lc-muted); }
.fct-lc-dots { display: inline-flex; gap: 3px; }
.fct-lc-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--lc-muted); animation: fct-lc-blink 1.2s infinite ease-in-out; }
.fct-lc-dots i:nth-child(2) { animation-delay: .2s; }
.fct-lc-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes fct-lc-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.fct-lc-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--lc-soft); background: #fff; }
.fct-lc-compose textarea { flex: 1; resize: none; max-height: 140px; overflow-y: auto; }
.fct-lc-send {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 48px; height: 48px; margin: 0; padding: 0; border: 2px solid transparent; border-radius: 12px;
  background: var(--lc-coral); color: #fff;
}
.fct-lc-send:hover { background: #9A3412; }
.fct-lc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 6px; background: #fff; }
.fct-lc-hint { font-size: .75rem; color: var(--lc-muted); }
.fct-lc-link {
  min-height: 44px; margin: 0; padding: 0 6px; border: 0; background: transparent;
  color: var(--lc-teal); font-weight: 700; font-size: .875rem; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap;
}
.fct-lc-link:hover { color: var(--lc-teal-d); }
.fct-lc-ended { display: grid; gap: 10px; justify-items: center; padding: 14px 16px 16px; border-top: 1px solid var(--lc-soft); background: #fff; text-align: center; }
.fct-lc-ended p { margin: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 767.98px) {
  .fct-lc-launcher { right: 14px; }
  .fct-lc-panel {
    /* Full width, between the top of the screen and the sticky call bar. */
    right: 8px; left: 8px; top: max(8px, env(safe-area-inset-top)); bottom: var(--fct-chat-bottom, 88px);
    width: auto; max-width: none; height: auto; max-height: none;
  }
  .fct-lc.is-open .fct-lc-launcher { display: none; }
  .fct-lc-hint { display: none; }
  .fct-lc-foot { justify-content: flex-end; }
}
@media (max-width: 380px) {
  .fct-lc-launcher { padding: 0 16px 0 14px; }
  .fct-lc-pre { padding: 14px 12px; }
}

/* ---------- Motion, contrast, print ---------- */
@media (prefers-reduced-motion: reduce) {
  .fct-lc-panel, .fct-lc-dots i { animation: none; }
  .fct-lc-launcher { transition: none; }
}
html.fct-hc .fct-lc-panel, html.fct-hc .fct-lc-head, html.fct-hc .fct-lc-body, html.fct-hc .fct-lc-compose,
html.fct-hc .fct-lc-foot, html.fct-hc .fct-lc-ended, html.fct-hc .fct-lc-note, html.fct-hc .fct-lc-err {
  background: #000 !important; color: #fff !important; border-color: #fff !important; box-shadow: none !important;
}
html.fct-hc .fct-lc-panel { border: 3px solid #fff !important; }
html.fct-hc .fct-lc * { transition: none !important; }
html.fct-hc .fct-lc .fct-lc-panel span, html.fct-hc .fct-lc .fct-lc-panel p, html.fct-hc .fct-lc .fct-lc-panel label,
html.fct-hc .fct-lc .fct-lc-panel div { color: #fff !important; }
html.fct-hc .fct-lc .fct-lc-title { color: #FFE600 !important; }
html.fct-hc .fct-lc-bubble, html.fct-hc .fct-lc-field input, html.fct-hc .fct-lc textarea {
  background: #000 !important; color: #fff !important; border: 2px solid #fff !important;
}
html.fct-hc .fct-lc-msg.is-visitor .fct-lc-bubble { border-color: #FFE600 !important; }
html.fct-hc .fct-lc-msg.is-system .fct-lc-bubble { border-style: dashed !important; }
html.fct-hc .fct-lc .fct-lc-launcher, html.fct-hc .fct-lc .fct-lc-btn, html.fct-hc .fct-lc .fct-lc-send {
  background: #FFE600 !important; color: #000 !important; border: 2px solid #fff !important; box-shadow: none !important;
}
html.fct-hc .fct-lc .fct-lc-launcher span, html.fct-hc .fct-lc .fct-lc-btn span, html.fct-hc .fct-lc .fct-lc-send span { color: #000 !important; }
html.fct-hc .fct-lc .fct-lc-launcher .fct-lc-badge { background: #000 !important; color: #FFE600 !important; border-color: #FFE600 !important; }
html.fct-hc .fct-lc .fct-lc-x, html.fct-hc .fct-lc .fct-lc-x span { color: #fff !important; border: 2px solid #fff; }
html.fct-hc .fct-lc .fct-lc-link, html.fct-hc .fct-lc .fct-lc-call, html.fct-hc .fct-lc .fct-lc-call span { color: #7FD4FF !important; }
html.fct-hc .fct-lc .fct-lc-dot { border-color: #000 !important; }
html.fct-hc .fct-lc :focus-visible { outline: 3px solid #FFE600 !important; outline-offset: 2px; }
@media (forced-colors: active) {
  .fct-lc-launcher, .fct-lc-panel, .fct-lc-bubble, .fct-lc-btn, .fct-lc-send { border: 2px solid CanvasText; }
  .fct-lc-dot { forced-color-adjust: none; }
}
@media print { .fct-lc { display: none !important; } }
