/* ========== CSS VARIABLES - SINGLE SOURCE OF TRUTH ========== */
/* All CSS custom properties: primitives, design tokens, and themed values */

:root {
  /* ========== Color Scheme ========== */
  color-scheme: dark;

  /* ========== Typography ========== */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* ========== Colors - Dark Theme ========== */
  --bg-page: #0a0a0a;
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-hover: #3a3a3a;
  --bg-input: rgba(0, 0, 0, 0.4);
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-light: rgba(255, 255, 255, 0.02);
  --bg-input-dark: rgba(0, 0, 0, 0.4);
  --bg-input-focus: rgba(0, 0, 0, 0.5);
  --bg-select: rgba(0, 0, 0, 0.3);

  --text-primary: #ffffff;
  --text-secondary: #ffffff;
  --text-muted: #707070;
  --text-white: #ffffff;
  --text-light: #d0d0d0;
  --text-dark: #333333;
  --text-link: #4da3ff;
  --text-link-hover: #6db5ff;

  --border: rgba(255, 255, 255, 0.1);
  --border-color: var(--border); /* Alias for compatibility */
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-card-light: rgba(255, 255, 255, 0.06);
  --border-input: rgba(255, 255, 255, 0.1);
  --border-input-strong: rgba(255, 255, 255, 0.15);
  --border-select: rgba(255, 255, 255, 0.3);

  /* ========== Surface & Semantic Aliases (Dark) ========== */
  /* Used by HQ Dashboard and components that need surface hierarchy */
  --bg-base: var(--bg-page);                     /* #0a0a0a */
  --bg-surface: var(--bg-primary);                /* #1a1a1a */
  --bg-surface-secondary: var(--bg-secondary);    /* #2a2a2a */
  --bg-surface-tertiary: #3a3a3a;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --bg-active: rgba(255, 255, 255, 0.1);
  --bg-selected: rgba(0, 123, 255, 0.2);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --text-disabled: rgba(255, 255, 255, 0.3);
  --text-placeholder: rgba(255, 255, 255, 0.4);
  --text-inverse: #212529;
  --border-default: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.06);

  /* ========== Theme Colors ========== */
  --accent: #007bff;
  --accent-hover: #0056b3;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --not-filled-bg: #8b0000;
  --not-filled-text: white;
  --bg-error: rgba(139, 0, 0, 0.3);
  --orange: #f39200;
  --primary-blue: #007bff;
  --primary-blue-hover: #0056b3;
  --primary-blue-dark: #003d82;
  --primary-orange: #f39200;

  /* ========== Gradients ========== */
  --gradient-blue: linear-gradient(135deg, #1e90ff 0%, #0066cc 100%);
  --gradient-blue-hover: linear-gradient(135deg, #00bfff 0%, #0080ff 100%);
  --gradient-blue-light: linear-gradient(135deg, rgba(30, 144, 255, 0.9) 0%, rgba(0, 102, 204, 0.9) 100%);
  --gradient-gray: linear-gradient(135deg, #666 0%, #444 100%);
  --gradient-gray-hover: linear-gradient(135deg, #777 0%, #555 100%);
  --gradient-dark: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(42, 42, 42, 0.95) 100%);

  /* ========== Shadows ========== */
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-blue: 0 2px 8px rgba(30, 144, 255, 0.3);
  --shadow-blue-hover: 0 4px 12px rgba(30, 144, 255, 0.4);
  --shadow-inset-light: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  --shadow-inset-dark: inset 0 -2px 0 rgba(0, 0, 0, 0.2);

  /* ========== Sizing ========== */
  --input-height: 36px;
  --input-width: 200px;
  --button-min-width: 100px;
  --fab-size: 40px;
  --padding-input: 8px 12px;
  --padding-button: 8px 24px;

  /* ========== Spacing ========== */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-xxl: 3rem;

  /* ========== Typography ========== */
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;

  /* ========== Border Radius ========== */
  --radius: 4px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* ========== Transitions ========== */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* ========== Z-index Scale ========== */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
  --z-notification: 800;

  /* ========== Breakpoints ========== */
  --breakpoint-xs: 480px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;

  /* ========== Inspection Component Variables ========== */
  --inspection-card-bg: rgba(255, 255, 255, 0.03);
  --inspection-card-border: rgba(255, 255, 255, 0.08);
  --inspection-header-bg: rgba(255, 255, 255, 0.05);
  --inspection-header-padding-v: 20px;
  --inspection-header-padding-h: 16px;
  --inspection-header-min-height: 52px;
  --inspection-icon-size-sm: 20px;
  --inspection-icon-size-lg: 24px;
  --inspection-icon-color: #4da3ff;
  --inspection-title-size: 16px;
  --inspection-section-title-size: 18px;
  --inspection-content-padding: 16px;

  /* ========== Material Design 3 System Color Tokens ========== */
  /* Aliases mapping M3 tokens to project design values.          */
  /* Used by Blazor components in /Pages and shared CSS files.    */
  /* Surface hierarchy: lowest(darkest) → highest(lightest)       */

  /* --- Surfaces --- */
  --md-sys-color-surface-container-lowest: #0e0e0e;
  --md-sys-color-surface-container-low: #171717;
  --md-sys-color-surface: var(--bg-primary);              /* #1a1a1a */
  --md-sys-color-surface-container: #222222;
  --md-sys-color-surface-variant: var(--bg-secondary);    /* #2a2a2a */
  --md-sys-color-surface-container-high: #2e2e2e;
  --md-sys-color-surface-container-highest: #383838;

  /* --- Text & outlines --- */
  --md-sys-color-on-surface: var(--text-primary);         /* #ffffff */
  --md-sys-color-on-surface-variant: #b0b0b0;
  --md-sys-color-outline: var(--border-strong);           /* rgba(255,255,255,0.2) */
  --md-sys-color-outline-variant: var(--border);          /* rgba(255,255,255,0.1) */

  /* --- Primary --- */
  --md-sys-color-primary: var(--accent);                  /* #007bff */
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: rgba(0, 123, 255, 0.15);
  --md-sys-color-on-primary-container: var(--text-link-hover); /* #6db5ff */
  --md-sys-color-primary-hover: var(--accent-hover);      /* #0056b3 */
  --md-sys-color-primary-rgb: 0, 123, 255;

  /* --- Secondary --- */
  --md-sys-color-secondary: #8e99a4;
  --md-sys-color-secondary-container: rgba(142, 153, 164, 0.15);
  --md-sys-color-on-secondary-container: #b0bec5;

  /* --- Tertiary --- */
  --md-sys-color-tertiary: var(--primary-orange);         /* #f39200 */
  --md-sys-color-tertiary-container: rgba(243, 146, 0, 0.15);
  --md-sys-color-on-tertiary-container: #ffb74d;

  /* --- Error --- */
  --md-sys-color-error: var(--danger);                    /* #dc3545 */
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: rgba(220, 53, 69, 0.15);
  --md-sys-color-on-error-container: #ff8a8a;
  --md-sys-color-error-rgb: 220, 53, 69;

  /* --- Status (success / warning / info) --- */
  --md-sys-color-success: var(--success);                 /* #28a745 */
  --md-sys-color-success-container: rgba(40, 167, 69, 0.15);
  --md-sys-color-on-success-container: #5fd87e;
  --md-sys-color-warning: var(--warning);                 /* #ffc107 */
  --md-sys-color-warning-container: rgba(255, 193, 7, 0.15);
  --md-sys-color-on-warning-container: #ffd54f;
  --md-sys-color-info: #2196f3;
  --md-sys-color-info-container: rgba(33, 150, 243, 0.15);
  --md-sys-color-on-info-container: #64b5f6;

  /* ========== Color Scales (Primitives) ========== */

  --color-black: #000000;
  --color-white: #ffffff;

  /* Gray Scale */
  --color-gray-50: #f8f9fa;
  --color-gray-100: #f1f3f5;
  --color-gray-200: #e9ecef;
  --color-gray-300: #dee2e6;
  --color-gray-400: #ced4da;
  --color-gray-500: #adb5bd;
  --color-gray-600: #6c757d;
  --color-gray-700: #495057;
  --color-gray-800: #343a40;
  --color-gray-900: #212529;
  --color-gray-950: #0a0a0a;

  /* Primary (Blue) Scale */
  --color-primary-50: #e6f2ff;
  --color-primary-100: #bae0ff;
  --color-primary-200: #8cc8ff;
  --color-primary-300: #5eb0ff;
  --color-primary-400: #3a9eff;
  --color-primary-500: #1890ff;
  --color-primary-600: #007bff;
  --color-primary-700: #0066e6;
  --color-primary-800: #0052cc;
  --color-primary-900: #003d99;

  /* Success (Green) Scale */
  --color-success-50: #e6f9ed;
  --color-success-100: #b8efc9;
  --color-success-200: #87e5a5;
  --color-success-300: #56db81;
  --color-success-400: #31d366;
  --color-success-500: #0dcc4b;
  --color-success-600: #28a745;
  --color-success-700: #238638;
  --color-success-800: #1e6b2c;
  --color-success-900: #155020;

  /* Warning (Amber) Scale */
  --color-warning-50: #fff8e6;
  --color-warning-100: #ffecb3;
  --color-warning-200: #ffe082;
  --color-warning-300: #ffd54f;
  --color-warning-400: #ffca28;
  --color-warning-500: #ffc107;
  --color-warning-600: #ffb300;
  --color-warning-700: #ff9800;
  --color-warning-800: #ff8f00;
  --color-warning-900: #ff6f00;

  /* Danger (Red) Scale */
  --color-danger-50: #ffebee;
  --color-danger-100: #ffcdd2;
  --color-danger-200: #ef9a9a;
  --color-danger-300: #e57373;
  --color-danger-400: #ef5350;
  --color-danger-500: #f44336;
  --color-danger-600: #dc3545;
  --color-danger-700: #c62828;
  --color-danger-800: #b71c1c;
  --color-danger-900: #a00000;

  /* Info (Blue) Scale */
  --color-info-50: #e3f2fd;
  --color-info-100: #bbdefb;
  --color-info-200: #90caf9;
  --color-info-300: #64b5f6;
  --color-info-400: #42a5f5;
  --color-info-500: #2196f3;
  --color-info-600: #1e88e5;
  --color-info-700: #1976d2;
  --color-info-800: #1565c0;
  --color-info-900: #0d47a1;

  /* ========== Extended Typography ========== */

  /* Font Sizes - Modular Scale (1.25 ratio) */
  --font-size-xs: 0.64rem;   /* 10.24px */
  --font-size-sm: 0.8rem;    /* 12.8px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-md: 1.25rem;   /* 20px */
  --font-size-lg: 1.563rem;  /* 25px */
  --font-size-xl: 1.953rem;  /* 31.25px */
  --font-size-2xl: 2.441rem; /* 39px */
  --font-size-3xl: 3.052rem; /* 48.8px */

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

  /* Line Heights */
  --line-height-none: 1;
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;

  /* Letter Spacing */
  --letter-spacing-tighter: -0.05em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;

  /* ========== Numeric Spacing System (8px base) ========== */
  --space-0: 0;
  --space-1: 0.125rem;  /* 2px */
  --space-2: 0.25rem;   /* 4px */
  --space-3: 0.375rem;  /* 6px */
  --space-4: 0.5rem;    /* 8px */
  --space-5: 0.625rem;  /* 10px */
  --space-6: 0.75rem;   /* 12px */
  --space-8: 1rem;      /* 16px */
  --space-10: 1.25rem;  /* 20px */
  --space-12: 1.5rem;   /* 24px */
  --space-16: 2rem;     /* 32px */
  --space-20: 2.5rem;   /* 40px */
  --space-24: 3rem;     /* 48px */
  --space-32: 4rem;     /* 64px */
  --space-40: 5rem;     /* 80px */
  --space-48: 6rem;     /* 96px */
  --space-56: 7rem;     /* 112px */
  --space-64: 8rem;     /* 128px */

  /* ========== Extended Border & Shape Tokens ========== */

  /* Border Widths */
  --border-width-thin: 1px;
  --border-width-base: 2px;
  --border-width-thick: 3px;
  --border-width-heavy: 4px;

  /* Extended Border Radius */
  --radius-none: 0;
  --radius-sm: 0.125rem;   /* 2px */
  --radius-md: 0.375rem;   /* 6px */
  --radius-2xl: 1rem;      /* 16px */
  --radius-3xl: 1.5rem;    /* 24px */
  --radius-round: 9999px;

  /* ========== Extended Shadows ========== */
  --shadow-none: none;
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-2xl: 0 35px 60px -15px rgba(0, 0, 0, 0.3);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* ========== Focus States ========== */
  --focus-ring-width: 3px;
  --focus-ring-color: rgba(0, 123, 255, 0.5);
  --focus-ring-offset: 2px;

  /* ========== Animation Easing ========== */
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* ========== Container Sizes ========== */
  --container-xs: 480px;
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;
  --container-full: 100%;

  /* ========== Aspect Ratios ========== */
  --aspect-square: 1 / 1;
  --aspect-video: 16 / 9;
  --aspect-portrait: 9 / 16;
  --aspect-photo: 4 / 3;
  --aspect-cinema: 21 / 9;
}

/* ========== Light Theme Variables ========== */
.theme-light,
[data-theme="light"] {
    color-scheme: light;
    --bg-page: #ffffff;
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.04);
    --bg-input: #ffffff;
    --bg-card: #ffffff;
    --bg-card-light: #f8f9fa;
    --bg-input-dark: #f8f9fa;
    --bg-input-focus: #ffffff;
    --bg-select: #ffffff;

    --text-primary: #212529;
    --text-secondary: #212529;
    --text-muted: #495057;
    --text-white: #ffffff;
    --text-light: #343a40;
    --text-link: #1976D2;
    --text-link-hover: #1565C0;

    --border: rgba(0, 0, 0, 0.15);
    --border-color: var(--border);
    --border-strong: rgba(0, 0, 0, 0.25);
    --border-card: rgba(0, 0, 0, 0.12);
    --border-card-light: rgba(0, 0, 0, 0.08);
    --border-input: rgba(0, 0, 0, 0.15);
    --border-input-strong: rgba(0, 0, 0, 0.25);
    --border-select: rgba(0, 0, 0, 0.2);

    /* --- Surface & Semantic Aliases (Light) --- */
    --bg-base: var(--bg-page);                        /* #ffffff */
    --bg-surface: var(--bg-primary);                   /* #f8f9fa */
    --bg-surface-secondary: var(--color-gray-100);       /* #f1f3f5 */
    --bg-surface-tertiary: var(--color-gray-200);
    --bg-overlay: rgba(0, 0, 0, 0.1);
    --bg-active: rgba(0, 0, 0, 0.05);
    --bg-selected: rgba(0, 123, 255, 0.1);
    --text-tertiary: var(--color-gray-700);
    --text-disabled: var(--color-gray-500);
    --text-placeholder: var(--color-gray-600);
    --text-inverse: var(--color-white);
    --border-default: rgba(0, 0, 0, 0.12);
    --border-light: rgba(0, 0, 0, 0.06);

    /* --- Button gradient overrides for light theme --- */
    --gradient-gray: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    --gradient-gray-hover: linear-gradient(135deg, #7b838a 0%, #6c757d 100%);

    /* --- M3 light theme overrides --- */
    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #f7f7f7;
    --md-sys-color-surface: #fafafa;
    --md-sys-color-surface-container: #f0f0f0;
    --md-sys-color-surface-variant: #e8e8e8;
    --md-sys-color-surface-container-high: #e2e2e2;
    --md-sys-color-surface-container-highest: #ddd;

    --md-sys-color-on-surface: #212529;
    --md-sys-color-on-surface-variant: #666666;
    --md-sys-color-outline: rgba(0, 0, 0, 0.25);
    --md-sys-color-outline-variant: rgba(0, 0, 0, 0.12);

    --md-sys-color-primary-container: rgba(0, 123, 255, 0.1);
    --md-sys-color-on-primary-container: #0056b3;
    --md-sys-color-secondary-container: rgba(108, 117, 125, 0.1);
    --md-sys-color-on-secondary-container: #495057;
    --md-sys-color-tertiary-container: rgba(243, 146, 0, 0.1);
    --md-sys-color-on-tertiary-container: #c67600;
    --md-sys-color-error-container: rgba(220, 53, 69, 0.1);
    --md-sys-color-on-error-container: #a71d2a;
    --md-sys-color-success-container: rgba(40, 167, 69, 0.1);
    --md-sys-color-on-success-container: #1e7e34;
    --md-sys-color-warning: #b8860b;
    --md-sys-color-warning-container: rgba(255, 193, 7, 0.12);
    --md-sys-color-on-warning-container: #856404;
    --md-sys-color-info-container: rgba(33, 150, 243, 0.1);
    --md-sys-color-on-info-container: #0b7dda;

    --not-filled-bg: #f8d7da;
    --not-filled-text: #c62828;
    --bg-error: #ffebee;
}

