/* ===== SearchAd AI — shared design system =====
   Single source of truth for tokens, typography, and core component
   styles used by index.html, login.html, and app.html. */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@300;400;500;600;700;800;900&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --bg:        oklch(0.985 0.005 85);
  --bg-2:      oklch(0.965 0.006 85);
  --bg-3:      oklch(0.945 0.008 85);
  --panel:     oklch(0.995 0.003 85);
  --ink:       oklch(0.18 0.015 260);
  --ink-2:     oklch(0.36 0.012 260);
  --muted:     oklch(0.54 0.01 260);
  --faint:     oklch(0.72 0.01 260);
  --border:    oklch(0.90 0.006 85);
  --border-2:  oklch(0.84 0.006 85);
  --accent:    oklch(0.62 0.18 148);
  --accent-2:  oklch(0.46 0.16 148);
  --accent-bg: oklch(0.945 0.06 148);
  --data:      oklch(0.55 0.20 265);
  --data-2:    oklch(0.42 0.18 265);
  --data-bg:   oklch(0.95 0.05 265);
  --warn:      oklch(0.62 0.13 55);
  --warn-bg:   oklch(0.96 0.04 70);
  --danger:    oklch(0.55 0.20 25);
  --danger-bg: oklch(0.96 0.04 25);
  --navy:      oklch(0.22 0.04 260);
}

html, body {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "ss01","cv11";
}

.font-serif { font-family: 'Instrument Serif', ui-serif, Georgia, serif; font-weight: 400; letter-spacing: -0.01em; }
.font-mono  { font-family: 'Geist Mono', ui-monospace, monospace; }

/* Color helpers */
.ink    { color: var(--ink); }
.ink-2  { color: var(--ink-2); }
.muted  { color: var(--muted); }
.faint  { color: var(--faint); }
.text-accent   { color: var(--accent-2); }
.text-accent-strong { color: oklch(0.40 0.18 148); }
.text-data     { color: var(--data-2); }
.text-warn     { color: var(--warn); }
.text-danger   { color: var(--danger); }

/* Surfaces */
.bg-panel { background: var(--panel); }
.bg-bg    { background: var(--bg); }
.bg-bg-2  { background: var(--bg-2); }
.bg-bg-3  { background: var(--bg-3); }
.bg-accent     { background: var(--accent); }
.bg-accent-bg  { background: var(--accent-bg); }
.bg-data       { background: var(--data); }
.bg-data-bg    { background: var(--data-bg); }
.bg-warn-bg    { background: var(--warn-bg); }
.bg-danger-bg  { background: var(--danger-bg); }
.bg-navy       { background: var(--navy); }

/* Borders */
.border-line   { border-color: var(--border) !important; }
.border-line-2 { border-color: var(--border-2) !important; }

/* Hairline card shadow */
.hairline {
  border: 1px solid var(--border);
  box-shadow:
    0 1px 0 0 oklch(1 0 0 / 0.5) inset,
    0 1px 1px -1px oklch(0 0 0 / 0.04),
    0 8px 24px -12px oklch(0 0 0 / 0.08);
}
.hairline-strong {
  border: 1px solid var(--border-2);
  box-shadow:
    0 1px 0 0 oklch(1 0 0 / 0.6) inset,
    0 2px 4px -2px oklch(0 0 0 / 0.06),
    0 20px 40px -20px oklch(0 0 0 / 0.12);
}

/* Eyebrow */
.eyebrow {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Editorial heading helpers */
.h-display { font-family: 'Instrument Serif', serif; line-height: 0.98; letter-spacing: -0.02em; }
.h-italic-accent { font-family: 'Instrument Serif', serif; font-style: italic; color: var(--accent-2); }
.h-hero { font-family: 'Geist', system-ui, sans-serif; font-weight: 800; letter-spacing: -0.045em; line-height: 0.94; }
.h-hero-accent { color: var(--accent-2); }
.h-hero-data   { color: var(--data-2); }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px;
  font-family: 'Geist Mono', monospace; font-size: 11px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink-2);
}
.chip-r { color: var(--accent-2); background: var(--accent-bg); border-color: oklch(0.85 0.05 150); }
.chip-w { color: var(--warn);     background: var(--warn-bg);   border-color: oklch(0.85 0.06 70); }
.chip-d { color: var(--data-2);   background: var(--data-bg);   border-color: oklch(0.85 0.06 265); }

