/* ============================================================
   Flash Sim: support assistant (chat widget)
   Markup: templates/footer.php · behaviour: assets/js/chat.js
   Layers: launcher 8900 (below the cookie banner 9000, above page modals 2000); open window 9100.
   The checkout overlay hides the whole widget (checkout-extra.css: body.ckx-overlay-open #chatWidget).
   ============================================================ */
.chat-widget {
  --chat-blue: #1B5BDB;
  --chat-navy: #004C93;
  --chat-deep: #0B3A78;
  --chat-green: #16A34A;
  --chat-green-soft: #DCFCE7;
  --chat-ink: #0F172A;
  --chat-muted: #64748B;
  --chat-line: rgba(15, 23, 42, 0.08);
  --chat-surface: #F5F7FB;
  --chat-radius: 22px;
  --chat-ease: cubic-bezier(0.22, 1, 0.36, 1);
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--chat-lift, 0px));
  z-index: 8900;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: var(--chat-ink);
  transition: bottom 0.3s var(--chat-ease);
}
.chat-widget.is-open { z-index: 9100; }
.chat-widget *, .chat-widget *::before, .chat-widget *::after { box-sizing: border-box; }
.chat-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;
}

/* ── Launcher ─────────────────────────────────────────────── */
.chat-widget__toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(140deg, #2F6FF0 0%, var(--chat-blue) 45%, var(--chat-navy) 100%);
  box-shadow: 0 12px 28px -8px rgba(0, 76, 147, 0.55), 0 2px 6px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.25s var(--chat-ease), box-shadow 0.25s var(--chat-ease);
  animation: chat-launch-in 0.6s var(--chat-ease) 0.5s both;
}
.chat-widget__toggle::after {           /* soft halo, pulses twice after the entrance */
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(27, 91, 219, 0.35);
  opacity: 0;
  animation: chat-halo 2.4s ease-out 1.3s 2;
  pointer-events: none;
}
.chat-widget__toggle:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 16px 34px -8px rgba(0, 76, 147, 0.6), 0 3px 8px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.chat-widget__toggle:active { transform: scale(0.97); }
.chat-widget__toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--chat-blue), 0 12px 28px -8px rgba(0, 76, 147, 0.55); }
.chat-widget__toggle svg {
  position: absolute;
  transition: opacity 0.22s ease, transform 0.3s var(--chat-ease);
}
.chat-widget__toggle .icon-chat  { opacity: 1; transform: none; }
.chat-widget__toggle .icon-close { opacity: 0; transform: rotate(-90deg) scale(0.5); }
.chat-widget.is-open .chat-widget__toggle .icon-chat  { opacity: 0; transform: rotate(90deg) scale(0.5); }
.chat-widget.is-open .chat-widget__toggle .icon-close { opacity: 1; transform: none; }

@keyframes chat-launch-in {
  from { opacity: 0; transform: translateY(18px) scale(0.6); }
  to   { opacity: 1; transform: none; }
}
@keyframes chat-halo {
  0%   { opacity: 0.9; transform: scale(0.9); }
  100% { opacity: 0;   transform: scale(1.35); }
}

/* Badge */
.chat-widget__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #EF4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  z-index: 1;
  animation: chat-pop 0.4s var(--chat-ease);
}
.chat-widget__badge[hidden] { display: none; }
@keyframes chat-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* Invite bubble */
.chat-widget__invite {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(300px, calc(100vw - 32px));
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  background: #fff;
  color: var(--chat-ink);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 14px 34px -10px rgba(15, 23, 42, 0.28), 0 0 0 1px var(--chat-line);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.35s var(--chat-ease);
}
.chat-widget__invite.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.chat-widget.is-open .chat-widget__invite { display: none; }
.chat-widget__invite-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--chat-green); box-shadow: 0 0 0 3px var(--chat-green-soft);
}

