/* Theme System - Light and Dark Mode */

/* CSS Custom Properties for Theme System */
:root {
  /* Light Theme Colors */
  --color-primary: #007bff;
  --color-primary-dark: #0056b3;
  --color-primary-light: #66b3ff;
  --color-secondary: #6c757d;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-info: #17a2b8;
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-dark: #343a40;
  --bg-darker: #212529;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --bg-glass: rgba(255, 255, 255, 0.1);
  
  /* Text Colors */
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #868e96;
  --text-light: #ffffff;
  --text-inverse: #ffffff;
  
  /* Border Colors */
  --border-color: #dee2e6;
  --border-light: #f8f9fa;
  --border-dark: #495057;
  
  /* Shadow Colors */
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-color-dark: rgba(0, 0, 0, 0.3);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  --gradient-hero: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-overlay: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.7) 100%);
  
  /* Transitions */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
  --transition-slow: 0.5s ease-in-out;
  --transition-theme: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 50%;
  
  /* Z-index */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
}

/* Dark Theme Colors */
[data-theme="dark"] {
  /* Background Colors */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #404040;
  --bg-dark: #0d1117;
  --bg-darker: #000000;
  --bg-overlay: rgba(0, 0, 0, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.05);
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #8b949e;
  --text-light: #ffffff;
  --text-inverse: #000000;
  
  /* Border Colors */
  --border-color: #30363d;
  --border-light: #21262d;
  --border-dark: #484f58;
  
  /* Shadow Colors */
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-color-dark: rgba(0, 0, 0, 0.6);
  
  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  --gradient-overlay: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.9) 100%);
}

/* 
  Botón de cambio de tema 
  - Posición fija en la pantalla
  - Ahora colocado en la parte superior IZQUIERDA (cambiamos right por left)
  - Capa z-index alta para que esté por encima de otros elementos
  - Fondo y borde usando variables CSS para adaptarse al tema
  - Forma circular perfecta (border-radius 50%)
  - Tamaño compacto
  - Centrado de icono interno con flexbox
  - Efectos visuales: sombra, transición y desenfoque de fondo
  - Color del icono según tema
*/
.theme-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem; /* Cambiado de right a left para alinear a la izquierda */
  z-index: var(--z-fixed);
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  width: 38px;
  height: 38px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: all var(--transition-theme);
  backdrop-filter: blur(10px);
  color: var(--text-primary);
  font-size: 1.2rem;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--shadow-color-dark);
  border-color: var(--color-primary);
}

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

.theme-toggle .icon {
  transition: all var(--transition-theme);
  position: absolute;
}

.theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(-180deg) scale(0);
}

[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Mobile Theme Toggle */
@media (max-width: 768px) {
  .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}

/* Theme Transition Animation */
.theme-transition {
  transition: 
    background-color var(--transition-theme),
    border-color var(--transition-theme),
    color var(--transition-theme),
    box-shadow var(--transition-theme),
    opacity var(--transition-theme),
    transform var(--transition-theme);
}

/* Apply theme transitions to all elements */
*,
*::before,
*::after {
  transition: 
    background-color var(--transition-theme),
    border-color var(--transition-theme),
    color var(--transition-theme),
    box-shadow var(--transition-theme);
}

/* Base Element Theming */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color var(--transition-theme), color var(--transition-theme);
}

/* Navigation Theming */
.navbar {
  background-color: var(--bg-primary) !important;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.navbar-brand,
.nav-link {
  color: var(--text-primary) !important;
}

.nav-link:hover {
  color: var(--color-primary) !important;
}

.navbar-toggler {
  border-color: var(--border-color);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

[data-theme="dark"] .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Hero Section Theming */
.hero-section {
  background: var(--gradient-hero);
}

/* Card Theming */
.card,
.mobile-edition-card {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.card-title,
.mobile-card-title {
  color: var(--text-primary);
}

.card-text,
.mobile-card-description {
  color: var(--text-secondary);
}

/* Button Theming */
.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Form Theming */
.form-control,
.form-select,
.mobile-search-input,
.mobile-filter-select {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.form-control:focus,
.form-select:focus,
.mobile-search-input:focus,
.mobile-filter-select:focus {
  background-color: var(--bg-primary);
  border-color: var(--color-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-control::placeholder,
.mobile-search-input::placeholder {
  color: var(--text-muted);
}

/* Modal Theming */
.modal-content {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
}

.modal-header {
  border-bottom-color: var(--border-color);
}

.modal-footer {
  border-top-color: var(--border-color);
}

.modal-title {
  color: var(--text-primary);
}

/* PDF Viewer Theming */
.mobile-pdf-viewer {
  background-color: var(--bg-darker);
}

.pdf-viewer-header {
  background-color: rgba(0, 0, 0, 0.9);
  border-bottom-color: var(--border-dark);
}

.pdf-navigation {
  background-color: rgba(0, 0, 0, 0.9);
  border-top-color: var(--border-dark);
}

/* Search Container Theming */
.mobile-search-container {
  background-color: var(--bg-primary);
  border-color: var(--border-color);
  backdrop-filter: blur(10px);
}

[data-theme="dark"] .mobile-search-container {
  background-color: rgba(26, 26, 26, 0.95);
}

/* Filter Tags Theming */
.mobile-filter-tag {
  background-color: var(--color-primary);
  color: var(--text-light);
}

/* Results Counter Theming */
.mobile-results-counter {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
}

/* Footer Theming */
footer {
  background-color: var(--bg-dark) !important;
  color: var(--text-light);
}

/* Glass Effect Theming */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-color: var(--border-color);
}

/* Scrollbar Theming */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection Theming */
::selection {
  background-color: var(--color-primary);
  color: var(--text-light);
}

::-moz-selection {
  background-color: var(--color-primary);
  color: var(--text-light);
}

/* Focus Outline Theming */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Loading Animation Theming */
@keyframes loading-dark {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.loading-skeleton-mobile {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: loading-dark 1.5s infinite;
}

/* Theme-specific animations */
[data-theme="dark"] .animate-pulse {
  animation: pulse-dark 2s ease-in-out infinite;
}

@keyframes pulse-dark {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
  }
  
  [data-theme="dark"] {
    --border-color: #ffffff;
    --text-secondary: #ffffff;
    --bg-primary: #000000;
    --text-primary: #ffffff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle .icon {
    transition: none !important;
    animation: none !important;
  }
  
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Print mode - force light theme */
@media print {
  * {
    background-color: white !important;
    color: black !important;
    border-color: black !important;
  }
  
  .theme-toggle {
    display: none !important;
  }
}

/* Theme preference detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --shadow-color: rgba(0, 0, 0, 0.3);
  }
}

/* Smooth theme transition overlay */
.theme-transition-overlay {
  position: fixed;
  top: 50;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.theme-transition-overlay.active {
  opacity: 0.8;
  visibility: visible;
}

/* Theme indicator */
.theme-indicator {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  z-index: var(--z-toast);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-indicator.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-10px);
}

/* Accessibility improvements */
.theme-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Theme toggle tooltip */
.theme-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -2.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-darker);
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  z-index: var(--z-tooltip);
}

.theme-toggle:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-5px);
}

