/* ============================================================
   DESIGN TOKENS - single source of truth (frontend/css/design-tokens.css)
   Load BEFORE every other stylesheet. Never redeclare these tokens
   inside page stylesheets; override only inside @media blocks.
   Visual direction (gemini-frontend-design + Automech brand):
   Signature Automech Blue & Crisp Slate SaaS workspace,
   single versatile sans family (Be Vietnam Pro + tabular-nums),
   disciplined 4-step dense-dashboard type scale, brisk ease-out motion.
   ============================================================ */
:root {
  /* Corporate Industrial Slate/Blue Palette */
  --color-primary-50:  #EFF6FF;
  --color-primary-100: #DBEAFE;
  --color-primary-200: #BFDBFE;
  --color-primary-300: #93C5FD;
  --color-primary-400: #60A5FA;
  --color-primary-500: #3B82F6;
  --color-primary-600: #2563EB;
  --color-primary-700: #1D4ED8;
  --color-primary-800: #1E40AF;
  --color-primary-900: #1E3A8A;

  /* Neutral Slate Palette */
  --color-white:       #FFFFFF;
  --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;

  /* Status Colors (softened & unified across charts, badges, Gantt) */
  --color-success-50:  #ECFDF5;
  --color-success-100: #D1FAE5;
  --color-success-400: #34D399;
  --color-success-500: #10B981;
  --color-success-600: #059669;
  --color-success-700: #047857;

  --color-warning-50:  #FFFBEB;
  --color-warning-100: #FEF3C7;
  --color-warning-400: #FBBF24;
  --color-warning-500: #F59E0B;
  --color-warning-600: #D97706;

  --color-danger-50:   #FEF2F2;
  --color-danger-100:  #FEE2E2;
  --color-danger-400:  #F87171;
  --color-danger-500:  #EF4444;
  --color-danger-600:  #DC2626;

  --color-info-50:     #EFF6FF;
  --color-info-100:    #DBEAFE;
  --color-info-400:    #60A5FA;
  --color-info-500:    #3B82F6;
  --color-info-600:    #2563EB;

  --color-orange-50:   #FFF7ED;
  --color-orange-100:  #FFEDD5;
  --color-orange-500:  #F97316;
  --color-orange-600:  #EA580C;

  /* Semantic Tokens */
  --bg-primary:        #F3F5F9;
  --bg-app:            var(--bg-primary);
  --bg-sidebar:        var(--color-white);
  --bg-card:           var(--color-white);
  --bg-kanban-col:     #F8FAFC;
  --bg-input:          var(--color-white);
  --bg-tertiary:       #F8FAFC;
  --bg-elevated:       var(--color-white);
  --surface:           var(--color-white);
  --surface-subtle:    #F8FAFC;

  --text-primary:      #0F172A;
  --text-secondary:    #475569;
  --text-muted:        #64748B;
  --text-inverse:      var(--color-white);
  --text-accent:       var(--color-primary-600);

  --border-color:      #DCE3EC;
  --border-strong:     #CBD5E1;
  --border-subtle:     #E8EEF5;
  --border:            var(--border-color);
  --bg:                #F8FAFC;

  /* Layout */
  --sidebar-width:     240px;
  --sidebar-collapsed: 64px;
  --header-height:     60px;
  --content-padding:   20px;

  /* Border Radius (standardized: Card/Modal 12px, Control 8px, Badge 6px) */
  --radius-xs:      4px;
  --radius-badge:   6px;
  --radius-sm:      8px;
  --radius-control: 8px;
  --radius-md:      12px;
  --radius-card:    12px;
  --radius-modal:   12px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --radius-2xl:     20px;
  --radius-full:    9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.02);
  --shadow-card:0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:  0 4px 8px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg:  0 10px 18px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.04);
  --shadow-xl:  0 20px 30px rgba(15, 23, 42, 0.10), 0 8px 12px rgba(15, 23, 42, 0.04);
  --shadow-purple: 0 2px 6px rgba(29, 78, 216, 0.18);
  --shadow-purple-lg: 0 6px 14px rgba(29, 78, 216, 0.22);

  /* Transitions (140ms-240ms brisk ease-out, never transition: all) */
  --ease-standard:     cubic-bezier(0.22, 1, 0.36, 1);
  --transition-fast:   150ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-base:   200ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-slow:   240ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-spring: 240ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
  --gradient-soft:    linear-gradient(135deg, var(--color-primary-50), var(--color-primary-100));
  --gradient-card:    linear-gradient(145deg, #ffffff, #f8fafc);

  /* Typography (1 versatile sans family + tabular-nums; 4-step dense-dashboard scale) */
  --font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-heading: 18px;
  --text-body:    14px;
  --text-sm:      13px;
  --text-xs:      12px;
  --font-size-xs:   12px;
  --font-size-sm:   13px;
  --font-size-base: 14px;
  --font-size-md:   14px;
  --font-size-lg:   16px;
  --font-size-xl:   18px;
  --font-size-2xl:  20px;
  --font-size-3xl:  24px;
  --font-size-4xl:  28px;
  --font-size-5xl:  34px;

  --font-weight-light:    300;
  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;
  --font-weight-extrabold:800;

  --line-height-tight:  1.2;
  --line-height-snug:   1.375;
  --line-height-base:   1.5;
  --line-height-relaxed:1.625;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;
  --z-tooltip:  600;

  /* ---- Legacy & Status aliases ---- */
  --primary:        var(--color-primary-600);
  --primary-hover:  var(--color-primary-700);
  --primary-light:  var(--color-primary-100);
  --primary-50:     var(--color-primary-50);
  --success:        #10B981;
  --warning:        #F59E0B;
  --danger:         #EF4444;
  --info:           #3B82F6;
  --status-done:    #10B981;
  --status-doing:   #3B82F6;
  --status-review:  #F59E0B;
  --status-overdue: #EF4444;
  --status-idle:    #94A3B8;
  --bg-page:        var(--bg-primary);
  --card-bg:        var(--surface);

  /* ---- Semantic surfaces & states (ui-ux-pro-max checklist) ---- */
  --surface-hover:     var(--color-gray-100);
  --surface-pressed:   var(--color-gray-200);
  --surface-selected:  var(--color-primary-50);
  --bg-hover:          var(--surface-hover);
  --focus-ring-color:  var(--color-primary-500);
  --focus-ring:        0 0 0 3px rgba(37, 99, 235, 0.25);
  --touch-target-min:  40px;

  /* ---- Elevation for interactive cards ---- */
  --elevation-rest:    var(--shadow-sm);
  --elevation-hover:   0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --lift-hover:        -1px;

  /* ---- Motion tokens (ported from animate-ui / Motion defaults) ----
     Effect/Fade/Slide default: spring stiffness 200, damping 20 (zeta .707)
     Highlight default:         spring stiffness 350, damping 35 (zeta .935)
     Icon tweens:               easeInOut 0.2 / 0.3 / 0.6s                 */
  --ease-in-out:       cubic-bezier(0.42, 0, 0.58, 1);   /* Motion 'easeInOut' */
  --ease-out:          cubic-bezier(0, 0, 0.58, 1);      /* Motion 'easeOut'   */
  --ease-out-expo:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:       cubic-bezier(0.34, 1.36, 0.64, 1); /* fallback for 200/20 */
  --ease-snappy:       cubic-bezier(0.22, 1, 0.36, 1);    /* fallback for 350/35 */
  --duration-instant:  100ms;
  --duration-fast:     200ms;
  --duration-base:     300ms;
  --duration-slow:     600ms;
  --duration-spring:   720ms;  /* settle time of spring 200/20 */
  --duration-snappy:   380ms;  /* settle time of spring 350/35 */
  --motion-distance:   12px;   /* animate-ui uses 100px offset; scaled down for dense dashboards */
  --motion-scale-from: 0.96;
  --stagger-step:      35ms;
}

