/**
 * Design System CSS - Foundation for Dashboard Enhancement
 * Implements CSS custom properties for consistent theming and responsive design
 */

:root {
  /* ===== COLOR SYSTEM ===== */
  
  /* Primary Colors */
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-900: #0c4a6e;
  
  /* Surface Colors */
  --surface-50: #f9fafb;
  --surface-100: #f3f4f6;
  --surface-200: #e5e7eb;
  --surface-800: #1f2937;
  --surface-900: #111827;
  
  /* Semantic Colors */
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  
  --error-50: #fef2f2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  
  --info-50: #eff6ff;
  --info-500: #3b82f6;
  --info-600: #2563eb;
  
  /* Glass Morphism */
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-backdrop: blur(10px);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  --gradient-warning: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
  --gradient-error: linear-gradient(135deg, #fd79a8 0%, #fdcb6e 100%);
  
  /* ===== TYPOGRAPHY SYSTEM ===== */
  
  /* Font Families */
  --font-family-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', Consolas, 'Courier New', monospace;
  
  /* Font Sizes */
  --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 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.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  
  /* ===== SPACING SYSTEM ===== */
  
  --spacing-0: 0;
  --spacing-1: 0.25rem;   /* 4px */
  --spacing-2: 0.5rem;    /* 8px */
  --spacing-3: 0.75rem;   /* 12px */
  --spacing-4: 1rem;      /* 16px */
  --spacing-5: 1.25rem;   /* 20px */
  --spacing-6: 1.5rem;    /* 24px */
  --spacing-8: 2rem;      /* 32px */
  --spacing-10: 2.5rem;   /* 40px */
  --spacing-12: 3rem;     /* 48px */
  --spacing-16: 4rem;     /* 64px */
  --spacing-20: 5rem;     /* 80px */
  --spacing-24: 6rem;     /* 96px */
  
  /* ===== BORDER RADIUS SYSTEM ===== */
  
  --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;
  
  /* ===== SHADOW SYSTEM ===== */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  
  /* Glass Morphism Shadows */
  --shadow-glass: 0 8px 32px rgba(31, 38, 135, 0.37);
  
  /* ===== ANIMATION SYSTEM ===== */
  
  /* Transition Durations */
  --duration-75: 75ms;
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
  --duration-700: 700ms;
  --duration-1000: 1000ms;
  
  /* Transition Easings */
  --easing-linear: linear;
  --easing-in: cubic-bezier(0.4, 0, 1, 1);
  --easing-out: cubic-bezier(0, 0, 0.2, 1);
  --easing-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Common Transitions */
  --transition-fast: var(--duration-150) var(--easing-out);
  --transition-normal: var(--duration-300) var(--easing-in-out);
  --transition-slow: var(--duration-500) var(--easing-in-out);
  
  /* ===== Z-INDEX SYSTEM ===== */
  
  --z-index-dropdown: 1000;
  --z-index-sticky: 1020;
  --z-index-fixed: 1030;
  --z-index-modal-backdrop: 1040;
  --z-index-modal: 1050;
  --z-index-popover: 1060;
  --z-index-tooltip: 1070;
  --z-index-toast: 1080;
  
  /* ===== RESPONSIVE BREAKPOINTS ===== */
  
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ===== DARK MODE THEME ===== */

[data-theme="dark"] {
  /* Surface Colors - Enhanced for WCAG AA compliance */
  --surface-50: #0a0e1a;          /* Deepest background for maximum contrast */
  --surface-100: #111827;         /* Primary dark background */
  --surface-200: #1f2937;         /* Secondary dark background */
  --surface-300: #374151;         /* Tertiary dark background */
  --surface-400: #4b5563;         /* Dark medium */
  --surface-500: #6b7280;         /* Dark text on light backgrounds */
  --surface-600: #9ca3af;         /* Medium contrast text */
  --surface-700: #d1d5db;         /* High contrast text */
  --surface-800: #e5e7eb;         /* Very high contrast text */
  --surface-900: #f3f4f6;         /* Maximum contrast text */
  
  /* Text Colors - WCAG AA compliant contrast ratios */
  --text-primary: #ffffff;         /* Primary text - 21:1 contrast on surface-100 */
  --text-secondary: #e5e7eb;       /* Secondary text - 15:1 contrast on surface-100 */
  --text-muted: #d1d5db;          /* Muted text - 11:1 contrast on surface-100 */
  --text-disabled: #9ca3af;       /* Disabled text - 7:1 contrast on surface-100 */
  
  /* Border Colors - Enhanced visibility */
  --border-primary: #4b5563;      /* Primary borders - visible contrast */
  --border-secondary: #374151;    /* Secondary borders */
  --border-subtle: #1f2937;       /* Subtle borders */
  
  /* Glass Morphism for Dark Mode - Enhanced opacity */
  --glass-bg: rgba(17, 24, 39, 0.85);     /* More opaque for better contrast */
  --glass-border: rgba(75, 85, 99, 0.4);   /* More visible border */
  --glass-backdrop: blur(12px);             /* Stronger blur for depth */
  
  /* Enhanced shadows for dark mode depth */
  --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.6);
  
  /* Chart Colors - Dark theme optimized */
  --chart-primary: #60a5fa;        /* Brighter blue for dark backgrounds */
  --chart-success: #34d399;        /* Brighter green */
  --chart-warning: #fbbf24;        /* Brighter yellow */
  --chart-error: #f87171;          /* Brighter red */
  --chart-info: #a78bfa;           /* Brighter purple */
}

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

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-75: 0ms;
    --duration-100: 0ms;
    --duration-150: 0ms;
    --duration-200: 0ms;
    --duration-300: 0ms;
    --duration-500: 0ms;
    --duration-700: 0ms;
    --duration-1000: 0ms;
    
    --transition-fast: none;
    --transition-normal: none;
    --transition-slow: none;
  }
}

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

@media (prefers-contrast: high) {
  :root {
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.8);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.8);
  }
  
  [data-theme="dark"] {
    --glass-bg: rgba(0, 0, 0, 0.95);
    --glass-border: rgba(255, 255, 255, 0.8);
  }
}

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

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

.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus Utilities */
.focus-ring {
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.focus-ring:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.focus-ring:focus:not(:focus-visible) {
  outline: none;
}

/* Theme Transition */
.theme-transition {
  transition: 
    background-color var(--transition-normal),
    border-color var(--transition-normal),
    color var(--transition-normal),
    box-shadow var(--transition-normal);
}

/* Loading Animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ===== COMPONENT BASE STYLES ===== */

/* Card Component Base */
.card-base {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: var(--glass-backdrop);
  box-shadow: var(--shadow-glass);
  transition: var(--transition-normal);
}

.card-base:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* Button Component Base */
.btn-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: var(--spacing-3) var(--spacing-6);
  border-radius: var(--radius-lg);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-tight);
  text-decoration: none;
  transition: var(--transition-fast);
  cursor: pointer;
  border: none;
  outline: none;
}

.btn-base:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.btn-base:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Status Indicator Base */
.status-indicator {
  display: inline-block;
  width: var(--spacing-3);
  height: var(--spacing-3);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-healthy { background-color: var(--success-500); }
.status-warning { background-color: var(--warning-500); }
.status-error { background-color: var(--error-500); }
.status-info { background-color: var(--info-500); }

/* Chart Container Base */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
  margin: var(--spacing-4) 0;
}

.chart-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}