/**
 * ============================================================================
 * DESIGN SYSTEM - Master Variables & Tokens
 * ============================================================================
 * This file contains all design tokens (colors, typography, spacing, etc.)
 * that are used throughout the application.
 *
 * ARCHITECTURE - Two-Layer Variable System:
 *
 *   Layer 1 - Brand Tokens (client identity)
 *     --brand-primary, --brand-secondary, --brand-accent, --brand-font
 *     Override ONLY these in themes/{client}.css to change all colours.
 *
 *   Layer 2 - Component Tokens (auto-derive from Layer 1)
 *     --header-bg, --btn-primary-bg, --table-header-bg, --input-border-focus
 *     These inherit automatically. Do NOT hardcode values in module CSS.
 *
 * CODING RULE - enforced across ALL files, ALL packages:
 *   FORBIDDEN: color: #2196F3;           (hardcoded hex)
 *   FORBIDDEN: background: #1a1a2e;      (hardcoded hex)
 *   USE: color: var(--brand-primary);
 *   USE: background: var(--header-bg);
 *
 * Usage: Include this file FIRST before any other CSS files.
 * <link rel="stylesheet" href="/assets/css/design-system.css">
 *
 * Version: 1.3.0
 * Updated:  2026-02-24  V1.30 Theme System - two-layer brand/component tokens,
 *                        dark mode ([data-theme="dark"]), print variables
 * Previous: 1.0.0  2025-11-24  Initial design tokens
 * ============================================================================
 */

