/* =====================================================================
 * assistant.css — Site Assistant floating chat widget (ADR 0024)
 * Companion to assistant.js. Every class is .ast-prefixed; all colours /
 * spacing / type come from the style.css design tokens (no hardcoded
 * values), so light & dark themes both work without extra blocks.
 *
 * The FAB (#assist-fab, class .ast-fab in index.html) replaces the old
 * .wa-fab: same spot (bottom/right 24px, 56px circle, z-index 90) and the
 * same mobile lift above the filter button.
 * ===================================================================== */

/* --- FAB --- */
.ast-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition-interactive),
              background var(--transition-interactive),
              box-shadow var(--transition-interactive);
  animation: ast-fab-in 480ms cubic-bezier(0.16, 1, 0.3, 1) 800ms backwards;
}
.ast-fab svg { display: block; }
.ast-fab:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px) scale(1.06);
  box-shadow: var(--shadow-lg);
}
.ast-fab:active { transform: scale(0.98); }
.ast-fab.ast-fab-open { box-shadow: var(--shadow-md); }
@keyframes ast-fab-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
/* Lift above the mobile filter button when both are visible (wa-fab parity). */
@media (max-width: 1023px) {
  body.has-mobile-filter .ast-fab { bottom: 80px; }
}
/* Inherit the WhatsApp-fab page suppressions: no fab on the deliberately
   fab-free developers directory, and never in print (kept it off the premium
   Market Intelligence report and every other printed page). */
body[data-page="developers"] .ast-fab { display: none !important; }
@media print { .ast-fab { display: none !important; } }

/* --- Panel --- */
.ast-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  /* Cap the top so the panel never slides under the fixed 80px header
     (its Close / New chat buttons live up there). */
  max-height: min(640px, calc(100vh - var(--nav-height) - 108px));
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 95;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              visibility 0s linear 0.4s;
}
.ast-panel.ast-open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
              visibility 0s;
}

/* --- Header (premium deep-navy bar; the message area below stays cream) --- */
.ast-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(12, 124, 132, 0.35) 0%, rgba(12, 124, 132, 0) 55%),
    linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-active) 100%);
  color: var(--color-text-inverse);
  flex-shrink: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.ast-head-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.ast-head-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  color: #ffffff;
}
.ast-head-icon svg { width: 22px; height: 22px; }
.ast-head-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ast-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  letter-spacing: 0.01em;
}
.ast-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.72);
}
.ast-status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-text-faint);
  flex-shrink: 0;
}
.ast-status--on .ast-status-dot {
  background: #46d19e;
  box-shadow: 0 0 0 0 rgba(70, 209, 158, 0.6);
  animation: ast-status-pulse 2.4s ease-out infinite;
}
.ast-status--off .ast-status-dot { background: var(--color-secondary); }
@keyframes ast-status-pulse {
  0% { box-shadow: 0 0 0 0 rgba(70, 209, 158, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(70, 209, 158, 0); }
  100% { box-shadow: 0 0 0 0 rgba(70, 209, 158, 0); }
}
.ast-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}
.ast-new-btn,
.ast-close-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: var(--radius-full);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
}
.ast-new-btn:hover,
.ast-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* --- Scrollable body --- */
.ast-body {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* --- Message bubbles --- */
.ast-msg { display: flex; flex-direction: column; flex-shrink: 0; }
.ast-msg-user { align-items: flex-end; }
.ast-msg-assistant { align-items: flex-start; }
.ast-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  max-width: 85%;
  font-size: var(--text-sm);
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}
.ast-msg-user .ast-bubble {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}
.ast-msg-assistant .ast-bubble {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}

/* --- Status indicator (thinking / searching) --- */
.ast-ind-bubble {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.ast-dots { display: inline-flex; gap: var(--space-1); }
.ast-dots span {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--color-text-faint);
  animation: ast-dot 1.2s ease-in-out infinite;
}
.ast-dots span:nth-child(2) { animation-delay: 0.2s; }
.ast-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ast-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-2px); }
}

/* --- Assistant link pills --- */
/* Navigation links: clearly buttons that take you elsewhere on the site —
   a tracked "Open on the site" label, teal accent, and a leading go-arrow. */
.ast-links {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-3);
  max-width: 92%;
}
.ast-links-label {
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-faint);
  padding-left: var(--space-1);
}
.ast-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-accent-highlight);
  text-decoration: none;
  line-height: 1.25;
  transition: background var(--transition-interactive),
              color var(--transition-interactive),
              transform var(--transition-interactive),
              box-shadow var(--transition-interactive);
}
.ast-link-label { min-width: 0; }
.ast-link-arrow {
  flex-shrink: 0;
  transition: transform var(--transition-interactive);
}
.ast-link:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}
.ast-link:hover .ast-link-arrow { transform: translateX(3px); }
.ast-link:active { transform: scale(0.99); }

