/* KOJIE AI Enterprise Design System
 * Based on Fibonacci sequence and Golden Ratio principles
 * Mathematical harmony for enterprise-grade aesthetics
 */

:root {
  /* Golden Ratio: φ = 1.618033988749... */
  --golden-ratio: 1.618;
  --golden-ratio-inverse: 0.618;
  
  /* Enhanced Fibonacci Typography Scale - Mathematical Progression */
  --text-xs: 0.75rem;     /* 12px - Fibonacci base */
  --text-sm: 1rem;        /* 16px - Standard reference */
  --text-base: 1.1875rem; /* 19px - Golden ratio progression */
  --text-lg: 1.9375rem;   /* 31px - Fibonacci sequence */
  --text-xl: 3.125rem;    /* 50px - Golden ratio x base */
  --text-2xl: 5.0625rem;  /* 81px - Fibonacci continuation */
  --text-3xl: 8.1875rem;  /* 131px - Next Fibonacci */
  
  /* Mathematical Line Heights - Golden Ratio Based */
  --line-height-tight: 1.2;
  --line-height-base: calc(1 * var(--golden-ratio)); /* ~1.618 */
  --line-height-loose: calc(1 * var(--golden-ratio) * var(--golden-ratio)); /* ~2.618 */
  
  /* Fibonacci Spacing Scale */
  --space-1: 0.0625rem;  /* 1px */
  --space-2: 0.125rem;   /* 2px */
  --space-3: 0.1875rem;  /* 3px */
  --space-5: 0.3125rem;  /* 5px */
  --space-8: 0.5rem;     /* 8px */
  --space-13: 0.8125rem; /* 13px */
  --space-21: 1.3125rem; /* 21px */
  --space-34: 2.125rem;  /* 34px */
  --space-55: 3.4375rem; /* 55px */
  
  /* Enhanced Mathematical Color Harmony - Golden Angle (137.5°) Progression */
  /* Primary: Base hue */
  --primary-hue: 223;
  --color-primary: hsl(var(--primary-hue), 85%, 58%);
  --color-primary-light: hsl(var(--primary-hue), 85%, 75%);
  --color-primary-dark: hsl(var(--primary-hue), 85%, 42%);
  --color-primary-subtle: hsl(var(--primary-hue), 85%, 95%);
  
  /* Mathematical Color Progression - Golden Angle Steps */
  --secondary-hue: calc(var(--primary-hue) + 137.5); /* 360.5 -> 0.5 */
  --accent-hue: calc(var(--primary-hue) + 137.5 * 2); /* 498 -> 138 */
  --warning-hue: calc(var(--primary-hue) + 137.5 * 3); /* 635.5 -> 275.5 */
  
  --color-secondary: hsl(0, 79%, 63%);     /* Red - complementary energy */
  --color-accent: hsl(138, 72%, 45%);      /* Green - mathematical harmony */
  --color-warning: hsl(45, 100%, 60%);     /* Yellow - attention grabbing */
  --color-info: hsl(195, 100%, 60%);       /* Cyan - information clarity */
  --color-success: hsl(142, 76%, 47%);     /* Green - positive feedback */
  --color-danger: hsl(354, 84%, 57%);      /* Red - critical attention */
  
  /* Neutral Scale - Golden ratio brightness progression */
  --color-white: #ffffff;
  --color-gray-50: hsl(210, 20%, 98%);
  --color-gray-100: hsl(210, 20%, 95%);
  --color-gray-200: hsl(210, 16%, 89%);
  --color-gray-300: hsl(210, 14%, 83%);
  --color-gray-400: hsl(210, 14%, 65%);
  --color-gray-500: hsl(210, 11%, 50%);
  --color-gray-600: hsl(210, 12%, 40%);
  --color-gray-700: hsl(210, 15%, 32%);
  --color-gray-800: hsl(210, 18%, 25%);
  --color-gray-900: hsl(210, 22%, 15%);
  --color-black: #000000;
  
  /* Layout Proportions - Golden Ratio Grid */
  --sidebar-width: 20rem;           /* 320px */
  --main-width: calc(20rem * var(--golden-ratio)); /* ~518px */
  --header-height: 4rem;            /* 64px */
  --footer-height: calc(4rem * var(--golden-ratio-inverse)); /* ~40px */
  
  /* Border Radius - Fibonacci Progression */
  --radius-sm: var(--space-2);      /* 2px */
  --radius-base: var(--space-3);    /* 3px */
  --radius-md: var(--space-5);      /* 5px */
  --radius-lg: var(--space-8);      /* 8px */
  --radius-xl: var(--space-13);     /* 13px */
  
  /* Shadows - Mathematical Depth */
  --shadow-sm: 0 var(--space-1) var(--space-2) rgba(0, 0, 0, 0.05);
  --shadow-base: 0 var(--space-3) var(--space-8) rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 var(--space-8) var(--space-21) rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 var(--space-13) var(--space-34) rgba(0, 0, 0, 0.15);
  
  /* Animation Timing - Golden Ratio Easing */
  --duration-fast: 0.15s;
  --duration-base: 0.25s;
  --duration-slow: calc(0.25s * var(--golden-ratio)); /* ~0.4s */
  --easing-default: cubic-bezier(0.618, 0, 0.382, 1);
  
  /* Z-Index Scale - Fibonacci Ordering */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 500;
  --z-modal: 800;
  --z-popover: 1300;
  --z-tooltip: 2100;
  --z-max: 3400;
  
  /* Advanced Component Variables */
  --form-control-height: calc(var(--space-21) + var(--space-13)); /* Golden ratio height */
  --table-row-height: calc(var(--space-34) + var(--space-8)); /* Fibonacci + golden */
  --sidebar-collapse-width: var(--space-55); /* Collapsed sidebar */
  --content-max-width: calc(100vw - var(--space-55) * 2); /* Golden content bounds */
}

