/* ===========================================
   AFFILYNC DESIGN TOKENS - Single Source of Truth
   Financial Edge Design System

   This file consolidates ALL design token definitions
   from the previously fragmented sources:
   - design-system.css (:root variables)
   - index.css (@layer base variables)
   - utilities.css (opacity variables)
   - components.css (z-index component variables)
   - layout.css (layout z-index classes)

   Import this file FIRST, before any other CSS.
   Other files should REFERENCE these tokens, not redefine them.
   =========================================== */

/* ============================================================================
   SECTION 1: CORE PALETTE
   Brand colors that remain consistent across light/dark themes
   ============================================================================ */

:root {
  /* -- Colors: Primary - Deep Electric Blue -- */
  --color-primary: #0066e6;
  --color-primary-light: #3388ff;
  --color-primary-dark: #004bb5;
  --color-primary-50: #e6f1ff;
  --color-primary-100: #b3d7ff;
  --color-primary-200: #80bdff;
  --color-primary-300: #4da3ff;
  --color-primary-400: #1a8aff;
  --color-primary-500: #0066e6;
  --color-primary-600: #0052b3;
  --color-primary-700: #003d80;
  --color-primary-800: #00294d;
  --color-primary-900: #00141a;

  /* -- Colors: Accent (default/dark mode - Strategic Amber) -- */
  --color-accent: #ffcc00;
  --color-accent-light: #ffe066;
  --color-accent-dark: #cc9900;

  /* -- Colors: Semantic Status -- */
  --color-success: #00ff88;
  --color-success-muted: #059669;
  --color-warning: #ffcc00;
  --color-error: #ff3366;
  --color-error-muted: #dc2626;
  --color-info: #00b4d8;

  /* -- Colors: Chart Palette (10 colors for data viz) -- */
  --chart-1: #0066e6;
  --chart-2: #ffcc00;
  --chart-3: #00ff88;
  --chart-4: #00d4ff;
  --chart-5: #8b5cf6;
  --chart-6: #ff3366;
  --chart-7: #ec4899;
  --chart-8: #14b8a6;
  --chart-9: #f97316;
  --chart-10: #84cc16;
}

/* ============================================================================
   SECTION 2: SURFACES & BACKGROUNDS
   Theme-responsive surface colors (light/dark mode aware)
   ============================================================================ */

:root {
  /* -- Surfaces (Dark mode defaults - Financial Edge terminal UI) -- */
  --surface-base: #0a0e1a;
  --surface-raised: #111827;
  --surface-overlay: #1f2937;
  --surface-panel: #1a2030;
  --surface-elevated: #131825;

  /* -- Glass morphism -- */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: 12px;
  --glass-background: rgba(19, 24, 37, 0.95);
  --glass-border-primary: rgba(0, 102, 230, 0.2);
}

/* Light theme surface overrides */
[data-theme='light'],
:root:not(.dark) {
  --surface-base: #f8fafc;
  --surface-raised: #ffffff;
  --surface-overlay: #f1f5f9;
  --surface-panel: #f1f5f9;
  --surface-elevated: #ffffff;
  --glass-bg: rgba(0, 0, 0, 0.03);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-background: rgba(255, 255, 255, 0.9);
  --glass-border-primary: rgba(0, 102, 230, 0.15);
}

/* ============================================================================
   SECTION 3: TEXT COLORS
   ============================================================================ */

:root {
  /* -- Text (Dark mode defaults) -- */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-tertiary: #7e8694; /* Bumped for WCAG AA 3:1+ on dark bg */
  --text-muted: #4b5563;
  --text-inverse: #0a0e1a;
}

/* Light theme text overrides */
[data-theme='light'],
:root:not(.dark) {
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #f9fafb;
}

/* ============================================================================
   SECTION 4: TYPOGRAPHY
   Font families, sizes, and fluid scale
   ============================================================================ */

:root {
  /* -- Font Families -- */
  --font-display: 'Clash Display', 'Cal Sans', 'General Sans', system-ui, -apple-system, sans-serif;
  --font-body:
    'General Sans', 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Courier New', monospace;

  /* -- Typography: Fixed Sizes -- */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  /* -- Typography: Fluid Sizes (responsive) -- */
  --text-fluid-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-fluid-sm: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
  --text-fluid-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-fluid-lg: clamp(1.125rem, 1.05rem + 0.375vw, 1.25rem);
  --text-fluid-xl: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --text-fluid-2xl: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
  --text-fluid-3xl: clamp(1.875rem, 1.65rem + 1.125vw, 2.5rem);
  --text-fluid-4xl: clamp(2.25rem, 1.95rem + 1.5vw, 3rem);
}