:root {
    
    /* ========================================================================
       COLOR SYSTEM
       ======================================================================== */
    
    /* Primary Brand Colors (Your Blue) */
    --primary-50:  #e8eeff;
    --primary-100: #d1ddff;
    --primary-200: #a3bbff;
    --primary-300: #7599ff;
    --primary-400: #4777ff;
    --primary-500: #5277e4;      /* Main brand blue (your current color) */
    --primary-600: #3d5eb3;
    --primary-700: #2e4682;
    --primary-800: #1f2d52;
    --primary-900: #0f1521;
    
    /* Semantic Colors - Success */
    --success-50:  #f0fdf4;
    --success-100: #dcfce7;
    --success-200: #bbf7d0;
    --success-300: #86efac;
    --success-400: #4ade80;
    --success-500: #28a745;      /* Replaces generic "green" */
    --success-600: #16a34a;
    --success-700: #15803d;
    --success-800: #166534;
    --success-900: #14532d;
    
    /* Semantic Colors - Danger */
    --danger-50:  #fef2f2;
    --danger-100: #fee2e2;
    --danger-200: #fecaca;
    --danger-300: #fca5a5;
    --danger-400: #f87171;
    --danger-500: #dc3545;       /* Replaces generic "red" */
    --danger-600: #dc2626;
    --danger-700: #b91c1c;
    --danger-800: #991b1b;
    --danger-900: #7f1d1d;
    
    /* Semantic Colors - Warning */
    --warning-50:  #fffbeb;
    --warning-100: #fef3c7;
    --warning-200: #fde68a;
    --warning-300: #fcd34d;
    --warning-400: #fbbf24;
    --warning-500: #ffc107;      /* Replaces generic "orange" */
    --warning-600: #f59e0b;
    --warning-700: #d97706;
    --warning-800: #b45309;
    --warning-900: #92400e;
    
    /* Semantic Colors - Info */
    --info-50:  #f0f9ff;
    --info-100: #e0f2fe;
    --info-200: #bae6fd;
    --info-300: #7dd3fc;
    --info-400: #38bdf8;
    --info-500: #17a2b8;
    --info-600: #0284c7;
    --info-700: #0369a1;
    --info-800: #075985;
    --info-900: #0c4a6e;
    
    /* Neutral Colors - Grays */
    --gray-50:   #f8f9fa;
    --gray-100:  #e9ecef;
    --gray-200:  #dee2e6;
    --gray-300:  #ced4da;
    --gray-400:  #adb5bd;
    --gray-500:  #6c757d;
    --gray-600:  #495057;
    --gray-700:  #343a40;
    --gray-800:  #212529;
    --gray-900:  #0d1117;
    
    /* Base Colors */
    --white:     #ffffff;
    --black:     #000000;
    
    /* Functional Colors */
    --body-bg:       #f5f7fa;
    --body-color:    #212529;
    --text-muted:    #6c757d;
    --border-color:  #dee2e6;
    --link-color:    var(--primary-500);
    --link-hover:    var(--primary-600);

    /* ========================================================================
       LAYER 1 - BRAND IDENTITY TOKENS
       These are the ONLY variables you need to override in a client theme file.
       Changing these cascades to every component automatically.
       ======================================================================== */

    /* Brand Colors - primary identity of this deployment */
    --brand-primary:   var(--primary-500);  /* #5277e4 - CTAs, active nav, badges   */
    --brand-secondary: #764ba2;             /* gradient end - purple accent          */
    --brand-accent:    #667eea;             /* gradient start - header highlight     */

    /* Brand Typography */
    --brand-font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --brand-font-url:  'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap';


    /* ========================================================================
       LAYER 2 - COMPONENT TOKENS
       Auto-derive from Layer 1. Do NOT override in theme files.
       Do NOT hardcode hex values in any module or feature CSS.
       ======================================================================== */

    /* -- Header / Navigation -- */
    --header-bg:        var(--brand-secondary);   /* Solid purple — no blue gradient */
    --header-bg-light:  linear-gradient(135deg, #8aa0ff 0%, var(--brand-accent) 100%);
    --header-bg-hover:  linear-gradient(135deg, var(--brand-accent) 0%, #5a67d8 100%);
    --header-text:      #ffffff;
    --header-accent:    var(--brand-accent);
    --header-shadow:    0 2px 12px rgba(0, 0, 0, 0.18);

    /* -- Buttons -- */
    --btn-primary-bg:    var(--brand-primary);
    --btn-primary-hover: var(--primary-600);

    /* -- Tables -- */
    --table-header-bg:     var(--brand-secondary);   /* Solid purple for <th> headers    */
    --table-header-text:   #ffffff;                  /* White text on dark header          */
    --table-stripe-bg:     #f0eeff;                  /* Very light brand tint (even rows)  */
    --table-hover-bg:      #e8e4ff;                  /* Hover tint (odd rows)              */
    --table-stripe-hover:  #ddd8ff;                  /* Hover tint (even rows)             */
    --table-row-hover:     var(--table-hover-bg);    /* Backwards compat alias             */
    --table-border:        var(--gray-200);           /* #dee2e6                           */
    --table-text:          var(--gray-600);           /* #495057                           */

    /* -- Forms / Inputs -- */
    --input-border:        var(--gray-200);
    --input-border-focus:  var(--brand-primary);
    --input-focus-shadow:  0 0 0 3px rgba(82, 119, 228, 0.15);
    --input-border-radius: var(--radius-lg);     /* 8px    */

    /* -- Cards / Surfaces -- */
    --bg-card:       #ffffff;
    --bg-card-hover: var(--gray-50);

    /* -- Semantic Backgrounds -- */
    --bg-main:       var(--body-bg);            /* #f5f7fa */

    /* -- Semantic Text -- */
    --color-text-main:   #1e293b;
    --color-text-muted:  var(--gray-500);       /* #6c757d */
    --color-text-subtle: var(--gray-400);       /* #adb5bd */

    /* -- Semantic Borders -- */
    --border-default: var(--gray-200);           /* #dee2e6 */
    --border-subtle:  var(--gray-100);           /* #e9ecef */

    /* -- Print / Export / PDF -- */
    --print-bg:     #ffffff;
    --print-text:   #000000;
    --print-border: #cccccc;

    
    
    /* ========================================================================
       TYPOGRAPHY SYSTEM
       ======================================================================== */
    
    /* Font Families */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 
                 Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    --font-mono: 'Fira Code', 'SF Mono', 'Roboto Mono', 'Courier New', monospace;
    
    /* Font Sizes (Modular Scale - 1.125 ratio) */
    --text-xs:   0.75rem;    /* 12px */
    --text-sm:   0.8125rem;  /* 13px */
    --text-base: 0.875rem;   /* 14px - Standard base size */
    --text-lg:   1rem;        /* 16px */
    --text-xl:   1.125rem;   /* 18px */
    --text-2xl:  1.3125rem;  /* 21px */
    --text-3xl:  1.625rem;   /* 26px */
    --text-4xl:  2rem;       /* 32px */
    --text-5xl:  2.5rem;     /* 40px */
    
    /* Font Weights */
    --font-thin:      100;
    --font-light:     300;
    --font-normal:    400;
    --font-medium:    500;
    --font-semibold:  600;
    --font-bold:      700;
    --font-extrabold: 800;
    --font-black:     900;
    
    /* Line Heights */
    --leading-none:    1;
    --leading-tight:   1.25;
    --leading-snug:    1.375;
    --leading-normal:  1.5;
    --leading-relaxed: 1.75;
    --leading-loose:   2;
    
    
    /* ========================================================================
       SPACING SYSTEM (Base 4px)
       ======================================================================== */
    
    --space-0:   0;
    --space-px:  1px;
    --space-0-5: 0.125rem;   /* 2px */
    --space-1:   0.25rem;    /* 4px */
    --space-1-5: 0.375rem;   /* 6px */
    --space-2:   0.5rem;     /* 8px */
    --space-2-5: 0.625rem;   /* 10px */
    --space-3:   0.75rem;    /* 12px */
    --space-3-5: 0.875rem;   /* 14px */
    --space-4:   1rem;       /* 16px */
    --space-5:   1.25rem;    /* 20px */
    --space-6:   1.5rem;     /* 24px */
    --space-7:   1.75rem;    /* 28px */
    --space-8:   2rem;       /* 32px */
    --space-9:   2.25rem;    /* 36px */
    --space-10:  2.5rem;     /* 40px */
    --space-11:  2.75rem;    /* 44px */
    --space-12:  3rem;       /* 48px */
    --space-14:  3.5rem;     /* 56px */
    --space-16:  4rem;       /* 64px */
    --space-20:  5rem;       /* 80px */
    --space-24:  6rem;       /* 96px */
    --space-28:  7rem;       /* 112px */
    --space-32:  8rem;       /* 128px */
    
    /* Semantic Spacing */
    --gap-xs:  var(--space-1);
    --gap-sm:  var(--space-2);
    --gap-md:  var(--space-4);
    --gap-lg:  var(--space-6);
    --gap-xl:  var(--space-8);
    --gap-2xl: var(--space-12);
    
    
    /* ========================================================================
       BORDER RADIUS
       ======================================================================== */
    
    --radius-none: 0;
    --radius-sm:   0.125rem;  /* 2px */
    --radius-base: 0.25rem;   /* 4px */
    --radius-md:   0.375rem;  /* 6px */
    --radius-lg:   0.5rem;    /* 8px */
    --radius-xl:   0.75rem;   /* 12px */
    --radius-2xl:  1rem;      /* 16px */
    --radius-3xl:  1.5rem;    /* 24px */
    --radius-full: 9999px;
    
    
    /* ========================================================================
       SHADOWS
       ======================================================================== */
    
    --shadow-xs:  0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm:  0 1px 3px 0 rgba(0, 0, 0, 0.1), 
                  0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                  0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.1), 
                  0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.1), 
                  0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    --shadow-none: none;
    
    
    /* ========================================================================
       TRANSITIONS
       ======================================================================== */
    
    --transition-fast:   150ms ease-in-out;
    --transition-base:   200ms ease-in-out;
    --transition-slow:   300ms ease-in-out;
    --transition-slower: 500ms ease-in-out;
    
    
    /* ========================================================================
       Z-INDEX LAYERS
       ======================================================================== */
    
    --z-base:         0;
    --z-dropdown:     1000;
    --z-sticky:       1020;
    --z-fixed:        1030;
    --z-modal-backdrop: 1040;
    --z-modal:        1050;
    --z-popover:      1060;
    --z-tooltip:      1070;
    --z-notification: 1080;
    
    
    /* ========================================================================
       BREAKPOINTS (for reference in media queries)
       ======================================================================== */
    
    --breakpoint-sm:  576px;
    --breakpoint-md:  768px;
    --breakpoint-lg:  992px;
    --breakpoint-xl:  1200px;
    --breakpoint-2xl: 1400px;
    
    
    /* ========================================================================
       CONTAINER WIDTHS
       ======================================================================== */
    
    --container-sm:  540px;
    --container-md:  720px;
    --container-lg:  960px;
    --container-xl:  1140px;
    --container-2xl: 1320px;
}


