/*
 * VulTech Unified Design System
 * Single source of truth for design tokens.
 * Dark-first, enterprise security standard.
 *
 * Token hierarchy:
 *   1. Surface/background tokens (from Sentinel)
 *   2. Text hierarchy tokens (from Sentinel)
 *   3. Border tokens (from Sentinel)
 *   4. Severity scale (unified, colorblind-accessible)
 *   5. Status indicators
 *   6. Accent/action colors
 *   7. Typography
 *   8. Spacing scale (8px base)
 *   9. Shadows, radius, transitions, z-index
 *  10. Legacy aliases (backward compat)
 */

:root {
  /* === 1. PRIMARY PALETTE (Deep Slate Blue) === */
  --primary-950: #020617;
  --primary-900: #0f172a;
  --primary-800: #1e293b;
  --primary-700: #334155;
  --primary-600: #475569;
  --primary-500: #64748b;
  --primary-400: #94a3b8;
  --primary-300: #cbd5e1;
  --primary-200: #e2e8f0;
  --primary-100: #f1f5f9;
  --primary-50: #f8fafc;

  /* === VulTech Brand (design/design-tokens.json — authoritative) === */
  --brand-green: #ACEC00; /* color.brand.green */
  --brand-navy:  #00182E; /* color.brand.navy  */
  --brand-white: #FFFFFF; /* color.brand.white */

  /* === 2. ACCENT — mapped to brand green ===
   * design-tokens.json defines a single accent green. Hover/active tints are
   * NOT tokenized yet (flagged: missing state tokens), so every accent step
   * references the one brand green; states use opacity/brightness, not new hues. */
  --accent-600: var(--brand-green);
  --accent-500: var(--brand-green);
  --accent-400: var(--brand-green);
  --accent-300: var(--brand-green);
  --accent-200: var(--brand-green);
  --accent-contrast: var(--brand-navy); /* text/icon color on green fills */
  --accent-foreground: #b9f23b; /* readable accent text on dark surfaces */

  /* === 3. SURFACE COLORS (Dark-first) === */
  --surface-base: var(--brand-navy); /* brand navy as dominant dark background */
  --surface-primary: #0f172a;
  --surface-elevated: #1e293b;
  --surface-card: #334155;
  --surface-interactive: #475569;
  --surface-overlay: rgba(15, 23, 42, 0.95);
  --surface-glass: rgba(30, 41, 59, 0.8);

  /* === 4. BORDER === */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-focus: var(--accent-500);
  --focus-halo: rgba(172, 236, 0, 0.35); /* brand-green focus halo (dark theme) */

  /* === 5. TEXT HIERARCHY === */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;
  --text-inverse: #0f172a;
  --text-link: var(--accent-400);
  --text-link-hover: var(--accent-300);

  /* === 6. SEVERITY SCALE (Colorblind-accessible) === */
  --severity-critical: #dc2626;
  --severity-critical-light: #fef2f2;
  --severity-critical-dark: #991b1b;
  --severity-critical-glow: rgba(220, 38, 38, 0.4);

  --severity-high: #ea580c;
  --severity-high-light: #fff7ed;
  --severity-high-dark: #c2410c;
  --severity-high-glow: rgba(234, 88, 12, 0.4);

  --severity-medium: #ca8a04;
  --severity-medium-light: #fefce8;
  --severity-medium-dark: #a16207;
  --severity-medium-glow: rgba(202, 138, 4, 0.4);

  --severity-low: #0891b2;
  --severity-low-light: #ecfeff;
  --severity-low-dark: #0e7490;
  --severity-low-glow: rgba(8, 145, 178, 0.4);

  --severity-info: #6366f1;
  --severity-info-light: #eef2ff;
  --severity-info-dark: #4f46e5;
  --severity-info-glow: rgba(99, 102, 241, 0.4);

  /* === 7. STATUS INDICATORS === */
  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.15);
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.15);
  --status-error: #ef4444;
  --status-error-bg: rgba(239, 68, 68, 0.15);
  --status-pending: #6366f1;
  --status-pending-bg: rgba(99, 102, 241, 0.15);
  --status-new: #8b5cf6;
  --status-new-bg: rgba(139, 92, 246, 0.15);
  --status-in-progress: #f59e0b;
  --status-in-progress-bg: rgba(245, 158, 11, 0.15);
  --status-fixed: #10b981;
  --status-fixed-bg: rgba(16, 185, 129, 0.15);
  --status-false-positive: #6b7280;
  --status-false-positive-bg: rgba(107, 114, 128, 0.15);
  --status-risk-accepted: #ec4899;
  --status-risk-accepted-bg: rgba(236, 72, 153, 0.15);

  /* === 8. TYPOGRAPHY === */
  --font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-family);
  --font-body: var(--font-family);
  --font-mono: 'Fira Code', 'JetBrains Mono', 'SF Mono', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;

  /* === 9. SPACING (8px base) === */
  --spacing-xxs: 4px;
  --spacing-xs: 8px;
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --spacing-xl: 48px;
  --spacing-xxl: 64px;

  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* === 10. BORDER RADIUS === */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* === 11. SHADOWS === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.4);
  --shadow-modal: var(--shadow-xl);
  --shadow-dropdown: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px var(--accent-500);
  --shadow-critical: 0 0 20px var(--severity-critical-glow);

  /* === 12. TRANSITIONS === */
  --transition-fast: 100ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === 13. Z-INDEX SCALE === */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;

  /* === LEGACY ALIASES (backward compat for templates using old names) === */
  --bg-primary: var(--surface-base);
  --bg-surface: var(--surface-elevated);
  --border-color: var(--border-default);
}