/* ============================================================================
   SECTION 5: SPACING
   Consistent spacing scale used across components
   ============================================================================ */

:root {
  /* -- Spacing: Numeric Scale -- */
  --space-1: 0.25rem; /* 4px */
  --space-2: 0.5rem; /* 8px */
  --space-3: 0.75rem; /* 12px */
  --space-4: 1rem; /* 16px */
  --space-5: 1.25rem; /* 20px */
  --space-6: 1.5rem; /* 24px */
  --space-8: 2rem; /* 32px */
  --space-10: 2.5rem; /* 40px */
  --space-12: 3rem; /* 48px */
  --space-16: 4rem; /* 64px */
  --space-20: 5rem; /* 80px */
  --space-24: 6rem; /* 96px */

  /* -- Spacing: Named Aliases -- */
  --space-xs: 0.25rem; /* 4px */
  --space-sm: 0.5rem; /* 8px */
  --space-md: 1rem; /* 16px */
  --space-lg: 1.5rem; /* 24px */
  --space-xl: 2rem; /* 32px */
  --space-2xl: 3rem; /* 48px */
  --space-3xl: 4rem; /* 64px */
}

/* ============================================================================
   SECTION 6: BORDERS & RADII
   ============================================================================ */

:root {
  /* -- Border Radius -- */
  --radius: 0.5rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  --radius-full: 9999px;
}

/* ============================================================================
   SECTION 7: SHADOWS & EFFECTS
   Elevation system and glow effects
   ============================================================================ */

:root {
  /* -- Shadows: Elevation -- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);

  /* -- Shadows: Box (theme-aware via design-system.css) -- */
  --box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --box-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

  /* -- Shadows: Glow Effects (Financial Edge brand) -- */
  --shadow-glow-primary: 0 0 20px rgba(0, 102, 230, 0.3);
  --shadow-glow-primary-lg: 0 0 48px rgba(0, 102, 230, 0.5);
  --shadow-glow-accent: 0 0 20px rgba(255, 204, 0, 0.3);
  --shadow-glow-accent-lg: 0 0 48px rgba(255, 204, 0, 0.4);
  --shadow-glow-success: 0 0 20px rgba(0, 255, 136, 0.3);
  --shadow-glow-error: 0 0 20px rgba(255, 51, 102, 0.3);
  --box-shadow-glow: 0 0 24px rgba(0, 102, 230, 0.4);
}

/* Light theme shadow overrides */
[data-theme='light'],
:root:not(.dark) {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
  --box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  --box-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
  --box-shadow-glow: 0 0 24px rgba(0, 102, 230, 0.2);
}

/* ============================================================================
   SECTION 8: TRANSITIONS & MOTION
   Duration, easing, and animation tokens
   ============================================================================ */

