/**
 * KeyRacer AI Agent Design System Foundation
 * 
 * This file contains the core design system including:
 * - CSS Custom Properties (colors, typography, spacing, shadows)
 * - Theme switching infrastructure (light/dark/auto)
 * - Responsive breakpoints and media queries
 * - Font imports (Inter and Fira Code)
 * 
 * Requirements: 1.1, 1.2, 11.1, 11.2
 */

/* ============================================
   FONT IMPORTS
   ============================================ */

/* Inter Font - Primary UI Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Fira Code - Monospace Font for Code */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

/* ============================================
   ROOT VARIABLES - LIGHT MODE (DEFAULT)
   ============================================ */

:root {
  /* Color Scheme Detection */
  color-scheme: light dark;
  
  /* ===== VIBRANT GRADIENT PALETTE (Option 1 - Recommended) ===== */
  
  /* Primary Colors */
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-light: #a78bfa;
  --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
  
  /* Secondary & Accent Colors */
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Background Colors */
  --background: #fafafa;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #f5f5f5;
  
  /* Text Colors */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Border Colors */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: var(--primary);
  
  /* Shadow Colors */
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-md: rgba(0, 0, 0, 0.12);
  --shadow-lg: rgba(0, 0, 0, 0.16);
  --shadow-colored: rgba(124, 58, 237, 0.15);
  
  /* ===== MODE-SPECIFIC COLORS ===== */
  
  /* Career Mode - Blue Theme */
  --mode-career-primary: #3b82f6;
  --mode-career-primary-hover: #2563eb;
  --mode-career-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --mode-career-shadow: rgba(59, 130, 246, 0.15);
  
  /* Interview Mode - Purple Theme */
  --mode-interview-primary: #a855f7;
  --mode-interview-primary-hover: #9333ea;
  --mode-interview-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --mode-interview-shadow: rgba(168, 85, 247, 0.15);
  
  /* Active Mode Colors (default to career) */
  --mode-accent: var(--mode-career-primary);
  --mode-accent-hover: var(--mode-career-primary-hover);
  --mode-gradient: var(--mode-career-gradient);
  --mode-shadow: var(--mode-career-shadow);
  
  /* ===== TYPOGRAPHY ===== */
  
  /* Font Families */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  --font-mono: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  
  /* Font Sizes */
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  
  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 1.75;
  
  /* ===== SPACING SCALE ===== */
  
  --space-0: 0;
  --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-7: 1.75rem;      /* 28px */
  --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 */
  
  /* ===== BORDER RADIUS ===== */
  
  --radius-none: 0;
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px */
  --radius-3xl: 2rem;      /* 32px */
  --radius-full: 9999px;   /* Fully rounded */
  
  /* ===== SHADOWS ===== */
  
  --shadow-none: none;
  --shadow-sm: 0 1px 2px 0 var(--shadow);
  --shadow-base: 0 1px 3px 0 var(--shadow), 0 1px 2px -1px var(--shadow);
  --shadow-md: 0 4px 6px -1px var(--shadow-md), 0 2px 4px -2px var(--shadow-md);
  --shadow-lg: 0 10px 15px -3px var(--shadow-lg), 0 4px 6px -4px var(--shadow-lg);
  --shadow-xl: 0 20px 25px -5px var(--shadow-lg), 0 8px 10px -6px var(--shadow-lg);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 var(--shadow);
  
  /* ===== Z-INDEX SCALE ===== */
  
  --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;
  
  /* ===== TRANSITIONS ===== */
  
  --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-slower: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Easing Functions */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* ===== RESPONSIVE BREAKPOINTS ===== */
  /* These are used in media queries below */
  
  --breakpoint-xs: 320px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  
  /* ===== LAYOUT ===== */
  
  --header-height: 64px;
  --sidebar-width: 280px;
  --input-area-height: auto;
  --max-content-width: 900px;
  --max-message-width: 70%;
  
  /* ===== GLASSMORPHISM ===== */
  
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-blur: blur(10px);
}

/* ============================================
   DARK MODE VARIABLES
   ============================================ */

