/* "Mai" chat widget. Self-contained (no Tailwind classes) so it works on every
   layout theme: light (default), dark (html.dark) and Tap&Turn sand (html.tt).
   House style: no shadows, 1px borders, line icons, Zeenly blue leads, orange
   only as a small accent. */

.zc {
  --zc-bg: #ffffff;
  --zc-surface: #f5f5f4;
  --zc-line: #e5e5e5;
  --zc-text: #11141C;
  --zc-dim: #5C5C5C;
  --zc-blue: #2563EB;
  --zc-blue-text: #1d4ed8;
  --zc-user: #2563EB;
  --zc-user-text: #ffffff;
  --zc-accent: #FF5722;
  --zc-error: #b91c1c;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 45; /* under the support modal (z-50) so a hand-off sits on top */
  font-family: inherit;
  color: var(--zc-text);
}
html.dark .zc {
  --zc-bg: #1f1f1f;
  --zc-surface: #2a2a2a;
  --zc-line: #3a3a3a;
  --zc-text: #f5f5f5;
  --zc-dim: #a3a3a3;
  --zc-blue-text: #93b4ff;
  --zc-error: #fca5a5;
}
html.tt .zc {
  --zc-bg: #FBF8EF;
  --zc-surface: #F3EEE0;
  --zc-line: #E2DAC5;
  --zc-text: #11141C;
  --zc-dim: #5C5C5C;
}

.zc *, .zc *::before, .zc *::after { box-sizing: border-box; }
.zc [hidden] { display: none !important; }
.zc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Launcher ─────────────────────────────────────────────────────────── */
.zc-launch {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto;
  padding: 5px 16px 5px 5px;
  border: 1px solid var(--zc-blue);
  border-radius: 999px;
  background: var(--zc-blue);
  color: #fff;
  font-weight: 600; font-size: 15px; line-height: 1;
  font-family: inherit;
  cursor: pointer;
  transition: background-color .15s ease;
}
.zc-launch:hover { background: #1d4ed8; }
.zc .zc-form textarea:focus { outline: none; border-color: var(--zc-blue); }
.zc-launch:focus-visible, .zc button:focus-visible, .zc a:focus-visible {
  outline: 2px solid var(--zc-accent); outline-offset: 2px;
}
.zc-launch img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; }
.zc-open .zc-launch { display: none; }

/* ── Proactive nudge ──────────────────────────────────────────────────── */
.zc-tease {
  position: absolute; right: 0; bottom: 60px;
  width: 260px;
  padding: 12px 34px 12px 14px;
  border: 1px solid var(--zc-line);
  border-left: 3px solid var(--zc-accent);
  border-radius: 12px;
  background: var(--zc-bg);
  font-size: 14px; line-height: 1.4;
}
.zc-tease p { margin: 0; cursor: pointer; }
.zc-tease-x { position: absolute; top: 6px; right: 6px; border: 0; background: none; color: var(--zc-dim); cursor: pointer; padding: 4px; }

/* ── Panel ────────────────────────────────────────────────────────────── */
.zc-panel {
  display: flex; flex-direction: column;
  width: 380px; height: min(620px, calc(100vh - 40px));
  border: 1px solid var(--zc-line);
  border-radius: 16px;
  background: var(--zc-bg);
  overflow: hidden;
}
.zc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--zc-line);
}
.zc-head img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.zc-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.2; }
.zc-who strong { font-size: 15px; letter-spacing: -.01em; }
.zc-who span { font-size: 12px; color: var(--zc-dim); }
.zc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: none; color: var(--zc-dim); cursor: pointer;
}
.zc-icon:hover { color: var(--zc-text); background: var(--zc-surface); }

.zc-log { flex: 1; overflow-y: auto; padding: 14px; scroll-behavior: smooth; overscroll-behavior: contain; }
.zc-msg { display: flex; flex-direction: column; margin-bottom: 12px; }
.zc-body { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.zc-assistant .zc-body { background: var(--zc-surface); border-bottom-left-radius: 4px; }
.zc-user { align-items: flex-end; }
.zc-user .zc-body { background: var(--zc-user); color: var(--zc-user-text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.zc-body p { margin: 0 0 8px; }
.zc-body p:last-child, .zc-body ul:last-child { margin-bottom: 0; }
.zc-body ul { margin: 0 0 8px; padding-left: 18px; }
.zc-body li { margin: 2px 0; }
.zc-link { color: var(--zc-blue-text); text-decoration: underline; text-underline-offset: 2px; }
.zc-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.zc-btns:last-child { margin-bottom: 0; }
.zc-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--zc-blue); color: #fff;
  font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.zc-btn:hover { background: #1d4ed8; color: #fff; }
.zc-error .zc-body { color: var(--zc-error); border: 1px solid currentColor; background: transparent; }
.zc-pending .zc-dots { display: inline-block; letter-spacing: 2px; animation: zc-pulse 1s ease-in-out infinite; }
@keyframes zc-pulse { 50% { opacity: .35; } }
/* "Mai is typing": three bouncing dots, then a short note if it's slow. */
.zc-typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; vertical-align: middle; }
.zc-typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .45; animation: zc-bounce 1.2s ease-in-out infinite; }
.zc-typing i:nth-child(2) { animation-delay: .15s; }
.zc-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes zc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.zc-typing-note { display: block; margin-top: 4px; font-size: 12px; color: var(--zc-dim); }
.zc-typing-note:empty { display: none; }
.zc-fb { display: flex; gap: 2px; margin-top: 2px; font-size: 12px; color: var(--zc-dim); align-items: center; min-height: 28px; }
.zc-fb .zc-icon { width: 28px; height: 28px; }

.zc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.zc-chip {
  padding: 6px 11px;
  border: 1px solid var(--zc-line); border-radius: 999px;
  background: var(--zc-bg); color: var(--zc-text);
  font-size: 13px; line-height: 1.3; font-family: inherit;
  cursor: pointer; text-align: left;
}
.zc-chip:hover { border-color: var(--zc-blue); color: var(--zc-blue-text); }

.zc-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--zc-line); }
.zc-form textarea {
  flex: 1; resize: none; max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--zc-line); border-radius: 12px;
  background: var(--zc-bg); color: var(--zc-text);
  font-size: 14.5px; line-height: 1.4; font-family: inherit;
}
.zc-form textarea::placeholder { color: var(--zc-dim); }
.zc-send {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 12px;
  background: var(--zc-blue); color: #fff; cursor: pointer;
}
.zc-send:disabled { opacity: .5; cursor: default; }
.zc-foot { margin: 0; padding: 0 14px 10px; font-size: 11.5px; color: var(--zc-dim); }
.zc-foot a { color: inherit; text-decoration: underline; }

/* ── Phones: launcher shrinks to the avatar; panel goes full screen ───── */
@media (max-width: 640px) {
  .zc { right: 14px; bottom: 14px; }
  .zc-launch { padding: 4px; }
  .zc-launch-label { display: none; }
  .zc-launch img { width: 44px; height: 44px; }
  .zc-tease { bottom: 64px; width: min(260px, calc(100vw - 28px)); }
  .zc.zc-open { inset: 0; }
  .zc-panel { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .zc-form textarea { font-size: 16px; } /* stops iOS zooming on focus */
}

@media (prefers-reduced-motion: reduce) {
  .zc-log { scroll-behavior: auto; }
  .zc-pending .zc-dots { animation: none; }
  .zc-typing i { animation: none; opacity: .7; }
}

@media print { .zc { display: none; } }