:root {
  /* -- Transition Shorthand -- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* -- Duration Tokens -- */
  --duration-fastest: 100ms;
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 400ms;
  --duration-slowest: 500ms;

  /* -- Easing Curves -- */
  --easing-default: cubic-bezier(0.4, 0, 0.2, 1);
  --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-spring: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* -- Transition Composites (design-system.css compat) -- */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   SECTION 9: Z-INDEX SCALE
   Unified z-index system for consistent layering

   Layer Groups:
   - Base (0): Normal page content
   - Navigation (1000-1200): Headers, sidebars, dropdowns
   - Overlays (1300-1500): Modals, dialogs, popovers
   - Priority (1600-1900): Tooltips, toasts, notifications
   - Critical (2000+): Command palette, auth recovery
   ============================================================================ */

:root {
  /* -- Z-Index: Core Scale -- */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-sidebar: 1040;
  --z-navbar: 1050;
  --z-fixed: 1100;
  --z-overlay: 1200;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;
  --z-toast: 1700;
  --z-notification: 1800;
  --z-command-palette: 1900;
  --z-auth-recovery: 2000;

  /* -- Z-Index: Component-Specific -- */
  --z-spinner: 1850;
  --z-chat-widget: 1750;
  --z-feature-tour: 1780;
  --z-critical-alert: 1950;
  --z-noise: 9999;

  /* -- Z-Index: Navbar Sub-Components (from components.css) -- */
  --z-navbar-container: 1050;
  --z-user-menu-button: 1055;
  --z-navbar-backdrop: 1100;
  --z-navbar-dropdown: 1200;
}

/* ============================================================================
   SECTION 10: BREAKPOINTS
   Reference values for media queries (use Tailwind classes when possible)
   ============================================================================ */

:root {
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ============================================================================
   SECTION 11: OPACITY SCALE
   Standardized opacity values (from utilities.css)
   ============================================================================ */

:root {
  --opacity-0: 0;
  --opacity-10: 0.1;
  --opacity-20: 0.2;
  --opacity-30: 0.3;
  --opacity-40: 0.4;
  --opacity-50: 0.5;
  --opacity-60: 0.6;
  --opacity-70: 0.7;
  --opacity-80: 0.8;
  --opacity-90: 0.9;
  --opacity-100: 1;
}

/* ============================================================================
   SECTION 12: FOCUS & ACCESSIBILITY TOKENS
   WCAG 2.2 compliant focus state tokens
   ============================================================================ */

:root {
  --focus-ring-color: 210 100% 45%;
  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;
}

.dark {
  --focus-ring-color: 210 100% 55%;
}

/* ============================================================================
   SECTION 13: REDUCED MOTION
   Respects prefers-reduced-motion user preference
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-base: 0ms;
    --transition-slow: 0ms;
    --transition-spring: 0ms;
    --duration-fastest: 0ms;
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
    --duration-slowest: 0ms;
    --transition: none;
  }
}

/**
 * CSS Reset & Browser Normalizations
 *
 * This file provides a modern CSS reset and browser normalizations.
 * Previously scattered across index.css and reset.css.
 *
 * Note: Opacity utilities have been moved to utilities.css
 */

/* ============================================================================
   MODERN CSS RESET
   ============================================================================ */

/* Universal box sizing and reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* HTML and Body setup */
html {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* Light mode: Subtle blue-tinted gradient background */
  background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 50%, #eef2ff 100%);
  background-attachment: fixed;
}

/* Dark mode: Deep blue-black gradient background */
.dark body {
  background: linear-gradient(135deg, #0f172a 0%, #020617 50%, #1e1b4b 100%);
  background-attachment: fixed;
}

/* Root container */
#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  position: relative;
}

/* Fix for images and media elements */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form elements inherit font */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove default list styles */
ul,
ol {
  list-style: none;
}

/* Prevent text overflow */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
          hyphens: auto;
}

/* Fix for absolute positioned elements */
main,
section,
article,
aside,
header,
footer,
nav {
  position: relative;
}

/* ============================================================================
   ACCESSIBILITY & PERFORMANCE
   ============================================================================ */

/* Ensure proper stacking context */
#root > * {
  position: relative;
  z-index: 1;
}

/* Fix for React Router warnings - add future flags support */
.router-transition * {
  transition: opacity 0.3s ease;
}

/* Layout Positioning Fix - Production CSS */

/* ==========================================================================
   LAYOUT STRUCTURE - Sidebar, TopNav, Main Content
   ========================================================================== */

.layout-wrapper {
  position: relative;
  min-height: 100vh;
  background-color: hsl(var(--background));
}

/* ==========================================================================
   SIDEBAR POSITIONING
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 288px;
  height: 100vh;
  z-index: 40;
  background: hsl(var(--background-elevated));
  border-right: 1px solid hsl(var(--border));
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s ease-in-out;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: hsl(var(--background));
}

.sidebar::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 3px;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 288px;
  }

  .sidebar.open {
    transform: translateX(0);
  }
}

@media (min-width: 769px) {
  .sidebar {
    transform: translateX(0);
  }
}

@media (min-width: 1440px) {
  .sidebar {
    width: 280px;
  }
}

/* ==========================================================================
   TOPNAV POSITIONING
   ========================================================================== */

.topnav {
  position: fixed;
  top: 0;
  left: 288px;
  right: 0;
  height: 64px;
  z-index: 50;
  background: hsl(var(--background-elevated));
  border-bottom: 1px solid hsl(var(--border));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .topnav {
    left: 0;
    z-index: 50;
  }
}

