/**
 * Engineering Design System - Professional UI Tokens
 * Schweißnahttool - Optimized for Professional Engineering Workflows
 * 
 * This design system provides:
 * - Professional color coding for safety thresholds (green <80%, yellow 80-95%, red >95%)
 * - Glassmorphism elements with engineering precision
 * - Accessibility-first approach (WCAG-AA compliance)
 * - Performance-optimized animations (≤200ms standard, ≤80ms micro-interactions)
 * - Responsive design for 1920x1080 and smaller viewports
 */

/* ==============================================
   DESIGN TOKENS - CSS CUSTOM PROPERTIES
   ============================================== */

:root {
  /* Primary Colors - Engineering Blue Palette */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-900: #1e3a8a;

  /* Secondary Colors - Engineering Grays */
  --secondary: #64748b;
  --secondary-50: #f8fafc;
  --secondary-100: #f1f5f9;
  --secondary-200: #e2e8f0;
  --secondary-300: #cbd5e1;
  --secondary-400: #94a3b8;
  --secondary-500: #64748b;
  --secondary-600: #475569;
  --secondary-700: #334155;
  --secondary-800: #1e293b;
  --secondary-900: #0f172a;

  /* Engineering Status Colors */
  --success: #10b981;       /* Safe zone - <80% utilization */
  --success-light: #d1fae5;
  --success-dark: #047857;

  --warning: #f59e0b;       /* Caution zone - 80-95% utilization */
  --warning-light: #fef3c7;
  --warning-dark: #d97706;

  --error: #ef4444;         /* Danger zone - >95% utilization */
  --error-light: #fee2e2;
  --error-dark: #dc2626;

  /* Accent Colors */
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --accent-dark: #d97706;

  /* Surface Colors - Glassmorphism Support */
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --surface-elevated: rgba(255, 255, 255, 0.95);
  --surface-glass: rgba(255, 255, 255, 0.85);
  --surface-glass-border: rgba(255, 255, 255, 0.2);

  /* Text Hierarchy */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --text-on-primary: #ffffff;

  /* Border Colors */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: var(--primary);
  --border-error: var(--error);

  /* Shadow System - Elevation Hierarchy */
  --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);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-glass: 0 8px 32px rgb(31 38 135 / 0.37);

  /* Border Radius System */
  --radius-none: 0;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Spacing System (8px grid) */
  --space-px: 1px;
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* Typography Scale */
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;

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

  --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-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;

  /* Animation & Transitions */
  --transition-fast: 80ms cubic-bezier(0.4, 0, 0.2, 1);      /* Micro-interactions */
  --transition-normal: 150ms cubic-bezier(0.4, 0, 0.2, 1);   /* Standard interactions */
  --transition-slow: 200ms cubic-bezier(0.4, 0, 0.2, 1);     /* Complex transitions */
  --transition-all: all var(--transition-normal);

  /* Engineering-specific tokens */
  --chart-grid: #e5e7eb;
  --chart-axis: #6b7280;
  --formula-bg: #f9fafb;
  --formula-border: #d1d5db;
  --result-positive: var(--success);
  --result-warning: var(--warning);
  --result-critical: var(--error);

  /* Glassmorphism tokens */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-bg-dark: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-blur: blur(20px);
  --glass-blur-subtle: blur(10px);
  
  /* Additional professional design tokens */
  --info: var(--primary);
  --text: var(--text-primary);
  --primary-200: rgba(37, 99, 235, 0.2);
  --surface-glass-elevated: rgba(255, 255, 255, 0.95);

  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ==============================================
   DARK MODE SUPPORT
   ============================================== */

@media (prefers-color-scheme: dark) {
  :root {
    /* Surface colors for dark mode */
    --surface: #0f172a;
    --surface-2: #1e293b;
    --surface-3: #334155;
    --surface-elevated: rgba(15, 23, 42, 0.95);
    --surface-glass: rgba(15, 23, 42, 0.85);
    --surface-glass-border: rgba(255, 255, 255, 0.1);

    /* Text colors for dark mode */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    /* Border colors for dark mode */
    --border: #475569;
    --border-light: #334155;

    /* Chart colors for dark mode */
    --chart-grid: #374151;
    --chart-axis: #9ca3af;

    /* Formula styling for dark mode */
    --formula-bg: #1f2937;
    --formula-border: #374151;

    /* Glassmorphism adjustments for dark mode */
    --glass-bg: rgba(15, 23, 42, 0.85);
    --glass-bg-dark: rgba(0, 0, 0, 0.3);
  }
}

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

@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-muted: var(--text-secondary);
    --glass-bg: var(--surface);
    --glass-border: var(--border);
  }
}

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

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

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==============================================
   BASE STYLES & RESET
   ============================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-family-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background: transparent;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Glassmorphism utilities */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

.glass-subtle {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur-subtle);
  border: 1px solid var(--glass-border);
}

/* Shadow utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }
.shadow-glass { box-shadow: var(--shadow-glass); }

/* Border radius utilities */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Status color utilities */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--warning); }
.bg-error { background-color: var(--error); }

/* Engineering status utilities */
.status-safe {
  color: var(--success);
  background-color: var(--success-light);
}

.status-caution {
  color: var(--warning-dark);
  background-color: var(--warning-light);
}

.status-critical {
  color: var(--error);
  background-color: var(--error-light);
}

/* Typography utilities */
.font-mono { font-family: var(--font-family-mono); }
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.font-light { font-weight: var(--font-weight-light); }
.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

/* Spacing utilities */
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }

/* ==============================================
   ANIMATION KEYFRAMES
   ============================================== */

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==============================================
   RESPONSIVE BREAKPOINTS
   ============================================== */

/* Mobile first approach */
@media (min-width: 640px) {
  /* sm: small screens */
}

@media (min-width: 768px) {
  /* md: medium screens */
}

@media (min-width: 1024px) {
  /* lg: large screens */
}

@media (min-width: 1280px) {
  /* xl: extra large screens */
}

@media (min-width: 1536px) {
  /* 2xl: 2x extra large screens */
}

/* Engineering workflow optimized breakpoints */
@media (min-width: 1920px) {
  /* Optimize for 1920x1080 and larger */
  :root {
    --font-size-base: 1.125rem; /* Slightly larger for better readability */
  }
}

/* Print styles for engineering documentation */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .no-print {
    display: none !important;
  }
}