/* =========================================================================
   Ask Saad - scoped chat widget styles
   All classes prefixed `ask-*`, all CSS vars `--ask-*`. Lives alongside the
   homepage React tree without collision. Cyan + violet to echo the site
   accent without being garish.
   ========================================================================= */
:root {
  --ask-bg:        #0a1426;
  --ask-bg-2:      #0e1a30;
  --ask-surface:   #14223b;
  --ask-surface-2: #1c2d4c;
  --ask-line:      rgba(120, 200, 255, 0.10);
  --ask-line-2:    rgba(120, 200, 255, 0.22);
  --ask-ink:       #e6eef9;
  --ask-ink-2:     #b8c5dd;
  --ask-muted:     #7a8aa6;
  --ask-cyan:      #22d3ee;
  --ask-cyan-2:    #06b6d4;
  --ask-violet:    #a78bfa;
  --ask-mint:      #4ade80;
  --ask-amber:     #fbbf24;
  --ask-red:       #ef4444;
  --ask-shadow:    0 4px 16px rgba(2, 10, 24, 0.45);
  --ask-shadow-lg: 0 18px 50px rgba(2, 10, 24, 0.55);
  --ask-radius:    14px;
  --ask-radius-sm: 8px;
  --ask-ease:      cubic-bezier(.2,.7,.2,1);
  --ask-font-ui:   'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --ask-font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ===== Floating bubble (collapsed) ===== */
.ask-bubble {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 2147483646;       /* below toasts which use max int */
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ask-cyan), var(--ask-violet));
  color: white;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.32), 0 4px 8px rgba(2, 10, 24, 0.35);
  transition: transform .15s var(--ask-ease), box-shadow .15s var(--ask-ease);
  font-family: var(--ask-font-ui);
}
.ask-bubble:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 32px rgba(34, 211, 238, 0.48), 0 6px 12px rgba(2, 10, 24, 0.4); }
.ask-bubble:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.35), 0 8px 24px rgba(34, 211, 238, 0.32); }
.ask-bubble[aria-expanded="true"] { transform: scale(0.92); opacity: 0.6; }

.ask-bubble-pulse {
  position: absolute; inset: -2px; border-radius: 999px;
  border: 2px solid rgba(34, 211, 238, 0.55);
  animation: ask-pulse-ring 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes ask-pulse-ring {
  0%   { transform: scale(1);    opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ===== Chat window ===== */
.ask-window {
  position: fixed;
  bottom: 92px;
  right: 22px;
  z-index: 2147483645;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);   /* tracks the actually-visible viewport so the footer isn't clipped */
  background: var(--ask-bg);
  border: 1px solid var(--ask-line-2);
  border-radius: var(--ask-radius);
  box-shadow: var(--ask-shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ask-font-ui);
  color: var(--ask-ink);
  font-size: 14px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition: opacity .18s var(--ask-ease), transform .18s var(--ask-ease);
}
.ask-window.open { display: flex; opacity: 1; transform: translateY(0) scale(1); }
@media (max-width: 480px) {
  .ask-window {
    width: calc(100vw - 24px); right: 12px; bottom: 86px;
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);   /* shrink with iOS Safari's collapsing chrome so the input row stays reachable */
  }
  .ask-bubble  { right: 16px; bottom: 16px; }
}

/* ===== Chat header ===== */
.ask-head {
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.10), rgba(167, 139, 250, 0.06));
  border-bottom: 1px solid var(--ask-line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.ask-avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: linear-gradient(135deg, var(--ask-cyan), var(--ask-violet));
  color: white;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(34, 211, 238, 0.25);
}
.ask-head-info { flex: 1; min-width: 0; }
.ask-head-info .name { font-weight: 700; font-size: 14px; color: var(--ask-ink); }
.ask-head-info .sub  { font-size: 11px; color: var(--ask-muted); font-family: var(--ask-font-mono); }
.ask-mode-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600; font-family: var(--ask-font-mono);
  background: rgba(120, 138, 166, 0.18); color: var(--ask-muted);
  cursor: help;
}
.ask-mode-badge::before { content: ''; width: 5px; height: 5px; border-radius: 999px; background: var(--ask-muted); }
.ask-mode-badge.live { background: rgba(74, 222, 128, 0.18); color: var(--ask-mint); }
.ask-mode-badge.live::before { background: var(--ask-mint); box-shadow: 0 0 6px var(--ask-mint); animation: ask-blink 1.6s ease infinite; }
@keyframes ask-blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.ask-close {
  background: transparent; border: none; color: var(--ask-muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px;
  border-radius: 6px;
}
.ask-close:hover { background: rgba(230, 238, 249, 0.06); color: var(--ask-ink); }

/* ===== Message body ===== */
.ask-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--ask-line-2) transparent;
}
.ask-body::-webkit-scrollbar { width: 6px; }
.ask-body::-webkit-scrollbar-thumb { background: var(--ask-line-2); border-radius: 999px; }