@media (min-width: 1440px) {
  .topnav {
    left: 288px;
  }
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.main-content {
  margin-left: 288px;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
  background: hsl(var(--background));
  position: relative;
  z-index: 1;
  padding: 0;
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    width: 100%;
  }
}

@media (min-width: 1440px) {
  .main-content {
    margin-left: 288px;
  }
}

/* ==========================================================================
   MOBILE OVERLAY
   ========================================================================== */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease-in-out,
    visibility 0.3s ease-in-out;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* ==========================================================================
   APP CONTAINER SYSTEM
   ========================================================================== */

.app-container {
  width: 100%;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .app-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .app-container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.app-container-sm {
  max-width: 768px;
}

.app-container-md {
  max-width: 1024px;
}

.app-container-lg {
  max-width: 1152px;
}

.app-container-xl {
  max-width: 1280px;
}

.app-container-2xl {
  max-width: 1536px;
}

/* ==========================================================================
   Z-INDEX MANAGEMENT
   ========================================================================== */

.z-sidebar {
  z-index: 40;
}

.z-topnav {
  z-index: 50;
}

.z-overlay {
  z-index: 30;
}

.z-dropdown {
  z-index: 60;
}

.z-modal {
  z-index: 70;
}

.z-tooltip {
  z-index: 80;
}

.z-toast {
  z-index: 90;
}

/* ==========================================================================
   LAYOUT ANIMATIONS
   ========================================================================== */

.layout-transition {
  transition:
    margin-left 0.3s ease-in-out,
    margin-top 0.3s ease-in-out,
    width 0.3s ease-in-out;
}

/* ==========================================================================
   ACCESSIBILITY & RESPONSIVE
   ========================================================================== */

/* Global Focus Indicators - WCAG 2.2 Compliant */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Dark theme focus indicators */
.dark *:focus-visible,
[data-theme='dark'] *:focus-visible {
  outline-color: #60a5fa;
}

/* Brand theme focus indicators (blue) */
.brand-focus:focus-visible,
[data-user-type='brand'] button:focus-visible,
[data-user-type='brand'] a:focus-visible {
  outline-color: #1a8aff;
  box-shadow: 0 0 0 4px rgba(26, 138, 255, 0.2);
}

/* Affiliate theme focus indicators (emerald) */
.affiliate-focus:focus-visible,
[data-user-type='affiliate'] button:focus-visible,
[data-user-type='affiliate'] a:focus-visible {
  outline-color: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* High contrast focus for better visibility */
.focus-ring-visible:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* Remove default outline for mouse users, keep for keyboard */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay,
  .layout-transition {
    transition: none !important;
  }
}

@media (prefers-contrast: high) {
  .sidebar {
    border-right: 2px solid #000000;
  }

  .topnav {
    border-bottom: 2px solid #000000;
  }
}

@media print {
  .sidebar,
  .topnav,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    margin-top: 0 !important;
  }

  .app-container {
    max-width: none !important;
    padding: 0 !important;
  }
}

/**
 * Utilities - Utility Classes & Animations
 *
 * This file consolidates utility classes from:
 * - background.css (gradients, glass morphism, animations)
 * - reset.css (opacity utilities)
 * - unifiedDesignSystem.css (responsive utilities, grid layouts)
 * - navigation-fixes.css (notification pulse)
 *
 * Organization:
 * 1. Opacity Utilities
 * 2. Background & Gradient Utilities
 * 3. Glass Morphism Effects
 * 4. Grid Layout Utilities
 * 5. Responsive Utilities
 * 6. Animation Utilities
 * 7. Keyframe Animations
 */

/* ============================================================================
   OPACITY UTILITIES
   ============================================================================ */

:root {
  --opacity-0: 0;
  --opacity-10: 0.1;
  --opacity-20: 0.2;
  --opacity-30: 0.3;
  --opacity-40: 0.4;
  --opacity-50: 0.5;
  --opacity-60: 0.6;
  --opacity-70: 0.7;
  --opacity-80: 0.8;
  --opacity-90: 0.9;
  --opacity-100: 1;
}

