/* ===========================================
   Theme Toggle - Refined Design
   =========================================== */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.theme-toggle:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-hover);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-surface);
}

.theme-toggle__icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform var(--duration-normal) var(--ease-spring);
}

.theme-toggle:hover .theme-toggle__icon {
  transform: rotate(15deg);
}

/* Show/hide icons based on theme */
[data-theme="dark"] .theme-toggle__icon--light,
[data-theme="light"] .theme-toggle__icon--dark {
  display: none;
}

/* ===========================================
   Sidebar Theme Toggle
   =========================================== */

.nav__item[data-action*="theme#toggle"] {
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.nav__item[data-action*="theme#toggle"]:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.nav__item[data-action*="theme#toggle"] .nav__icon {
  margin-right: var(--spacing-md);
  transition: transform var(--duration-fast) var(--ease-spring);
}

.nav__item[data-action*="theme#toggle"]:hover .nav__icon {
  transform: scale(1.1) rotate(15deg);
}

/* Only show the appropriate icon based on current theme */
[data-theme="dark"] .nav__item[data-action*="theme#toggle"] .theme-toggle__icon--dark,
[data-theme="light"] .nav__item[data-action*="theme#toggle"] .theme-toggle__icon--light {
  display: block;
}

[data-theme="dark"] .nav__item[data-action*="theme#toggle"] .theme-toggle__icon--light,
[data-theme="light"] .nav__item[data-action*="theme#toggle"] .theme-toggle__icon--dark {
  display: none;
}

/* ===========================================
   App Layout Theme Transition
   =========================================== */

.app-layout {
  transition:
    background-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle__icon,
  .nav__item[data-action*="theme#toggle"],
  .app-layout {
    transition: none;
  }
}
