/* aao.guide Dashboard — Production Styles */

/* ── Fonts ────────────────────────────────────────── */
@import url('https://api.fontshare.com/v2/css?f[]=satoshi@400,500,600,700&display=swap');

/* ── Tokens ───────────────────────────────────────── */
:root {
  --font-body: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --color-bg:             #f7f6f2;
  --color-surface:        #ffffff;
  --color-surface-2:      #f9f8f5;
  --color-surface-offset: #f3f0ec;
  --color-divider:        #dcd9d5;
  --color-border:         #d4d1ca;
  --color-text:           #28251d;
  --color-text-muted:     #7a7974;
  --color-text-faint:     #bab9b4;
  --color-primary:        #01696f;
  --color-primary-hover:  #0c4e54;
  --color-primary-light:  #cedcd8;
  --color-success:        #437a22;
  --color-warning:        #964219;
  --color-error:          #a12c7b;
  --color-high:           #a12c7b;
  --color-medium:         #964219;
  --color-low:            #437a22;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --shadow-sm: 0 1px 2px rgba(40,37,29,0.06);
  --shadow-md: 0 4px 12px rgba(40,37,29,0.08);
  --transition: 180ms cubic-bezier(0.16,1,0.3,1);
}
[data-theme="dark"] {
  --color-bg:             #171614;
  --color-surface:        #1c1b19;
  --color-surface-2:      #201f1d;
  --color-surface-offset: #1d1c1a;
  --color-divider:        #262523;
  --color-border:         #393836;
  --color-text:           #cdccca;
  --color-text-muted:     #797876;
  --color-text-faint:     #5a5957;
  --color-primary:        #4f98a3;
  --color-primary-hover:  #227f8b;
  --color-primary-light:  #313b3b;
  --color-success:        #6daa45;
  --color-warning:        #bb653b;
  --color-error:          #d163a7;
  --color-high:           #d163a7;
  --color-medium:         #bb653b;
  --color-low:            #6daa45;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }
img { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* ── Layout ───────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  position: sticky;
  top: 0;
  z-index: 100;
}
.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-divider);
  padding: 1.25rem 0.75rem;
  position: sticky;
  top: 56px;
  height: calc(100dvh - 56px);
  overflow-y: auto;
}
.main-content {
  padding: 2rem 2.5rem;
  overflow-x: hidden;
}

/* ── Logo ─────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.logo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  display: inline-block;
}

/* ── Nav ──────────────────────────────────────────── */
.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: 0.75rem 0.75rem 0.375rem;
  margin-top: 0.5rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  user-select: none;
}
.nav-item:hover { background: var(--color-surface-offset); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-light); color: var(--color-primary); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Topbar right ─────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--color-surface-offset); color: var(--color-text); }
.btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* ── Section header ───────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.375rem;
}
.page-subtitle { color: var(--color-text-muted); font-size: 0.9375rem; margin-bottom: 2rem; }

/* ── KPI Cards ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}
.kpi-meta { font-size: 0.8125rem; color: var(--color-text-faint); }
.kpi-score-ring {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 48px; height: 48px;
}

/* ── Score arc in KPI ─────────────────────────────── */
.score-arc { transform: rotate(-90deg); transform-origin: 50% 50%; }

/* ── Panel / Card ─────────────────────────────────── */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-divider);
}
.panel-title { font-size: 0.9375rem; font-weight: 600; }
.panel-body { padding: 1.25rem; }

/* ── Table ────────────────────────────────────────── */
.data-table { width: 100%; font-size: 0.9rem; }
.data-table th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-divider);
  white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-surface-2); }
.data-table .page-name { font-weight: 600; color: var(--color-text); }
.data-table .page-url  { font-size: 0.8125rem; color: var(--color-text-muted); margin-top: 1px; }

/* ── Score bar ────────────────────────────────────── */
.score-bar { display: flex; align-items: center; gap: 0.625rem; }
.score-bar-track {
  flex: 1; height: 6px;
  background: var(--color-surface-offset);
  border-radius: 9999px;
  overflow: hidden;
  min-width: 60px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--color-primary);
  transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}
.score-num { font-weight: 600; min-width: 2.25rem; font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-high    { background: color-mix(in oklch, var(--color-high) 12%, transparent);    color: var(--color-high); }
.badge-medium  { background: color-mix(in oklch, var(--color-medium) 12%, transparent);  color: var(--color-medium); }
.badge-low     { background: color-mix(in oklch, var(--color-low) 12%, transparent);     color: var(--color-low); }
.badge-open    { background: color-mix(in oklch, var(--color-primary) 12%, transparent); color: var(--color-primary); }
.badge-done    { background: color-mix(in oklch, var(--color-success) 10%, transparent); color: var(--color-success); }
.badge-ignored { background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge-active  { background: color-mix(in oklch, var(--color-success) 10%, transparent); color: var(--color-success); }
.badge-trust   { background: #e8f4f5; color: #01696f; }
.badge-visibility { background: #f0edf8; color: #7a39bb; }
.badge-conversion { background: #fdf3e8; color: #964219; }
.badge-recommendation { background: #eef5e9; color: #437a22; }

/* ── Status dot ───────────────────────────────────── */
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.375rem;
  flex-shrink: 0;
}
.status-dot.open     { background: var(--color-primary); box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-primary) 20%, transparent); }
.status-dot.done     { background: var(--color-success); }
.status-dot.ignored  { background: var(--color-text-faint); }

/* ── Action row expand ────────────────────────────── */
.action-detail {
  display: none;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-divider);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}
.action-detail.open { display: block; }
.action-detail p + p { margin-top: 0.5rem; }
.action-detail strong { color: var(--color-text); }
.action-actions { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 4rem 2rem;
  color: var(--color-text-muted);
}
.empty-icon { width: 48px; height: 48px; margin-bottom: 1rem; color: var(--color-text-faint); }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--color-text); margin-bottom: 0.375rem; }
.empty-desc  { font-size: 0.875rem; max-width: 36ch; line-height: 1.5; }