/* Enterprise Typography System */
.text-enterprise {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  line-height: calc(1 * var(--golden-ratio));
  letter-spacing: -0.01em;
}

.heading-xl {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-21);
}

.heading-lg {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-13);
}

.heading-md {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-8);
}

.heading-sm {
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: var(--space-5);
}

.body-lg {
  font-size: var(--text-base);
  line-height: var(--golden-ratio);
  margin-bottom: var(--space-13);
}

.body-base {
  font-size: var(--text-sm);
  line-height: var(--golden-ratio);
  margin-bottom: var(--space-8);
}

.body-sm {
  font-size: var(--text-xs);
  line-height: 1.5;
  margin-bottom: var(--space-5);
}

/* Enhanced Golden Ratio Layout System */
.layout-golden {
  display: grid;
  grid-template-columns: 1fr calc(1fr * var(--golden-ratio));
  gap: var(--space-21);
  align-items: start;
}

.layout-golden-reverse {
  display: grid;
  grid-template-columns: calc(1fr * var(--golden-ratio)) 1fr;
  gap: var(--space-21);
  align-items: start;
}

/* Advanced Mathematical Grid System */
.grid-fibonacci {
  display: grid;
  gap: var(--space-13);
  grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-55) * 5), 1fr));
}

.grid-golden-thirds {
  display: grid;
  grid-template-columns: 1fr calc(1fr * var(--golden-ratio)) 1fr;
  gap: var(--space-21);
}

.grid-golden-quarters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-13);
}

.grid-golden-quarters > :nth-child(2) {
  grid-column: span 2;
}

.sidebar-golden {
  width: var(--sidebar-width);
  flex-shrink: 0;
}

.main-golden {
  min-width: 0;
  max-width: var(--main-width);
}

/* Enterprise Card Components */
.card-enterprise {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-base);
  padding: var(--space-21);
  transition: all var(--duration-base) var(--easing-default);
}

.card-enterprise:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(calc(-1 * var(--space-2)));
}

.card-header {
  padding-bottom: var(--space-13);
  border-bottom: 1px solid var(--color-gray-100);
  margin-bottom: var(--space-13);
}

.card-content {
  padding: var(--space-13) 0;
}

.card-footer {
  padding-top: var(--space-13);
  border-top: 1px solid var(--color-gray-100);
  margin-top: var(--space-13);
}

/* Enterprise Button System */
.btn-enterprise {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  padding: var(--space-8) var(--space-13);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--duration-base) var(--easing-default);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  min-height: calc(var(--space-21) + var(--space-13));
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left var(--duration-slow) var(--easing-default);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: var(--color-white);
  transform: translateY(calc(-1 * var(--space-1)));
}

.btn-accent {
  background: var(--color-accent);
  color: var(--color-white);
  border-color: var(--color-accent);
}

