/* Theme Management System */

/* Light Theme (Default) */
:root,
[data-theme="light"] {
  /* Primary Colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-foreground: #ffffff;
  
  /* Secondary Colors */
  --secondary: #64748b;
  --secondary-hover: #475569;
  --secondary-foreground: #ffffff;
  
  /* Background Colors */
  --background: #ffffff;
  --foreground: #1e293b;
  
  /* Card Colors */
  --card: #ffffff;
  --card-foreground: #1e293b;
  
  /* Border Colors */
  --border: #e2e8f0;
  --input: #e2e8f0;
  
  /* Muted Colors */
  --muted: #f8fafc;
  --muted-foreground: #64748b;
  
  /* Accent Colors */
  --accent: #f1f5f9;
  --accent-foreground: #0f172a;
  
  /* Destructive Colors */
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  
  /* Success Colors */
  --success: #10b981;
  --success-foreground: #ffffff;
  
  /* Warning Colors */
  --warning: #f59e0b;
  --warning-foreground: #ffffff;
  
  /* Info Colors */
  --info: #3b82f6;
  --info-foreground: #ffffff;
  
  /* Ring Colors */
  --ring: #3b82f6;
  
  /* Radius */
  --radius: 0.75rem;
}

/* Dark Theme */
[data-theme="dark"] {
  /* Primary Colors */
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-foreground: #1e293b;
  
  /* Secondary Colors */
  --secondary: #94a3b8;
  --secondary-hover: #cbd5e1;
  --secondary-foreground: #1e293b;
  
  /* Background Colors */
  --background: #0f172a;
  --foreground: #f8fafc;
  
  /* Card Colors */
  --card: #1e293b;
  --card-foreground: #f8fafc;
  
  /* Border Colors */
  --border: #334155;
  --input: #334155;
  
  /* Muted Colors */
  --muted: #1e293b;
  --muted-foreground: #94a3b8;
  
  /* Accent Colors */
  --accent: #334155;
  --accent-foreground: #f8fafc;
  
  /* Destructive Colors */
  --destructive: #f87171;
  --destructive-foreground: #1e293b;
  
  /* Success Colors */
  --success: #34d399;
  --success-foreground: #1e293b;
  
  /* Warning Colors */
  --warning: #fbbf24;
  --warning-foreground: #1e293b;
  
  /* Info Colors */
  --info: #60a5fa;
  --info-foreground: #1e293b;
  
  /* Ring Colors */
  --ring: #60a5fa;
}

/* Auto Theme (follows system preference) */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    /* Primary Colors */
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --primary-foreground: #1e293b;
    
    /* Secondary Colors */
    --secondary: #94a3b8;
    --secondary-hover: #cbd5e1;
    --secondary-foreground: #1e293b;
    
    /* Background Colors */
    --background: #0f172a;
    --foreground: #f8fafc;
    
    /* Card Colors */
    --card: #1e293b;
    --card-foreground: #f8fafc;
    
    /* Border Colors */
    --border: #334155;
    --input: #334155;
    
    /* Muted Colors */
    --muted: #1e293b;
    --muted-foreground: #94a3b8;
    
    /* Accent Colors */
    --accent: #334155;
    --accent-foreground: #f8fafc;
    
    /* Destructive Colors */
    --destructive: #f87171;
    --destructive-foreground: #1e293b;
    
    /* Success Colors */
    --success: #34d399;
    --success-foreground: #1e293b;
    
    /* Warning Colors */
    --warning: #fbbf24;
    --warning-foreground: #1e293b;
    
    /* Info Colors */
    --info: #60a5fa;
    --info-foreground: #1e293b;
    
    /* Ring Colors */
    --ring: #60a5fa;
  }
}

/* Theme Toggle Button Styles */
.theme-toggle {
  position: relative;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  color: var(--foreground);
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.1);
}

.theme-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--ring);
}

/* Theme Icons */
.theme-icon {
  transition: all 0.3s ease;
}

[data-theme="light"] .theme-icon-moon {
  opacity: 1;
}

[data-theme="light"] .theme-icon-sun {
  opacity: 0;
}

[data-theme="dark"] .theme-icon-moon {
  opacity: 0;
}

[data-theme="dark"] .theme-icon-sun {
  opacity: 1;
}

/* Smooth transitions for theme changes */
* {
  transition: background-color 0.3s ease, 
              color 0.3s ease, 
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Theme-specific component overrides */

/* Navigation in dark theme */
[data-theme="dark"] .navbar {
  background-color: rgba(30, 41, 59, 0.8);
}

/* Hero section gradients */
[data-theme="dark"] .hero-section {
  background: linear-gradient(135deg, var(--background) 0%, var(--muted) 100%);
}

[data-theme="dark"] .hero-section::before {
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  opacity: 0.1;
}

/* Card shadows in dark theme */
[data-theme="dark"] .service-card,
[data-theme="dark"] .about-stats,
[data-theme="dark"] .contact-form {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .service-card:hover,
[data-theme="dark"] .portfolio-item:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

/* Modal backdrop in dark theme */
[data-theme="dark"] .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.7);
}

/* Loading spinner in dark theme */
[data-theme="dark"] .loading-spinner {
  background: rgba(15, 23, 42, 0.9);
}

/* Cookie consent in dark theme */
[data-theme="dark"] .cookie-consent {
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.3), 0 -2px 4px -2px rgba(0, 0, 0, 0.3);
}

/* Form controls in dark theme */
[data-theme="dark"] .form-control {
  background-color: var(--muted);
}

[data-theme="dark"] .form-control:focus {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* Button hover effects in dark theme */
[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 10px 15px -3px rgba(96, 165, 250, 0.3), 0 4px 6px -4px rgba(96, 165, 250, 0.3);
}

/* Social links in dark theme */
[data-theme="dark"] .social-links a:hover {
  color: var(--primary);
  text-shadow: 0 0 8px var(--primary);
}

/* Portfolio overlay in dark theme */
[data-theme="dark"] .portfolio-overlay {
  background: linear-gradient(
    135deg,
    rgba(96, 165, 250, 0.9),
    rgba(59, 130, 246, 0.9)
  );
}

/* Utility classes for theme-aware components */
.theme-bg {
  background-color: var(--background);
}

.theme-fg {
  color: var(--foreground);
}

.theme-card {
  background-color: var(--card);
  color: var(--card-foreground);
}

.theme-muted {
  color: var(--muted-foreground);
}

.theme-border {
  border-color: var(--border);
}

.theme-primary {
  color: var(--primary);
}

.theme-secondary {
  color: var(--secondary);
}

/* Accessibility improvements */
.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;
}

/* Focus indicators */
.focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --muted-foreground: #000000;
  }
  
  [data-theme="dark"] {
    --border: #ffffff;
    --muted-foreground: #ffffff;
  }
}