/* ── Skeleton ─────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--color-surface-offset) 25%,
    var(--color-divider) 50%,
    var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text    { height: 1em; margin-bottom: 0.375rem; }
.skeleton-heading { height: 1.5em; width: 40%; margin-bottom: 1rem; }
.skeleton-kpi     { height: 5rem; border-radius: var(--radius-lg); }
.skeleton-row     { height: 3.25rem; border-radius: 0; }

/* ── Error banner ─────────────────────────────────── */
.error-banner {
  background: color-mix(in oklch, var(--color-error) 8%, var(--color-surface));
  border: 1px solid color-mix(in oklch, var(--color-error) 25%, transparent);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--color-error);
  margin-bottom: 1.5rem;
  display: none;
}
.error-banner.visible { display: flex; align-items: center; gap: 0.5rem; }

/* ── Toast ────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 9999;
}
.toast {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.625rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s cubic-bezier(0.16,1,0.3,1);
  max-width: 320px;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Refresh indicator ─────────────────────────────── */
.refresh-spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 1.25rem 1rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .data-table th:nth-child(n+4),
  .data-table td:nth-child(n+4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════════════════
   AAO Visibility Score Block
════════════════════════════════════════════════════ */
#aao-score-block {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 20px 24px;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px oklch(0.2 0.01 80 / 0.06);
}
.aao-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.aao-ring-wrap { display: flex; align-items: center; gap: 14px; }
.aao-ring {
  position: relative; width: 80px; height: 80px; flex-shrink: 0;
}
.aao-ring-bg  { fill: none; stroke: var(--color-divider); stroke-width: 8; }
.aao-ring-fill {
  fill: none; stroke-width: 8; stroke-linecap: round;
  stroke-dashoffset: 201;
}
.aao-ring-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; letter-spacing: -0.04em;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.kpi-delta { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
.delta-up   { color: var(--color-success); background: oklch(from var(--color-success) l c h / 0.12); }
.delta-down { color: var(--color-error);   background: oklch(from var(--color-error)   l c h / 0.12); }

/* Breakdown bars */
.aao-breakdown { display: flex; flex-direction: column; gap: 9px; }
.aao-bd-row { display: flex; align-items: center; gap: 8px; }
.aao-bd-label {
  font-size: 11px; color: var(--color-text-muted);
  min-width: 118px; flex-shrink: 0;
}
.aao-bd-bar {
  flex: 1; height: 4px; background: var(--color-divider);
  border-radius: 2px; overflow: hidden;
}
.aao-bd-fill { height: 100%; border-radius: 2px; width: 0; }
.aao-bd-val {
  font-size: 11px; font-weight: 700; color: var(--color-text);
  min-width: 28px; text-align: right; font-variant-numeric: tabular-nums;
}

/* LLM rows */
.aao-llms { display: flex; flex-direction: column; gap: 7px; }
.aao-llm-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 0.375rem;
  background: var(--color-surface-offset, var(--color-bg));
  border: 1px solid var(--color-border);
}
.aao-llm-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.aao-llm-name { font-size: 11px; font-weight: 600; color: var(--color-text); flex: 1; }
.aao-llm-bar  { width: 56px; height: 4px; background: var(--color-divider); border-radius: 2px; overflow: hidden; }
.aao-llm-fill { height: 100%; border-radius: 2px; width: 0; }
.aao-llm-pct  {
  font-size: 11px; font-weight: 700; color: var(--color-text);
  min-width: 32px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ════════════════════════════════════════════════════
   Two-column layout: Trend + Competitor
════════════════════════════════════════════════════ */
.ov-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 1rem;
}

/* ════════════════════════════════════════════════════
   AI Exposure Trend Chart
════════════════════════════════════════════════════ */
.trend-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 3px oklch(0.2 0.01 80 / 0.06);
}
.trend-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.trend-title { font-size: 12px; font-weight: 700; color: var(--color-text); }
.trend-range-btn {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; border: none; cursor: pointer;
  background: transparent; color: var(--color-text-muted);
  transition: all 180ms ease;
}
.trend-range-btn.active {
  background: var(--color-primary-light, oklch(from var(--color-primary) l c h / 0.12));
  color: var(--color-primary);
}
.trend-body { padding: 12px 16px; }
.trend-canvas-wrap { height: 168px; position: relative; }
.trend-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 6px 16px 12px;
}
.trend-leg-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--color-text-muted); font-weight: 500;
}
.trend-leg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ════════════════════════════════════════════════════
   Competitor Table
════════════════════════════════════════════════════ */
.comp-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 3px oklch(0.2 0.01 80 / 0.06);
}
.comp-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.comp-title { font-size: 12px; font-weight: 700; color: var(--color-text); }
.comp-rank  { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.comp-domain { font-size: 12px; font-weight: 600; color: var(--color-text); }
.comp-you-badge {
  font-size: 9px; font-weight: 700;
  background: oklch(from var(--color-primary) l c h / 0.12);
  color: var(--color-primary);
  padding: 1px 5px; border-radius: 999px; margin-left: 6px;
}
.comp-you-row { background: oklch(from var(--color-primary) l c h / 0.05); }
.comp-you-row td { font-weight: 600; }

/* ════════════════════════════════════════════════════
   Responsive
════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  #aao-score-block { grid-template-columns: 1fr; }
  .ov-2col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  #aao-score-block { padding: 16px; }
}