/* Premium (paid) tools: muted gold/bronze border + PRO badge so they read as a
   distinct, upsell-worthy feature — matched to the home page's PRO tag palette
   (--ledger-gold #c9a45c / --ledger-gold-bright #e8d4a0), not a loud orange. */
.ast-link--premium {
  border-color: #c9a45c;
  color: #927238;
  background: linear-gradient(135deg, rgba(201, 164, 92, 0.16), rgba(201, 164, 92, 0.05));
  box-shadow: inset 0 0 0 1px rgba(201, 164, 92, 0.2);
}
.ast-link--premium:hover {
  background: linear-gradient(135deg, #e8d4a0, #c9a45c);
  color: #0a1322;
  box-shadow: 0 4px 14px rgba(201, 164, 92, 0.3);
}
.ast-link-pro {
  flex-shrink: 0;
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 3px;
  background: linear-gradient(135deg, #e8d4a0, #c9a45c);
  color: #0a1322;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.5;
}
.ast-link--premium .ast-link-arrow { margin-left: var(--space-1); }
@media (prefers-color-scheme: dark) {
  .ast-link--premium { color: #d9c288; }
}
:root[data-theme="dark"] .ast-link--premium { color: #d9c288; }
:root[data-theme="light"] .ast-link--premium { color: #927238; }

/* --- Prompt chips (empty thread) --- */
/* --- Welcome (empty state): greeting, tagline, chips, self-dismissing note --- */
.ast-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-2) var(--space-2);
  animation: ast-welcome-in 0.5s cubic-bezier(0.25, 1, 0.5, 1) both;
}
@keyframes ast-welcome-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ast-welcome-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-accent);
  background: var(--color-accent-highlight);
}
.ast-welcome-icon svg { width: 28px; height: 28px; }
.ast-welcome-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.05;
  color: var(--color-text);
}
.ast-welcome-sub {
  max-width: 30ch;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text-muted);
}
.ast-welcome-note {
  margin-top: var(--space-2);
  max-width: 34ch;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-faint);
}
.ast-welcome .ast-chips { justify-content: center; margin-top: var(--space-1); }

.ast-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.ast-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text);
  background: var(--color-surface-2);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition-interactive),
              background var(--transition-interactive);
}
.ast-chip:hover { border-color: var(--color-primary); }

/* --- Quick results block --- */
.ast-quick {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border-left: 2px solid var(--color-divider);
  padding-left: var(--space-3);
}
.ast-quick-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}
.ast-qr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-xs);
  color: var(--color-text);
  text-decoration: none;
}
.ast-qr-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ast-qr-row:hover .ast-qr-name {
  color: var(--color-primary);
  text-decoration: underline;
}
.ast-qr-type {
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
}
.ast-qr-all { color: var(--color-accent); font-weight: 600; }
.ast-qr-all:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* --- Notes (errors, timeouts, unavailable) --- */
.ast-note {
  align-self: stretch;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.ast-note-block { padding: var(--space-4); text-align: center; }

/* --- Footer (input + send) --- */
.ast-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-top: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.ast-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--color-surface-offset);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}
.ast-input:focus {
  outline: none;
  background: var(--color-surface);
  border-color: var(--color-primary);
}
.ast-input::placeholder { color: var(--color-text-faint); }
.ast-input:disabled { opacity: 0.6; cursor: not-allowed; }
.ast-send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-interactive), transform var(--transition-interactive);
}
.ast-send-btn:hover { background: var(--color-primary-hover); }
.ast-send-btn:active { transform: scale(0.94); }
.ast-send-btn:disabled { opacity: 0.45; cursor: default; }

/* --- Microcopy: subtle always-on disclosure under the input --- */
.ast-microcopy {
  flex-shrink: 0;
  padding: 0 var(--space-4) var(--space-3);
  text-align: center;
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  color: var(--color-text-faint);
}

/* Tablet range only: when the mobile filter pill has lifted the fab, lift the
   floating panel to clear it too (below this range it becomes a bottom sheet). */
@media (min-width: 641px) and (max-width: 1023px) {
  body.has-mobile-filter .ast-panel { bottom: 148px; }
}

/* --- Mobile: full-width bottom sheet --- */
@media (max-width: 640px) {
  .ast-panel {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    height: min(85vh, 640px);
    max-height: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .ast-fab { animation: none; }
  .ast-fab:hover { transform: none; }
  .ast-panel,
  .ast-panel.ast-open { transition: none; }
  .ast-dots span { animation: none; opacity: 0.6; }
  .ast-status--on .ast-status-dot { animation: none; }
  .ast-welcome { animation: none; }
}
