/* ==========================================================================
   MTM INDUS OS — OFFICIAL DESIGN SYSTEM
   Single Source of Truth for All Design Tokens
   Global Premium White Theme
   ========================================================================== */

:root {
  /* ======================================================================
     COLOR PRIMITIVES — Raw brand & semantic values
     ====================================================================== */

  /* Brand Blue (Primary) */
  --blue-50: #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE;
  --blue-300: #93C5FD;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-800: #1E40AF;
  --blue-900: #1E3A8A;
  --blue-950: #172554;

  /* Cyan Accent */
  --cyan-50: #ECFEFF;
  --cyan-100: #CFFAFE;
  --cyan-200: #A5F3FC;
  --cyan-300: #67E8F9;
  --cyan-400: #22D3EE;
  --cyan-500: #06B6D4;
  --cyan-600: #0891B2;
  --cyan-700: #0E7490;
  --cyan-800: #155E75;
  --cyan-900: #164E63;
  --cyan-950: #083344;

  /* Emerald (Success) */
  --emerald-50: #ECFDF5;
  --emerald-100: #D1FAE5;
  --emerald-200: #A7F3D0;
  --emerald-300: #6EE7B7;
  --emerald-400: #34D399;
  --emerald-500: #10B981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065F46;
  --emerald-900: #064E3B;
  --emerald-950: #022C22;

  /* Amber (Warning) */
  --amber-50: #FFFBEB;
  --amber-100: #FEF3C7;
  --amber-200: #FDE68A;
  --amber-300: #FCD34D;
  --amber-400: #FBBF24;
  --amber-500: #F59E0B;
  --amber-600: #D97706;
  --amber-700: #B45309;
  --amber-800: #92400E;
  --amber-900: #78350F;
  --amber-950: #451A03;

  /* Rose (Error) */
  --rose-50: #FFF1F2;
  --rose-100: #FFE4E6;
  --rose-200: #FECDD3;
  --rose-300: #FDA4AF;
  --rose-400: #FB7185;
  --rose-500: #F43F5E;
  --rose-600: #E11D48;
  --rose-700: #BE123C;
  --rose-800: #9F1239;
  --rose-900: #881337;
  --rose-950: #4C0519;

  /* Slate Neutral (Primary neutral scale) */
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1E293B;
  --slate-900: #0F172A;
  --slate-950: #020617;

  /* ======================================================================
     SEMANTIC COLOR ALIASES — Use these in components
     ====================================================================== */

  /* Backgrounds */
  --color-bg-primary: var(--slate-50);
  --color-bg-secondary: var(--slate-100);
  --color-bg-tertiary: var(--slate-200);
  --color-bg-inverse: var(--slate-900);
  --color-bg-brand: var(--blue-600);
  --color-bg-brand-hover: var(--blue-700);
  --color-bg-brand-subtle: var(--blue-50);
  --color-bg-success-subtle: var(--emerald-50);
  --color-bg-warning-subtle: var(--amber-50);
  --color-bg-error-subtle: var(--rose-50);
  --color-bg-info-subtle: var(--cyan-50);

  /* Surfaces */
  --color-surface: #FFFFFF;
  --color-surface-hover: var(--slate-50);
  --color-surface-active: var(--slate-100);
  --color-surface-raised: #FFFFFF;
  --color-surface-border: var(--slate-200);
  --color-surface-border-strong: var(--slate-300);
  --color-surface-border-focus: var(--blue-500);
  --color-surface-border-error: var(--rose-500);

  /* Text */
  --color-text-primary: var(--slate-900);
  --color-text-secondary: var(--slate-600);
  --color-text-tertiary: var(--slate-400);
  --color-text-quaternary: var(--slate-300);
  --color-text-inverse: #FFFFFF;
  --color-text-brand: var(--blue-700);
  --color-text-brand-light: var(--blue-600);
  --color-text-success: var(--emerald-700);
  --color-text-warning: var(--amber-700);
  --color-text-error: var(--rose-700);
  --color-text-info: var(--cyan-700);
  --color-text-link: var(--blue-600);
  --color-text-link-hover: var(--blue-700);

  /* Interactive */
  --color-interactive-primary: var(--blue-600);
  --color-interactive-primary-hover: var(--blue-700);
  --color-interactive-primary-active: var(--blue-800);
  --color-interactive-secondary: var(--slate-600);
  --color-interactive-secondary-hover: var(--slate-700);
  --color-interactive-tertiary: transparent;
  --color-interactive-tertiary-hover: var(--slate-100);
  --color-interactive-disabled: var(--slate-300);

  /* Focus */
  --color-focus-ring: var(--blue-300);
  --color-focus-ring-offset: #FFFFFF;

  /* Status */
  --color-status-success: var(--emerald-600);
  --color-status-success-bg: var(--emerald-50);
  --color-status-success-border: var(--emerald-200);
  --color-status-warning: var(--amber-600);
  --color-status-warning-bg: var(--amber-50);
  --color-status-warning-border: var(--amber-200);
  --color-status-error: var(--rose-600);
  --color-status-error-bg: var(--rose-50);
  --color-status-error-border: var(--rose-200);
  --color-status-info: var(--cyan-600);
  --color-status-info-bg: var(--cyan-50);
  --color-status-info-border: var(--cyan-200);

  /* Overlay */
  --color-overlay: rgba(15, 23, 42, 0.5);
  --color-overlay-strong: rgba(15, 23, 42, 0.75);

  /* ======================================================================
     TYPOGRAPHY — Fluid type scale using clamp()
     ====================================================================== */

  /* Font Families */
  --font-family-sans: 'Inter Variable', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-display: 'Inter Variable', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, Consolas, monospace;

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

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

  /* Fluid Font Sizes — clamp(min, preferred, max) */
  --text-2xs: clamp(0.625rem, 0.58rem + 0.2vw, 0.6875rem);   /* 10-11px */
  --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);        /* 11-12px */
  --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);       /* 12-14px */
  --text-base: clamp(0.9375rem, 0.875rem + 0.3vw, 1rem);      /* 15-16px */
  --text-md: clamp(0.9375rem, 0.875rem + 0.3vw, 1rem);        /* 15-16px */
  --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);        /* 17-18px */
  --text-xl: clamp(1.25rem, 1.125rem + 0.6vw, 1.5rem);        /* 20-24px */
  --text-2xl: clamp(1.5rem, 1.25rem + 1.2vw, 2rem);           /* 24-32px */
  --text-3xl: clamp(1.875rem, 1.5rem + 1.8vw, 2.5rem);        /* 30-40px */
  --text-4xl: clamp(2.25rem, 1.75rem + 2.5vw, 3.5rem);        /* 36-56px */
  --text-5xl: clamp(3rem, 2rem + 5vw, 5rem);                  /* 48-80px */

  /* Display Sizes (for hero, headlines) */
  --display-sm: clamp(2rem, 1.5rem + 2.5vw, 3rem);            /* 32-48px */
  --display-md: clamp(2.5rem, 2rem + 3vw, 4rem);              /* 40-64px */
  --display-lg: clamp(3rem, 2.5rem + 4vw, 5rem);              /* 48-80px */
  --display-xl: clamp(3.5rem, 3rem + 5vw, 6rem);              /* 56-96px */

  /* Letter Spacing */
  --tracking-tight: -0.03em;
  --tracking-tighter: -0.045em;
  --tracking-normal: 0;
  --tracking-wide: 0.08em;
  --tracking-wider: 0.16em;

  /* ======================================================================
     SPACING — 4px base scale
     ====================================================================== */

  --space-0: 0;
  --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-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;

  /* Component-specific spacing */
  --space-component-xs: var(--space-1);
  --space-component-sm: var(--space-2);
  --space-component-md: var(--space-4);
  --space-component-lg: var(--space-6);
  --space-component-xl: var(--space-8);

  /* Layout spacing */
  --space-layout-sm: var(--space-4);
  --space-layout-md: var(--space-8);
  --space-layout-lg: var(--space-16);
  --space-layout-xl: var(--space-24);

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

  --radius-none: 0;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Component radius */
  --radius-button: var(--radius-md);
  --radius-button-sm: var(--radius-sm);
  --radius-button-lg: var(--radius-lg);
  --radius-input: var(--radius-sm);
  --radius-card: var(--radius-lg);
  --radius-modal: var(--radius-xl);
  --radius-badge: var(--radius-full);
  --radius-avatar: 50%;

  /* ======================================================================
     SHADOWS & ELEVATION
     ====================================================================== */

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 16px -4px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 24px -5px rgba(0, 0, 0, 0.09), 0 8px 8px -6px rgba(0, 0, 0, 0.06);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

  /* Colored shadows */
  --shadow-brand: 0 8px 20px -5px rgba(37, 99, 235, 0.25);
  --shadow-brand-lg: 0 16px 30px -10px rgba(37, 99, 235, 0.3);
  --shadow-cyan: 0 8px 20px -5px rgba(6, 182, 212, 0.25);
  --shadow-emerald: 0 8px 20px -5px rgba(16, 185, 129, 0.25);
  --shadow-rose: 0 8px 20px -5px rgba(220, 38, 38, 0.25);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.04);

  /* Focus shadow */
  --shadow-focus: 0 0 0 3px var(--color-focus-ring);

  /* ======================================================================
     TRANSITIONS & MOTION
     ====================================================================== */

  /* Durations */
  --duration-instant: 0ms;
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 500ms;

  /* Easings */
  --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-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Transition presets */
  --transition-fast: all var(--duration-fast) var(--ease-out);
  --transition-normal: all var(--duration-normal) var(--ease-out);
  --transition-slow: all var(--duration-slow) var(--ease-out);
  --transition-colors: color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  --transition-transform: transform var(--duration-normal) var(--ease-out);
  --transition-shadow: box-shadow var(--duration-normal) var(--ease-out);
  --transition-opacity: opacity var(--duration-fast) var(--ease-out);

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

  --z-index-hide: -1;
  --z-index-base: 0;
  --z-index-dropdown: 100;
  --z-index-sticky: 200;
  --z-index-fixed: 300;
  --z-index-modal-backdrop: 400;
  --z-index-modal: 500;
  --z-index-popover: 600;
  --z-index-tooltip: 700;
  --z-index-toast: 800;
  --z-index-max: 9999;

  /* ======================================================================
     BREAKPOINTS (for reference in JS)
     ====================================================================== */

  --bp-xs: 320px;
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-2xl: 1536px;

  /* ======================================================================
     CONTAINER WIDTHS
     ====================================================================== */

  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;
  --container-full: 100%;

  /* ======================================================================
     COMPONENT TOKENS — Specific component overrides
     ====================================================================== */

  /* Button */
  --btn-height-sm: 36px;
  --btn-height-md: 44px;
  --btn-height-lg: 52px;
  --btn-height-xl: 60px;
  --btn-padding-x-sm: var(--space-3);
  --btn-padding-x-md: var(--space-4);
  --btn-padding-x-lg: var(--space-6);
  --btn-padding-x-xl: var(--space-8);
  --btn-font-size-sm: var(--text-xs);
  --btn-font-size-md: var(--text-sm);
  --btn-font-size-lg: var(--text-base);
  --btn-font-size-xl: var(--text-lg);

  /* Input */
  --input-height-sm: 36px;
  --input-height-md: 44px;
  --input-height-lg: 52px;
  --input-padding-x: var(--space-3);
  --input-font-size: var(--text-base);

  /* Card */
  --card-padding-sm: var(--space-4);
  --card-padding-md: var(--space-6);
  --card-padding-lg: var(--space-8);

  /* Modal */
  --modal-max-width-sm: 360px;
  --modal-max-width-md: 480px;
  --modal-max-width-lg: 640px;
  --modal-max-width-xl: 800px;
  --modal-max-width-full: calc(100% - var(--space-8));

  /* Table */
  --table-cell-padding-y: var(--space-3);
  --table-cell-padding-x: var(--space-4);
  --table-header-height: 48px;
  --table-row-height: 56px;

  /* Sidebar */
  --sidebar-width-collapsed: 72px;
  --sidebar-width-expanded: 280px;
  --sidebar-width-mobile: 280px;

  /* Header */
  --header-height: 64px;
  --header-height-mobile: 56px;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, var(--blue-600) 0%, var(--cyan-500) 100%);
  --grad-primary-soft: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(6, 182, 212, 0.05));
  --grad-growth: linear-gradient(135deg, var(--emerald-500) 0%, var(--cyan-500) 100%);
  --grad-warning: linear-gradient(135deg, var(--amber-500) 0%, var(--amber-400) 100%);
  --grad-error: linear-gradient(135deg, var(--rose-500) 0%, var(--rose-400) 100%);
  --grad-hero: radial-gradient(1200px 700px at 75% -10%, rgba(37, 99, 235, 0.08), transparent 60%),
               radial-gradient(900px 600px at -10% 40%, rgba(6, 182, 212, 0.05), transparent 55%);

  /* Logo ring */
  --logo-ring: 0 0 0 1px rgba(37, 99, 235, 0.2), 0 4px 12px -4px rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   DARK MODE DISABLED — White theme only
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Force light theme — override dark mode */
    --color-bg-primary: #FFFFFF;
    --color-bg-secondary: var(--slate-100);
    --color-bg-tertiary: var(--slate-200);
    --color-bg-inverse: var(--slate-900);
    --color-bg-brand: var(--blue-600);
    --color-bg-brand-hover: var(--blue-700);
    --color-bg-brand-subtle: var(--blue-50);
    --color-bg-success-subtle: var(--emerald-50);
    --color-bg-warning-subtle: var(--amber-50);
    --color-bg-error-subtle: var(--rose-50);
    --color-bg-info-subtle: var(--cyan-50);

    --color-surface: #FFFFFF;
    --color-surface-hover: var(--slate-50);
    --color-surface-active: var(--slate-100);
    --color-surface-raised: #FFFFFF;
    --color-surface-border: var(--slate-200);
    --color-surface-border-strong: var(--slate-300);
    --color-surface-border-focus: var(--blue-500);
    --color-surface-border-error: var(--rose-500);

    --color-text-primary: var(--slate-900);
    --color-text-secondary: var(--slate-600);
    --color-text-tertiary: var(--slate-400);
    --color-text-quaternary: var(--slate-300);
    --color-text-inverse: #FFFFFF;
    --color-text-brand: var(--blue-700);
    --color-text-brand-light: var(--blue-600);
    --color-text-success: var(--emerald-700);
    --color-text-warning: var(--amber-700);
    --color-text-error: var(--rose-700);
    --color-text-info: var(--cyan-700);
    --color-text-link: var(--blue-600);
    --color-text-link-hover: var(--blue-700);

    --color-interactive-primary: var(--blue-600);
    --color-interactive-primary-hover: var(--blue-700);
    --color-interactive-primary-active: var(--blue-800);
    --color-interactive-secondary: var(--slate-600);
    --color-interactive-secondary-hover: var(--slate-700);
    --color-interactive-tertiary: transparent;
    --color-interactive-tertiary-hover: var(--slate-100);
    --color-interactive-disabled: var(--slate-300);

    --color-focus-ring: var(--blue-300);
    --color-focus-ring-offset: #FFFFFF;

    --color-status-success: var(--emerald-600);
    --color-status-success-bg: var(--emerald-50);
    --color-status-success-border: var(--emerald-200);
    --color-status-warning: var(--amber-600);
    --color-status-warning-bg: var(--amber-50);
    --color-status-warning-border: var(--amber-200);
    --color-status-error: var(--rose-600);
    --color-status-error-bg: var(--rose-50);
    --color-status-error-border: var(--rose-200);
    --color-status-info: var(--cyan-600);
    --color-status-info-bg: var(--cyan-50);
    --color-status-info-border: var(--cyan-200);

    --color-overlay: rgba(15, 23, 42, 0.5);
    --color-overlay-strong: rgba(15, 23, 42, 0.75);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 16px -4px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 20px 24px -5px rgba(0, 0, 0, 0.09), 0 8px 8px -6px rgba(0, 0, 0, 0.06);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);

    --shadow-brand: 0 8px 20px -5px rgba(37, 99, 235, 0.25);
    --shadow-brand-lg: 0 16px 30px -10px rgba(37, 99, 235, 0.3);
    --shadow-cyan: 0 8px 20px -5px rgba(6, 182, 212, 0.25);
    --shadow-emerald: 0 8px 20px -5px rgba(16, 185, 129, 0.25);
    --shadow-rose: 0 8px 20px -5px rgba(220, 38, 38, 0.25);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.04);

    --shadow-focus: 0 0 0 3px var(--color-focus-ring);
  }
}