/* ── Window ───────────────────────────────────────────────── */
.chat-widget__window {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 384px;
  height: min(660px, calc(100vh - 128px));
  height: min(660px, calc(100dvh - 128px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--chat-surface);
  border-radius: var(--chat-radius);
  box-shadow: 0 28px 70px -18px rgba(15, 23, 42, 0.42), 0 10px 24px -12px rgba(0, 76, 147, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.32s var(--chat-ease);
}
.chat-widget__window[hidden] { display: none !important; }
.chat-widget.is-open .chat-widget__window { opacity: 1; transform: none; }

/* Header */
.chat-widget__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 16px 16px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(74, 143, 239, 0.55) 0%, rgba(74, 143, 239, 0) 55%),
    linear-gradient(135deg, var(--chat-navy) 0%, var(--chat-blue) 100%);
  flex-shrink: 0;
}
.chat-widget__header::after {            /* hairline that separates the header from the conversation */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}
.chat-widget__avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}
.chat-widget__avatar img {             /* the lightning mark of LogoFlashSim.png (left part of the wordmark) */
  width: 30px;
  height: 34px;
  object-fit: cover;
  object-position: left center;
}
.chat-widget__presence {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22C55E;
  border: 2.5px solid var(--chat-navy);
}
.chat-widget__info { flex: 1; min-width: 0; }
.chat-widget__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-widget__status {
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.86);
}
.chat-widget__status-dot {
  position: relative;
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ADE80;
  flex-shrink: 0;
}
.chat-widget__status-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.45);
  animation: chat-live 2.2s ease-out infinite;
}
@keyframes chat-live {
  0%   { transform: scale(0.6); opacity: 0.9; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { opacity: 0; }
}
.chat-widget__close-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: background 0.18s ease;
}
.chat-widget__close-btn:hover { background: rgba(255, 255, 255, 0.26); }
.chat-widget__close-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ── Conversation ─────────────────────────────────────────── */
.chat-widget__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.18) transparent;
}
.chat-widget__body:focus { outline: none; }
.chat-widget__body::-webkit-scrollbar { width: 6px; }
.chat-widget__body::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.16); border-radius: 6px; }

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: chat-msg-in 0.34s var(--chat-ease) both;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.chat-msg--user { justify-content: flex-end; }
.chat-msg__avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--chat-line), 0 2px 6px -3px rgba(15, 23, 42, 0.2);
}
.chat-msg__avatar img { width: 19px; height: 22px; object-fit: cover; object-position: left center; }

.chat-msg__bubble {
  min-width: 0;
  max-width: 84%;
  padding: 11px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.chat-msg__bubble p { margin: 0; }
.chat-msg__bubble p + p,
.chat-msg__bubble p + ul,
.chat-msg__bubble ul + p { margin-top: 8px; }
.chat-msg__bubble ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 5px; }
.chat-msg__bubble li { position: relative; padding-left: 15px; }
.chat-msg__bubble li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-blue);
  opacity: 0.85;
}
.chat-msg--bot .chat-msg__bubble {
  background: #fff;
  color: var(--chat-ink);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px var(--chat-line);
}
.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(135deg, var(--chat-blue) 0%, var(--chat-navy) 100%);
  color: #fff;
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 6px 14px -8px rgba(0, 76, 147, 0.6);
}

/* Answer card */
.chat-msg--card .chat-msg__bubble { max-width: calc(100% - 36px); padding: 14px 15px 14px; }
.chat-card__topic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(27, 91, 219, 0.08);
  color: var(--chat-navy);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.chat-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--chat-line);
}
.chat-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(27, 91, 219, 0.28);
  background: #fff;
  color: var(--chat-navy);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.chat-cta svg { flex-shrink: 0; transition: transform 0.2s var(--chat-ease); }
.chat-cta:hover { background: rgba(27, 91, 219, 0.07); border-color: var(--chat-blue); color: var(--chat-navy); }
.chat-cta:hover svg { transform: translateX(2px); }
.chat-cta--primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--chat-blue) 0%, var(--chat-navy) 100%);
  color: #fff;
  box-shadow: 0 6px 14px -8px rgba(0, 76, 147, 0.7);
}
.chat-cta--primary:hover { background: linear-gradient(135deg, #2A68E4 0%, var(--chat-deep) 100%); color: #fff; border-color: transparent; }
.chat-cta:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }

/* Typing indicator */
.chat-typing { display: inline-flex; align-items: center; gap: 4px; padding: 14px 16px; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--chat-blue);
  opacity: 0.35;
  animation: chat-dot 1.1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Topic picker / follow-ups ────────────────────────────── */
.chat-widget__quick-replies {
  flex-shrink: 0;
  max-height: 40%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 4px;
  background: #fff;
  border-top: 1px solid var(--chat-line);
  scrollbar-width: thin;
}
.chat-widget__quick-replies:empty { display: none; }
.chat-qr__title {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chat-muted);
}
.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: #EEF2F8;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab {
  flex: 1 0 auto;
  padding: 7px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #475569;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.chat-tab:hover { color: var(--chat-navy); }
