/**
 * Enhanced Dark Mode with Smooth Transitions
 * Provides beautiful theme switching and color scheme support
 */

:root {
  /* Light mode colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-primary: rgba(0, 0, 0, 0.1);
  --border-secondary: rgba(0, 0, 0, 0.05);

  /* Transition timings */
  --theme-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode colors */
[data-theme="dark"],
.app-shell-dark {
  --bg-primary: #030308;
  --bg-secondary: #0a0a14;
  --bg-tertiary: #111120;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-tertiary: #707070;
  --border-primary: rgba(255, 255, 255, 0.1);
  --border-secondary: rgba(255, 255, 255, 0.05);
}

/* Smooth transitions for theme changes */
body,
.app-container,
.app-header,
.feature-card,
.hero-section,
.site-footer {
  transition:
    background-color var(--theme-transition),
    color var(--theme-transition),
    border-color var(--theme-transition);
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

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

.theme-toggle-icon {
  font-size: 1.5rem;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle.switching .theme-toggle-icon {
  transform: rotate(360deg);
}

/* Theme transition overlay */
.theme-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.2) 0%, transparent 70%);
  opacity: 0;
  pointer-events: none;
  z-index: 9998;
  transition: opacity 0.6s ease;
}

.theme-transition-overlay.active {
  opacity: 1;
}

/* Glassmorphism adjustments for dark mode */
[data-theme="dark"] .app-header,
.app-shell-dark .app-header {
  background: rgba(3, 3, 8, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .feature-card,
.app-shell-dark .feature-card {
  background: rgba(17, 17, 32, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .feature-card:hover,
.app-shell-dark .feature-card:hover {
  background: rgba(17, 17, 32, 0.8);
  border-color: rgba(59, 130, 246, 0.3);
}

/* Respect system preferences */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #030308;
    --bg-secondary: #0a0a14;
    --bg-tertiary: #111120;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --border-primary: rgba(255, 255, 255, 0.1);
    --border-secondary: rgba(255, 255, 255, 0.05);
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-primary: rgba(0, 0, 0, 0.3);
  }

  [data-theme="dark"],
  .app-shell-dark {
    --border-primary: rgba(255, 255, 255, 0.3);
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .theme-toggle {
    width: 44px;
    height: 44px;
    top: max(0.75rem, env(safe-area-inset-top));
    right: 0.75rem;
  }

  .theme-toggle-icon {
    font-size: 1.25rem;
  }
}