/* ============================================================================
   DARK MODE - [data-theme="dark"] (JS-toggled, preferred for ERP)
   To activate: document.documentElement.setAttribute('data-theme', 'dark')
   To deactivate: document.documentElement.removeAttribute('data-theme')
   ============================================================================ */

[data-theme="dark"] {
    /* Surfaces */
    --bg-main:           #0d1117;
    --bg-card:           #161b22;
    --bg-card-hover:     #1c2128;
    --body-bg:           #0d1117;
    /* Text */
    --body-color:        #e6edf3;
    --color-text-main:   #e6edf3;
    --color-text-muted:  #8b949e;
    --color-text-subtle: #6e7681;
    /* Borders */
    --border-color:      #30363d;
    --border-default:    #30363d;
    --border-subtle:     #21262d;
    /* Tables */
    --table-header-bg:   #161b22;
    --table-header-text: #8b949e;
    --table-row-hover:   #1c2128;
    --table-border:      #30363d;
    /* Inputs */
    --input-border:      #30363d;
    /* Tables */
    --table-stripe-bg:    #1a1f2e;
    --table-hover-bg:     #212738;
    --table-stripe-hover: #282f42;
    /* Brand stays the same - dark mode does not change identity */
}


/* ============================================================================
   DARK MODE - @media fallback (system preference, no JS required)
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    /* Intentionally left empty - use [data-theme="dark"] for controlled toggle */
    /* Uncomment the block below to enable automatic OS-level dark mode: */
    /*
    :root {
        --bg-main:         #0d1117;
        --bg-card:         #161b22;
        --body-bg:         #0d1117;
        --body-color:      #e6edf3;
        --border-color:    #30363d;
        --border-default:  #30363d;
        --color-text-main: #e6edf3;
    }
    */
}


/* ============================================================================
   UTILITY: Print Optimization
   ============================================================================ */

@media print {
    :root {
        --body-bg: white;
        --body-color: black;
    }
}
