/* Theme Manager Styles */
.theme-toggle {
  position: relative;
  z-index: 100;
}

.theme-toggle-container {
  display: flex;
  background: var(--bg-light, #f8f9fa);
  border-radius: 8px;
  border: 1px solid var(--border-color, #e1e5e9);
  padding: 0.25rem;
  gap: 0.25rem;
}

.theme-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #666);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
}

.theme-btn:hover {
  background: var(--bg-lighter, #ffffff);
  color: var(--text-color, #333);
}

.theme-btn:focus {
  outline: 2px solid var(--focus-color, #4158D0);
  outline-offset: 2px;
}

.theme-btn:focus:not(:focus-visible) {
  outline: none;
}

.theme-btn:focus-visible {
  outline: 2px solid var(--focus-color, #4158D0);
  outline-offset: 2px;
}

.theme-btn.active {
  background: var(--brand-color, #4158D0);
  color: white;
  box-shadow: 0 2px 4px rgba(65, 88, 208, 0.3);
}

.theme-icon {
  font-size: 1.125rem;
  line-height: 1;
}

.theme-label {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Compact variant */
.theme-toggle--compact .theme-btn {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
}

.theme-toggle--compact .theme-label {
  display: none;
}

/* Minimal variant */
.theme-toggle--minimal .theme-btn {
  padding: 0.5rem;
  border-radius: 50%;
  min-width: 2.5rem;
  height: 2.5rem;
  justify-content: center;
}

.theme-toggle--minimal .theme-label {
  display: none;
}

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

/* Floating variant */
.theme-toggle--floating {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-light, #f8f9fa);
  border-radius: 8px;
  border: 1px solid var(--border-color, #e1e5e9);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.theme-toggle--floating .theme-toggle-container {
  border: none;
  background: transparent;
  padding: 0.125rem;
  gap: 0.125rem;
}

.theme-toggle--floating .theme-btn {
  background: transparent;
}

.theme-toggle--floating .theme-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle--floating .theme-btn.active {
  background: var(--brand-color, #4158D0);
}

/* Header variant */
.theme-toggle--header {
  display: flex;
  align-items: center;
}

.theme-toggle--header .theme-toggle-container {
  background: transparent;
  border: none;
  padding: 0;
  gap: 0;
}

.theme-toggle--header .theme-btn {
  background: transparent;
  border-radius: 0;
  padding: 0.5rem;
  margin: 0;
}

.theme-toggle--header .theme-btn.active {
  background: var(--bg-light, #f8f9fa);
  color: var(--brand-color, #4158D0);
}

/* Dark theme adjustments */
[data-theme="dark"] .theme-toggle-container {
  background: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] .theme-btn {
  color: #aaa;
}

[data-theme="dark"] .theme-btn:hover {
  background: #333;
  color: #e0e0e0;
}

[data-theme="dark"] .theme-btn.active {
  background: #667eea;
  color: white;
}

[data-theme="dark"] .theme-toggle--floating {
  background: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] .theme-toggle--header .theme-btn.active {
  background: #333;
  color: #667eea;
}

/* Smooth transitions for theme changes */
:root {
  --transition-duration: 300ms;
  --transition-timing: ease;
}

html {
  transition: background-color var(--transition-duration) var(--transition-timing),
              color var(--transition-duration) var(--transition-timing);
}

body {
  transition: background-color var(--transition-duration) var(--transition-timing),
              color var(--transition-duration) var(--transition-timing),
              border-color var(--transition-duration) var(--transition-timing);
}

/* Component transitions */
.site-header,
.post-card,
.topic-card,
.hero,
.footer {
  transition: background-color var(--transition-duration) var(--transition-timing),
              border-color var(--transition-duration) var(--transition-timing);
}

.form-input,
.textarea {
  transition: background-color var(--transition-duration) var(--transition-timing),
              border-color var(--transition-duration) var(--transition-timing),
              color var(--transition-duration) var(--transition-timing);
}

.btn {
  transition: background-color var(--transition-duration) var(--transition-timing),
              color var(--transition-duration) var(--transition-timing),
              border-color var(--transition-duration) var(--transition-timing);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-duration: 0ms;
  }
  
  html,
  body,
  .site-header,
  .post-card,
  .topic-card,
  .hero,
  .footer,
  .form-input,
  .textarea,
  .btn,
  .theme-btn {
    transition: none;
  }
  
  .theme-btn:hover {
    transform: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .theme-toggle-container {
    border-width: 2px;
  }
  
  .theme-btn {
    font-weight: 600;
  }
  
  .theme-btn.active {
    outline: 2px solid var(--focus-color, #4158D0);
    outline-offset: 2px;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .theme-toggle-container {
    padding: 0.125rem;
    gap: 0.125rem;
  }
  
  .theme-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
  }
  
  .theme-label {
    display: none;
  }
  
  .theme-icon {
    font-size: 1rem;
  }
  
  .theme-toggle--floating {
    top: 0.5rem;
    right: 0.5rem;
  }
}

@media (max-width: 480px) {
  .theme-toggle-container {
    border-radius: 6px;
  }
  
  .theme-btn {
    padding: 0.375rem;
    min-width: 2rem;
    justify-content: center;
  }
  
  .theme-icon {
    font-size: 0.875rem;
  }
}

/* Print styles */
@media print {
  .theme-toggle {
    display: none;
  }
}

/* Loading state */
.theme-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.theme-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* Focus management */
.theme-btn:active {
  transform: scale(0.98);
}

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

/* Tooltip styles */
.theme-btn[title] {
  position: relative;
}

.theme-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1001;
  pointer-events: none;
  margin-bottom: 0.25rem;
}