/* ==========================================================================
   EXPLICIT THEME ATTRIBUTE SUPPORT
   ========================================================================== */

[data-theme="light"] {
  /* Light mode values (same as defaults) */
}

[data-theme="dark"] {
  /* Force light theme values */
  --color-bg-primary: #FFFFFF;
  --color-bg-secondary: var(--slate-100);
  --color-bg-tertiary: var(--slate-200);
  --color-surface: #FFFFFF;
  --color-surface-hover: var(--slate-50);
  --color-surface-active: var(--slate-100);
  --color-text-primary: var(--slate-900);
  --color-text-secondary: var(--slate-600);
  --color-text-tertiary: var(--slate-400);
  --color-surface-border: var(--slate-200);
  --color-surface-border-strong: var(--slate-300);
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
    --transition-fast: none;
    --transition-normal: none;
    --transition-slow: none;
    --transition-colors: none;
    --transition-transform: none;
    --transition-shadow: none;
    --transition-opacity: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   HIGH CONTRAST MODE
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --color-surface-border: currentColor;
    --color-surface-border-strong: currentColor;
    --color-focus-ring: currentColor;
    --shadow-focus: 0 0 0 3px currentColor;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  :root {
    --color-bg-primary: #FFFFFF;
    --color-text-primary: #000000;
    --color-surface-border: #CCCCCC;
  }

  .no-print {
    display: none !important;
  }
}