/* Apple Design System - Theme Variables */
:root {
  /* Brand & Accent Colors */
  --primary-color: #0066cc;
  --primary-focus: #0071e3;
  --primary-on-dark: #2997ff;
  --primary-hover: #0071e3;
  
  /* Surface Colors */
  --canvas: #ffffff;
  --canvas-parchment: #f5f5f7;
  --surface-pearl: #fafafc;
  --surface-tile-1: #272729;
  --surface-tile-2: #2a2a2c;
  --surface-tile-3: #252527;
  --surface-black: #000000;
  --surface-chip-translucent: #d2d2d7;
  
  /* Text Colors */
  --ink: #1d1d1f;
  --body-color: #1d1d1f;
  --body-on-dark: #ffffff;
  --body-muted: #cccccc;
  --ink-muted-80: #333333;
  --ink-muted-48: #7a7a7a;
  
  /* Divider Colors */
  --divider-soft: #f0f0f0;
  --hairline: #e0e0e0;
  
  /* Semantic Colors */
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  
  /* Dark Theme (Default) */
  --bg-primary: var(--canvas);
  --bg-secondary: var(--canvas-parchment);
  --bg-tertiary: var(--surface-pearl);
  --bg-hover: var(--divider-soft);
  --bg-active: rgba(0, 102, 204, 0.1);
  
  --text-primary: var(--ink);
  --text-secondary: var(--ink-muted-48);
  
  --border-color: var(--hairline);
  
  /* Spacing System */
  --spacing-xxs: 4px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 17px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;
  --spacing-section: 80px;
  
  /* Border Radius */
  --radius-none: 0px;
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius-md: 11px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  --radius-full: 9999px;
  
  /* Typography */
  --font-display: 'SF Pro Display', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-text: 'SF Pro Text', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  /* Elevation */
  --shadow-product: rgba(0, 0, 0, 0.22) 3px 5px 30px;

  /* Text on primary */
  --on-primary: #ffffff;

  /* Sidebar fallbacks (defaults match light theme) */
  --sidebar-bg: var(--canvas);
  --sidebar-text: var(--ink);
  --sidebar-text-muted: var(--ink-muted-48);
  --sidebar-border: rgba(0, 0, 0, 0.1);
  --sidebar-hover: rgba(0, 0, 0, 0.05);
  --sidebar-active-bg: rgba(0, 102, 204, 0.1);
}

/* Light Theme */
.theme-light {
  --bg-primary: var(--canvas);
  --bg-secondary: var(--canvas-parchment);
  --bg-tertiary: var(--surface-pearl);
  --bg-hover: var(--divider-soft);
  --bg-active: rgba(0, 102, 204, 0.1);
  
  --text-primary: var(--ink);
  --text-secondary: var(--ink-muted-48);
  
  --border-color: var(--hairline);

  --sidebar-bg: var(--canvas);
  --sidebar-text: var(--ink);
  --sidebar-text-muted: var(--ink-muted-48);
  --sidebar-border: rgba(0, 0, 0, 0.1);
  --sidebar-hover: rgba(0, 0, 0, 0.05);
  --sidebar-active-bg: rgba(0, 102, 204, 0.1);
}

/* Dark Theme */
.theme-dark {
  /* Raw color overrides for dark mode */
  --canvas: #272729;
  --canvas-parchment: #333336;
  --surface-pearl: #383838;
  --surface-chip-translucent: rgba(255, 255, 255, 0.12);
  --hairline: rgba(255, 255, 255, 0.1);
  --divider-soft: rgba(255, 255, 255, 0.06);
  --ink: #f5f5f7;
  --ink-muted-80: rgba(255, 255, 255, 0.8);
  --ink-muted-48: rgba(255, 255, 255, 0.5);
  --body-color: #f5f5f7;
  --body-muted: rgba(255, 255, 255, 0.5);

  /* Semantic overrides */
  --bg-primary: #1d1d1f;
  --bg-secondary: #272729;
  --bg-tertiary: #2a2a2c;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(0, 102, 204, 0.2);
  
  --text-primary: var(--body-on-dark);
  --text-secondary: var(--body-muted);
  
  --border-color: rgba(255, 255, 255, 0.1);

  /* Sidebar */
  --sidebar-bg: #1d1d1f;
  --sidebar-text: var(--body-on-dark);
  --sidebar-text-muted: var(--body-muted);
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active-bg: rgba(0, 102, 204, 0.2);
}

/* Theme Toggle */
.theme-toggle {
  position: relative;
}

.theme-toggle .btn-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
}

/* Icon Visibility */
.theme-dark .icon-sun {
  display: none;
}

.theme-dark .icon-moon {
  display: block;
}

.theme-light .icon-sun {
  display: block;
}

.theme-light .icon-moon {
  display: none;
}

/* Transitions */
body {
  transition: background-color 0.3s ease, color 0.3s ease;
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.374px;
}

.sidebar,
.main-content,
.stat-card,
.content-section,
.model-card,
.api-key-item,
.modal-content {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-xs);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Selection */
::selection {
  background-color: var(--primary-color);
  color: var(--on-primary, #ffffff);
}

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

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page.active {
  animation: fadeIn 0.3s ease;
}

/* Modal Animation */
.modal {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal .modal-content {
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: scale(1);
}

/* Apple Typography Classes */
.typography-hero-display {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.28px;
}

.typography-display-lg {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
}

.typography-display-md {
  font-family: var(--font-text);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.47;
  letter-spacing: -0.374px;
}

.typography-lead {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: 0.196px;
}

.typography-lead-airy {
  font-family: var(--font-text);
  font-size: 24px;
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: 0;
}

.typography-tagline {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: 0.231px;
}

.typography-body-strong {
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.374px;
}

.typography-body {
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.374px;
}

.typography-dense-link {
  font-family: var(--font-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 2.41;
  letter-spacing: 0;
}

.typography-caption {
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.43;
  letter-spacing: -0.224px;
}

.typography-caption-strong {
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  letter-spacing: -0.224px;
}

.typography-button-large {
  font-family: var(--font-text);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.0;
  letter-spacing: 0;
}

.typography-button-utility {
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.29;
  letter-spacing: -0.224px;
}

.typography-fine-print {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.12px;
}

.typography-micro-legal {
  font-family: var(--font-text);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.08px;
}

.typography-nav-link {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.12px;
}
