/**
 * ============================================================================
 * TAXCODEX DESIGN SYSTEM — SINGLE SOURCE OF TRUTH
 * ============================================================================
 *
 * This file defines all shared CSS variables, typography, and component
 * classes. Every HTML page should import this file instead of duplicating
 * :root blocks and base styles.
 *
 * Two design systems share this file:
 *   - GREEN:  horizontal top nav, green accent (#1a5c3a)
 *   - NAVY:  vertical sidebar, teal accent (#0D7377)
 *
 * Usage:
 *   In every HTML <head>, replace inline :root blocks with:
 *   <link relpreconnect href=...>
 *   <link href=...fonts.googleapis.com/css2?family=Space+Grotesk...>
 *   <link rel=stylesheet href=/css/design-system.css>
 *
 * Adding a new nav link:
 *   Edit shared-sidebar-nav.js NAV_CONFIG — all sidebar pages get it.
 *
 * Changing a color:
 *   Edit a :root block here — all pages get it.
 *
 * ============================================================================
 */

/* ─── FONTS ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

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

/* ─── UNIFIED DESIGN SYSTEM VARIABLES ─────────────────────────────────────────
   All CSS custom properties for TaxCodex.
   Green design (horizontal nav): --ink, --paper, --accent, etc.
   Navy design (sidebar nav): --navy, --white, --teal, etc.

   Used by: dashboard.html, pricing.html, state.html, alerts.html,
            dashboard/individual.html, dashboard/sales-tax.html,
            and all other pages.
*/
:root {
  /* ── GREEN SYSTEM (horizontal nav pages) ── */
  --ink: #0a0f1c;
  --paper: #f8f7f4;
  --accent: #1a5c3a;
  --accent-light: #2d8f5e;
  --accent-bg: rgba(26, 92, 58, 0.08);
  --muted: #6b7280;
  --border: #e2e0db;
  --glow: rgba(26, 92, 58, 0.08);
  --card-bg: #ffffff;

  /* ── NAVY SYSTEM (sidebar nav pages) ── */
  --navy: #2C3E50;
  --navy-dark: #1a2734;
  --navy-deeper: #152029;
  --navy-light: #34495E;
  --tan: #8B7355;
  --tan-light: #A89279;
  --tan-muted: rgba(139, 115, 85, 0.12);
  --white: #FFFFFF;
  --off-white: #F5F5F0;
  --light-gray: #ECEAE5;
  --mid-gray: #D1CFC9;
  --charcoal: #333333;
  --text-secondary: #6B7280;
  --steel: #5B7A8A;
  --steel-light: #7A9DAE;
  --steel-bg: rgba(91, 122, 138, 0.08);
  --steel-hover: rgba(91, 122, 138, 0.12);
  --teal: #0D7377;
  --teal-light: #14A085;
  --teal-bg: rgba(13, 115, 119, 0.08);
  --teal-border: rgba(13, 115, 119, 0.18);

  /* ── PRIORITY / IMPACT ── */
  --high: #dc2626;
  --high-bg: #fef2f2;
  --high-border: #fecaca;
  --medium: #d97706;
  --medium-bg: #fffbeb;
  --medium-border: #fde68a;
  --low: #059669;
  --low-bg: #ecfdf5;
  --low-border: #a7f3d0;

  /* ── SHARED SEMANTIC ── */
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-dark: #166534;
  --warning: #f59e0b;
  --warning-bg: #fef08a;
  --warning-dark: #713f12;
  --info: #0891b2;
  --info-bg: #e0f2fe;

  /* ── COLOR OPACITY VARIANTS ── */
  --accent-10: rgba(26, 92, 58, 0.10);
  --accent-15: rgba(26, 92, 58, 0.15);
  --accent-20: rgba(26, 92, 58, 0.20);
  --navy-04: rgba(44, 62, 80, 0.04);
  --navy-06: rgba(44, 62, 80, 0.06);
  --navy-10: rgba(44, 62, 80, 0.10);
  --navy-15: rgba(44, 62, 80, 0.15);
  --navy-medium: #1e3a5f;
  --overlay-light: rgba(0, 0, 0, 0.05);
  --overlay: rgba(0, 0, 0, 0.08);
  --overlay-heavy: rgba(0, 0, 0, 0.50);
  --gold: #d4a96a;

  /* ── BADGE COLORS ── */
  --badge-green-bg: #f0fdf4;
  --badge-green-border: #bbf7d0;
  --badge-green-text: #15803d;
  --badge-yellow-bg: #fef08a;
  --badge-yellow-border: #fde047;
  --badge-yellow-text: #713f12;
  --badge-red-bg: #fef2f2;
  --badge-red-border: #fecaca;
  --badge-red-text: #dc2626;
  --badge-purple-bg: #ede9fe;
  --badge-purple-text: #7c3aed;
  --badge-blue-bg: #e0f2fe;
  --badge-blue-text: #0284c7;

  /* ── ADDITIONAL SEMANTIC ── */
  --warning-muted-bg: #fffbeb;
  --warning-muted-text: #92400e;
  --error-dark: #b91c1c;
  --success-muted: #065f46;
  --success-muted-border: #6ee7b7;
  --success-muted-bg: #ecfdf5;
  --live-green: #2ECC71;
  --teal-active: #1ABC9C;

  /* ── WHITE OPACITY VARIANTS (for dark backgrounds) ── */
  --white-06: rgba(255, 255, 255, 0.06);
  --white-07: rgba(255, 255, 255, 0.07);
  --white-10: rgba(255, 255, 255, 0.10);
  --white-13: rgba(255, 255, 255, 0.13);
  --white-25: rgba(255, 255, 255, 0.25);
  --white-30: rgba(255, 255, 255, 0.30);
  --white-50: rgba(255, 255, 255, 0.50);
  --white-60: rgba(255, 255, 255, 0.60);

  /* ── TYPOGRAPHY ── */
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', 'Segoe UI', sans-serif;
  --font-mono: 'Courier New', 'Monaco', monospace;

  /* ── SPACING & LAYOUT ── */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --sidebar-w: 260px;
  --topbar-h: 60px;

  /* ── SHADOWS ── */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
}

