/* ============================================================
   Sunaiva Memory — Synapse Dashboard — site.css
   Brand: cyan accent (#06b6d4 / cyan-500), dark backgrounds
   No purple/violet gradients. Monospace for stat numbers.
   ============================================================ */

/* ── Reset / base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0a0e17;
  --bg-surface:   #111827;
  --bg-elevated:  #1a2332;
  --bg-border:    #1f2e42;
  --bg-hover:     #1f2e42;

  --cyan-50:   #ecfeff;
  --cyan-100:  #cffafe;
  --cyan-200:  #a5f3fc;
  --cyan-300:  #67e8f9;
  --cyan-400:  #22d3ee;
  --cyan-500:  #06b6d4;
  --cyan-600:  #0891b2;
  --cyan-700:  #0e7490;
  --cyan-800:  #155e75;
  --cyan-900:  #164e63;

  --text-primary:   #f0f9ff;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  --danger-bg:  #2a1215;
  --danger-fg:  #f87171;
  --warn-bg:    #2a1f0a;
  --warn-fg:    #fbbf24;
  --success-bg: #0a2010;
  --success-fg: #34d399;

  /* System font stack — no external CDN dependency, no SRI risk */
  --font-sans:  'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:  'Geist Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, 'Cascadia Code', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --transition: 150ms ease;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

.mono { font-family: var(--font-mono); }
.text-muted  { color: var(--text-secondary); }
.text-dim    { color: var(--text-muted); }
.text-cyan   { color: var(--cyan-400); }
.text-danger { color: var(--danger-fg); }
.text-warn   { color: var(--warn-fg); }
.text-ok     { color: var(--success-fg); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--cyan-800); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-600); }

/* ── Layout ───────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.topbar-logo .logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 8px var(--cyan-400);
}

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--bg-hover); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cyan-800);
  color: var(--cyan-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
  margin-top: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: rgba(6, 182, 212, 0.12); color: var(--cyan-400); }
.nav-link svg { opacity: 0.6; flex-shrink: 0; }
.nav-link.active svg { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--bg-border);
}

.main-content {
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Stat tiles ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.875rem;
}

.stat-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--cyan-300);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-delta {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  margin-top: 0.25rem;
}
.stat-delta.up   { color: var(--success-fg); }
.stat-delta.down { color: var(--danger-fg); }

/* ── Progress bars ────────────────────────────────────────── */
.progress-track {
  height: 5px;
  background: var(--bg-border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--cyan-700), var(--cyan-400));
}
.progress-fill.warn   { background: linear-gradient(90deg, #b45309, #f59e0b); }
.progress-fill.danger { background: linear-gradient(90deg, #991b1b, #ef4444); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--cyan-600);
  color: #fff;
}
.btn-primary:hover { background: var(--cyan-500); box-shadow: 0 0 16px rgba(6,182,212,0.3); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(127,29,29,0.4);
  color: var(--danger-fg);
  border: 1px solid rgba(127,29,29,0.5);
}
.btn-danger:hover { background: rgba(127,29,29,0.7); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-cyan    { background: rgba(6,182,212,0.15); color: var(--cyan-300); }
.badge-green   { background: rgba(52,211,153,0.15); color: var(--success-fg); }
.badge-amber   { background: rgba(251,191,36,0.15); color: var(--warn-fg); }
.badge-red     { background: rgba(248,113,113,0.15); color: var(--danger-fg); }

/* ── Forms / inputs ───────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font-sans);
}
.input:focus {
  border-color: var(--cyan-600);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.12);
}
.input::placeholder { color: var(--text-muted); }

label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); display: block; margin-bottom: 0.3rem; }

.form-group { margin-bottom: 1rem; }

/* ── Dividers ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--bg-border);
  margin: 1.25rem 0;
}

/* ── Table ────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--bg-border);
}
.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-primary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ── Skeleton loader ──────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  animation: slideIn 0.2s ease, fadeOut 0.35s ease 3.3s forwards;
  max-width: 320px;
}
@keyframes slideIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; pointer-events: none; } }

.toast.info    { border-color: var(--cyan-800); }
.toast.success { border-color: rgba(52,211,153,0.4); }
.toast.error   { border-color: rgba(248,113,113,0.4); }
.toast.warn    { border-color: rgba(251,191,36,0.4); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary); font-size: 1.1rem; border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Search box ───────────────────────────────────────────── */
.search-wrapper {
  position: relative;
}
.search-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrapper .input { padding-left: 2.25rem; }

/* ── Memory item ──────────────────────────────────────────── */
.memory-item {
  display: flex;
  gap: 0.875rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--bg-border);
}
.memory-item:last-child { border-bottom: none; }
.memory-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--cyan-400);
}
.memory-text { font-size: 0.875rem; color: var(--text-primary); }
.memory-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* ── Upgrade banner ───────────────────────────────────────── */
.upgrade-banner {
  background: linear-gradient(135deg, rgba(6,182,212,0.08) 0%, rgba(14,116,144,0.05) 100%);
  border: 1px solid rgba(6,182,212,0.2);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

/* ── Tier comparison ──────────────────────────────────────── */
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.tier-card {
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition);
}
.tier-card.current { border-color: var(--cyan-600); background: rgba(6,182,212,0.05); }
.tier-card:not(.current):hover { border-color: var(--bg-hover); }

.tier-name   { font-weight: 700; font-size: 0.875rem; }
.tier-price  { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; color: var(--cyan-300); }
.tier-price span { font-size: 0.7rem; font-family: var(--font-sans); color: var(--text-secondary); font-weight: 400; }
.tier-feature { font-size: 0.775rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.3rem; }
.tier-feature.yes { color: var(--success-fg); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--text-secondary);
  text-align: center;
}
.empty-state svg { opacity: 0.3; }