.ask-msg { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-bottom: 12px; }
.ask-msg.out { grid-template-columns: 1fr auto; }
.ask-msg-avatar {
  width: 26px; height: 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--ask-cyan), var(--ask-violet));
  color: white; display: grid; place-items: center;
  font-weight: 800; font-size: 11px; flex-shrink: 0;
}
.ask-msg.out .ask-msg-avatar {
  background: var(--ask-surface-2); color: var(--ask-ink); font-size: 10px;
  font-weight: 700;
}
.ask-bubble-msg {
  background: var(--ask-surface);
  border: 1px solid var(--ask-line);
  padding: 9px 12px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  color: var(--ask-ink);
}
.ask-msg.out .ask-bubble-msg {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.15), rgba(167, 139, 250, 0.10));
  border-color: rgba(34, 211, 238, 0.30);
  color: var(--ask-ink);
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}

/* Citation chips row */
.ask-cites { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.ask-cite {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.32);
  color: var(--ask-cyan);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--ask-font-ui);
  transition: all .12s ease;
  appearance: none; line-height: 1.4; text-transform: none; margin: 0;
}
.ask-cite:hover { background: rgba(34, 211, 238, 0.20); border-color: var(--ask-cyan); color: white; }
.ask-cite:focus-visible { outline: 2px solid var(--ask-cyan); outline-offset: 2px; }

/* Feedback buttons under assistant messages */
.ask-feedback { margin-top: 4px; display: inline-flex; gap: 4px; }
.ask-feedback button {
  background: transparent; border: 1px solid transparent;
  padding: 2px 6px; border-radius: 6px;
  font-size: 11px; cursor: pointer; color: var(--ask-muted);
  transition: all .12s ease;
}
.ask-feedback button:hover { background: rgba(230, 238, 249, 0.06); color: var(--ask-ink); }
.ask-feedback button.up.on    { background: rgba(74, 222, 128, 0.18); color: var(--ask-mint);  border-color: var(--ask-mint); }
.ask-feedback button.down.on  { background: rgba(239, 68, 68, 0.18);  color: var(--ask-red);   border-color: var(--ask-red); }
.ask-meta-line {
  font-size: 9.5px;
  color: var(--ask-muted);
  font-family: var(--ask-font-mono);
  margin-top: 3px;
  margin-inline-start: 6px;
}

/* Typing dots */
.ask-typing {
  display: inline-flex; gap: 4px; padding: 9px 14px;
  background: var(--ask-surface); border: 1px solid var(--ask-line);
  border-radius: 12px; border-top-left-radius: 4px;
}
.ask-typing span {
  width: 6px; height: 6px; border-radius: 999px; background: var(--ask-muted);
  animation: ask-typing 1s ease infinite;
}
.ask-typing span:nth-child(2) { animation-delay: 0.15s; }
.ask-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes ask-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Starter chips */
.ask-starters {
  margin-top: 12px; display: flex; flex-direction: column; gap: 6px;
}
.ask-starter {
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.30);
  color: var(--ask-ink-2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 500;
  text-align: start;
  cursor: pointer;
  font-family: var(--ask-font-ui);
  transition: all .12s ease;
}
.ask-starter:hover { background: rgba(167, 139, 250, 0.16); border-color: var(--ask-violet); color: var(--ask-ink); }