.opacity-0 {
  opacity: 0 !important;
}
.opacity-10 {
  opacity: 0.1 !important;
}
.opacity-20 {
  opacity: 0.2 !important;
}
.opacity-30 {
  opacity: 0.3 !important;
}
.opacity-40 {
  opacity: 0.4 !important;
}
.opacity-50 {
  opacity: 0.5 !important;
}
.opacity-60 {
  opacity: 0.6 !important;
}
.opacity-70 {
  opacity: 0.7 !important;
}
.opacity-80 {
  opacity: 0.8 !important;
}
.opacity-90 {
  opacity: 0.9 !important;
}
.opacity-100 {
  opacity: 1 !important;
}

/* ============================================================================
   BACKGROUND & GRADIENT UTILITIES
   ============================================================================ */

/* Note: Tailwind @layer utilities moved to index.css for proper processing */

/* ============================================================================
   GLASS MORPHISM EFFECTS
   ============================================================================ */

/* Note: Glass morphism utilities moved to index.css for proper Tailwind processing */

/* ============================================================================
   GRID LAYOUT UTILITIES
   ============================================================================ */

.dashboard-grid {
  display: grid;
  gap: 1.5rem;
}

.dashboard-grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
  .dashboard-grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .dashboard-grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1536px) {
  .dashboard-grid-cols-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ============================================================================
   RESPONSIVE UTILITIES
   ============================================================================ */

.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none;
  }
}

/* ============================================================================
   ANIMATION UTILITIES
   ============================================================================ */

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.animate-gradient {
  animation: gradient-shift 8s ease-in-out infinite;
}

.animate-shimmer {
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  background-size: 2000px 100%;
  animation: shimmer 2s linear infinite;
}

/* Notification Pulse */
.notification-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================================================
   HOVER & INTERACTION UTILITIES
   Phase 5 - Micro-interactions & Polish
   ============================================================================ */

/**
 * Standardized hover interactions with consistent timing and effects
 *
 * Timing Standards:
 * - Fast: 150ms - Quick feedback (buttons, toggles)
 * - Standard: 200ms - Default interaction (most UI elements)
 * - Smooth: 250ms - Gentle transitions (cards, panels)
 *
 * Performance:
 * - Uses will-change for transform/opacity animations
 * - GPU-accelerated via transform: translateZ(0)
 */

/* Base Hover Transition Speeds */
.hover-transition-fast {
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-transition-standard {
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-transition-smooth {
  transition-duration: 250ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover Lift Effects - Elevate element with shadow */
.hover-lift-sm,
.hover-lift-md,
.hover-lift-lg,
.hover-card {
  transition-property: transform, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.hover-lift-sm:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.06);
}

.hover-lift-md:hover,
.hover-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.1),
    0 3px 6px rgba(0, 0, 0, 0.08);
}

