// Design Tokens - CSS Custom Properties
// These tokens form the foundation of our design system

:root {
  // ============================================
  // Color Palette - Dark Theme (Default)
  // ============================================

  // Background colors
  --color-bg-primary: #0f1419;
  --color-bg-secondary: #1a1f2e;
  --color-bg-tertiary: #242b3d;
  --color-bg-elevated: #2d3548;
  --color-bg-hover: #353d52;

  // Surface colors
  --color-surface: #1a1f2e;
  --color-surface-variant: #242b3d;

  // Brand colors
  --color-brand-primary: #3b82f6;
  --color-brand-accent: #609926;

  // Status colors (improved contrast)
  --color-status-success: #22c55e;
  --color-status-warning: #f59e0b;
  --color-status-error: #ef4444;
  --color-status-info: #3b82f6;
  --color-status-neutral: #6b7280;

  // Status background colors (subtle)
  --color-status-success-bg: rgba(34, 197, 94, 0.15);
  --color-status-warning-bg: rgba(245, 158, 11, 0.15);
  --color-status-error-bg: rgba(239, 68, 68, 0.15);
  --color-status-info-bg: rgba(59, 130, 246, 0.15);
  --color-status-neutral-bg: rgba(107, 114, 128, 0.15);

  // Package status colors
  --color-pkg-latest: #22c55e;
  --color-pkg-built: #3b82f6;
  --color-pkg-failed: #ef4444;
  --color-pkg-skipped: #6b7280;
  --color-pkg-delayed: #f59e0b;
  --color-pkg-queued: #f97316;
  --color-pkg-building: #14b8a6;
  --color-pkg-signing: #6366f1;
  --color-pkg-unknown: #9ca3af;

  // Version colors
  --color-version-v2: #60a5fa;
  --color-version-v3: #fbbf24;
  --color-version-v4: #34d399;

  // Text colors
  --color-text-primary: #f9fafb;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #6b7280;
  --color-text-inverse: #111827;

  // Border colors
  --color-border: #374151;
  --color-border-light: #4b5563;

  // ============================================
  // Spacing Scale (8px base)
  // ============================================
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  // ============================================
  // Border Radius
  // ============================================
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  // ============================================
  // Shadows
  // ============================================
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);

  // ============================================
  // Transitions
  // ============================================
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  // ============================================
  // Typography
  // ============================================
  --font-family: 'Roboto', sans-serif;
  --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-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  // ============================================
  // Safe Area Insets (for notched devices)
  // ============================================
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
}

// ============================================
// Light Theme Override
// ============================================
[data-theme="light"] {
  // Background colors
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-bg-tertiary: #f3f4f6;
  --color-bg-elevated: #ffffff;
  --color-bg-hover: #e5e7eb;

  // Surface colors
  --color-surface: #ffffff;
  --color-surface-variant: #f3f4f6;

  // Text colors
  --color-text-primary: #111827;
  --color-text-secondary: #4b5563;
  --color-text-muted: #9ca3af;
  --color-text-inverse: #f9fafb;

  // Border colors
  --color-border: #e5e7eb;
  --color-border-light: #d1d5db;

  // Status background colors (adjusted for light theme)
  --color-status-success-bg: rgba(34, 197, 94, 0.1);
  --color-status-warning-bg: rgba(245, 158, 11, 0.1);
  --color-status-error-bg: rgba(239, 68, 68, 0.1);
  --color-status-info-bg: rgba(59, 130, 246, 0.1);
  --color-status-neutral-bg: rgba(107, 114, 128, 0.1);

  // Shadows (lighter for light theme)
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --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);
}

// ============================================
// Global Styles
// ============================================

// Theme transition class - only apply transitions during theme switch
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color var(--transition-normal),
              border-color var(--transition-normal),
              color var(--transition-fast) !important;
}

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

// Selection color
::selection {
  background-color: var(--color-brand-primary);
  color: var(--color-text-inverse);
}

// Scrollbar styling (WebKit)
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border-light);
  border-radius: var(--radius-full);

  &:hover {
    background: var(--color-text-muted);
  }
}

// Firefox scrollbar
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-light) var(--color-bg-secondary);
}

// ============================================
// Vuetify Tooltip Override
// ============================================
.v-tooltip > .v-overlay__content {
  background: var(--color-bg-elevated) !important;
  color: var(--color-text-primary) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-2) var(--space-3) !important;
  font-size: var(--font-size-sm) !important;
  box-shadow: var(--shadow-lg) !important;
}

[data-theme="light"] .v-tooltip > .v-overlay__content {
  background: #1f2937 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

// ============================================
// Reduced Motion Support (accessibility)
// ============================================
@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;
  }
}