/* Footer / input row */
.ask-foot {
  padding: 10px 12px;
  background: var(--ask-bg-2);
  border-top: 1px solid var(--ask-line);
  flex-shrink: 0;
}
.ask-foot-reset {
  font-size: 11px; color: var(--ask-muted); text-align: center;
  margin-bottom: 6px;
}
.ask-foot-reset a { color: var(--ask-cyan); text-decoration: none; cursor: pointer; }
.ask-foot-reset a:hover { text-decoration: underline; }
.ask-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--ask-surface);
  border: 1px solid var(--ask-line-2);
  border-radius: var(--ask-radius-sm);
  padding: 6px 8px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.ask-input-row:focus-within {
  border-color: var(--ask-cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}
.ask-input {
  flex: 1; min-width: 0;
  background: transparent; color: var(--ask-ink);
  border: none; outline: none;
  font-family: inherit; font-size: 13.5px;
  resize: none;
  max-height: 120px; min-height: 22px;
  padding: 4px 6px;
  line-height: 1.4;
}
.ask-input::placeholder { color: var(--ask-muted); }
.ask-send {
  background: linear-gradient(135deg, var(--ask-cyan), var(--ask-cyan-2));
  color: white;
  border: none;
  width: 32px; height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  transition: all .12s ease;
  flex-shrink: 0;
}
.ask-send:hover:not(:disabled) { transform: scale(1.05); }
.ask-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* Greeting banner */
.ask-greeting-strip {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.06), rgba(167, 139, 250, 0.04));
  border: 1px solid var(--ask-line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--ask-ink-2);
}
.ask-greeting-strip strong { color: var(--ask-ink); }

/* Modal (used by the citation source popup) */
.ask-modal-backdrop {
  position: fixed; inset: 0; z-index: 2147483647;
  background: rgba(2, 10, 24, 0.80); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
  font-family: var(--ask-font-ui);
}
.ask-modal-backdrop.show { opacity: 1; pointer-events: auto; }
.ask-modal {
  background: var(--ask-bg);
  color: var(--ask-ink);
  border: 1px solid var(--ask-line-2);
  border-radius: var(--ask-radius);
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--ask-shadow-lg);
}
.ask-modal-head { padding: 14px 18px; border-bottom: 1px solid var(--ask-line); display: flex; align-items: center; gap: 10px; }
.ask-modal-head h3 { margin: 0; font-size: 15px; flex: 1; color: var(--ask-ink); }
.ask-modal-close {
  background: transparent; border: none; color: var(--ask-muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px;
  border-radius: 6px;
}
.ask-modal-close:hover { background: rgba(230, 238, 249, 0.06); color: var(--ask-ink); }
.ask-modal-body { padding: 16px 18px; font-size: 13.5px; line-height: 1.6; color: var(--ask-ink-2); }
.ask-modal-foot { padding: 12px 18px; border-top: 1px solid var(--ask-line); display: flex; gap: 8px; justify-content: flex-end; }

/* Inline pill button (used in the hero CTA injection point on the homepage) */
.ask-cta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.14), rgba(167, 139, 250, 0.10));
  border: 1px solid rgba(34, 211, 238, 0.40);
  color: var(--ask-cyan);
  border-radius: 999px;
  font-family: var(--ask-font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .12s ease;
}
.ask-cta-pill:hover {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.24), rgba(167, 139, 250, 0.18));
  border-color: var(--ask-cyan);
  color: white;
  transform: translateY(-1px);
}
