/*
 * RailScanPro Design System Tokens
 *
 * Single source of truth for all design values.
 * Consolidates 15+ overlapping color systems into one unified system.
 *
 * Created: November 16, 2025
 * Purpose: ADR-0063/ADR-0064 compliance
 */

:root {
    /* ========================================
     * COLORS - Primary Brand
     * ======================================== */
    --color-primary-50: #f0f9ff;
    --color-primary-100: #e0f2fe;
    --color-primary-200: #bae6fd;
    --color-primary-300: #7dd3fc;
    --color-primary-400: #38bdf8;
    --color-primary-500: #0ea5e9;  /* Main brand color */
    --color-primary-600: #0284c7;
    --color-primary-700: #0369a1;
    --color-primary-800: #075985;
    --color-primary-900: #0c4a6e;
    --color-primary-950: #082f49;

    /* ========================================
     * SURFACES - Background colors
     * ======================================== */
    --surface-primary: #0f172a;      /* Darkest - main background */
    --surface-secondary: #1e293b;    /* Cards, elevated surfaces */
    --surface-tertiary: #334155;     /* Hover states, subtle backgrounds */
    --surface-quaternary: #475569;   /* Higher elevation */
    --surface-inverse: #f8fafc;      /* Light mode surfaces */

    /* ========================================
     * TEXT COLORS
     * ======================================== */
    --text-emphasis: #f1f5f9;        /* High emphasis text */
    --text-primary: #e2e8f0;         /* Primary text */
    --text-secondary: #cbd5e1;       /* Secondary text */
    --text-muted: #94a3b8;           /* Muted/placeholder text */
    --text-disabled: #64748b;        /* Disabled text */
    --text-inverse: #0f172a;         /* Text on light backgrounds */
    --text-onbrand: #ffffff;         /* Text on brand color backgrounds */

    /* ========================================
     * BORDERS
     * ======================================== */
    --border-primary: #334155;       /* Default borders */
    --border-secondary: #475569;     /* Lighter borders */
    --border-strong: #64748b;        /* Emphasized borders */
    --border-focus: #38bdf8;         /* Focus ring color */
    --border-brand: #0ea5e9;         /* Brand accent borders */

    /* ========================================
     * SEMANTIC COLORS - Status/Feedback
     * ======================================== */
    /* Success */
    --color-success-50: #f0fdf4;
    --color-success-100: #dcfce7;
    --color-success-500: #10b981;
    --color-success-600: #059669;
    --color-success-700: #047857;

    /* Warning */
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;
    --color-warning-700: #b45309;

    /* Error/Danger */
    --color-error-50: #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-500: #ef4444;
    --color-error-600: #dc2626;
    --color-error-700: #b91c1c;

    /* Info */
    --color-info-50: #eff6ff;
    --color-info-100: #dbeafe;
    --color-info-500: #3b82f6;
    --color-info-600: #2563eb;
    --color-info-700: #1d4ed8;

    /* ========================================
     * SPACING SCALE (8px base)
     * ======================================== */
    --space-0: 0;
    --space-1: 0.25rem;    /* 4px */
    --space-2: 0.5rem;     /* 8px */
    --space-3: 0.75rem;    /* 12px */
    --space-4: 1rem;       /* 16px */
    --space-5: 1.25rem;    /* 20px */
    --space-6: 1.5rem;     /* 24px */
    --space-8: 2rem;       /* 32px */
    --space-10: 2.5rem;    /* 40px */
    --space-12: 3rem;      /* 48px */
    --space-16: 4rem;      /* 64px */
    --space-20: 5rem;      /* 80px */
    --space-24: 6rem;      /* 96px */

    /* ========================================
     * TYPOGRAPHY
     * ======================================== */
    /* Font Family */
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;      /* 12px */
    --text-sm: 0.875rem;     /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg: 1.125rem;     /* 18px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.875rem;    /* 30px */
    --text-4xl: 2.25rem;     /* 36px */
    --text-5xl: 3rem;        /* 48px */

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

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

    /* ========================================
     * SHADOWS (3 levels only)
     * ======================================== */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* For dark mode (higher contrast shadows) */
    --shadow-dark-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-dark-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-dark-lg: 0 12px 24px rgba(0, 0, 0, 0.25);
    --shadow-dark-xl: 0 20px 40px rgba(0, 0, 0, 0.35);

    /* ========================================
     * BORDER RADIUS
     * ======================================== */
    --radius-none: 0;
    --radius-sm: 0.125rem;   /* 2px */
    --radius-md: 0.375rem;   /* 6px */
    --radius-lg: 0.5rem;     /* 8px */
    --radius-xl: 0.75rem;    /* 12px */
    --radius-2xl: 1rem;      /* 16px */
    --radius-full: 9999px;

    /* Component-specific radii */
    --radius-button: var(--radius-md);
    --radius-input: var(--radius-md);
    --radius-card: var(--radius-lg);
    --radius-dialog: var(--radius-xl);
    --radius-toast: var(--radius-md);

    /* Tailwind custom names for consistency */
    --rounded-rsp-button: var(--radius-button);
    --rounded-rsp-input: var(--radius-input);
    --rounded-rsp-card: var(--radius-card);
    --rounded-rsp-dialog: var(--radius-dialog);
    --rounded-rsp-toast: var(--radius-toast);

    /* ========================================
     * Z-INDEX SCALE
     * ======================================== */
    --z-base: 0;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* ========================================
     * TRANSITIONS
     * ======================================== */
    --transition-fast: 150ms;
    --transition-base: 200ms;
    --transition-slow: 300ms;
    --transition-slower: 500ms;

    --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);

    /* ========================================
     * BRAND ALIASES (backwards compatibility)
     * ======================================== */
    --brand-primary: var(--color-primary-500);
    --brand-primary-hover: var(--color-primary-600);
    --brand-primary-light: var(--color-primary-400);
    --brand-primary-dark: var(--color-primary-700);

    /* Status aliases */
    --status-success: var(--color-success-500);
    --status-success-hover: var(--color-success-600);
    --status-warning: var(--color-warning-500);
    --status-warning-hover: var(--color-warning-600);
    --status-error: var(--color-error-500);
    --status-error-hover: var(--color-error-600);
    --status-info: var(--color-info-500);
    --status-info-hover: var(--color-info-600);

    /* ========================================
     * FOCUS RING
     * ======================================== */
    --focus-ring-width: 2px;
    --focus-ring-offset: 2px;
    --focus-ring-color: var(--border-focus);
}

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

