/* shared/tokens.css — Light/Dark theme design tokens v3
   Inspired by superhuman.com (minimalist, airy) + SMTPgoGRAPH dashboard (card/border/pill accents)
   Cloudflare Pages compatible — pure CSS variables, no build step
   Supports: prefers-color-scheme, manual toggle via .light/.dark class, localStorage persistence
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Dark theme (default) */
:root {
  --bg: #070A12;
  --bg-elevated: #0F172A;
  --surface: #111E36;
  --surface-raised: #162447;
  --surface-hover: #1A2E4F;
  --border: #1E335C;
  --border-subtle: rgba(255,255,255,0.07);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --accent: #123060;
  --accent-hover: #1A4280;
  --accent-subtle: rgba(18,48,96,0.45);
  --accent-text: #EFF6FF;
  --accent-ring: rgba(18,48,96,0.6);
  --success: #10B981;
  --success-bg: rgba(16,185,129,0.15);
  --warning: #F59E0B;
  --warning-bg: rgba(245,158,11,0.15);
  --danger: #EF4444;
  --module-identity: #3B82F6;
  --module-observe: #10B981;
  --module-dns: #06B6D4;
  --module-smtp: #8B5CF6;
  --module-tls: #F59E0B;
  --module-utils: #64748B;
  --header-bg: rgba(7,10,18,0.78);
  --link-color: #EFF6FF;
  --btn-primary-text: #EFF6FF;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --shadow: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.35);
  --max-width: 1120px;
  --gutter: 24px;
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Light theme overrides */
:root.light {
  --bg: #F8FAFC;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-raised: #F1F5F9;
  --surface-hover: #E2E8F0;
  --border: #CBD5E1;
  --border-subtle: rgba(0,0,0,0.06);
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --accent: #1E3A8A;
  --accent-hover: #1E40AF;
  --accent-subtle: rgba(30,58,138,0.10);
  --accent-text: #FFFFFF;
  --accent-ring: rgba(30,58,138,0.30);
  --success: #059669;
  --success-bg: rgba(5,150,105,0.10);
  --warning: #D97706;
  --warning-bg: rgba(217,119,6,0.10);
  --danger: #DC2626;
  --module-identity: #2563EB;
  --module-observe: #059669;
  --module-dns: #0891B2;
  --module-smtp: #7C3AED;
  --module-tls: #D97706;
  --module-utils: #64748B;
  --header-bg: rgba(255,255,255,0.88);
  --link-color: #1E3A8A;
  --btn-primary-text: #FFFFFF;
  --shadow: 0 8px 32px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.06);
}

/* System preference detection */
@media (prefers-color-scheme: light) {
  :root:not(.dark) {
    --bg: #F8FAFC;
    --bg-elevated: #FFFFFF;
    --surface: #FFFFFF;
    --surface-raised: #F1F5F9;
    --surface-hover: #E2E8F0;
    --border: #CBD5E1;
    --border-subtle: rgba(0,0,0,0.06);
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --accent: #1E3A8A;
    --accent-hover: #1E40AF;
    --accent-subtle: rgba(30,58,138,0.10);
    --accent-text: #FFFFFF;
    --accent-ring: rgba(30,58,138,0.30);
    --success: #059669;
    --success-bg: rgba(5,150,105,0.10);
    --warning: #D97706;
    --warning-bg: rgba(217,119,6,0.10);
    --danger: #DC2626;
    --module-identity: #2563EB;
    --module-observe: #059669;
    --module-dns: #0891B2;
    --module-smtp: #7C3AED;
    --module-tls: #D97706;
    --module-utils: #64748B;
    --header-bg: rgba(255,255,255,0.88);
    --link-color: #1E3A8A;
    --btn-primary-text: #FFFFFF;
    --shadow: 0 8px 32px rgba(0,0,0,0.08);
    --shadow-card: 0 4px 24px rgba(0,0,0,0.06);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 200ms ease, color 200ms ease;
}
a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }

/* utility */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font: 12px/1 var(--font-mono); font-weight: 600; letter-spacing: 0.02em;
}
.pill-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16,185,129,0.25); }
.pill-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245,158,11,0.25); }
.pill-accent { background: var(--accent-subtle); color: var(--accent-text); border: 1px solid rgba(18,48,96,0.5); }
:root.light .pill-accent, :root:not(.dark) .pill-accent { color: var(--accent); border-color: rgba(30,58,138,0.22); }
@media (prefers-color-scheme: light) {
  :root:not(.dark) .pill-accent { color: #1E3A8A; border-color: rgba(30,58,138,0.22); }
}

/* Theme toggle — floating viewport-fixed, compact icon-only, expands on hover */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 80;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  transition: width 160ms ease, padding 160ms ease, gap 160ms ease, background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
}
.theme-toggle .toggle-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  transition: max-width 160ms ease, opacity 120ms ease, margin 160ms ease;
  margin-left: 0;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  width: auto;
  padding: 0 12px;
  gap: 6px;
  background: var(--surface-hover);
  color: var(--text-primary);
}
.theme-toggle:hover .toggle-label,
.theme-toggle:focus-visible .toggle-label {
  max-width: 90px;
  opacity: 1;
  margin-left: 2px;
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle:active { transform: scale(0.97); }
@media (max-width: 880px) {
  .theme-toggle { display: none; }
}