.btn-warning {
  background: var(--color-warning);
  color: var(--color-gray-900);
  border-color: var(--color-warning);
}

.btn-lg {
  padding: var(--space-13) var(--space-21);
  font-size: var(--text-base);
  min-height: calc(var(--space-34) + var(--space-8));
}

.btn-sm {
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-xs);
  min-height: calc(var(--space-21) + var(--space-5));
}

/* ========================================
   ENTERPRISE COMPOUND COMPONENTS
   ======================================== */

/* Mathematical Form System */
.form-enterprise {
  display: grid;
  gap: var(--space-13);
  max-width: calc(var(--main-width) * var(--golden-ratio));
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-gray-700);
  margin-bottom: var(--space-3);
}

.form-control {
  height: var(--form-control-height);
  padding: var(--space-8) var(--space-13);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: all var(--duration-base) var(--easing-default);
  background: var(--color-white);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 calc(var(--space-3)) var(--color-primary-subtle);
}

.form-control.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 calc(var(--space-3)) hsl(354, 84%, 95%);
}

.form-control.success {
  border-color: var(--color-success);
  box-shadow: 0 0 0 calc(var(--space-3)) hsl(142, 76%, 95%);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-13);
}

.form-grid-golden {
  display: grid;
  grid-template-columns: 1fr calc(1fr * var(--golden-ratio));
  gap: var(--space-13);
}

/* Advanced Data Table System */
.table-enterprise {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-base);
}

.table-enterprise thead {
  background: var(--color-gray-50);
}

.table-enterprise th,
.table-enterprise td {
  padding: var(--space-8) var(--space-13);
  text-align: left;
  border-bottom: 1px solid var(--color-gray-200);
  height: var(--table-row-height);
  vertical-align: middle;
}

.table-enterprise th {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-gray-700);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.table-enterprise tbody tr {
  transition: background-color var(--duration-fast) var(--easing-default);
}

.table-enterprise tbody tr:hover {
  background: var(--color-gray-50);
}

.table-enterprise tbody tr:nth-child(even) {
  background: rgba(var(--primary-hue), 5%, 98%);
}

.table-sortable th {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.table-sortable th:hover {
  background: var(--color-gray-100);
}

.table-sortable th::after {
  content: '';
  position: absolute;
  right: var(--space-8);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: var(--space-3) solid transparent;
  border-right: var(--space-3) solid transparent;
  border-bottom: var(--space-3) solid var(--color-gray-400);
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.table-sortable th:hover::after {
  opacity: 1;
}

.table-sortable th.sort-asc::after {
  border-bottom: var(--space-3) solid var(--color-primary);
  border-top: none;
  opacity: 1;
}

.table-sortable th.sort-desc::after {
  border-top: var(--space-3) solid var(--color-primary);
  border-bottom: none;
  opacity: 1;
}

/* Responsive Table Wrapper */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-base);
}

/* Mathematical Card Grid System */
.card-grid {
  display: grid;
  gap: var(--space-21);
  grid-template-columns: repeat(auto-fit, minmax(calc(var(--space-55) * 6), 1fr));
}

.card-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-21);
}

.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-21);
}

.card-grid-golden {
  display: grid;
  grid-template-columns: 1fr calc(1fr * var(--golden-ratio)) 1fr;
  gap: var(--space-21);
}

/* Enhanced Enterprise Cards */
.card-feature {
  background: linear-gradient(135deg, var(--color-white) 0%, var(--color-gray-50) 100%);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-21);
  position: relative;
  overflow: hidden;
  transition: all var(--duration-slow) var(--easing-default);
}

.card-feature::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--space-3);
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
}

.card-feature:hover {
  transform: translateY(calc(-1 * var(--space-3)));
  box-shadow: var(--shadow-xl);
  border-color: var(--color-primary);
}

.card-metric {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-21);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card-metric-value {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-8);
}

.card-metric-label {
  font-size: var(--text-sm);
  color: var(--color-gray-600);
  font-weight: 500;
}

