/* ============================================================================
   Quantums site chat assistant ("Quinn")
   Peeking SVG character + WhatsApp-style chat window. Loaded on public pages.
   ========================================================================== */

:root {
  --qbot-wa-header: #075E54;
  --qbot-wa-accent: #128C7E;
  --qbot-wa-send:   #25D366;
  --qbot-wa-bg:     #e5ddd5;
  --qbot-wa-me:     #dcf8c6;
  --qbot-wa-bot:    #ffffff;
  --qbot-text:      #111b21;
  --qbot-muted:     #667781;
}

.qbot { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* ── Peeking character / launcher ───────────────────────────────────────── */
.qbot-launcher {
  position: fixed;
  right: 0; top: 50%;
  transform: translate(110%, -50%);       /* fully off-screen when hidden */
  width: 120px; height: 150px;
  padding: 0; border: 0; background: none; cursor: pointer;
  z-index: 9998;
  transition: transform .55s cubic-bezier(.22,1,.36,1);
  filter: drop-shadow(-6px 6px 10px rgba(0,0,0,.35));
}
.qbot-figure { display: block; }

/* Visible phase (JS toggles .qbot-show on #qbot) — she leans out and waves. */
.qbot.qbot-show .qbot-launcher { transform: translate(8%, -50%); }
.qbot.qbot-show .qbot-arm {
  transform-origin: 32% 80%;              /* left-hand shoulder pivot */
  animation: qbotWave .7s ease-in-out infinite;
}
.qbot-launcher:hover { transform: translate(4%, -50%); }

/* Hide the character entirely while the chat window is open. */
.qbot.qbot-open .qbot-launcher { transform: translate(130%, -50%); pointer-events: none; }

@keyframes qbotWave {
  0%,100% { transform: rotate(-8deg); }
  25%     { transform: rotate(14deg); }
  50%     { transform: rotate(-4deg); }
  75%     { transform: rotate(18deg); }
}

/* Speech bubble shown during the visible phase. */
.qbot-bubble {
  position: absolute;
  right: 112px; top: 26px;
  white-space: nowrap;
  background: #fff; color: #111b21;
  font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 14px 14px 2px 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  opacity: 0; transform: translateX(12px) scale(.9);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.qbot.qbot-show .qbot-bubble { opacity: 1; transform: none; }
.qbot.qbot-open .qbot-bubble { display: none; }

/* ── Chat window ────────────────────────────────────────────────────────── */
.qbot-window {
  position: fixed;
  right: 20px; bottom: 20px;
  width: 350px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--qbot-wa-bg);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  z-index: 9999;
  transform-origin: bottom right;
  animation: qbotPop .25s ease-out;
}
.qbot-window[hidden] { display: none; }
@keyframes qbotPop {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* Header */
.qbot-head {
  display: flex; align-items: center; gap: 10px;
  background: var(--qbot-wa-header); color: #fff;
  padding: 10px 12px; flex-shrink: 0;
}
.qbot-head-avatar svg { display: block; border-radius: 50%; }
.qbot-head-id { flex: 1; line-height: 1.25; }
.qbot-head-id strong { font-size: 15px; display: block; }
.qbot-head-id small  { font-size: 11px; color: #cfe9e4; display: flex; align-items: center; gap: 5px; }
.qbot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--qbot-wa-send); display: inline-block; }
.qbot-x {
  background: none; border: 0; color: #cfe9e4; font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.qbot-x:hover { color: #fff; }

/* Body (chat wallpaper) */
.qbot-body {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  background-color: var(--qbot-wa-bg);
  background-image:
    radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px);
  background-size: 22px 22px; background-position: 0 0, 11px 11px;
}

/* Onboarding card */
.qbot-onboard {
  background: #fff; border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.qbot-onboard-lead { margin: 0 0 2px; font-size: 14px; color: var(--qbot-text); }
.qbot-input-field {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; border: 1px solid #d6dbdf; border-radius: 8px;
  font-size: 14px; color: var(--qbot-text); background: #fff;
}
.qbot-input-field:focus { outline: none; border-color: var(--qbot-wa-accent); }
.qbot-onboard-btn {
  background: var(--qbot-wa-accent); color: #fff; border: 0;
  padding: 11px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.qbot-onboard-btn:hover { background: #0e7a6e; }
.qbot-privacy { color: var(--qbot-muted); font-size: 11px; text-align: center; }
.qbot-err { color: #c0392b; font-size: 12px; margin: 0; }

/* Thread + bubbles */
.qbot-thread { display: flex; flex-direction: column; gap: 8px; }
.qbot-msg {
  max-width: 82%; padding: 7px 10px 8px; border-radius: 9px;
  font-size: 14px; line-height: 1.4; color: var(--qbot-text);
  box-shadow: 0 1px 1px rgba(0,0,0,.14); position: relative; word-wrap: break-word;
  animation: qbotMsgIn .18s ease-out;
}
@keyframes qbotMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.qbot-msg--bot { align-self: flex-start; background: var(--qbot-wa-bot); border-top-left-radius: 2px; }
.qbot-msg--me  { align-self: flex-end;   background: var(--qbot-wa-me);  border-top-right-radius: 2px; }
.qbot-meta { display: block; text-align: right; font-size: 10px; color: var(--qbot-muted); margin-top: 3px; }
.qbot-meta .qbot-ticks { color: #53bdeb; margin-left: 3px; }

/* Quick-reply chips */
.qbot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 2px; align-self: flex-start; }
.qbot-chip {
  background: #fff; color: var(--qbot-wa-accent);
  border: 1px solid var(--qbot-wa-accent); border-radius: 16px;
  padding: 6px 11px; font-size: 12.5px; cursor: pointer; transition: background .15s, color .15s;
}
.qbot-chip:hover { background: var(--qbot-wa-accent); color: #fff; }

/* Typing indicator */
.qbot-typing { display: inline-flex; gap: 4px; align-items: center; }
.qbot-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #9aa6ac; display: inline-block;
  animation: qbotBlink 1.2s infinite both;
}
.qbot-typing span:nth-child(2) { animation-delay: .2s; }
.qbot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes qbotBlink { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

/* Attachments */
.qbot-att-img { display: block; max-width: 100%; border-radius: 8px; margin-bottom: 4px; }
.qbot-att-name { font-size: 12.5px; }

/* Composer */
.qbot-composer { display: flex; align-items: center; gap: 6px; padding: 8px; background: #f0f0f0; flex-shrink: 0; }
.qbot-composer[hidden] { display: none; }
.qbot-attach {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--qbot-wa-accent); cursor: pointer; transition: background .15s;
}
.qbot-attach:hover { background: rgba(0,0,0,.06); }
.qbot-text {
  flex: 1; border: 0; border-radius: 20px; padding: 10px 14px; font-size: 14px;
  background: #fff; color: var(--qbot-text);
}
.qbot-text:focus { outline: none; }
.qbot-send {
  flex-shrink: 0; width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: var(--qbot-wa-accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qbot-send:hover { background: #0e7a6e; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .qbot-window { right: 10px; left: 10px; bottom: 10px; width: auto; height: 72vh; }
  .qbot-launcher { width: 96px; height: 120px; }
  .qbot-bubble { right: 90px; top: 18px; font-size: 12px; }
}

/* ── Respect reduced-motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .qbot-launcher { transition: none; transform: translate(8%, -50%); }   /* stay visible, no sliding */
  .qbot.qbot-show .qbot-arm { animation: none; }
  .qbot-window, .qbot-msg { animation: none; }
}
