/* EVE Corporate Identity & Design System - Three Theme System
 * Light Theme: Daytime (7am-6pm)
 * Dark Theme: Evening (6pm-10pm)
 * Night Shift Theme: Late night (10pm-6am) with reduced blue light
 */

/* ============================================
   LIGHT THEME (Default)
   ============================================ */
:root,
:root.light-theme {
  /* Backgrounds */
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #ffffff;
  --bg-hover: #f7fafc;
  --bg-active: #edf2f7;
  
  /* Text */
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --text-muted: #a0aec0;
  --text-emphasis: #1a202c;
  
  /* Borders */
  --border-color: #e2e8f0;
  --border-emphasis: #cbd5e0;
  --divider: #edf2f7;
  
  /* Accents */
  --accent-primary: #4a5568;
  --accent-hover: #2d3748;
  --accent-active: #1a202c;
  --accent-subtle: #edf2f7;
  
  /* Status Colors */
  --status-operational: #10b981;
  --status-degraded: #f59e0b;
  --status-outage: #ef4444;
  --status-operational-bg: #d1fae5;
  --status-degraded-bg: #fef3c7;
  --status-outage-bg: #fee2e2;
  
  /* Interactive */
  --link-color: #4a5568;
  --link-hover: #2d3748;
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --input-focus: #4a5568;
  --button-primary-bg: #4a5568;
  --button-primary-hover: #2d3748;
  --button-secondary-border: #4a5568;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* ============================================
   DARK THEME
   ============================================ */
:root.dark-theme {
  /* Backgrounds */
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f26;
  --bg-tertiary: #252b35;
  --bg-hover: #2d3441;
  --bg-active: #363d4d;
  
  /* Text */
  --text-primary: #e4e7eb;
  --text-secondary: #a8b3c1;
  --text-muted: #6b7785;
  --text-emphasis: #f7fafc;
  
  /* Borders */
  --border-color: #2d3441;
  --border-emphasis: #3d4554;
  --divider: #252b35;
  
  /* Accents */
  --accent-primary: #7a8ba0;
  --accent-hover: #8fa1b5;
  --accent-active: #6b7c91;
  --accent-subtle: #4a5568;
  
  /* Status Colors */
  --status-operational: #34d399;
  --status-degraded: #fbbf24;
  --status-outage: #f87171;
  --status-operational-bg: #064e3b;
  --status-degraded-bg: #78350f;
  --status-outage-bg: #7f1d1d;
  
  /* Interactive */
  --link-color: #93a5ba;
  --link-hover: #adbdcf;
  --input-bg: #1a1f26;
  --input-border: #2d3441;
  --input-focus: #4a5568;
  --button-primary-bg: #4a5568;
  --button-primary-hover: #5a6578;
  --button-secondary-border: #4a5568;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ============================================
   NIGHT SHIFT THEME (Reduced Blue Light)
   ============================================ */
:root.night-theme {
  /* Backgrounds - Warm brown-black tones */
  --bg-primary: #1a0f0a;
  --bg-secondary: #251812;
  --bg-tertiary: #2f1f18;
  --bg-hover: #3a2820;
  --bg-active: #453228;
  
  /* Text - Warm cream/tan tones */
  --text-primary: #e8d5c4;
  --text-secondary: #c9a98a;
  --text-muted: #8d7865;
  --text-emphasis: #f5e6d8;
  
  /* Borders - Warm brown tones */
  --border-color: #3a2820;
  --border-emphasis: #4a3830;
  --divider: #2f1f18;
  
  /* Accents - Warm taupe */
  --accent-primary: #b89878;
  --accent-hover: #c8a888;
  --accent-active: #a88868;
  --accent-subtle: #6d5845;
  
  /* Status Colors - Warm alternatives (no blue/green) */
  --status-operational: #d4a574; /* Warm gold instead of green */
  --status-degraded: #e8a562; /* Warm orange-amber */
  --status-outage: #d87868; /* Warm coral-red */
  --status-operational-bg: #3d2a1a;
  --status-degraded-bg: #3d2615;
  --status-outage-bg: #3d1e1a;
  
  /* Interactive - Warm tones */
  --link-color: #c9a98a;
  --link-hover: #d9b99a;
  --input-bg: #251812;
  --input-border: #3a2820;
  --input-focus: #6d5845;
  --button-primary-bg: #6d5845;
  --button-primary-hover: #7d6855;
  --button-secondary-border: #6d5845;
  
  /* Shadows - Darker for night */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* ============================================
   AUTO THEME DETECTION
   ============================================ */
@media (prefers-color-scheme: dark) {
  :root:not(.light-theme):not(.dark-theme):not(.night-theme) {
    /* Use dark theme as default for dark mode preference */
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f26;
    --bg-tertiary: #252b35;
    --bg-hover: #2d3441;
    --bg-active: #363d4d;
    --text-primary: #e4e7eb;
    --text-secondary: #a8b3c1;
    --text-muted: #6b7785;
    --text-emphasis: #f7fafc;
    --border-color: #2d3441;
    --border-emphasis: #3d4554;
    --accent-primary: #7a8ba0;
    --accent-hover: #8fa1b5;
    --status-operational: #34d399;
    --status-degraded: #fbbf24;
    --status-outage: #f87171;
    --link-color: #93a5ba;
    --link-hover: #adbdcf;
    --input-bg: #1a1f26;
    --input-border: #2d3441;
    --input-focus: #4a5568;
    --button-primary-bg: #4a5568;
    --button-primary-hover: #5a6578;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

/* ============================================
   THEME TRANSITIONS
   ============================================ */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Disable transitions during theme switch */
.theme-switching * {
  transition: none !important;
}

/* ============================================
   THEME SELECTOR COMPONENT
   ============================================ */
.theme-selector {
  position: relative;
  display: inline-block;
}

.theme-button {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-button:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.theme-menu {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-emphasis);
  border-radius: 8px;
  padding: 0.5rem;
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.theme-menu.hidden {
  display: none;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
  text-align: left;
}

.theme-option:hover {
  background: var(--bg-hover);
}

.theme-option.active {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

.theme-option span.icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
}

/* Night shift status indicator badge */
.night-shift-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--status-degraded-bg);
  color: var(--status-degraded);
  border: 1px solid var(--status-degraded);
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.night-shift-badge::before {
  content: "🌅";
}

/* Hide night shift badge in non-night themes */
:root:not(.night-theme) .night-shift-badge {
  display: none;
}
