/* ==========================================================================
   Modern Design System Variables
   ========================================================================== */

:root {
  /* Colors - Dark Theme */
  --bg-primary: #0a0e1a;
  --bg-secondary: #1a1f2e;
  --bg-tertiary: #2a2f3e;
  
  --surface-primary: #141927;
  --surface-secondary: #1f2437;
  --surface-tertiary: #2a3141;
  --surface-elevated: #353b4a;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-disabled: #64748b;
  
  --border-primary: rgba(148, 163, 184, 0.1);
  --border-secondary: rgba(148, 163, 184, 0.05);
  --border-focus: rgba(59, 130, 246, 0.5);
  
  /* Brand Colors */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  
  --accent-50: #f0f9ff;
  --accent-100: #e0f2fe;
  --accent-200: #bae6fd;
  --accent-300: #7dd3fc;
  --accent-400: #38bdf8;
  --accent-500: #0ea5e9;
  --accent-600: #0284c7;
  --accent-700: #0369a1;
  --accent-800: #075985;
  --accent-900: #0c4a6e;
  
  /* Status Colors */
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --success-700: #15803d;
  
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  
  --danger-50: #fef2f2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  --gradient-secondary: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  --gradient-accent: linear-gradient(135deg, var(--accent-400), var(--accent-600));
  
  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  
  /* Spacing 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 */
  
  /* Border Radius */
  --radius-xs: 0.125rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-3xl: 1.5rem;
  --radius-full: 9999px;
  
  /* Typography */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;
  
  --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;
  
  /* Legacy compatibility */
  --bg: var(--bg-primary);
  --card: var(--surface-primary);
  --muted: var(--text-muted);
  --text: var(--text-primary);
  --accent: var(--primary-500);
  --danger: var(--danger-500);
}

/* Light Theme */
body.light-mode {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  
  --surface-primary: #ffffff;
  --surface-secondary: #f8fafc;
  --surface-tertiary: #f1f5f9;
  --surface-elevated: #ffffff;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  
  --border-primary: rgba(15, 23, 42, 0.1);
  --border-secondary: rgba(15, 23, 42, 0.05);
  
  /* Legacy compatibility for light mode */
  --bg: var(--bg-primary);
  --card: var(--surface-primary);
  --muted: var(--text-muted);
  --text: var(--text-primary);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
              radial-gradient(ellipse at bottom right, rgba(14, 165, 233, 0.1) 0%, transparent 50%),
              var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--line-height-normal);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-500);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-400);
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  background: rgba(20, 25, 39, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xl);
  letter-spacing: -0.025em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav a {
  margin: 0 var(--space-2);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  transition: color 0.2s ease;
}

.nav a:hover {
  color: var(--text-primary);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

form {
  display: grid;
  gap: var(--space-5);
  max-width: 42rem;
}

label {
  display: grid;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

input,
select,
textarea {
  background: var(--surface-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  transition: all 0.2s ease;
}

/* Ensure dropdown options have proper background in dark mode */
select option {
  background-color: var(--surface-secondary);
  color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* Password field with toggle eye icon */
.password-field {
  position: relative;
}

.password-field input {
  width: 100%;
  padding-right: 2.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
}

.password-toggle:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   Button Components
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background: var(--surface-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
  background: var(--surface-tertiary);
  border-color: var(--border-focus);
}

.btn-outline {
  background: transparent;
  color: var(--primary-500);
  border: 1px solid var(--primary-500);
}

.btn-outline:hover {
  background: var(--primary-500);
  color: white;
}

.btn-danger {
  background: var(--danger-500);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-600);
  transform: translateY(-1px);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-base);
}

button {
  @extend .btn;
  @extend .btn-primary;
}

/* Legacy button styles */
.btn-primary {
  background: var(--gradient-primary);
  border: 0;
  color: white;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-6);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}

.card {
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-focus);
}

.card .title {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-2);
}

.card .value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.card .icon {
  width: 3rem;
  height: 3rem;
  background: var(--gradient-primary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   Table Components
   ========================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table th,
.table td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-secondary);
  text-align: left;
}

.table th {
  background: var(--surface-secondary);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover {
  background: var(--surface-secondary);
}

/* ==========================================================================
   Alert Components
   ========================================================================== */

.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid;
  margin-bottom: var(--space-4);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger-300);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning-300);
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success-300);
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--primary-300);
}

/* Legacy alert */
.alert {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  color: #ffdede;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  opacity: 0.6;
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  border-top: 1px solid var(--border-secondary);
  margin-top: var(--space-16);
}

/* ==========================================================================
   Auth Components
   ========================================================================== */

.auth-card {
  max-width: 28rem;
  margin: var(--space-16) auto;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-3xl);
  padding: var(--space-8);
  text-align: center;
  box-shadow: var(--shadow-2xl);
}

.auth-card .logo {
  font-weight: var(--font-weight-extrabold);
  font-size: var(--font-size-2xl);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-2);
}

.auth-card h1 {
  margin: var(--space-2) 0 var(--space-6);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.auth-form {
  text-align: left;
}

.auth-form .btn-primary {
  width: 100%;
  margin-top: var(--space-2);
}

.auth-form label {
  display: block;
  margin-bottom: var(--space-4);
}

.auth-form input,
.auth-form select {
  width: 100%;
}

.auth-links {
  margin-top: var(--space-4);
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}