/* Buttons */
.btn-primary {
  background: var(--navy);
  color: oklch(0.98 0 0);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--navy);
  transition: opacity 140ms ease, transform 80ms ease;
}
.btn-primary:hover:not(:disabled) { opacity: 0.92; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: var(--panel);
  color: var(--ink-2);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.btn-secondary:hover:not(:disabled) { color: var(--ink); border-color: var(--border-2); }
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-accent {
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--accent);
  transition: opacity 140ms ease;
}
.btn-accent:hover:not(:disabled) { opacity: 0.92; }
.btn-accent:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  transition: color 140ms ease, background 140ms ease;
  border: none;
}
.btn-ghost:hover { color: var(--ink); background: var(--bg-2); }

/* Input */
.input-line {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
  width: 100%;
}
.input-line::placeholder { color: var(--faint); }
.input-line:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px oklch(0.36 0.012 260 / 0.08);
}
.input-mono { font-family: 'Geist Mono', monospace; font-size: 13px; }

/* Ticker dot */
.ticker-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px oklch(0.56 0.11 150 / 0.18);
  display: inline-block;
}

/* Pulse on approve buttons */
@keyframes apulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.56 0.11 150 / 0.35); }
  50%      { box-shadow: 0 0 0 10px oklch(0.56 0.11 150 / 0); }
}
.approve-pulse { animation: apulse 2.4s ease-out infinite; }

/* Logo (mark + wordmark) */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink);
}
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--navy);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-word {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-word b { font-weight: 500; }
.brand-word .muted-word { color: var(--muted); font-weight: 400; }

/* App shell — sidebar slides in as an overlay on mobile, sits inline on desktop. */
.app-sidebar {
  width: 16rem;
  background: var(--panel);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-backdrop {
  display: none;
}
.hamburger-btn { display: none; }

@media (max-width: 767px) {
  .app-sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 35;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
    box-shadow: 18px 0 40px -20px oklch(0 0 0 / 0.25);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 56px 0 0 0;
    background: oklch(0.18 0.015 260 / 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 34;
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
  }
  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--ink-2);
    transition: background 140ms ease;
  }
  .hamburger-btn:hover { background: var(--bg-2); }
}

/* Sticky nav */
.app-nav {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: oklch(0.985 0.005 85 / 0.82);
  border-bottom: 1px solid var(--border);
}

/* Section divider */
.section-divider { border-top: 1px solid var(--border); }

/* Grid bg used on hero-ish surfaces */
.grid-bg {
  background-image:
    linear-gradient(to right,  oklch(0.18 0.015 260 / 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(0.18 0.015 260 / 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}

/* Hide scrollbars on horizontally-scrolling tab strips (kept scrollable for touch). */
#header-tabs::-webkit-scrollbar { display: none; }

/* Tab pill (for the in-app top tabs) */
.tab-pill {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: color 140ms ease, background 140ms ease;
  border: 1px solid transparent;
}
.tab-pill:hover { color: var(--ink); background: var(--bg-2); }
.tab-pill.active {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--border);
  box-shadow: 0 1px 0 0 oklch(1 0 0 / 0.5) inset, 0 1px 2px -1px oklch(0 0 0 / 0.04);
}

/* =====================================================================
   Loading states
   ===================================================================== */

/* Full-section centered loader: brand mark + animated dots + status text.
   Used on app boot, route changes, and any "fetching first paint" moment. */
.loader-screen {
  min-height: 320px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px 24px;
  position: relative;
}
.loader-screen::before {
  /* Soft green halo, mirrors the landing hero radial. */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(50% 50% at 50% 40%, oklch(0.955 0.035 150 / 0.45), transparent 70%);
  z-index: 0;
}
.loader-screen > * { position: relative; z-index: 1; }

.loader-mark {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--navy);
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  position: relative;
  animation: loader-bob 2.6s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  box-shadow:
    0 1px 0 0 oklch(1 0 0 / 0.08) inset,
    0 12px 28px -10px oklch(0 0 0 / 0.25);
}
.loader-mark::after {
  /* Pulsing accent ring around the mark. */
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 18px;
  border: 1px solid oklch(0.56 0.18 148 / 0.5);
  animation: loader-ring 2.2s ease-out infinite;
  pointer-events: none;
}

@keyframes loader-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes loader-ring {
  0%   { opacity: 0.9; transform: scale(0.96); }
  70%  { opacity: 0;   transform: scale(1.18); }
  100% { opacity: 0;   transform: scale(1.18); }
}

.loader-eyebrow {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.loader-title {
  font-family: 'Instrument Serif', serif;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
  text-align: center;
  max-width: 420px;
}
.loader-title em {
  font-style: italic;
  color: var(--accent-2);
}
.loader-subtitle {
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  max-width: 380px;
  line-height: 1.55;
  margin-top: -8px;
}

/* Animated three-dot row used both inline (typing) and on loader screens. */
.loader-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}
.loader-dots > span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.35;
  animation: loader-dot 1.2s ease-in-out infinite;
}
.loader-dots > span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots > span:nth-child(3) { animation-delay: 0.30s; }
@keyframes loader-dot {
  0%, 80%, 100% { transform: translateY(0)   scale(0.85); opacity: 0.35; }
  40%           { transform: translateY(-4px) scale(1);    opacity: 1; }
}

