/* ==============================================
   UNIFIED THEME SYSTEM - CSS CUSTOM PROPERTIES
   ============================================== */

/* Day Theme (Default) - Root Variables */
:root {
  /* Text Colors */
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: rgba(255, 255, 255, 0.95);
  --bg-tertiary: #f8f9fa;
  --bg-gradient-start: #ffffff;
  --bg-gradient-end: #ffffff;
  
  /* Accent Colors */
  --accent-primary: #4169E1;
  --accent-secondary: #667eea;
  --accent-tertiary: #764ba2;
  
  /* Border Colors */
  --border-color: #e9ecef;
  --border-strong: #333333;
  --border-light: #cccccc;
  
  /* Shadow Colors */
  --shadow-color: rgba(0, 0, 0, 0.2);
  --shadow-strong: rgba(0, 0, 0, 0.3);
  --shadow-light: rgba(0, 0, 0, 0.1);
  
  /* Interactive States */
  --hover-overlay: rgba(65, 105, 225, 0.1);
  --active-overlay: rgba(65, 105, 225, 0.2);
  
  /* Special Effects */
  --glow-color: rgba(65, 105, 225, 0.5);
  --text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  --holo-blend-mode: multiply;
}

/* Day Theme - Explicit body selector to ensure proper theme switching */
body.day-mode {
  /* Text Colors */
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: rgba(255, 255, 255, 0.95);
  --bg-tertiary: #f8f9fa;
  --bg-gradient-start: #ffffff;
  --bg-gradient-end: #ffffff;
  
  /* Accent Colors */
  --accent-primary: #4169E1;
  --accent-secondary: #667eea;
  --accent-tertiary: #764ba2;
  
  /* Border Colors */
  --border-color: #e9ecef;
  --border-strong: #333333;
  --border-light: #cccccc;
  
  /* Shadow Colors */
  --shadow-color: rgba(0, 0, 0, 0.2);
  --shadow-strong: rgba(0, 0, 0, 0.3);
  --shadow-light: rgba(0, 0, 0, 0.1);
  
  /* Interactive States */
  --hover-overlay: rgba(65, 105, 225, 0.1);
  --active-overlay: rgba(65, 105, 225, 0.2);
  
  /* Special Effects */
  --glow-color: rgba(65, 105, 225, 0.5);
  --text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  --holo-blend-mode: multiply;
}

/* Night Theme */
body.night-mode {
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-tertiary: #cccccc;
  
  --bg-primary: #1a1a1a;
  --bg-secondary: rgba(42, 42, 42, 0.95);
  --bg-tertiary: #2d2d2d;
  --bg-gradient-start: #2c3e50;
  --bg-gradient-end: #34495e;
  
  --accent-primary: #4169E1;
  --accent-secondary: #5dade2;
  --accent-tertiary: #3498db;
  
  --border-color: #404040;
  --border-strong: #ffffff;
  --border-light: #666666;
  
  --shadow-color: rgba(255, 255, 255, 0.2);
  --shadow-strong: rgba(255, 255, 255, 0.3);
  --shadow-light: rgba(255, 255, 255, 0.1);
  
  --hover-overlay: rgba(255, 255, 255, 0.1);
  --active-overlay: rgba(255, 255, 255, 0.2);
  
  --glow-color: rgba(255, 255, 255, 0.5);
  --text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  --holo-blend-mode: screen;
}

