/**
 * SAR-OS Drift — Design Tokens
 * Version: 2.0
 * Based on: SAR-OS Brand Guidelines v2.0
 * Compliance: WCAG 2.2 Level AA
 *
 * All color combinations validated for minimum contrast ratios:
 * - Normal text: 4.5:1
 * - Large text (18px+): 3:1
 * - UI components: 3:1
 * - Focus indicators: 3:1
 */

:root {
  /* ============================================
     COLOR SYSTEM — Blue-Grey Hybrid (Dark Default)
     Background: #1E293B, Cards: #263548
     Maritime feel preserved with better card separation
     ============================================ */

  /* Base Background Colors — Blue-Grey Hybrid */
  --deep-ocean: #1E293B;        /* Primary background - blue-grey */
  --card-panel: #263548;        /* Card/panel backgrounds - lifted slate */
  --card-border: #344B60;       /* All borders - visible separation */
  --graphite: #1E293B;          /* Table headers */
  --sidebar-bg: #0B1829;        /* Sidebar background - stays navy */
  --row-alt: #1E293B;           /* Alternating table rows */

  /* Brand Accent Colors */
  --signal-blue: #2E86DE;       /* Primary accent, buttons, active states */
  --tide-teal: #17A2B8;         /* Secondary accent, toggle switches */
  --rescue-orange: #E67E22;     /* LKP markers, trajectory lines, alerts */

  /* Typography Colors */
  --text-primary: #E8ECF1;      /* Headings, body text - Contrast: 11.2:1 on #1E293B ✓ */
  --text-secondary: #94A3B8;    /* Labels, hints - Contrast: 5.6:1 on #1E293B ✓ */
  --text-muted: #8899AA;        /* Subtle text, hints - Contrast: 5.1:1 on #1E293B ✓ */

  /* State Colors */
  --success: #27AE60;           /* Active/enabled badges, success states */
  --warning: #F39C12;           /* Pending states, warnings */
  --danger: #E74C3C;            /* Errors, destructive actions */
  --info: #3498DB;              /* Informational messages */

  /* Focus & Interaction States */
  --focus-ring: #2E86DE;        /* Focus indicator color */
  --focus-ring-width: 2px;      /* Focus indicator width */
  --focus-ring-offset: 2px;     /* Focus indicator offset */
  --focus-glow: 0 0 0 3px rgba(46, 134, 222, 0.3); /* Focus glow effect */

  /* Glassmorphic Panel Colors */
  --glass-bg: rgba(30, 41, 59, 0.9);            /* Semi-transparent panel background */
  --glass-border: rgba(255, 255, 255, 0.08);    /* Subtle border */
  --glass-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); /* Deep shadow */

  /* ============================================
     TYPOGRAPHY SYSTEM
     ============================================ */

  /* Font Families */
  --font-ui: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-data: 'Courier New', Courier, ui-monospace, monospace;

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Font Sizes — WCAG 2.2 AA compliant scale (min 12px for any text) */
  --font-size-xs: 12px;         /* Timestamps, codes, badges */
  --font-size-sm: 13px;         /* Table cells, secondary labels */
  --font-size-base: 15px;       /* Body text, form inputs */
  --font-size-md: 16px;         /* Nav items, buttons */
  --font-size-lg: 18px;         /* Section headings, card headers */
  --font-size-xl: 22px;         /* Page headings */
  --font-size-2xl: 24px;        /* Large headings */
  --font-size-3xl: 28px;        /* Main page titles */

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* Letter Spacing */
  --letter-spacing-tight: -0.01em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.05em;
  --letter-spacing-wider: 0.08em;
  --letter-spacing-widest: 0.12em;
  --letter-spacing-ultra: 0.15em;

  /* ============================================
     SPACING SYSTEM — 8px Grid
     ============================================ */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ============================================
     BORDER RADIUS
     ============================================ */

  --radius-sm: 4px;            /* Small elements, tags */
  --radius-md: 6px;            /* Form inputs, small buttons */
  --radius-lg: 8px;            /* Small cards, icons */
  --radius-xl: 10px;           /* Medium cards */
  --radius-2xl: 12px;          /* Large cards, panels, modals */
  --radius-3xl: 16px;          /* Extra large containers */
  --radius-full: 9999px;       /* Pills, circular buttons */

  /* ============================================
     SHADOWS
     ============================================ */

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.4);
  --shadow-2xl: 0 25px 60px rgba(0, 0, 0, 0.5);

  /* ============================================
     Z-INDEX SCALE
     ============================================ */

  --z-base: 0;                 /* Map canvas, base content */
  --z-floating: 100;           /* Floating panels start */
  --z-panel-sim: 100;          /* Simulation panel */
  --z-panel-basemap: 110;      /* Basemap selector */
  --z-panel-layers: 120;       /* Layer toggles */
  --z-panel-status: 130;       /* Status bar */
  --z-panel-results: 140;      /* Results panel */
  --z-dropdown: 500;           /* Dropdown menus */
  --z-sticky: 600;             /* Sticky headers */
  --z-fixed: 700;              /* Fixed navigation */
  --z-modal-backdrop: 900;     /* Modal backdrop */
  --z-modal: 1000;             /* Modal dialogs */
  --z-popover: 1100;           /* Popovers, tooltips */
  --z-toast: 1200;             /* Toast notifications */

  /* ============================================
     TRANSITIONS
     ============================================ */

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ============================================
     LAYOUT DIMENSIONS
     ============================================ */

  --sidebar-width: 220px;
  --sidebar-width-collapsed: 60px;

  --header-height: 60px;

  --container-xs: 480px;
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;

  /* ============================================
     FORM ELEMENTS
     ============================================ */

  --input-height: 38px;
  --input-padding-x: 12px;
  --input-padding-y: 8px;
  --input-bg: var(--deep-ocean);
  --input-border: var(--card-border);
  --input-text: var(--text-primary);
  --input-placeholder: var(--text-muted);

  /* Button Heights */
  --button-height-sm: 32px;
  --button-height-md: 38px;
  --button-height-lg: 44px;

  /* Minimum Touch Target Size (WCAG 2.2 - 2.5.8) */
  --touch-target-min: 24px;

  /* ============================================
     BADGE & STATUS COLORS
     ============================================ */

  /* Success/Active - Green */
  --badge-success-bg: rgba(39, 174, 96, 0.15);
  --badge-success-text: var(--success);
  --badge-success-border: rgba(39, 174, 96, 0.3);

  /* Warning/Pending - Amber */
  --badge-warning-bg: rgba(243, 156, 18, 0.15);
  --badge-warning-text: var(--warning);
  --badge-warning-border: rgba(243, 156, 18, 0.3);

  /* Danger/Error - Red */
  --badge-danger-bg: rgba(231, 76, 60, 0.15);
  --badge-danger-text: var(--danger);
  --badge-danger-border: rgba(231, 76, 60, 0.3);

  /* Info/Blue */
  --badge-info-bg: rgba(46, 134, 222, 0.12);
  --badge-info-text: var(--signal-blue);
  --badge-info-border: rgba(46, 134, 222, 0.3);

  /* Neutral/Grey */
  --badge-neutral-bg: rgba(131, 149, 167, 0.15);
  --badge-neutral-text: var(--text-secondary);
  --badge-neutral-border: rgba(131, 149, 167, 0.3);

  /* ============================================
     WCAG 2.2 COMPLIANCE NOTES
     ============================================

     Dark Theme — Blue-Grey Hybrid (tested against --deep-ocean #1E293B):

     ✓ PASS - Exceeds AA Standard (4.5:1 for normal text)
     - --text-primary (#E8ECF1): 11.2:1
     - --text-secondary (#94A3B8): 5.6:1
     - --signal-blue (#2E86DE): 4.5:1
     - --success (#27AE60): 4.7:1
     - --warning (#F39C12): 6.1:1
     - --danger (#E74C3C): 4.5:1
     - --text-muted (#8899AA): 5.1:1

     Light Theme — Slate Grey (tested against --deep-ocean #F1F3F8):

     ✓ PASS - Exceeds AA Standard (4.5:1 for normal text)
     - --text-primary (#1E293B): 12.6:1
     - --text-secondary (#64748B): 5.1:1
     - --signal-blue (#2563EB): 4.6:1

     ============================================ */
}

