/*
 * SchedDSI theme tokens
 *
 * Keep theme values in this file. Component and page styles should consume
 * semantic tokens such as --surface-raised and --border-default rather than
 * introducing light- or dark-specific colors.
 */

:root {
    color-scheme: light;

    /* Brand palette sampled from the production SchedDSI logo artwork. */
    --brand-primary: #004895;
    --brand-primary-rgb: 0, 72, 149;
    --brand-highlight: #2196de;
    --brand-highlight-rgb: 33, 150, 222;
    --primary-color: var(--brand-primary);
    --primary-color-rgb: var(--brand-primary-rgb);
    --primary-hover: #003b7a;
    --primary-active: #003165;
    --link-color: var(--primary-color);
    --link-hover: var(--primary-hover);
    --interactive-foreground: var(--primary-color);
    --secondary-color: var(--brand-highlight);
    --secondary-color-rgb: var(--brand-highlight-rgb);
    --accent-color: var(--brand-highlight);
    --light-accent: #73bdf0;
    --lighter-accent: #a8d7f5;
    --lightest-accent: #e8f4fc;
    --dark-accent: var(--primary-hover);
    --darkest-color: #002446;
    --light-neutral: #f1f5f9;
    --deep-blue: #002d5d;
    --deep-blue-rgb: 0, 45, 93;

    /* Workflow diagram palette */
    --workflow-node-color: #126db5;
    --workflow-node-color-rgb: 18, 109, 181;
    --workflow-node-hover: #0b5c9b;
    --workflow-node-surface: #e8f4fc;
    --workflow-selection-color: #ff6b6b;
    --workflow-selection-color-rgb: 255, 107, 107;

    /* Operational schedule colors retain fixed meaning across color modes. */
    --schedule-critical-strong: #ff0000;
    --schedule-critical-rgb: 255, 0, 0;
    --schedule-critical: #ff4444;
    --schedule-critical-medium: #ff6666;
    --schedule-critical-soft: #ff8888;
    --schedule-critical-dark: #cc0000;
    --schedule-critical-accent: #ff2222;
    --schedule-dependency-marker: #ff4fa3;
    --schedule-dependency-marker-rgb: 255, 79, 163;
    --schedule-expedited-marker: #ffd43b;
    --schedule-item-outline: #000000;
    --schedule-default-item-color: #006bb6;

    /* Status palette */
    --color-success: #247a4a;
    --color-success-hover: #1d643d;
    --color-warning: #e28743;
    --color-warning-hover: #c96f2f;
    --color-danger: #dc3545;
    --color-danger-hover: #c82333;
    --color-danger-active: #bd2130;
    --color-error: var(--color-danger);
    --color-info: #006bb6;
    --color-info-hover: #005694;
    --info-color-rgb: 0, 107, 182;
    --color-neutral-action: #475569;
    --color-neutral-action-hover: #334155;
    --neutral-action-rgb: 71, 85, 105;
    --color-area-action: var(--color-info);
    --color-area-action-hover: var(--primary-color);
    --area-action-rgb: var(--info-color-rgb);
    --color-print-action: #0f766e;
    --color-print-action-hover: #115e59;
    --print-action-rgb: 15, 118, 110;
    --color-reopen-action: #5b4b8a;
    --color-reopen-action-hover: #493a73;
    --reopen-action-rgb: 91, 75, 138;
    --color-delete-action: #b34852;
    --color-delete-action-hover: #993a43;
    --color-delete-action-active: #86313a;
    --delete-action-rgb: 179, 72, 82;
    --color-labor-action: var(--color-reopen-action);
    --color-labor-action-hover: var(--color-reopen-action-hover);
    --color-plating-action: var(--color-reopen-action);
    --color-plating-action-hover: var(--color-reopen-action-hover);
    --plating-action-rgb: var(--reopen-action-rgb);
    --success-color-rgb: 36, 122, 74;
    --warning-color-rgb: 226, 135, 67;
    --danger-color-rgb: 220, 53, 69;
    --error-color-rgb: var(--danger-color-rgb);
    --status-success-text: #1d643d;
    --status-warning-text: #7a3e00;
    --status-danger-text: #9f2532;
    --status-info-text: var(--brand-primary);

    /* Neutral palette. These are fixed swatches, not surface assignments. */
    --color-gray-50: #f8fafc;
    --color-gray-100: #f1f5f9;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e1;
    --color-gray-400: #94a3b8;
    --color-gray-500: #64748b;
    --color-gray-600: #475569;
    --color-gray-700: #334155;
    --color-gray-800: #1e293b;
    --color-gray-900: #0f172a;
    --gray-600-rgb: 71, 85, 105;

    /* Semantic text */
    --text-primary: var(--color-gray-900);
    --text-primary-rgb: 15, 23, 42;
    --text-secondary: var(--color-gray-600);
    --text-tertiary: var(--color-gray-500);
    --text-inverse: #ffffff;
    --text-on-primary: var(--text-inverse);
    --text-on-dark: var(--text-inverse);
    --text-on-light: var(--text-primary);
    --chrome-foreground: var(--primary-color);
    --chrome-foreground-hover: var(--secondary-color);
    --navbar-logo-filter: none;

    /* Navigation shell */
    --sidebar-text: rgba(var(--bs-white-rgb), 0.82);
    --sidebar-text-strong: var(--text-inverse);
    --sidebar-text-muted: rgba(var(--bs-white-rgb), 0.58);
    --sidebar-border: rgba(var(--bs-white-rgb), 0.16);
    --sidebar-hover: rgba(var(--bs-white-rgb), 0.10);
    --sidebar-active: rgba(var(--bs-white-rgb), 0.16);
    --sidebar-active-indicator: var(--text-inverse);

    /* Semantic surfaces and borders */
    --surface-page: #ffffff;
    --surface-raised: #ffffff;
    --surface-muted: var(--color-gray-50);
    --surface-subtle: var(--color-gray-100);
    --surface-input: #ffffff;
    --surface-navbar: #ffffff;
    --surface-footer: #ffffff;
    --surface-sidebar: var(--primary-color);
    --surface-hover: rgba(var(--secondary-color-rgb), 0.10);
    --surface-active: rgba(var(--primary-color-rgb), 0.14);
    --surface-selected: var(--lightest-accent);
    --surface-success-subtle: #e8f5ed;
    --surface-warning-subtle: #fdf6ee;
    /* Saved annotation intent is yellow, distinct from warning alerts. */
    --annotation-surface: #fff3bf;
    --annotation-text: #664d03;
    --annotation-border: #d8b331;
    --surface-danger-subtle: #fdf0f0;
    --surface-info-subtle: var(--lightest-accent);
    --surface-code: var(--color-gray-800);
    --surface-media-light: var(--color-gray-50);
    --surface-login-illustration: var(--surface-media-light);
    --text-code: #e2e8f0;
    /* Syntax colors for editable code on the theme's raised surface. */
    --syntax-keyword: #6b3fa0;
    --syntax-string: #86520a;
    --syntax-number: #005ea8;
    --syntax-function: #006b5b;
    --syntax-variable: #9a315b;
    --syntax-comment: #526277;
    --border-subtle: var(--color-gray-100);
    --border-default: var(--color-gray-200);
    --border-strong: var(--color-gray-400);
    --border-table: var(--color-gray-300);
    --border-selected: #9bcbee;
    --timeline-axis-major-text: var(--text-primary);
    --timeline-axis-minor-text: var(--text-tertiary);
    --timeline-grid-minor: var(--color-gray-200);
    --timeline-grid-major: var(--color-gray-400);
    --timeline-grid-row: var(--color-gray-300);
    --focus-ring: rgba(var(--primary-color-rgb), 0.25);
    --overlay-background: rgba(var(--bs-white-rgb), 0.72);
    --backdrop-background: rgba(var(--bs-black-rgb), 0.5);
    --scrollbar-thumb: var(--color-gray-400);
    --scrollbar-track: var(--color-gray-100);

    /* Dense data surfaces */
    --table-surface: var(--surface-raised);
    --table-surface-alt: var(--color-gray-50);
    --table-header-surface: var(--color-gray-100);
    --table-header-surface-hover: var(--color-gray-200);
    --table-text: var(--color-gray-700);
    --table-muted-text: var(--color-gray-500);

    /* Compatibility aliases for existing component styles */
    --body-bg: var(--surface-page);
    --navbar-bg: var(--surface-navbar);
    --sidebar-bg: var(--surface-sidebar);
    --card-bg: var(--surface-raised);
    --input-bg: var(--surface-input);
    --footer-bg: var(--surface-footer);

    /* Bootstrap 5.3 color-mode bridge */
    --bs-primary: var(--primary-color);
    --bs-primary-rgb: var(--primary-color-rgb);
    --bs-success: var(--color-success);
    --bs-success-rgb: var(--success-color-rgb);
    --bs-warning: var(--color-warning);
    --bs-warning-rgb: var(--warning-color-rgb);
    --bs-danger: var(--color-danger);
    --bs-danger-rgb: var(--danger-color-rgb);
    --bs-info: var(--color-info);
    --bs-info-rgb: var(--info-color-rgb);
    --bs-secondary: var(--color-neutral-action);
    --bs-secondary-rgb: var(--neutral-action-rgb);
    --bs-success-text-emphasis: var(--status-success-text);
    --bs-warning-text-emphasis: var(--status-warning-text);
    --bs-danger-text-emphasis: var(--status-danger-text);
    --bs-info-text-emphasis: var(--status-info-text);
    --bs-link-color: var(--link-color);
    --bs-link-color-rgb: var(--primary-color-rgb);
    --bs-link-hover-color: var(--link-hover);
    --bs-link-hover-color-rgb: 0, 59, 122;
    --bs-body-color: var(--text-primary);
    --bs-body-color-rgb: var(--text-primary-rgb);
    --bs-body-bg: var(--surface-page);
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-emphasis-color: var(--text-primary);
    --bs-emphasis-color-rgb: var(--text-primary-rgb);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-tertiary);
    --bs-secondary-bg: var(--surface-subtle);
    --bs-tertiary-bg: var(--surface-muted);
    --bs-border-color: var(--border-default);
    --bs-border-color-translucent: rgba(var(--text-primary-rgb), 0.16);
    --bs-focus-ring-color: var(--focus-ring);

    /* Table density */
    --table-cell-padding-normal: 4px 8px;
    --table-cell-padding-high: 0 2px;
    --table-header-padding-normal: 6px 8px;
    --table-header-padding-high: 1px 2px;

    /* Layout */
    --navbar-height: 70px;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --footer-height: 60px;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-compact: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-xl-plus-footer: calc(var(--spacing-xl) + var(--footer-height));

    /* Controls and page chrome */
    --control-height-sm: 32px;
    --control-height: 38px;
    --control-height-lg: 44px;
    --control-disabled-opacity: 0.65;
    --page-header-gap: 1rem;
    --page-section-gap: 1.25rem;

    /* Shape */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-full: 9999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(var(--text-primary-rgb), 0.05);
    --shadow-md: 0 4px 6px -1px rgba(var(--text-primary-rgb), 0.10), 0 2px 4px -1px rgba(var(--text-primary-rgb), 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(var(--text-primary-rgb), 0.10), 0 4px 6px -2px rgba(var(--text-primary-rgb), 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(var(--text-primary-rgb), 0.10), 0 10px 10px -5px rgba(var(--text-primary-rgb), 0.04);

    /* Typography */
    --font-family-base: system-ui, "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-loose: 1.75;

    /* Motion */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Stacking */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
    --z-loader: 1090;
}

[data-bs-theme="dark"] {
    color-scheme: dark;

    --primary-color: #006bb6;
    --primary-color-rgb: 0, 107, 182;
    --primary-hover: #0575bd;
    --primary-active: #005694;
    --link-color: #59b9f3;
    --link-hover: #8bcffc;
    --interactive-foreground: var(--link-color);
    --secondary-color: var(--brand-highlight);
    --secondary-color-rgb: var(--brand-highlight-rgb);
    /* Solid action fills are darker and quieter than dark-mode link accents. */
    --color-neutral-action: #46515d;
    --color-neutral-action-hover: #596777;
    --neutral-action-rgb: 70, 81, 93;
    --color-area-action: #245f85;
    --color-area-action-hover: #2d739e;
    --area-action-rgb: 36, 95, 133;
    --color-print-action: #225f5b;
    --color-print-action-hover: #2b746e;
    --print-action-rgb: 34, 95, 91;
    --color-reopen-action: #51466f;
    --color-reopen-action-hover: #645685;
    --reopen-action-rgb: 81, 70, 111;
    --color-delete-action: #8f424b;
    --color-delete-action-hover: #a54c57;
    --color-delete-action-active: #793740;
    --delete-action-rgb: 143, 66, 75;
    --light-accent: #ffffff;
    --lighter-accent: #8bcffc;
    --lightest-accent: #dff3ff;
    --workflow-node-color: #4e9bd2;
    --workflow-node-color-rgb: 78, 155, 210;
    --workflow-node-hover: #69afe0;
    --workflow-node-surface: var(--surface-info-subtle);
    --status-success-text: #7bd3a1;
    --status-warning-text: #f0b27f;
    --status-danger-text: #f19aa3;
    --status-info-text: var(--link-color);

    --text-primary: #edf2f7;
    --text-primary-rgb: 237, 242, 247;
    --text-secondary: #c6d0da;
    --text-tertiary: #9ca9b6;
    --text-on-light: #0f172a;
    --chrome-foreground: #ffffff;
    --chrome-foreground-hover: #ffffff;
    --navbar-logo-filter: brightness(0) invert(1);

    --surface-page: #151a20;
    --surface-raised: #1d242c;
    --surface-muted: #252e38;
    --surface-subtle: #2d3844;
    --surface-input: #202832;
    --surface-navbar: #11161b;
    --surface-footer: #11161b;
    --surface-sidebar: #172431;
    --surface-login-illustration: #151b22;
    --sidebar-text: rgba(var(--bs-white-rgb), 0.82);
    --sidebar-text-strong: #ffffff;
    --sidebar-text-muted: rgba(var(--bs-white-rgb), 0.56);
    --sidebar-border: rgba(var(--bs-white-rgb), 0.12);
    --sidebar-hover: rgba(var(--bs-white-rgb), 0.08);
    --sidebar-active: rgba(var(--secondary-color-rgb), 0.18);
    --sidebar-active-indicator: var(--secondary-color);
    --surface-hover: rgba(var(--secondary-color-rgb), 0.16);
    --surface-active: rgba(var(--primary-color-rgb), 0.22);
    --surface-selected: #243e50;
    --surface-success-subtle: #1d382b;
    --surface-warning-subtle: #3d3023;
    --annotation-surface: #493b12;
    --annotation-text: #ffe08a;
    --annotation-border: #9a7c25;
    --surface-danger-subtle: #40272a;
    --surface-info-subtle: #203744;
    --surface-code: #0f141a;
    --text-code: #edf2f7;
    --syntax-keyword: #c7a4ee;
    --syntax-string: #e8bf82;
    --syntax-number: #83c4f4;
    --syntax-function: #84d3bd;
    --syntax-variable: #f1a9c3;
    --syntax-comment: #9ca9b6;
    --border-subtle: #303b47;
    --border-default: #3d4956;
    --border-strong: #596777;
    --border-table: #4a5867;
    --border-selected: #477c9d;
    --timeline-axis-major-text: #ffffff;
    --timeline-axis-minor-text: #9ca9b6;
    --timeline-grid-minor: #303943;
    --timeline-grid-major: #46515d;
    --timeline-grid-row: #38434e;
    --focus-ring: rgba(var(--primary-color-rgb), 0.35);
    --overlay-background: rgba(var(--bs-black-rgb), 0.76);
    --backdrop-background: rgba(var(--bs-black-rgb), 0.68);
    --scrollbar-thumb: #596777;
    --scrollbar-track: #202832;

    --table-surface: var(--surface-raised);
    --table-surface-alt: #222b35;
    --table-header-surface: #2d3844;
    --table-header-surface-hover: #374554;
    --table-text: var(--text-primary);
    --table-muted-text: var(--text-secondary);

    --bs-primary: var(--primary-color);
    --bs-primary-rgb: var(--primary-color-rgb);
    --bs-link-color: var(--link-color);
    --bs-link-color-rgb: 89, 185, 243;
    --bs-link-hover-color: var(--link-hover);
    --bs-link-hover-color-rgb: 139, 207, 252;
    --bs-body-color: var(--text-primary);
    --bs-body-color-rgb: 237, 242, 247;
    --bs-body-bg: var(--surface-page);
    --bs-body-bg-rgb: 21, 26, 32;
    --bs-emphasis-color: #ffffff;
    --bs-emphasis-color-rgb: 255, 255, 255;
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-tertiary);
    --bs-secondary-bg: var(--surface-subtle);
    --bs-secondary-bg-rgb: 45, 56, 68;
    --bs-tertiary-bg: var(--surface-muted);
    --bs-tertiary-bg-rgb: 37, 46, 56;
    --bs-border-color: var(--border-default);
    --bs-border-color-translucent: rgba(var(--bs-white-rgb), 0.15);
    --bs-focus-ring-color: var(--focus-ring);

    --shadow-sm: 0 1px 2px rgba(var(--bs-black-rgb), 0.25);
    --shadow-md: 0 4px 6px -1px rgba(var(--bs-black-rgb), 0.35), 0 2px 4px -1px rgba(var(--bs-black-rgb), 0.18);
    --shadow-lg: 0 10px 15px -3px rgba(var(--bs-black-rgb), 0.38), 0 4px 6px -2px rgba(var(--bs-black-rgb), 0.20);
    --shadow-xl: 0 20px 25px -5px rgba(var(--bs-black-rgb), 0.42), 0 10px 10px -5px rgba(var(--bs-black-rgb), 0.22);
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
        --transition-normal: 0ms;
        --transition-slow: 0ms;
    }
}