.hover-lift-lg:hover {
  transform: translateY(-6px);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Dark mode lift shadows */
.dark .hover-lift-sm:hover {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark .hover-lift-md:hover,
.dark .hover-card:hover {
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.4),
    0 3px 6px rgba(0, 0, 0, 0.3);
}

.dark .hover-lift-lg:hover {
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Hover Scale Effects - Subtle zoom */
.hover-scale-sm,
.hover-scale-md,
.hover-scale-lg {
  transition-property: transform;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.hover-scale-sm:hover {
  transform: scale(1.02);
}

.hover-scale-md:hover {
  transform: scale(1.05);
}

.hover-scale-lg:hover {
  transform: scale(1.08);
}

/* Hover Glow Effects - Shadow-based glow */
.hover-glow-primary,
.hover-glow-success,
.hover-glow-warning,
.hover-glow-destructive {
  transition-property: box-shadow;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: box-shadow;
}

.hover-glow-primary:hover {
  box-shadow:
    0 0 0 3px hsl(var(--primary) / 0.15),
    0 4px 12px hsl(var(--primary) / 0.2);
}

.hover-glow-success:hover {
  box-shadow:
    0 0 0 3px hsl(var(--success) / 0.15),
    0 4px 12px hsl(var(--success) / 0.2);
}

.hover-glow-warning:hover {
  box-shadow:
    0 0 0 3px hsl(var(--warning) / 0.15),
    0 4px 12px hsl(var(--warning) / 0.2);
}

.hover-glow-destructive:hover {
  box-shadow:
    0 0 0 3px hsl(var(--destructive) / 0.15),
    0 4px 12px hsl(var(--destructive) / 0.2);
}

/* Hover Brightness - Subtle color shifts */
.hover-brighten {
  transition-property: filter;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: filter;
}

.hover-brighten:hover {
  filter: brightness(1.05);
}

.hover-brighten-md:hover {
  filter: brightness(1.1);
}

/* Hover Opacity - Fade effects */
.hover-opacity-80 {
  transition-property: opacity;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-opacity-80:hover {
  opacity: 0.8;
}

.hover-opacity-60:hover {
  opacity: 0.6;
}

/* Combined Effects - Lift + Scale */
.hover-lift-scale-sm {
  transition-property: transform, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.hover-lift-scale-sm:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Combined Effects - Lift + Glow */
.hover-lift-glow-primary {
  transition-property: transform, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.hover-lift-glow-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px hsl(var(--primary) / 0.15),
    0 8px 20px hsl(var(--primary) / 0.15);
}

/* Active States - Click feedback */
.active-scale-down {
  transition-property: transform;
  transition-duration: 100ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.active-scale-down:active {
  transform: scale(0.95);
}

.active-scale-down-sm:active {
  transform: scale(0.98);
}

/* Focus States - Keyboard navigation */
.focus-ring-primary:focus-visible {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}

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

/* Accessibility - Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .hover-lift-sm,
  .hover-lift-md,
  .hover-lift-lg,
  .hover-card,
  .hover-scale-sm,
  .hover-scale-md,
  .hover-scale-lg,
  .hover-lift-scale-sm,
  .hover-lift-glow-primary,
  .hover-brighten,
  .active-scale-down,
  .active-scale-down-sm {
    transition-duration: 0ms;
    will-change: auto;
  }

  .hover-lift-sm:hover,
  .hover-lift-md:hover,
  .hover-lift-lg:hover,
  .hover-card:hover,
  .hover-scale-sm:hover,
  .hover-scale-md:hover,
  .hover-scale-lg:hover,
  .hover-lift-scale-sm:hover,
  .hover-lift-glow-primary:hover {
    transform: none;
  }
}

/* ============================================================================
   LOADING TRANSITIONS & ANIMATIONS
   Phase 5 - Task 5.2: Loading Transitions
   ============================================================================ */

/**
 * Loading animations for spinners, skeletons, and progress indicators
 *
 * Animations:
 * - Shimmer: Left-to-right shine effect for skeletons
 * - Progress Indeterminate: Sliding animation for progress bars
 * - Fade In/Out: Smooth content transitions
 * - Skeleton Pulse: Breathing animation for loading placeholders
 *
 * Performance:
 * - GPU-accelerated transforms
 * - Reduced motion support
 */

/* Shimmer Animation - Skeleton loading effect */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* Dark mode shimmer */
.dark .animate-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 100%
  );
}

/* Indeterminate Progress Animation */
@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

.animate-progress-indeterminate {
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* Striped Progress Bar Pattern */
@keyframes progress-stripe {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}

.bg-stripe {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255, 255, 255, 0.1) 10px,
    rgba(255, 255, 255, 0.1) 20px
  );
  background-size: 40px 40px;
  animation: progress-stripe 1s linear infinite;
}

/* Fade Transitions */
.fade-in {
  animation: fade-in 300ms ease-in;
}

.fade-out {
  animation: fade-out 300ms ease-out;
}

.fade-in-fast {
  animation: fade-in 150ms ease-in;
}

.fade-out-fast {
  animation: fade-out 150ms ease-out;
}

.fade-in-slow {
  animation: fade-in 500ms ease-in;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Slide Fade Transitions - Combined fade + slide */
.slide-fade-in-up {
  animation: slide-fade-in-up 400ms ease-out;
}

.slide-fade-in-down {
  animation: slide-fade-in-down 400ms ease-out;
}

.slide-fade-out-up {
  animation: slide-fade-out-up 300ms ease-in;
}

.slide-fade-out-down {
  animation: slide-fade-out-down 300ms ease-in;
}

@keyframes slide-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-fade-out-up {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes slide-fade-out-down {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* Scale Fade Transitions */
.scale-fade-in {
  animation: scale-fade-in 300ms ease-out;
}

.scale-fade-out {
  animation: scale-fade-out 200ms ease-in;
}

@keyframes scale-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scale-fade-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

/* Skeleton Loading States */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(229, 231, 235, 1) 0%,
    rgba(243, 244, 246, 1) 50%,
    rgba(229, 231, 235, 1) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 2s ease-in-out infinite;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(55, 65, 81, 1) 0%,
    rgba(75, 85, 99, 1) 50%,
    rgba(55, 65, 81, 1) 100%
  );
}

@keyframes skeleton-pulse {
  0%,
  100% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 0%;
  }
}

/* Loading Overlay Transitions */
.loading-overlay-enter {
  animation: fade-in 200ms ease-in;
}

.loading-overlay-exit {
  animation: fade-out 200ms ease-out;
}

/* Spinner Rotation (smooth) */
@keyframes spinner-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

/* Content Transition - Skeleton to Content */
.content-transition-enter {
  animation: content-fade-in 400ms ease-out;
}

@keyframes content-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduced Motion - Loading Animations */
@media (prefers-reduced-motion: reduce) {
  .animate-shimmer,
  .animate-progress-indeterminate,
  .bg-stripe,
  .fade-in,
  .fade-out,
  .fade-in-fast,
  .fade-out-fast,
  .fade-in-slow,
  .slide-fade-in-up,
  .slide-fade-in-down,
  .slide-fade-out-up,
  .slide-fade-out-down,
  .scale-fade-in,
  .scale-fade-out,
  .skeleton,
  .loading-overlay-enter,
  .loading-overlay-exit,
  .animate-spinner,
  .content-transition-enter {
    animation: none !important;
    transition: opacity 0ms !important;
  }

  /* For reduced motion, show instant opacity changes only */
  .fade-in,
  .fade-in-fast,
  .fade-in-slow,
  .slide-fade-in-up,
  .slide-fade-in-down,
  .scale-fade-in,
  .loading-overlay-enter,
  .content-transition-enter {
    opacity: 1;
    transform: none;
  }

  .fade-out,
  .fade-out-fast,
  .slide-fade-out-up,
  .slide-fade-out-down,
  .scale-fade-out,
  .loading-overlay-exit {
    opacity: 0;
    transform: none;
  }
}

/* ============================================================================
   KEYFRAME ANIMATIONS
   ============================================================================ */

/* Float Animation */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Gradient Shift Animation */
@keyframes gradient-shift {
  0%,
  100% {
    transform: translate(0, 0);
    opacity: 0.5;
  }
  50% {
    transform: translate(-10px, -10px);
    opacity: 0.8;
  }
}

/* Shimmer Animation */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

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

/* Toast Animations */
@keyframes toast-slide-in-right {
  from {
    transform: translateX(calc(100% + 1rem));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(calc(100% + 1rem));
    opacity: 0;
  }
}

@keyframes toast-slide-in-bottom {
  from {
    transform: translateY(calc(100% + 1rem));
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes toast-swipe-out {
  from {
    transform: translateX(var(--radix-toast-swipe-end-x));
  }
  to {
    transform: translateX(calc(100% + 1rem));
  }
}

.animate-toast-slide-in {
  animation: toast-slide-in-right 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-toast-slide-out {
  animation: toast-slide-out-right 100ms ease-in;
}

.animate-toast-swipe {
  animation: toast-swipe-out 100ms ease-out;
}

/* Success Checkmark Animation */
@keyframes success-checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes success-circle {
  0% {
    stroke-dashoffset: 166;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.animate-success-checkmark {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: success-checkmark 0.3s ease-in-out 0.1s forwards;
}

.animate-success-circle {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: success-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

/* Confetti Animation */
@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.animate-confetti {
  animation: confetti-fall 3s ease-in forwards;
}

/* Celebration Animation */
@keyframes celebrate-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-20px);
  }
  50% {
    transform: translateY(-10px);
  }
  75% {
    transform: translateY(-5px);
  }
}

.animate-celebrate {
  animation: celebrate-bounce 0.6s ease-out;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .animate-float,
  .animate-gradient,
  .animate-shimmer,
  .notification-pulse,
  .animate-toast-slide-in,
  .animate-toast-slide-out,
  .animate-toast-swipe,
  .animate-success-checkmark,
  .animate-success-circle,
  .animate-confetti,
  .animate-celebrate {
    animation: none;
  }
}

