/* Dark/Light Theme Support */

/* Dark Theme Variables */
[data-theme="dark"] {
  /* Colors - Dark Theme */
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  --border-color: #374151;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
}

/* Dark theme adjustments for specific components */
[data-theme="dark"] .theme-toggle-icon {
  mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>') no-repeat center;
  mask-size: contain;
  -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>') no-repeat center;
  -webkit-mask-size: contain;
}

/* Enhanced shadows for dark theme */
[data-theme="dark"] {
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* Code highlighting adjustments for dark theme */
[data-theme="dark"] .prose code {
  background: var(--bg-tertiary);
  color: #fbbf24;
}

[data-theme="dark"] .prose pre {
  background: #0f172a;
  border: 1px solid var(--border-color);
}

/* Better contrast for blockquotes in dark theme */
[data-theme="dark"] .prose blockquote {
  background: var(--bg-tertiary);
  border-left-color: var(--accent-color);
}

/* Improved table styling for dark theme */
[data-theme="dark"] .prose th {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .prose th,
[data-theme="dark"] .prose td {
  border-color: var(--border-color);
}

/* Enhanced image contrast for dark theme */
[data-theme="dark"] .prose img {
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

/* Smooth theme transitions */
*,
*::before,
*::after {
  transition: 
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

/* Preserve user's theme preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    /* Colors - Dark Theme */
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --border-color: #374151;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* Enhanced shadows for dark theme */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  }
  
  :root:not([data-theme]) .theme-toggle-icon {
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>') no-repeat center;
    mask-size: contain;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>') no-repeat center;
    -webkit-mask-size: contain;
  }
  
  :root:not([data-theme]) .prose code {
    background: var(--bg-tertiary);
    color: #fbbf24;
  }
  
  :root:not([data-theme]) .prose pre {
    background: #0f172a;
    border: 1px solid var(--border-color);
  }
  
  :root:not([data-theme]) .prose blockquote {
    background: var(--bg-tertiary);
    border-left-color: var(--accent-color);
  }
  
  :root:not([data-theme]) .prose th {
    background: var(--bg-tertiary);
  }
  
  :root:not([data-theme]) .prose th,
  :root:not([data-theme]) .prose td {
    border-color: var(--border-color);
  }
  
  :root:not([data-theme]) .prose img {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: currentColor;
    --shadow-sm: 0 2px 4px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 12px 20px -4px rgb(0 0 0 / 0.5), 0 4px 8px -4px rgb(0 0 0 / 0.5);
  }
  
  .prose a {
    text-decoration-thickness: 3px;
  }
  
  .action-button,
  .nav-link {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
  
  .theme-toggle-icon,
  .progress-fill {
    transition: none;
  }
}