.chat-tab[aria-selected="true"] {
  background: #fff;
  color: var(--chat-navy);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.04);
}
.chat-tab:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 1px; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 7px; padding-bottom: 8px; }
.chat-chips:empty { display: none; }
.chat-chips--extra { padding-top: 2px; border-top: 1px dashed var(--chat-line); padding-top: 9px; }
.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(27, 91, 219, 0.22);
  background: #F5F8FF;
  color: var(--chat-navy);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
  animation: chat-msg-in 0.3s var(--chat-ease) both;
}
.chat-chip:hover { background: var(--chat-blue); border-color: var(--chat-blue); color: #fff; }
.chat-chip:active { transform: scale(0.98); }
.chat-chip:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }
.chat-chip--human { background: #F0FDF4; border-color: #86EFAC; color: #15803D; font-weight: 600; }
.chat-chip--human:hover { background: var(--chat-green); border-color: var(--chat-green); color: #fff; }
.chat-chip--back { background: #fff; border-color: rgba(15, 23, 42, 0.14); color: #334155; font-weight: 600; }
.chat-chip--back:hover { background: #0F172A; border-color: #0F172A; color: #fff; }

/* ── Input ────────────────────────────────────────────────── */
.chat-widget__input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px 6px;
  background: #fff;
  border-top: 1px solid var(--chat-line);
}
.chat-widget__quick-replies:not(:empty) + .chat-widget__input-row { border-top-color: transparent; }
.chat-widget__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background: #F1F4F9;
  color: var(--chat-ink);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.chat-widget__input::placeholder { color: #94A3B8; }
.chat-widget__input:focus { background: #fff; border-color: var(--chat-blue); box-shadow: 0 0 0 4px rgba(27, 91, 219, 0.12); }
.chat-widget__send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--chat-blue) 0%, var(--chat-navy) 100%);
  box-shadow: 0 6px 14px -8px rgba(0, 76, 147, 0.8);
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}
.chat-widget__send:hover { transform: translateX(1px); filter: brightness(1.08); }
.chat-widget__send:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }
.chat-widget__note {
  flex-shrink: 0;
  margin: 0;
  padding: 2px 16px 10px;
  background: #fff;
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: center;
  color: #94A3B8;
}

/* ── Hand-off form (base rules in support.css) ────────────── */
.chat-msg--form .chat-handoff {
  max-width: calc(100% - 36px);
  padding: 14px;
  background: #fff;
  border: 0;
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px var(--chat-line);
}
.chat-widget .chat-handoff__input { border-radius: 10px; border-color: rgba(15, 23, 42, 0.14); padding: 8px 11px; font-size: 0.86rem; }
.chat-widget .chat-handoff__input:focus { border-color: var(--chat-blue); box-shadow: 0 0 0 3px rgba(27, 91, 219, 0.12); }
.chat-widget .chat-handoff__submit { background: linear-gradient(135deg, var(--chat-blue) 0%, var(--chat-navy) 100%); }
.chat-widget .chat-handoff__submit:focus-visible,
.chat-widget .chat-handoff__cancel:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }

/* ── Phones: full-height bottom sheet ─────────────────────── */
@media (max-width: 480px) {
  .chat-widget { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px) + var(--chat-lift, 0px)); }
  .chat-widget__toggle { width: 56px; height: 56px; }
  .chat-widget__invite { bottom: 68px; max-width: calc(100vw - 32px); }
  .chat-widget__window {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: max(10px, env(safe-area-inset-top, 0px));
    width: 100%;
    height: auto;
    border-radius: 22px 22px 0 0;
    transform: translateY(40px);
    transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--chat-surface);
  }
  .chat-widget.is-open .chat-widget__window { transform: none; }
  .chat-widget.is-open .chat-widget__toggle,
  .chat-widget.is-open .chat-widget__invite { display: none; }
  .chat-widget__header { padding: 14px 12px 14px 16px; }
  .chat-widget__header::before {        /* sheet grabber */
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.4);
  }
  .chat-widget__close-btn { width: 40px; height: 40px; }
  .chat-widget__input { font-size: 16px; }   /* no zoom on iOS */
  .chat-widget__quick-replies { max-height: 44%; }
  .chat-msg__bubble { max-width: 88%; }
  .chat-widget__input-row,
  .chat-widget__note { background: #fff; }
}
html.chat-sheet-open, html.chat-sheet-open body { overflow: hidden; }

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .chat-widget,
  .chat-widget *,
  .chat-widget *::before,
  .chat-widget *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .chat-widget__window { transform: none !important; }
}

/* Long lists (e.g. the Unlimited Lite price list) in two columns */
.chat-msg__bubble ul:has(> li:nth-child(6)) { grid-template-columns: 1fr 1fr; column-gap: 12px; }