/* ── Error alert ──────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: var(--danger-bg); color: var(--danger-fg); border: 1px solid rgba(248,113,113,0.3); }
.alert-success { background: var(--success-bg); color: var(--success-fg); border: 1px solid rgba(52,211,153,0.3); }
.alert-info    { background: rgba(6,182,212,0.08); color: var(--cyan-300); border: 1px solid rgba(6,182,212,0.25); }

/* ── Auth pages ───────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  font-weight: 700;
}

.auth-logo .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 10px var(--cyan-400);
}

/* ── Key display ──────────────────────────────────────────── */
.api-key-box {
  background: var(--bg-base);
  border: 1px solid var(--cyan-800);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan-200);
  word-break: break-all;
  margin: 0.5rem 0;
}

/* ── Footer links ─────────────────────────────────────────── */
.footer-links {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  padding: 1rem 0;
  flex-wrap: wrap;
}
.footer-links a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--cyan-400); }

/* ── Mobile responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 40;
    width: 220px;
    border-right: 1px solid var(--bg-border);
  }
  .sidebar.mobile-open { display: flex; }

  .main-content {
    padding: 1rem;
    grid-column: 1;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tier-grid { grid-template-columns: 1fr 1fr; }

  .topbar .hamburger { display: flex; }

  h1 { font-size: 1.35rem; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .tier-grid { grid-template-columns: 1fr; }
  .upgrade-banner { flex-direction: column; align-items: flex-start; }
}

/* ── Hamburger (hidden on desktop) ───────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
}
.hamburger:hover { background: var(--bg-hover); }
.hamburger span {
  width: 18px; height: 2px;
  background: currentColor;
  border-radius: 1px;
  display: block;
}

/* ── Plan badge in sidebar ────────────────────────────────── */
.plan-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(6,182,212,0.15);
  color: var(--cyan-300);
  margin-left: 0.35rem;
}

/* ── Code / API key inline ────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--cyan-300);
}

/* ── Glow on primary action ───────────────────────────────── */
.glow-cyan:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(6,182,212,0.35);
}
