/* Design Tokens - Foundational CSS Variables */
:root {
  /* ============================================
     SPACING SCALE
     Based on 0.25rem (4px) increments
     ============================================ */
  --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 */

  /* ============================================
     TYPOGRAPHY
     Font sizes, weights, and line heights
     ============================================ */
  --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-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* ============================================
     BORDER RADIUS
     Consistent rounding for components
     ============================================ */
  --radius-sm: 0.25rem;     /* 4px */
  --radius-md: 0.375rem;    /* 6px */
  --radius-lg: 0.5rem;      /* 8px */
  --radius-xl: 0.75rem;     /* 12px */
  --radius-2xl: 1rem;       /* 16px */
  --radius-full: 9999px;    /* Fully rounded */

  /* ============================================
     SHADOWS
     Elevation system for depth
     ============================================ */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);

  /* ============================================
     TRANSITIONS
     Consistent animation timing
     ============================================ */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Transition properties */
  --transition-all: all var(--transition-base);
  --transition-colors: color, background-color, border-color, text-decoration-color, fill, stroke var(--transition-base);
  --transition-opacity: opacity var(--transition-base);
  --transition-transform: transform var(--transition-base);

  /* ============================================
     Z-INDEX SCALE
     Layering system for overlays
     ============================================ */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-fixed: 1200;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;
  --z-toast: 1700;

  /* ============================================
     BREAKPOINTS (Reference only - use in media queries)
     Mobile-first responsive design
     ============================================ */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ============================================
   UTILITY CLASSES
   Common patterns using design tokens
   ============================================ */

/* Focus Ring - Accessible focus states */
.focus-ring {
  outline: none;
  transition: var(--transition-colors);
}

.focus-ring:focus {
  outline: 2px solid rgb(59 130 246 / 0.5); /* blue-500 */
  outline-offset: 2px;
}

.focus-ring:focus-visible {
  outline: 2px solid rgb(59 130 246); /* blue-500 */
  outline-offset: 2px;
}

/* Dark mode focus ring */
@media (prefers-color-scheme: dark) {
  .focus-ring:focus,
  .focus-ring:focus-visible {
    outline-color: rgb(96 165 250); /* blue-400 */
  }
}

/* Screen Reader Only - Hide visually but keep accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Not Screen Reader Only - Reverse sr-only */
.not-sr-only {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus visible for keyboard navigation */
.focus-visible:focus-visible {
  outline: 2px solid rgb(59 130 246); /* blue-500 */
  outline-offset: 2px;
}

/* ============================================
   COMPONENT BASE STYLES
   Reusable patterns for components
   ============================================ */

/* Button Base */
.btn-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  transition: var(--transition-all);
  cursor: pointer;
  border: none;
  outline: none;
}

.btn-base:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Card Base */
.card-base {
  background-color: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-6);
  transition: var(--transition-all);
}

@media (prefers-color-scheme: dark) {
  .card-base {
    background-color: rgb(30 41 59); /* slate-800 */
  }
}

/* Input Base */
.input-base {
  display: block;
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid rgb(226 232 240); /* slate-200 */
  padding: var(--spacing-3) var(--spacing-4);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  transition: var(--transition-colors);
  background-color: white;
}

.input-base:focus {
  outline: none;
  border-color: rgb(59 130 246); /* blue-500 */
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

@media (prefers-color-scheme: dark) {
  .input-base {
    background-color: rgb(30 41 59); /* slate-800 */
    border-color: rgb(71 85 105); /* slate-600 */
    color: white;
  }

  .input-base:focus {
    border-color: rgb(96 165 250); /* blue-400 */
    box-shadow: 0 0 0 3px rgb(96 165 250 / 0.1);
  }
}

/* ============================================
   ANIMATION UTILITIES
   Common animation patterns
   ============================================ */

/* Smooth hover lift */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Smooth scale on hover */
.hover-scale {
  transition: transform var(--transition-base);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Spin animation for loading states */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Pulse animation for loading states */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-in;
}

/* Slide in from top */
@keyframes slideInTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-slide-in-top {
  animation: slideInTop var(--transition-slow) ease-out;
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   Support for user preferences
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hover-lift:hover,
  .hover-scale:hover {
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn-base,
  .input-base {
    border-width: 2px;
  }

  .focus-ring:focus-visible {
    outline-width: 3px;
  }
}