/* Exact spring curves (generated from damped-oscillator equation) for
   browsers supporting linear() easing — Chrome 113+, Firefox 112+, Safari 17.2+ */
@supports (animation-timing-function: linear(0, 1)) {
  :root {
    --ease-spring: linear(0, 0.0739, 0.2387, 0.4312, 0.6129, 0.7644, 0.879, 0.958, 1.0068, 1.0327, 1.0424, 1.0421, 1.0362, 1.0282, 1.02, 1.0128, 1.0072, 1.0031, 1.0005, 0.999, 0.9983, 0.9981, 0.9983, 0.9986, 1);
    --ease-snappy: linear(0, 0.0363, 0.1214, 0.2288, 0.342, 0.4509, 0.5501, 0.6372, 0.7114, 0.7733, 0.824, 0.8649, 0.8975, 0.923, 0.9428, 0.958, 0.9696, 0.9782, 0.9847, 0.9894, 0.9928, 0.9953, 0.997, 0.9982, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast:    0ms;
    --duration-base:    0ms;
    --duration-slow:    0ms;
    --duration-spring:  0ms;
    --duration-snappy:  0ms;
    --motion-distance:  0px;
    --motion-scale-from: 1;
    --stagger-step:     0ms;
    --lift-hover:       0px;
  }
}

/* Semantic Dark Mode Tokens (paired with [data-theme="dark"] & body.dark-theme) */
[data-theme="dark"],
body.dark-theme,
.dark-theme {
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  --primary:           #3B82F6;
  --color-primary-50:  rgba(59, 130, 246, 0.14);
  --color-primary-100: rgba(59, 130, 246, 0.22);
  --color-primary-200: rgba(96, 165, 250, 0.35);
  --color-primary-700: #93C5FD;
  --color-gray-50:     #111827;
  --color-gray-100:    #1B2538;
  --color-gray-200:    #263449;
  --color-gray-300:    #334155;
  --bg-app:            #0B1120;
  --bg-page:           #0B1120;
  --bg-primary:        #0B1120;
  --bg-secondary:      #151E2E;
  --bg-sidebar:        #111827;
  --bg-card:           #151E2E;
  --card-bg:           #151E2E;
  --bg-kanban-col:     #111827;
  --bg:                #0F172A;
  --bg-input:          #0F172A;
  --bg-tertiary:       #1B2538;
  --bg-elevated:       #1E293B;
  --surface:           #151E2E;
  --surface-subtle:    #1B2538;
  --surface-hover:     rgba(148, 163, 184, 0.10);
  --surface-pressed:   rgba(148, 163, 184, 0.16);
  --bg-hover:          var(--surface-hover);
  --text-primary:      #F1F5F9;
  --text-secondary:    #CBD5E1;
  --text-muted:        #94A3B8;
  --text-accent:       #60A5FA;
  --border-color:      #263449;
  --border:            #263449;
  --border-subtle:     rgba(148, 163, 184, 0.14);
  --gradient-card:     linear-gradient(145deg, #151E2E, #111827);
  --shadow-xs:         0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm:         0 1px 3px rgba(0, 0, 0, 0.40);
  --shadow-card:       0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md:         0 6px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg:         0 12px 24px rgba(0, 0, 0, 0.55);
  --elevation-hover:   0 10px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.30);
}
