/* 🌙 NAMERLY DARK MODE & ACCESSIBILITY STYLES */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Light mode colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-heavy: 0 10px 25px rgba(0, 0, 0, 0.15);
  
  /* Brand colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  
  /* Animation properties */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  --animation-duration: 0.6s;
}

/* Dark mode colors */
:root.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #374151;
  --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-heavy: 0 10px 25px rgba(0, 0, 0, 0.4);
  
  /* Adjust gradients for dark mode */
  --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --gradient-secondary: linear-gradient(135deg, #ec4899 0%, #ef4444 100%);
}

/* Reduced motion preferences */
:root.reduced-motion {
  --transition-fast: 0s;
  --transition-normal: 0s;
  --transition-slow: 0s;
  --animation-duration: 0s;
}

:root.reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* High contrast mode */
:root.high-contrast {
  --bg-primary: #000000;
  --bg-secondary: #000000;
  --text-primary: #ffffff;
  --text-secondary: #ffffff;
  --primary: #ffff00;
  --border-color: #ffffff;
}

/* ===== THEME TRANSITIONS ===== */
.theme-transitions,
.theme-transitions *,
.theme-transitions *:before,
.theme-transitions *:after {
  transition: background-color var(--transition-normal),
              color var(--transition-normal),
              border-color var(--transition-normal),
              box-shadow var(--transition-normal) !important;
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
  position: relative;
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 25px;
  width: 60px;
  height: 30px;
  cursor: pointer;
  transition: all var(--transition-normal);
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.theme-toggle:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.toggle-track {
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  border-radius: 23px;
  position: relative;
  overflow: hidden;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  transition: transform var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.theme-toggle.dark .toggle-thumb {
  transform: translateX(28px);
}

.sun-icon {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.moon-icon {
  position: absolute;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.theme-toggle.dark .sun-icon {
  opacity: 0;
}

.theme-toggle.dark .moon-icon {
  opacity: 1;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 4px;
  transition: top var(--transition-fast);
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* Enhanced focus indicators */
.keyboard-navigation *:focus {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

.keyboard-navigation button:focus,
.keyboard-navigation a:focus,
.keyboard-navigation input:focus,
.keyboard-navigation textarea:focus,
.keyboard-navigation select:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3) !important;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== ENHANCED ANIMATIONS ===== */

/* Scroll animations */
.animate-in {
  animation: slideInUp var(--animation-duration) ease-out forwards;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hover effects */
.hovered {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

/* Loading states */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: loading-shimmer 1.5s infinite;
}

.dark-mode .loading::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
}

@keyframes loading-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ===== COMPONENT UPDATES FOR DARK MODE ===== */

/* Update existing components */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.container,
.main-content {
  background-color: var(--bg-primary);
}

.card,
.category-card,
.generator-card {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-light);
}

.card:hover,
.category-card:hover {
  box-shadow: var(--shadow-medium);
}

button,
.btn {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
  transition: all var(--transition-fast);
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

input,
textarea,
select {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Text colors */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
}

p, span, div {
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted);
}

/* Links */
a {
  color: var(--primary);
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* Borders */
.border,
hr {
  border-color: var(--border-color);
}

/* ===== RESPONSIVE DARK MODE ===== */
@media (max-width: 768px) {
  .theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    width: 50px;
    height: 25px;
  }
  
  .toggle-thumb {
    width: 19px;
    height: 19px;
    font-size: 10px;
  }
  
  .theme-toggle.dark .toggle-thumb {
    transform: translateX(23px);
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .theme-toggle,
  .skip-link {
    display: none !important;
  }
  
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }
}

/* ===== PREFERENCE QUERIES ===== */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast support */
@media (prefers-contrast: high) {
  :root {
    --border-color: currentColor;
  }
  
  button,
  .btn {
    border: 2px solid currentColor;
  }
  
  .card,
  .category-card {
    border: 2px solid currentColor;
  }
}

/* Light mode preference */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
  }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    color-scheme: dark;
  }
}
