/* ==========================================================
   Syndeo Dashboard — Theme Toggle Component
   Tri-state switcher: Light / Dark / Auto
   ========================================================== */

.theme-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 2rem;
  padding: 0.25rem 0.4rem;
  height: 2rem;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.theme-switcher {
  --theme-sun-color: #ff8c00;
  --theme-sun-glow: rgba(255, 140, 0, 0.45);
  --theme-moon-color: #3b82f6;
  --theme-moon-glow: rgba(59, 130, 246, 0.45);
  --theme-default-glow: rgba(91, 140, 255, 0.35);
}

/* Hidden from sight only: they're what the keyboard and screen readers use
   (display: none had left the switch unreachable and nameless). */
.theme-switcher input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

.theme-switcher input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  border-radius: 1rem;
}

.theme-switcher label {
  --theme-hover-color: var(--accent-color);
  --theme-hover-glow: var(--theme-default-glow);
  cursor: pointer;
  padding: 0.3rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted) !important;
  transition: color 0.25s ease, text-shadow 0.25s ease, filter 0.25s ease;
  position: relative;
  z-index: 1;
}

.theme-switcher label i {
  color: inherit;
  transition: color 0.25s ease, text-shadow 0.25s ease, filter 0.25s ease;
}

.theme-switcher input[type="radio"]:checked + label {
  color: var(--accent-color) !important;
}

/* Make light mode icon orange when active */
#theme-light:checked + label,
#theme-mobile-light:checked + label {
  color: var(--theme-sun-color) !important;
}

/* Auto mode should reflect the resolved theme color */
[data-theme='light'] #theme-auto:checked + label,
[data-bs-theme='light'] #theme-auto:checked + label,
[data-theme='light'] #theme-mobile-auto:checked + label,
[data-bs-theme='light'] #theme-mobile-auto:checked + label {
  color: var(--theme-sun-color) !important;
}

[data-theme='dark'] #theme-auto:checked + label,
[data-bs-theme='dark'] #theme-auto:checked + label,
[data-theme='dark'] #theme-mobile-auto:checked + label,
[data-bs-theme='dark'] #theme-mobile-auto:checked + label {
  color: var(--theme-moon-color) !important;
}

.theme-switcher label:hover,
.theme-switcher input[type="radio"]:checked + label:hover {
  color: var(--theme-hover-color) !important;
  text-shadow: 0 0 8px var(--theme-hover-glow);
  filter: drop-shadow(0 0 6px var(--theme-hover-glow));
}

.theme-switcher label:hover i,
.theme-switcher input[type="radio"]:checked + label:hover i {
  color: var(--theme-hover-color) !important;
  text-shadow: 0 0 8px var(--theme-hover-glow);
  filter: drop-shadow(0 0 6px var(--theme-hover-glow));
}

.theme-switcher label:hover .theme-icon,
.theme-switcher input[type="radio"]:checked + label:hover .theme-icon {
  filter: drop-shadow(0 0 6px var(--theme-hover-glow));
}

#theme-light + label,
#theme-mobile-light + label {
  --theme-hover-color: var(--theme-sun-color);
  --theme-hover-glow: var(--theme-sun-glow);
}

#theme-dark + label,
#theme-mobile-dark + label {
  --theme-hover-color: var(--theme-moon-color);
  --theme-hover-glow: var(--theme-moon-glow);
}

@media (prefers-color-scheme: light) {
  #theme-auto + label,
  #theme-mobile-auto + label {
    --theme-hover-color: var(--theme-sun-color);
    --theme-hover-glow: var(--theme-sun-glow);
  }
}

@media (prefers-color-scheme: dark) {
  #theme-auto + label,
  #theme-mobile-auto + label {
    --theme-hover-color: var(--theme-moon-color);
    --theme-hover-glow: var(--theme-moon-glow);
  }
}

/* SVG icons */
.theme-icon {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* Slider animation */
.theme-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(33.333% - 4px);
  height: calc(100% - 4px);
  background: var(--accent-color);
  border-radius: 1rem;
  z-index: 0;
  transition: all 0.3s ease;
  opacity: 0.2;
}

#theme-light:checked ~ .theme-slider,
#theme-mobile-light:checked ~ .theme-slider {
  transform: translateX(0);
}

#theme-dark:checked ~ .theme-slider,
#theme-mobile-dark:checked ~ .theme-slider {
  transform: translateX(100%);
}

#theme-auto:checked ~ .theme-slider,
#theme-mobile-auto:checked ~ .theme-slider {
  transform: translateX(200%);
}

/* Auto slider should match the resolved theme color */
[data-theme='light'] #theme-auto:checked ~ .theme-slider,
[data-bs-theme='light'] #theme-auto:checked ~ .theme-slider,
[data-theme='light'] #theme-mobile-auto:checked ~ .theme-slider,
[data-bs-theme='light'] #theme-mobile-auto:checked ~ .theme-slider {
  background: var(--theme-sun-color);
}

[data-theme='dark'] #theme-auto:checked ~ .theme-slider,
[data-bs-theme='dark'] #theme-auto:checked ~ .theme-slider,
[data-theme='dark'] #theme-mobile-auto:checked ~ .theme-slider,
[data-bs-theme='dark'] #theme-mobile-auto:checked ~ .theme-slider {
  background: var(--theme-moon-color);
}

/* Dark mode adjustments */
[data-theme='dark'] .theme-switcher,
[data-bs-theme='dark'] .theme-switcher {
  background: var(--bg-secondary);
  border-color: var(--border-color);
}

[data-theme='dark'] .theme-switcher label,
[data-bs-theme='dark'] .theme-switcher label {
  color: var(--text-muted) !important;
}

[data-theme='dark'] .theme-switcher input[type="radio"]:checked + label,
[data-bs-theme='dark'] .theme-switcher input[type="radio"]:checked + label {
  color: var(--accent-color) !important;
}

[data-theme='dark'] .theme-icon,
[data-bs-theme='dark'] .theme-icon {
  filter: brightness(1.3);
}

[data-theme='dark'] .theme-switcher label:hover .theme-icon,
[data-bs-theme='dark'] .theme-switcher label:hover .theme-icon,
[data-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover .theme-icon,
[data-bs-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover .theme-icon {
  filter: brightness(1.3) drop-shadow(0 0 6px var(--theme-hover-glow));
}

[data-theme='dark'] .theme-switcher label:hover,
[data-bs-theme='dark'] .theme-switcher label:hover,
[data-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover,
[data-bs-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover {
  color: var(--theme-hover-color) !important;
  text-shadow: 0 0 8px var(--theme-hover-glow);
  filter: drop-shadow(0 0 6px var(--theme-hover-glow));
}

[data-theme='dark'] .theme-switcher label:hover i,
[data-bs-theme='dark'] .theme-switcher label:hover i,
[data-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover i,
[data-bs-theme='dark'] .theme-switcher input[type="radio"]:checked + label:hover i {
  color: var(--theme-hover-color) !important;
  text-shadow: 0 0 8px var(--theme-hover-glow);
  filter: drop-shadow(0 0 6px var(--theme-hover-glow));
}

/* Smooth theme transition */
html {
  transition: background-color 0.25s ease, color 0.25s ease;
}