/* Inline "AI is thinking" bubble — paired with the AI avatar in chat. The
   bubble can grow to host an expandable list of intermediate tool steps when
   the agent is in a long tool-use loop. */
.thinking-bubble {
  display: block;
  max-width: min(100%, 520px);
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  color: var(--muted);
  font-family: 'Geist Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}
.thinking-bubble .loader-dots > span {
  width: 6px;
  height: 6px;
}
.thinking-bubble [data-typing-steps] {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-family: 'Inter', system-ui, sans-serif;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--ink-2);
  max-height: 240px;
  overflow-y: auto;
}
.thinking-bubble [data-typing-toggle] {
  font-family: 'Inter', system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
}

/* Skeleton placeholders for line-level / block-level loading. Use sparingly —
   prefer .loader-screen for whole sections. */
.sk-line {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-2) 0%,
    oklch(0.93 0.006 85) 50%,
    var(--bg-2) 100%
  );
  background-size: 400px 100%;
  animation: sk-shimmer 1.4s linear infinite;
}
.sk-block {
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    var(--bg-2) 0%,
    oklch(0.93 0.006 85) 50%,
    var(--bg-2) 100%
  );
  background-size: 400px 100%;
  animation: sk-shimmer 1.4s linear infinite;
}
@keyframes sk-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: oklch(0.18 0.015 260 / 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow:
    0 1px 0 0 oklch(1 0 0 / 0.6) inset,
    0 30px 60px -20px oklch(0 0 0 / 0.25);
}

/* Onboarding screenshot thumbnails + lightbox */
.onboard-thumb-row {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.onboard-thumb {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  vertical-align: middle;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.onboard-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.onboard-thumb:hover,
.onboard-thumb:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 4px 10px -4px oklch(0 0 0 / 0.25);
  outline: none;
}

.onboard-hover-preview {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: 0 20px 40px -12px oklch(0 0 0 / 0.35);
}
.onboard-hover-preview img {
  display: block;
  width: 320px;
  max-width: 60vw;
  height: auto;
  border-radius: 6px;
}

#onboard-lightbox:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}
#onboard-lightbox {
  background: oklch(0.12 0.015 260 / 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px;
}
.onboard-lightbox-figure {
  margin: 0;
  max-width: min(1200px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.onboard-lightbox-figure img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  box-shadow: 0 30px 60px -20px oklch(0 0 0 / 0.5);
  background: var(--panel);
}
.onboard-lightbox-caption {
  color: oklch(1 0 0 / 0.85);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}
.onboard-lightbox-close,
.onboard-lightbox-nav {
  position: fixed;
  width: 44px; height: 44px;
  border-radius: 999px;
  border: 1px solid oklch(1 0 0 / 0.2);
  background: oklch(0.18 0.015 260 / 0.6);
  color: oklch(1 0 0 / 0.92);
  font-size: 26px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: background 120ms ease, transform 120ms ease;
}
.onboard-lightbox-close { top: 18px; right: 18px; font-size: 28px; }
.onboard-lightbox-prev  { left: 18px;  top: 50%; transform: translateY(-50%); }
.onboard-lightbox-next  { right: 18px; top: 50%; transform: translateY(-50%); }
.onboard-lightbox-close:hover,
.onboard-lightbox-nav:hover {
  background: oklch(0.22 0.015 260 / 0.85);
}
.onboard-lightbox-prev:hover { transform: translateY(-50%) scale(1.05); }
.onboard-lightbox-next:hover { transform: translateY(-50%) scale(1.05); }
.onboard-lightbox-nav[disabled] { opacity: 0.4; cursor: default; }

@media (max-width: 640px) {
  .onboard-hover-preview { display: none !important; }
  .onboard-lightbox-prev { left: 8px; }
  .onboard-lightbox-next { right: 8px; }
}
