/* ========================================
   ESTILOS PRINCIPALES v0.7.0
   Estilos base, layout, temas y elementos desktop
   ======================================== */

/* Import estilos específicos para visualización móvil */
@import url('./mobile-charts.css') screen;

/* Variables CSS para temas */
:root {
  --primary-color: #2563eb;
  --success-color: #16a34a;
  --error-color: #dc2626;
  --info-color: #0891b2;
  --warning-color: #ca8a04;
  --border-radius: 8px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --transition: all 0.3s ease-in-out;
  
  /* Colores de gráficos */
  --chart-male: rgba(54, 162, 235, 0.8);
  --chart-male-border: rgba(54, 162, 235, 1);
  --chart-female: rgba(255, 99, 132, 0.8);
  --chart-female-border: rgba(255, 99, 132, 1);
  --chart-total: rgba(100, 100, 255, 0.8);
  --chart-total-border: rgba(100, 100, 255, 1);
  --chart-text: #1e293b;
  --chart-text-light: #ffffff;
  
  /* Tema claro (por defecto) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
}

/* Tema oscuro */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --card-bg: #1e293b;
  --card-border: #475569;
  --primary-color: #3b82f6;
  
  /* Colores de gráficos en tema oscuro */
  --chart-text: #f1f5f9;
  --chart-text-light: #1e293b;
}

/* Reset y base */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 1rem;
  line-height: 1.6;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition);
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
header {
  margin-bottom: 0.5rem;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 0.5rem 1.5rem;
  border: 1px solid var(--card-border);
  max-height: 80px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.title-section h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4vw, 2rem);
  color: var(--primary-color);
  font-weight: 700;
  line-height: normal;
}

.title-section p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.header-controls {
  flex-shrink: 0;
}

/* Botón hamburguesa */
.filters-toggle {
  padding: 0.75rem;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 2rem;
  transition: var(--transition);
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filters-toggle:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

/* Contenedor del gráfico principal */
.chart-container {
  width: 100%;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  padding: 1.5rem;
  margin-bottom: 2rem;
  height: calc(100vh - 100px); /* ALTURA OPTIMIZADA */
  position: relative;
}

.chart-container canvas {
  height: 100% !important;
  width: auto !important;
  transition: opacity 0.3s ease;
}

/* Sidebar universal */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--card-bg);
  border-left: 1px solid var(--card-border);
  box-shadow: -4px 0 6px -1px rgb(0 0 0 / 0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.sidebar.visible {
  transform: translateX(0);
}

/* Header del sidebar */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.close-sidebar {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.4rem;
  padding: 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-sidebar:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

/* Contenido del sidebar */
.sidebar-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Labels y selects */
label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

select {
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
}

select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Estados de carga y mensajes */
.status-message {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-message.loading {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-message.success {
  background-color: rgba(34, 197, 94, 0.1);
  color: var(--success-color);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-message.error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Footer del sidebar */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.footer-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Botones de control (tema, idioma, etc.) */
.theme-toggle,
.language-toggle,
.view-toggle{
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.theme-toggle:hover,
.language-toggle:hover,
.view-toggle:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

.theme-toggle:focus-visible,
.language-toggle:focus-visible,
.view-toggle:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Overlay para cerrar sidebar */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  pointer-events: none;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

/* Responsive - Solo elementos base */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--card-border);
  }
  
  .chart-container {
    padding: 1rem;
  }
  
  .footer-controls {
    flex-direction: row;
    gap: 0.5rem;
  }
  
  .theme-toggle,
  .language-toggle {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.6rem 0.8rem;
  }
}

@media (max-width: 480px) {
  .footer-controls {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .theme-toggle,
  .language-toggle {
    flex: none;
    width: 100%;
  }
}

/* Accesibilidad general */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  [data-i18n] {
    transition: none;
  }
}

select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

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

/* Animaciones para cambio de idioma */
[data-i18n] {
  transition: opacity 0.2s ease-in-out;
}

.changing-language [data-i18n] {
  opacity: 0.7;
}

/* Indicadores visuales adicionales */
.language-toggle {
  position: relative;
}

.language-toggle::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--success-color);
  transition: width 0.3s ease;
}

.language-toggle:hover::after {
  width: 80%;
}

/* Estado de carga en sidebar */
.sidebar-content:has(.status-message) {
  position: relative;
}