/* Monochrome Theme */
body.monochrome-mode {
  --text-primary: #8b4513;
  --text-secondary: #654321;
  --text-tertiary: #a0522d;
  
  --bg-primary: #f5f5dc;
  --bg-secondary: rgba(245, 245, 220, 0.95);
  --bg-tertiary: #deb887;
  --bg-gradient-start: #f5f5dc;
  --bg-gradient-end: #deb887;
  
  --accent-primary: #654321;
  --accent-secondary: #8b4513;
  --accent-tertiary: #a0522d;
  
  --border-color: #d2b48c;
  --border-strong: #8b4513;
  --border-light: #cd853f;
  
  --shadow-color: rgba(139, 69, 19, 0.3);
  --shadow-strong: rgba(139, 69, 19, 0.4);
  --shadow-light: rgba(139, 69, 19, 0.2);
  
  --hover-overlay: rgba(139, 69, 19, 0.1);
  --active-overlay: rgba(139, 69, 19, 0.15);
  
  --glow-color: rgba(139, 69, 19, 0.5);
  --text-shadow: 2px 2px 4px rgba(139, 69, 19, 0.3);
}

/* Cyberpunk Theme */
body.cyberpunk-mode {
  --text-primary: #00ffff;
  --text-secondary: #ff00ff;
  --text-tertiary: #ffff00;
  
  --bg-primary: #0f0f23;
  --bg-secondary: rgba(26, 13, 46, 0.95);
  --bg-tertiary: #1a0d2e;
  --bg-gradient-start: #0f0f23;
  --bg-gradient-end: #1a0d2e;
  
  --accent-primary: #00ffff;
  --accent-secondary: #ff00ff;
  --accent-tertiary: #ffff00;
  
  --border-color: rgba(255, 0, 255, 0.4);
  --border-strong: #ff00ff;
  --border-light: #00ffff;
  
  --shadow-color: rgba(255, 0, 255, 0.3);
  --shadow-strong: rgba(255, 0, 255, 0.5);
  --shadow-light: rgba(255, 0, 255, 0.2);
  
  --hover-overlay: rgba(0, 255, 255, 0.1);
  --active-overlay: rgba(0, 255, 255, 0.2);
  
  --glow-color: rgba(0, 255, 255, 0.6);
  --text-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
  --holo-blend-mode: screen;
}

/* Blueprint Theme */
body.blueprint-mode {
  --text-primary: #ffffff;
  --text-secondary: #e5e7eb;
  --text-tertiary: #93c5fd;
  
  --bg-primary: #1e3a8a;
  --bg-secondary: rgba(30, 58, 138, 0.95);
  --bg-tertiary: #3b82f6;
  --bg-gradient-start: #0f172a;
  --bg-gradient-end: #3b82f6;
  
  --accent-primary: #ffffff;
  --accent-secondary: #93c5fd;
  --accent-tertiary: #3b82f6;
  
  --border-color: rgba(255, 255, 255, 0.3);
  --border-strong: #ffffff;
  --border-light: #93c5fd;
  
  --shadow-color: rgba(255, 255, 255, 0.2);
  --shadow-strong: rgba(255, 255, 255, 0.4);
  --shadow-light: rgba(255, 255, 255, 0.1);
  
  --hover-overlay: rgba(255, 255, 255, 0.1);
  --active-overlay: rgba(255, 255, 255, 0.15);
  
  --glow-color: rgba(255, 255, 255, 0.5);
  --text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  --holo-blend-mode: screen;
}

/* Theme Toggle Styles */

.theme-selector {
  position: fixed;
  top: 70px;
  right: 80px;
  z-index: 1000;
  font-family: 'VT323', monospace;
}

.theme-toggle {
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  border: 2px solid var(--border-strong);
  border-radius: 15px;
  width: 120px;
  height: 32px;
  font-size: 1rem;
  font-family: 'VT323', monospace;
  cursor: pointer;
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px var(--shadow-color), 0 2px 4px var(--shadow-light);
  position: relative;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  background: var(--bg-secondary);
  box-shadow: 0 6px 20px var(--shadow-color), 0 4px 8px var(--shadow-color);
  border-color: var(--accent-primary);
}

.theme-toggle.active {
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}

.theme-text {
  color: var(--text-primary);
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
  font-weight: bold;
  z-index: 2;
  text-align: center;
  width: 100%;
}