/* === LIGHT MODE === */
.light, [data-theme="light"] {
  --surface-base: #f8fafc;
  --surface-primary: #f1f5f9;
  --surface-elevated: #ffffff;
  --surface-card: #ffffff;
  --surface-interactive: #e2e8f0;
  --surface-overlay: rgba(248, 250, 252, 0.95);
  --surface-glass: rgba(255, 255, 255, 0.8);

  --border-subtle: rgba(0, 0, 0, 0.05);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  --text-inverse: #f1f5f9;
  /* Brand green fails WCAG as text on white (~1.4:1), so links/focus use navy in
   * light mode. Flagged: an accessible accent-on-light token is missing in
   * design-tokens.json. Green remains the accent for fills/borders/emphasis. */
  --text-link: var(--brand-navy);
  --text-link-hover: #000000;
  --accent-foreground: #4f7100; /* 5.68:1 on white */
  --border-focus: var(--brand-navy);
  --focus-halo: rgba(0, 24, 46, 0.25); /* navy focus halo (light theme) */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

  /* Stronger status contrast on light surfaces */
  --status-success: #047857;
  --status-success-bg: #d1fae5;
  --status-warning: #a16207;
  --status-warning-bg: #fef3c7;
  --status-error: #b91c1c;
  --status-error-bg: #fee2e2;
  --status-new: #6d28d9;
  --status-new-bg: #ede9fe;
  --status-in-progress: #b45309;
  --status-in-progress-bg: #fef3c7;
  --status-fixed: #047857;
  --status-fixed-bg: #d1fae5;
  --status-false-positive: #374151;
  --status-false-positive-bg: #e5e7eb;
  --status-risk-accepted: #be185d;
  --status-risk-accepted-bg: #fce7f3;

  --bg-primary: var(--surface-base);
  --bg-surface: var(--surface-elevated);
  --border-color: var(--border-default);
}

/* Dark mode alias for Tailwind class-based switching */
.dark {
  --bg-primary: var(--surface-base);
  --bg-surface: var(--surface-elevated);
  --border-color: var(--border-default);
}


/* ============================================
   BASE STYLES
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html.dark {
  color-scheme: dark;
}

html.light {
  color-scheme: light;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-base);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
  margin: 0 0 var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--text-link-hover); }

code, pre { font-family: var(--font-mono); font-size: 0.9em; }
code {
  background: var(--surface-elevated);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  color: var(--text-link); /* adapts: green on dark, navy on light (contrast-safe) */
}
pre {
  background: var(--surface-primary);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
}


/* ============================================
   UTILITY CLASSES
   ============================================ */

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}
@media (max-width: 640px) {
  .container { padding: 0 var(--spacing-sm); }
}

/* Focus */
.focus-ring { outline: 2px solid transparent; outline-offset: 2px; }
.focus-ring:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand-navy); /* navy + white guarantees contrast in both themes */
  color: var(--brand-white);
  padding: var(--spacing-xs) var(--spacing-sm);
  text-decoration: none;
  z-index: 100;
  border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--spacing-xs); }


/* ============================================
   SEVERITY & STATUS BADGES
   ============================================ */

.badge-critical { background-color: var(--severity-critical); color: white; }
.badge-high { background-color: var(--severity-high); color: white; }
.badge-medium { background-color: var(--severity-medium); color: white; }
.badge-low { background-color: var(--severity-low); color: white; }
.badge-info { background-color: var(--severity-info); color: white; }

.status-success { color: var(--status-success); }
.status-warning { color: var(--status-warning); }
.status-error { color: var(--status-error); }
.status-pending { color: var(--status-pending); }


/* ============================================
   ANIMATIONS (functional only)
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.fade-in { animation: fadeIn 0.5s ease-in; }
.slide-in-right { animation: slideInRight 0.25s ease-out; }
.scale-in { animation: scaleIn 0.3s ease-out; }


/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, var(--surface-card) 0%, var(--surface-elevated) 50%, var(--surface-card) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 16px; margin-bottom: var(--space-2); }
.skeleton-text-sm { height: 12px; width: 60%; }
.skeleton-card { height: 200px; border-radius: var(--radius-lg); }
.skeleton-chart { height: 300px; border-radius: var(--radius-lg); }


/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-base); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }


/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .no-print { display: none !important; }
  body { background: white; color: black; }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

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

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

@media (max-width: 1280px) {
  :root { --text-3xl: 1.75rem; --text-4xl: 2rem; }
}
@media (max-width: 640px) {
  :root { --text-2xl: 1.375rem; --text-3xl: 1.5rem; }
}
