/**
 * Estilos Canónicos - Semáforo y Mapa de Polen y Calidad del Aire
 * Fijate Tools - Suite de Salud Respiratoria y Alergias
 * Paleta: Midnight Slate (#0b0f17) con acentos semafóricos de salud
 */

:root {
  --bg-primary: #0b0f17;
  --bg-secondary: #111827;
  --bg-card: #1a2234;
  --bg-card-hover: #222d42;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #27354f;
  --border-focus: #3b82f6;

  /* Escala cromática oficial EAQI (Índice Europeo de Calidad del Aire) */
  --aqi-excelente: #10b981;  /* 0 - 20 Verde esmeralda */
  --aqi-aceptable: #84cc16;  /* 21 - 40 Verde lima */
  --aqi-moderado: #f59e0b;   /* 41 - 60 Ámbar */
  --aqi-deficiente: #f97316; /* 61 - 80 Naranja */
  --aqi-muy-def: #ef4444;    /* 81 - 100 Rojo */
  --aqi-severo: #8b5cf6;     /* > 100 Púrpura */

  --accent-cyan: #06b6d4;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
}

.mono-num {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout Canónico */
.tool-layout {
  max-width: 1400px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Hero & Barra de Control */
.air-hero {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hero-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.hero-title-group h2 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.hero-title-group p {
  font-size: 0.925rem;
  color: var(--text-secondary);
  max-width: 780px;
}

/* Barra de Búsqueda */
.search-controls-box {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
}

@media (max-width: 768px) {
  .search-controls-box {
    grid-template-columns: 1fr;
  }
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 1rem 0 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-search, .btn-geo {
  height: 44px;
  min-height: 44px;
  padding: 0 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-search {
  background: #3b82f6;
  color: #ffffff;
  border: 1px solid transparent;
}

.btn-search:hover {
  background: #2563eb;
}

.btn-geo {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-geo:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

/* Accesos rápidos de capitales */
.quick-cities-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.quick-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.city-pill-btn {
  padding: 0.3rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
  font-size: 0.825rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.city-pill-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* Cuadrícula Principal: Semáforo AQI + Consejos Médicos */
.overview-dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .overview-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjeta del Semáforo / Tacómetro AQI */
.aqi-gauge-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.gauge-svg-container {
  position: relative;
  width: 220px;
  height: 130px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-center-content {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.gauge-unit {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.aqi-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-xl);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(16, 185, 129, 0.15);
  color: var(--aqi-excelente);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.aqi-desc-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.location-indicator-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Tarjetas de Recomendaciones Sanitarias */
.medical-advice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .medical-advice-grid {
    grid-template-columns: 1fr;
  }
}

.advice-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
}

.advice-card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.advice-icon-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--accent-cyan);
}

.advice-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.advice-card-body {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Sección de Pólenes y Alergias */
.section-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-header-row h3 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pollen-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.pollen-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.pollen-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.pollen-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.pollen-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pollen-level-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.pollen-meter-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

.pollen-meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.pollen-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pollen-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text-primary);
}

/* Desglose de Contaminantes Químicos (PM2.5, PM10, O3, NO2, etc.) */
.pollutants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.pollutant-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.pollutant-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pollutant-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pollutant-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
}

.pollutant-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Gráfico de Evolución Horaria 48 h */
.forecast-chart-box {
  position: relative;
  width: 100%;
  height: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow: hidden;
}

#hourly-chart-canvas {
  width: 100%;
  height: 100%;
}

/* Mapa de Red Nacional Leaflet */
.map-container-box {
  position: relative;
  width: 100%;
  height: 520px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #1e293b;
}

#air-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Marcadores Semafóricos en el Mapa */
.air-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 11px;
  transition: transform 0.15s ease;
}

.air-pin:hover {
  transform: scale(1.2);
  z-index: 999 !important;
}

/* Leyenda del Mapa */
.map-legend-bar {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Guía Educativa SEO Inferior */
.seo-guide-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.seo-guide-section h3 {
  font-size: 1.35rem;
}

.seo-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.seo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seo-card h4 {
  font-size: 1.05rem;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.seo-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Toast */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  border: 1px solid #3b82f6;
  color: #f8fafc;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-xl);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 10000;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
}
