/* =========================================================
   Care Navigator — Dark Mode System
   Version: 1.0
   System-aware dark mode with smooth transitions
   ========================================================= */

:root {
  /* Light mode colors (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  
  --accent-primary: #0ea5e9;
  --accent-hover: #0284c7;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
}

/* Dark mode colors */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  
  --border-primary: #334155;
  --border-secondary: #475569;
  
  --accent-primary: #38bdf8;
  --accent-hover: #0ea5e9;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

/* Smooth transitions for theme changes */
body,
.site-header-modern,
.modern-brand,
.nav-link,
.pricing-card,
.pricing-faq-item,
.auth-form-panel,
.dashboard-card {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================================
   DARK MODE TOGGLE BUTTON
   ============================================ */

.theme-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  transform: scale(1.05);
}

.theme-toggle-icon {
  width: 20px;
  height: 20px;
  transition: all 0.3s ease;
}

/* Sun icon (light mode) */
.theme-toggle-sun {
  stroke: #f59e0b;
  display: block;
}

/* Moon icon (dark mode) */
.theme-toggle-moon {
  stroke: #818cf8;
  display: none;
}

[data-theme="dark"] .theme-toggle-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle-moon {
  display: block;
}

/* ============================================
   DARK MODE STYLES FOR COMPONENTS
   ============================================ */

/* Headers */
[data-theme="dark"] .site-header-modern {
  background: var(--bg-primary);
  border-bottom-color: var(--border-primary);
}

/* Navigation */
[data-theme="dark"] .nav-link {
  color: var(--text-secondary);
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.is-active {
  color: var(--accent-primary);
}

/* Cards */
[data-theme="dark"] .pricing-card,
[data-theme="dark"] .pricing-faq-item,
[data-theme="dark"] .dashboard-card {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
  color: var(--text-primary);
}

[data-theme="dark"] .pricing-card:hover,
[data-theme="dark"] .pricing-faq-item:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.15);
}

/* Text */
[data-theme="dark"] .pricing-card-title,
[data-theme="dark"] .pricing-faq-question,
[data-theme="dark"] .pricing-hero-title,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
  color: var(--text-primary);
}

[data-theme="dark"] .pricing-card-description,
[data-theme="dark"] .pricing-faq-answer,
[data-theme="dark"] .pricing-hero-subtitle,
[data-theme="dark"] p {
  color: var(--text-secondary);
}

/* Forms */
[data-theme="dark"] .auth-input-wrapper {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

[data-theme="dark"] .auth-input {
  background: transparent;
  color: var(--text-primary);
}

[data-theme="dark"] .auth-input::placeholder {
  color: var(--text-tertiary);
}

/* Tables */
[data-theme="dark"] .pricing-comparison-table-wrapper {
  background: var(--bg-secondary);
}

[data-theme="dark"] .pricing-table-header {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-primary);
}

[data-theme="dark"] .pricing-table-feature {
  color: var(--text-primary);
  border-color: var(--border-primary);
}

[data-theme="dark"] .pricing-table-value {
  color: var(--text-secondary);
  border-color: var(--border-primary);
}

/* Sections */
[data-theme="dark"] .pricing-hero,
[data-theme="dark"] .pricing-comparison-section,
[data-theme="dark"] .pricing-faq-section {
  background: var(--bg-primary);
}

/* Buttons maintain their gradient in dark mode for contrast */
[data-theme="dark"] .pricing-cta-secondary {
  background: var(--bg-secondary);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

[data-theme="dark"] .pricing-cta-secondary:hover {
  background: var(--bg-tertiary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes theme-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.theme-transitioning {
  animation: theme-fade-in 0.3s ease;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  body,
  .site-header-modern,
  .theme-toggle,
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* System preference detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    
    --border-primary: #334155;
    --border-secondary: #475569;
    
    --accent-primary: #38bdf8;
    --accent-hover: #0ea5e9;
  }
}