/* ─── BASE TYPOGRAPHY ──────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* ─── SHARED COMPONENT CLASSES ─────────────────────────────────────────────── */

/* Typography helpers */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }

/* Text colors */
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-high   { color: var(--high); }
.text-medium { color: var(--medium); }
.text-low    { color: var(--low); }

/* ─── IMPACT BADGES ─────────────────────────────────────────────────────────── */
.impact-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
}
.impact-badge.high   { background: var(--high-bg);   color: var(--high); }
.impact-badge.medium { background: var(--medium-bg); color: var(--medium); }
.impact-badge.low   { background: var(--low-bg);      color: var(--low); }

/* ─── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn-primary {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--accent-light);
}

.btn-secondary {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}
.btn-secondary:hover {
  background: var(--accent-bg);
}

.btn-ghost {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost:hover {
  background: rgba(0,0,0,0.05);
}

/* Navy/Teal variants */
.btn-navy {
  background: var(--navy, #2C3E50);
  color: #fff;
  border: none;
}
.btn-navy:hover {
  background: var(--navy-dark, #1a2734);
}

/* ─── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.metric-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--charcoal, var(--ink));
  letter-spacing: -0.01em;
}
.panel-action {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.panel-action:hover { color: var(--ink); }
.panel-body { padding: 1.25rem 1.5rem; }

/* ─── TABLES ─────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table thead tr {
  background: var(--paper);
}
.data-table th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: var(--paper); }
.data-table tbody tr:nth-child(odd) { background: var(--card-bg); }
.data-table tbody tr:hover { background: rgba(44, 62, 80, 0.04); }

/* ─── STATUS BADGES ─────────────────────────────────────────────────────────── */
.status-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}
.status-badge.active   { background: var(--low-bg);  color: var(--low); }
.status-badge.pending  { background: var(--medium-bg); color: var(--medium); }
.status-badge.error    { background: var(--high-bg);   color: var(--high); }
.status-badge.inactive { background: var(--paper); color: var(--muted); }

/* ─── FORM ELEMENTS ─────────────────────────────────────────────────────────── */
input[type=text],
input[type=number],
input[type=password],
input[type=email],
input[type=search],
textarea,
select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--card-bg);
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem 0.6rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: var(--paper) url('data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2716%27 height=%2716%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%236b7280%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Ccircle cx=%2711%27 cy=%2711%27 r=%278%27/%3E%3Cpath d=%27m21 21-4.3-4.3%27/%3E%3C/svg%3E') no-repeat 0.7rem center;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }

/* ─── LOADING & EMPTY STATES ────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

/* Skeleton loading */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--light-gray, #e8e6e1) 25%, var(--off-white, #f5f5f0) 50%, var(--light-gray, #e8e6e1) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ─── LIVE INDICATOR ─────────────────────────────────────────────────────────── */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  background: var(--accent-bg);
  border: 1px solid rgba(26, 92, 58, 0.15);
  border-radius: 100px;
}
.live-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 2s ease-in-out infinite;
}

/* ─── PAGINATION ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
}
.pagination button {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination .info { font-size: 0.8rem; color: var(--muted); }

/* ─── ENCYCLOPEDIA / GOLD ACCENT ──────────────────────────────────────────────
   Historical Encyclopedia: gold accent (#d4a96a) used consistently across nav.
*/
.encyclopedia-link {
  border-left: 3px solid rgba(160,120,72,0.5) !important;
  background: rgba(124,92,58,0.1) !important;
}
.encyclopedia-badge {
  background: rgba(160,120,72,0.25) !important;
  color: #d4a96a !important;
  font-size: 0.6rem !important;
  font-weight: 700 !important;
  padding: 0.1rem 0.45rem !important;
  border-radius: 4px !important;
}

/* ─── RESPONSIVE HELPERS ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hide-mobile { display: none; }
  .metric-card { font-size: 0.9rem; }
}
@media (max-width: 768px) {
  .hide-tablet { display: none; }
}
@media (max-width: 540px) {
  .hide-small { display: none; }
}