/* Focus visible styles */
.focus-ring {
    outline: none;
}

.focus-ring:focus-visible {
    box-shadow: 0 0 0 var(--focus-ring-offset) var(--surface-primary),
                0 0 0 calc(var(--focus-ring-offset) + var(--focus-ring-width)) var(--focus-ring-color);
}

/* Minimum touch target (WCAG 2.1 AA) */
.min-touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-primary: #94a3b8;
        --text-secondary: #e2e8f0;
    }
}

/* ========================================
 * Organization Switcher - Syncfusion SfDropDownList
 * Custom styling for header navigation dropdown
 * ======================================== */
.org-switcher-dropdown.e-ddl.e-outline {
    /* Input wrapper - transparent background */
    --sf-ddl-bgcolor: transparent;
    background: transparent !important;
    border: 1px solid var(--border-secondary) !important;
    border-radius: 0.5rem !important;
    min-width: 200px;
    max-width: 280px;
}

.org-switcher-dropdown.e-ddl.e-outline .e-ddl-icon {
    color: var(--text-secondary) !important;
}

.org-switcher-dropdown.e-ddl.e-outline:hover {
    border-color: var(--border-emphasis) !important;
    background: var(--surface-tertiary) !important;
}

.org-switcher-dropdown.e-ddl.e-outline.e-input-focus {
    border-color: var(--color-primary-500) !important;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2) !important;
}

/* Popup styling */
.org-switcher-dropdown.e-popup {
    background: var(--surface-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
    margin-top: 4px !important;
}

.org-switcher-dropdown.e-popup .e-list-parent {
    background: transparent !important;
}

.org-switcher-dropdown.e-popup .e-list-item {
    background: transparent !important;
    border-radius: 0.375rem;
    margin: 2px 4px;
    padding: 0 !important;
}

.org-switcher-dropdown.e-popup .e-list-item:hover,
.org-switcher-dropdown.e-popup .e-list-item.e-hover {
    background: var(--surface-tertiary) !important;
}

.org-switcher-dropdown.e-popup .e-list-item.e-active {
    background: var(--color-primary-500) !important;
    color: var(--text-onbrand) !important;
}

/* Hide the default scrollbar styling */
.org-switcher-dropdown.e-popup::-webkit-scrollbar {
    width: 6px;
}

.org-switcher-dropdown.e-popup::-webkit-scrollbar-track {
    background: var(--surface-secondary);
}

.org-switcher-dropdown.e-popup::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}