.theme-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 2px solid var(--border-strong);
  border-radius: 15px;
  min-width: 160px;
  box-shadow: 0 8px 25px var(--shadow-color);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
  overflow: hidden;
}

.theme-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
  border-bottom: 1px solid var(--border-color);
  font-size: 1rem;
  color: var(--text-primary);
}

.theme-option:last-child {
  border-bottom: none;
}

.theme-option:hover {
  background: var(--hover-overlay);
  color: var(--accent-primary);
  transform: translateX(5px);
}

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

.theme-option .theme-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  margin-left: 8px;
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.theme-option:hover .theme-preview {
  transform: scale(1.1);
  border-color: var(--accent-primary);
}

.theme-preview.day {
  background: linear-gradient(45deg, #fff 50%, #f0f0f0 50%);
}

.theme-preview.night {
  background: linear-gradient(45deg, #1a1a1a 50%, #333 50%);
}

.theme-preview.monochrome {
  background: linear-gradient(45deg, #f5f5dc 50%, #deb887 50%);
}

.theme-preview.cyberpunk {
  background: linear-gradient(45deg, #ff00ff, #00ffff);
}

.theme-preview.blueprint {
  background: linear-gradient(45deg, #1e3a8a, #3b82f6);
  border: 1px solid #ffffff;
}

.theme-option.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.theme-option.locked:hover {
  background: transparent;
  transform: none;
}

.locked-preview {
  background: linear-gradient(45deg, #374151, #6b7280);
  color: #9ca3af;
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.2;
}

/* Theme-specific toggle button styling - matches active theme */
.theme-toggle[data-theme="day"] {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.theme-toggle[data-theme="day"] .theme-text {
  color: var(--text-primary);
}

.theme-toggle[data-theme="night"] {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  box-shadow: 0 4px 15px var(--shadow-color);
}

.theme-toggle[data-theme="night"] .theme-text {
  color: var(--text-primary);
}

.theme-toggle[data-theme="monochrome"] {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  box-shadow: 5px 5px 0px var(--accent-tertiary);
}

.theme-toggle[data-theme="monochrome"] .theme-text {
  color: var(--text-primary);
}

.theme-toggle[data-theme="cyberpunk"] {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  box-shadow: 0 0 15px var(--glow-color), 0 4px 15px var(--shadow-color);
}

.theme-toggle[data-theme="cyberpunk"] .theme-text {
  color: var(--accent-primary);
  text-shadow: var(--text-shadow);
}

.theme-toggle[data-theme="blueprint"] {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  box-shadow: 0 0 15px var(--glow-color);
}

.theme-toggle[data-theme="blueprint"] .theme-text {
  color: var(--text-primary);
  text-shadow: var(--text-shadow);
}

/* Smooth theme transitions - Applied globally for seamless color morphing */
* {
  transition: 
    background-color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    border-color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    box-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    text-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    background 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    fill 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    stroke 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

*::before,
*::after {
  transition: 
    background-color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    border-color 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    box-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    text-shadow 0.8s cubic-bezier(0.4, 0.0, 0.2, 1),
    background 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

body.theme-transitioning {
  transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* All theme colors now handled by CSS variables defined at the top of this file.
   No hardcoded colors below - everything uses var(--text-primary), var(--bg-primary), etc. */

/* Responsive */
@media (max-width: 768px) {
  .theme-selector {
    right: 15px;
    top: 15px;
  }

  .theme-toggle {
    width: 100px;
    height: 28px;
    font-size: 0.9rem;
  }

  .theme-dropdown {
    min-width: 140px;
  }

  .theme-option {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .theme-selector {
    right: 10px;
    top: 10px;
  }

  .theme-toggle {
    width: 90px;
    height: 26px;
    font-size: 0.8rem;
  }

  .theme-dropdown {
    min-width: 120px;
  }

  .theme-option {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .theme-preview {
    width: 16px;
    height: 16px;
  }
}