/* ============================================
   LIGHT THEME — Slate Grey
   Navy sidebar retained, light grey content area
   Activated via [data-theme="light"] on <html>
   ============================================ */

[data-theme="light"] {
  /* Base Background Colors */
  --deep-ocean: #F1F3F8;        /* Primary background - light grey */
  --card-panel: #FFFFFF;        /* Card/panel backgrounds - white */
  --card-border: #E2E8F0;       /* Borders - subtle grey */
  --graphite: #F8FAFC;          /* Table headers - near-white */
  --sidebar-bg: #0D1B2A;        /* Sidebar - stays navy */
  --row-alt: #F8FAFC;           /* Alternating table rows */

  /* Typography Colors */
  --text-primary: #1E293B;      /* Dark text on light - Contrast: 12.6:1 ✓ */
  --text-secondary: #64748B;    /* Muted text - Contrast: 5.1:1 ✓ */
  --text-muted: #64748B;        /* Subtle text - Contrast: 5.1:1 on white ✓ WCAG AA */

  /* Accent adjustments for light backgrounds */
  --signal-blue: #2563EB;       /* Darker blue for light bg contrast */
  --success: #16A34A;           /* Darker green for light bg */
  --warning: #D97706;           /* Darker amber for light bg */
  --danger: #DC2626;            /* Darker red for light bg */

  /* Focus & Interaction */
  --focus-ring: #2563EB;
  --focus-glow: 0 0 0 3px rgba(37, 99, 235, 0.2);

  /* Glassmorphic (not used in light, but override for safety) */
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);

  /* Input fields */
  --input-bg: #F8FAFC;
  --input-border: #E2E8F0;
  --input-text: #1E293B;
  --input-placeholder: #94A3B8;

  /* Shadows - lighter */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);

  /* Badge colors - semi-transparent on white */
  --badge-success-bg: rgba(22, 163, 74, 0.08);
  --badge-success-border: rgba(22, 163, 74, 0.2);
  --badge-warning-bg: rgba(217, 119, 6, 0.08);
  --badge-warning-border: rgba(217, 119, 6, 0.2);
  --badge-danger-bg: rgba(220, 38, 38, 0.08);
  --badge-danger-border: rgba(220, 38, 38, 0.2);
  --badge-info-bg: rgba(37, 99, 235, 0.08);
  --badge-info-border: rgba(37, 99, 235, 0.2);
  --badge-neutral-bg: rgba(100, 116, 139, 0.08);
  --badge-neutral-border: rgba(100, 116, 139, 0.2);
}

/* ============================================
   DARK THEME UTILITIES
   ============================================ */

/* Ensure proper contrast on glassmorphic backgrounds */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
  .glass-panel {
    background: rgba(30, 41, 59, 0.98); /* More opaque for better contrast */
  }
}

[data-theme="light"] .glass-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* High contrast mode support (Windows High Contrast Mode) */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #FFFFFF;
    --text-secondary: #E0E0E0;
    --card-border: #4A5A6A;
    --focus-ring-width: 3px;
  }
}

/* Reduced motion support (WCAG 2.2 - 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles - switch to light theme for better readability */
@media print {
  :root {
    --deep-ocean: #FFFFFF;
    --card-panel: #F5F5F5;
    --text-primary: #000000;
    --text-secondary: #333333;
    --card-border: #CCCCCC;
  }
}