[data-theme="dark"] {
  /* ===== VIBRANT GRADIENT PALETTE - DARK MODE ===== */
  
  /* Primary Colors */
  --primary: #a78bfa;
  --primary-hover: #c4b5fd;
  --primary-light: #ddd6fe;
  --primary-gradient: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
  
  /* Secondary & Accent Colors */
  --secondary: #22d3ee;
  --accent: #fbbf24;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #60a5fa;
  
  /* Background Colors */
  --background: #0a0a0f;
  --surface: #1a1a24;
  --surface-elevated: #252535;
  --surface-hover: #2d2d3d;
  
  /* Text Colors */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-inverse: #0f172a;
  
  /* Border Colors */
  --border: #2d2d3d;
  --border-light: #1e1e2e;
  --border-focus: var(--primary);
  
  /* Shadow Colors */
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-md: rgba(0, 0, 0, 0.5);
  --shadow-lg: rgba(0, 0, 0, 0.6);
  --shadow-colored: rgba(167, 139, 250, 0.2);
  
  /* ===== GLASSMORPHISM - DARK MODE ===== */
  
  --glass-bg: rgba(26, 26, 36, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(10px);
}

/* ============================================
   AUTO THEME (SYSTEM PREFERENCE)
   ============================================ */

/* When no theme is explicitly set, respect system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    /* Apply dark mode variables */
    --primary: #a78bfa;
    --primary-hover: #c4b5fd;
    --primary-light: #ddd6fe;
    --primary-gradient: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
    
    --secondary: #22d3ee;
    --accent: #fbbf24;
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    --info: #60a5fa;
    
    --background: #0a0a0f;
    --surface: #1a1a24;
    --surface-elevated: #252535;
    --surface-hover: #2d2d3d;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-inverse: #0f172a;
    
    --border: #2d2d3d;
    --border-light: #1e1e2e;
    
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-md: rgba(0, 0, 0, 0.5);
    --shadow-lg: rgba(0, 0, 0, 0.6);
    --shadow-colored: rgba(167, 139, 250, 0.2);
    
    --glass-bg: rgba(26, 26, 36, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
   THEME TRANSITION
   ============================================ */

/* Smooth transition when switching themes */
* {
  transition: background-color var(--transition-base),
              border-color var(--transition-base),
              color var(--transition-base);
}

/* Disable transitions for elements that shouldn't animate */
*:focus,
*:active,
input,
textarea,
select {
  transition: none;
}

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

/* Extra Small Devices (phones, less than 640px) */
@media (max-width: 639px) {
  :root {
    --sidebar-width: 0;
    --max-message-width: 85%;
    --text-base: 0.9375rem; /* 15px */
  }
}

/* Small Devices (landscape phones, 640px and up) */
@media (min-width: 640px) {
  :root {
    --sidebar-width: 280px;
  }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) {
  :root {
    --max-message-width: 75%;
  }
}

/* Large Devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
  :root {
    --max-message-width: 70%;
    --sidebar-width: 300px;
  }
}

/* Extra Large Devices (large desktops, 1280px and up) */
@media (min-width: 1280px) {
  :root {
    --max-content-width: 1000px;
  }
}

/* 2XL Devices (larger desktops, 1536px and up) */
@media (min-width: 1536px) {
  :root {
    --max-content-width: 1200px;
  }
}

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

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    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 {
    --border: #000000;
    --text-secondary: var(--text-primary);
  }
  
  [data-theme="dark"] {
    --border: #ffffff;
    --text-secondary: var(--text-primary);
  }
}

/* ============================================
   BASE RESET & NORMALIZATION
   ============================================ */

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

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

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--background);
  overflow-x: hidden;
}

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

/* Theme Toggle Classes */
.theme-light {
  /* Light theme is default, no additional styles needed */
}

.theme-dark {
  /* Dark theme applied via [data-theme="dark"] */
}

.theme-auto {
  /* Auto theme respects system preference */
}

/* Visibility Classes */
.hidden {
  display: none !important;
}

.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;
}

/* Focus Visible */
.focus-visible:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  a,
  a:visited {
    text-decoration: underline;
  }
  
  pre,
  blockquote {
    border: 1px solid #999;
    page-break-inside: avoid;
  }
  
  thead {
    display: table-header-group;
  }
  
  tr,
  img {
    page-break-inside: avoid;
  }
  
  img {
    max-width: 100% !important;
  }
  
  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }
  
  h2,
  h3 {
    page-break-after: avoid;
  }
}
