/* ── @ai: concierge chat widget styles (PLAN 16 P0.5 pilot) ──
   Data flow: styled by the React SPA's own theme variables where present
   (--primary/--card/--border/--ring) with RapidLaunch design-token fallbacks
   (--rl-*) and last-resort hex — so the widget follows light/dark mode on
   www AND stays branded on any surface that loads it.
   Connected: chat-concierge.js (builds the DOM), api/chat.php (data),
   rapidlaunch.ie/index.php (injects on the pricing page).
   Edge cases: prefers-reduced-motion kills the typing dots animation; print
   hides the widget entirely; no !important anywhere (rule 5).
   Tier: pilot
   ────────────────────────────────────────── */

#chat-concierge {
  --cc-accent: var(--primary, var(--rl-accent, #0d9488));
  --cc-accent-strong: var(--primary-hover, var(--rl-accent-hover, #0b7f76));
  --cc-panel-bg: var(--card, var(--background, #ffffff));
  --cc-body-bg: var(--background, #f6f8f7);
  --cc-text: var(--foreground, var(--rl-text-primary, #1a2421));
  --cc-muted: var(--muted-foreground, var(--rl-text-muted, #5b6b66));
  --cc-border: var(--border, rgba(0, 0, 0, 0.12));
  --cc-input-border: var(--input, rgba(0, 0, 0, 0.15));
  --cc-ring: var(--ring, var(--rl-accent, #0d9488));
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 1100; /* modal tier — above site chrome (rule 106), below nothing */
  font-family: inherit;
}

/* ── launcher ── */
.cc-launcher {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--cc-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(13, 20, 18, 0.28);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.cc-launcher:hover { background: var(--cc-accent-strong); transform: scale(1.04); }
.cc-launcher:focus-visible {
  outline: 2px solid var(--cc-ring);
  outline-offset: 3px;
}

/* ── panel ── */
.cc-panel {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: min(360px, calc(100vw - 32px));
  height: min(500px, calc(100dvh - 160px));
  display: flex;
  flex-direction: column;
  background: var(--cc-panel-bg);
  color: var(--cc-text);
  border: 1px solid var(--cc-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .cc-panel { animation: cc-rise 0.18s ease-out; }
}
@keyframes cc-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── header ── */
.cc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--cc-accent);
  color: #fff;
  font-size: 14px;
  gap: 8px;
}
.cc-head-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cc-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.cc-close:hover { background: rgba(255, 255, 255, 0.18); }
.cc-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ── body ── */
.cc-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--cc-body-bg);
  overscroll-behavior: contain;
}
.cc-status {
  /* screen-reader live region — visually hidden but announced (E84) */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── messages ── */
.cc-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.cc-visitor {
  align-self: flex-end;
  background: var(--cc-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cc-agent {
  align-self: flex-start;
  background: var(--cc-panel-bg);
  border: 1px solid var(--cc-border);
  border-bottom-left-radius: 4px;
  color: var(--cc-text);
}
.cc-persona {
  /* persona identity row above an agent message (H3) */
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -2px;
  padding-left: 2px;
}
.cc-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cc-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cc-persona-name { font-size: 12px; font-weight: 600; color: var(--cc-muted); }

/* ── system notes / greet / transfer / errors ── */
.cc-note { align-self: center; font-size: 12.5px; color: var(--cc-muted); text-align: center; max-width: 90%; }
.cc-greet { padding: 10px 12px; background: var(--cc-accent-light, rgba(13, 148, 136, 0.08)); border-radius: 10px; color: var(--cc-text); }
.cc-sys { color: var(--cc-muted); font-size: 12px; }
.cc-transfer { padding: 8px 10px; background: var(--cc-accent-light, rgba(13, 148, 136, 0.08)); border-radius: 8px; font-style: italic; }
.cc-err { color: #b3261e; }

/* ── typing indicator (H4) ── */
.cc-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cc-panel-bg);
  border: 1px solid var(--cc-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.cc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cc-muted);
}
@media (prefers-reduced-motion: no-preference) {
  .cc-typing span { animation: cc-blink 1.2s infinite ease-in-out; }
  .cc-typing span:nth-child(2) { animation-delay: 0.15s; }
  .cc-typing span:nth-child(3) { animation-delay: 0.3s; }
}
@keyframes cc-blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* ── transfer offer card (PLAN 19 5.3) ── */
.cc-offer {
  align-self: stretch;
  padding: 10px 12px;
  background: var(--cc-panel-bg);
  border: 1px dashed var(--cc-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--cc-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cc-offer button {
  background: var(--cc-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.cc-offer button + button { background: var(--cc-panel-bg); color: var(--cc-text); border: 1px solid var(--cc-border); }
.cc-offer button:hover { background: var(--cc-accent-strong); color: #fff; }
.cc-offer button:disabled { opacity: 0.5; cursor: default; }
.cc-offer button:focus-visible { outline: 2px solid var(--cc-ring); outline-offset: 2px; }

/* ── consent gate (H5 / GDPR) ── */.cc-consent {
  margin-top: auto;
  margin-bottom: 4px;
  padding: 12px;
  background: var(--cc-panel-bg);
  border: 1px solid var(--cc-border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--cc-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cc-consent strong { color: var(--cc-text); }
.cc-consent button {
  background: var(--cc-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.cc-consent button:hover { background: var(--cc-accent-strong); }
.cc-consent button:focus-visible { outline: 2px solid var(--cc-ring); outline-offset: 2px; }

/* ── form ── */
.cc-form { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--cc-border); background: var(--cc-panel-bg); }
.cc-input {
  flex: 1;
  border: 1px solid var(--cc-input-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--cc-text);
  background: var(--cc-panel-bg);
}
.cc-input:focus-visible { outline: 2px solid var(--cc-ring); outline-offset: 0; }
.cc-input:disabled { opacity: 0.55; }
.cc-send {
  background: var(--cc-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
}
.cc-send:hover { background: var(--cc-accent-strong); }
.cc-send:disabled { opacity: 0.45; cursor: default; }
.cc-send:focus-visible { outline: 2px solid var(--cc-ring); outline-offset: 2px; }

/* ── print: hide the widget entirely ── */
@media print {
  #chat-concierge { display: none; }
}

/* ── small screens ── */
@media (max-width: 480px) {
  .cc-panel { width: calc(100vw - 32px); height: min(70dvh, 520px); }
}
/* ── @ai: typing indicator dots (human-feel v2, 2026-11-03) ── */
.cc-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.cc-dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3ab; animation: cc-blink 1.2s infinite ease-in-out; }
.cc-dot:nth-child(2) { animation-delay: 0.2s; }
.cc-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cc-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ── @ai: F2/F14 consent + transfer offer UI (2026-11-10) ── */
.cc-consent,
.cc-offer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--rl-surface-2, #f1f5f5);
  font-size: 13px;
}
.cc-consent-btns,
.cc-offer-btns {
  display: flex;
  gap: 6px;
}
.cc-consent button,
.cc-offer button {
  border: 1px solid var(--rl-border, #d7dede);
  border-radius: 8px;
  background: var(--rl-bg, #ffffff);
  color: var(--rl-text, #1b2b2b);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.cc-consent button:first-child,
.cc-offer button:first-child {
  background: var(--rl-accent, #0d9488);
  border-color: var(--rl-accent, #0d9488);
  color: #ffffff;
}
.cc-consent button:disabled,
.cc-offer button:disabled {
  cursor: default;
  opacity: 0.6;
}