.card-metric-trend {
  position: absolute;
  top: var(--space-8);
  right: var(--space-8);
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.card-metric-trend.positive {
  background: var(--color-success);
  color: var(--color-white);
}

.card-metric-trend.negative {
  background: var(--color-danger);
  color: var(--color-white);
}

/* Advanced Navigation Components */
.nav-enterprise {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  padding: var(--space-8) 0;
  position: sticky;
  top: 0;
  z-index: var(--z-fixed);
  backdrop-filter: blur(var(--space-8));
}

.nav-tabs-enterprise {
  border-bottom: 1px solid var(--color-gray-200);
  margin-bottom: var(--space-21);
}

.nav-tab {
  padding: var(--space-8) var(--space-13);
  border: none;
  background: transparent;
  color: var(--color-gray-600);
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: all var(--duration-base) var(--easing-default);
}

.nav-tab:hover {
  color: var(--color-primary);
}

.nav-tab.active {
  color: var(--color-primary);
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: var(--space-2);
  background: var(--color-primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* Mathematical Progress Indicators */
.progress-enterprise {
  height: var(--space-8);
  background: var(--color-gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-md);
  transition: width var(--duration-slow) var(--easing-default);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ========================================
   MOBILE-FIRST RESPONSIVE DESIGN
   Mathematical Breakpoints: 320px, 480px, 768px, 1024px, 1200px
   ======================================== */

/* Mobile Small - 320px (iPhone SE) */
@media (max-width: 320px) {
  :root {
    --space-base: 0.75rem; /* Reduce base spacing for tiny screens */
  }
  
  .container {
    padding: var(--space-8);
  }
  
  .btn-lg {
    padding: var(--space-8) var(--space-13);
    font-size: var(--text-sm);
  }
  
  .command-palette {
    width: 95vw !important;
    top: 10vh !important;
  }
}

/* Mobile Portrait - 480px */
@media (max-width: 480px) {
  :root {
    /* Enhanced mobile typography scale */
    --text-xs: 0.6875rem;   /* 11px */
    --text-sm: 0.875rem;    /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg: 1.5rem;      /* 24px */
    --text-xl: 2rem;        /* 32px */
    
    /* Mobile-optimized spacing */
    --space-mobile-base: var(--space-8);
    --space-mobile-large: var(--space-13);
  }
  
  /* Mobile Navigation */
  .nav-enterprise {
    padding: var(--space-5) 0;
  }
  
  /* Mobile Forms */
  .form-control {
    height: calc(var(--form-control-height) * 0.9);
    padding: var(--space-8) var(--space-13);
    font-size: var(--text-base);
    /* Enhanced touch targets */
    min-height: 44px; /* iOS guideline */
  }
  
  .form-grid-2,
  .form-grid-golden {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
  
  /* Mobile Cards */
  .card-enterprise,
  .card-feature,
  .card-metric {
    padding: var(--space-13);
    margin-bottom: var(--space-8);
  }
  
  .card-grid,
  .card-grid-2,
  .card-grid-3,
  .card-grid-golden {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
  
  /* Mobile Tables - Horizontal Scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* iOS smooth scrolling */
  }
  
  .table-enterprise {
    font-size: var(--text-xs);
    min-width: 600px; /* Maintain table structure */
  }
  
  .table-enterprise th,
  .table-enterprise td {
    padding: var(--space-5) var(--space-8);
    white-space: nowrap;
  }
  
  /* Mobile Buttons - Enhanced Touch Targets */
  .btn {
    min-height: 44px;
    padding: var(--space-8) var(--space-13);
    font-size: var(--text-sm);
  }
  
  .btn-lg {
    min-height: 48px;
    padding: var(--space-13) var(--space-21);
  }
  
  /* Mobile Typography */
  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }
  h3 { font-size: var(--text-base); }
  h4 { font-size: var(--text-sm); }
}

/* Tablet Portrait - 768px */
@media (max-width: 768px) {
  .layout-golden,
  .layout-golden-reverse {
    grid-template-columns: 1fr;
    gap: var(--space-13);
  }
  
  .grid-golden-thirds {
    grid-template-columns: 1fr;
  }
  
  .grid-golden-quarters {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Tablet-optimized navigation */
  .nav-tab {
    padding: var(--space-5) var(--space-8);
    font-size: var(--text-xs);
  }
  
  /* Tablet forms */
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  
  .form-grid-golden {
    grid-template-columns: 1fr;
  }
}

/* Tablet Landscape - 1024px */
@media (max-width: 1024px) and (min-width: 769px) {
  .card-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .form-grid-golden {
    grid-template-columns: 1fr 1.2fr; /* Reduced golden ratio for tablets */
  }
}

/* ========================================
   TOUCH & GESTURE OPTIMIZATIONS
   ======================================== */

/* Enhanced touch targets */
@media (pointer: coarse) {
  .btn,
  .form-control,
  .nav-tab,
  .command-item {
    min-height: 44px; /* iOS/Android minimum */
  }
  
  /* Larger tap areas for icons */
  .icon-button {
    padding: var(--space-8);
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Enhanced hover states for touch */
  .btn:active,
  .command-item:active {
    background: var(--color-primary-light);
    transform: scale(0.98);
    transition: all 0.1s ease;
  }
}

/* ========================================
   BROWSER COMPATIBILITY & FALLBACKS
   ======================================== */

/* CSS Grid Fallback for older browsers */
@supports not (display: grid) {
  .card-grid,
  .form-grid-2,
  .layout-golden {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .card-grid > *,
  .form-grid-2 > * {
    flex: 1 1 300px;
  }
}

/* Flexbox fallback for very old browsers */
@supports not (display: flex) {
  .card-grid,
  .form-grid-2 {
    display: block;
  }
  
  .card-grid > *,
  .form-grid-2 > * {
    display: inline-block;
    width: 48%;
    margin: 1%;
    vertical-align: top;
  }
}

/* CSS Custom Properties fallback */
@supports not (--css: variables) {
  .btn-primary {
    background: #4f46e5;
    color: white;
  }
  
  .form-control {
    border: 1px solid #d1d5db;
    padding: 0.5rem;
  }
}

/* Backdrop-filter fallback */
@supports not (backdrop-filter: blur(4px)) {
  .command-palette-backdrop {
    background: rgba(0, 0, 0, 0.8) !important;
  }
  
  .nav-enterprise {
    background: var(--color-white) !important;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Reduce animations on slower devices */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Hardware acceleration for smooth animations */
.btn,
.card-enterprise,
.command-palette,
.nav-tab {
  transform: translateZ(0); /* Force GPU acceleration */
  will-change: transform;
}

/* Optimize images for mobile */
@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
  }
}

/* ========================================
   DARK MODE & HIGH CONTRAST SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --color-white: #1f2937;
    --color-gray-50: #374151;
    --color-gray-900: #f9fafb;
  }
}

@media (prefers-contrast: high) {
  :root {
    --color-primary: #000080;
    --color-gray-300: #000000;
    --color-gray-700: #ffffff;
  }
  
  .btn {
    border-width: 2px;
  }
  
  .form-control {
    border-width: 2px;
  }
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(calc(-1 * var(--space-1)));
  box-shadow: var(--shadow-base);
}

.btn-secondary {
  background: var(--color-white);
  color: var(--color-gray-700);
  border-color: var(--color-gray-300);
}

.btn-secondary:hover {
  background: var(--color-gray-50);
  border-color: var(--color-gray-400);
}

.btn-lg {
  padding: var(--space-13) var(--space-21);
  font-size: var(--text-base);
  min-height: calc(var(--space-34) + var(--space-8));
}

.btn-sm {
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-xs);
  min-height: var(--space-21);
}

/* Enterprise Form Controls */
.form-control-enterprise {
  width: 100%;
  font-size: var(--text-sm);
  line-height: var(--golden-ratio);
  padding: var(--space-8) var(--space-13);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-md);
  background: var(--color-white);
  transition: all var(--duration-base) var(--easing-default);
}

.form-control-enterprise:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 var(--space-3) hsla(223, 100%, 58%, 0.1);
}

.form-label-enterprise {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-gray-700);
  margin-bottom: var(--space-5);
}

/* Accessibility Enhancements */
.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;
}

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

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --color-white: hsl(210, 22%, 15%);
    --color-gray-50: hsl(210, 20%, 10%);
    --color-gray-100: hsl(210, 20%, 15%);
    --color-gray-200: hsl(210, 16%, 20%);
    --color-gray-300: hsl(210, 14%, 25%);
    --color-gray-400: hsl(210, 14%, 35%);
    --color-gray-500: hsl(210, 11%, 50%);
    --color-gray-600: hsl(210, 12%, 60%);
    --color-gray-700: hsl(210, 15%, 70%);
    --color-gray-800: hsl(210, 18%, 85%);
    --color-gray-900: hsl(210, 22%, 95%);
    --color-black: #ffffff;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --color-primary: #0000ff;
    --color-secondary: #ff0000;
    --color-gray-300: #606060;
    --color-gray-700: #303030;
  }
}