/**
 * ESTILOS CSS PARA EL GEOVISOR
 * Archivo: geovisor.css
 * 
 * Agregar al <style> de tu HTML o crear archivo separado
 */

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.geovisor-container {
  padding: 20px;
  height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* ========================================
   HEADER DEL GEOVISOR
   ======================================== */
.geovisor-header {
  background: linear-gradient(135deg, #ff6b35 0%, #f97316 100%);
  color: white;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.header-titulo {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.icono-principal {
  font-size: 3rem;
  opacity: 0.9;
}

.header-titulo h2 {
  margin: 0;
  font-weight: 700;
  font-size: 1.8rem;
}

.header-titulo p {
  opacity: 0.9;
  font-size: 0.95rem;
}

.estadisticas-header {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.stat-municipal {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.15);
  padding: 10px 15px;
  border-radius: 10px;
  backdrop-filter: blur(10px);
}

.stat-municipal i {
  font-size: 2rem;
  opacity: 0.8;
}

.stat-valor {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.stat-etiqueta {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* ========================================
   CONTROLES Y FILTROS
   ======================================== */
.geovisor-controles {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-weight: 600;
  color: #64748b;
  margin: 0;
  white-space: nowrap;
}

.control-group select {
  min-width: 150px;
}

/* ========================================
   CONTENEDOR PRINCIPAL (MAPA + PANEL)
   ======================================== */
.geovisor-main {
  flex: 1;
  display: flex;
  gap: 15px;
  min-height: 0;
}

/* ========================================
   MAPA
   ======================================== */
.mapa-contenedor {
  flex: 1;
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#mapa-leaflet {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Spinner de carga */
.spinner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 1000;
}

/* Leyenda del mapa */
.mapa-leyenda {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: white;
  padding: 12px 15px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  min-width: 150px;
}

.mapa-leyenda h6 {
  margin: 0 0 10px 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
}

.leyenda-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.leyenda-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.leyenda-item span {
  font-size: 0.85rem;
  color: #64748b;
}

/* ========================================
   MARCADORES PERSONALIZADOS
   ======================================== */
.marcador-personalizado {
  background: transparent;
  border: none;
}

.marcador-contenido {
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  border: 3px solid white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.marcador-contenido:hover {
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.marcador-contenido i {
  color: white;
  font-size: 1.2rem;
  transform: rotate(45deg);
}

/* ========================================
   POPUPS DEL MAPA
   ======================================== */
.popup-geovisor {
  min-width: 250px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.popup-geovisor h5 {
  margin: 0 0 8px 0;
  color: #1e293b;
  font-size: 1.1rem;
}

.popup-stats {
  margin: 10px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
}

.stat-item:last-child {
  border-bottom: none;
}

.stat-item i {
  font-size: 1.2rem;
}

.stat-item strong {
  color: #475569;
}

/* ========================================
   PANEL DE DETALLES (LATERAL)
   ======================================== */
.panel-detalles {
  width: 400px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(420px);
  transition: transform 0.3s ease;
}

.panel-detalles.visible {
  transform: translateX(0);
}

.empty-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  padding: 40px;
  text-align: center;
}

.empty-panel i {
  font-size: 4rem;
  margin-bottom: 15px;
  opacity: 0.4;
}

.detalles-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.detalles-header h4 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.detalles-header .btn-close {
  filter: brightness(0) invert(1);
}

.detalles-contenido {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detalles-contenido::-webkit-scrollbar {
  width: 8px;
}

.detalles-contenido::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.detalles-contenido::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* ========================================
   SECCIONES DE DETALLES
   ======================================== */
.seccion-detalle {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
}

.seccion-detalle:last-child {
  border-bottom: none;
}

.seccion-detalle h5 {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.seccion-detalle h5 i {
  color: #667eea;
  font-size: 1.2rem;
}

.stat-card {
  background: #f8fafc;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 5px;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   PIRÁMIDE POBLACIONAL
   ======================================== */
.piramide-poblacional {
  margin-top: 10px;
}

.piramide-fila {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  gap: 10px;
}

.piramide-hombres {
  background: linear-gradient(to left, #3b82f6, #60a5fa);
  color: white;
  text-align: right;
  padding: 5px 10px;
  border-radius: 4px 0 0 4px;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 40px;
}

.piramide-mujeres {
  background: linear-gradient(to right, #ec4899, #f472b6);
  color: white;
  text-align: left;
  padding: 5px 10px;
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 40px;
}

.piramide-edad {
  min-width: 60px;
  text-align: center;
  font-weight: 600;
  color: #475569;
  font-size: 0.85rem;
}

/* ========================================
   BARRAS DE COBERTURA
   ======================================== */
.barras-cobertura {
  margin-top: 10px;
}

.barra-item {
  margin-bottom: 12px;
}

.barra-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}

.barra-container {
  background: #e2e8f0;
  border-radius: 8px;
  height: 30px;
  overflow: hidden;
  position: relative;
}

.barra-fill {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  transition: width 0.5s ease;
}

/* ========================================
   LISTA DE DATOS
   ======================================== */
.lista-datos {
  margin-top: 10px;
}

.dato-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
  gap: 10px;
}

.dato-nombre {
  flex: 1;
  font-weight: 600;
  color: #1e293b;
  font-size: 0.9rem;
}

.dato-badge {
  flex-shrink: 0;
}

.dato-valor {
  font-weight: 700;
  color: #475569;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ========================================
   FOOTER DEL GEOVISOR
   ======================================== */
.geovisor-footer {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.info-card i {
  font-size: 2rem;
}

.info-card strong {
  display: block;
  color: #1e293b;
  font-size: 1rem;
  margin-bottom: 2px;
}

.info-card p {
  color: #64748b;
  font-size: 0.85rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
  .panel-detalles {
    width: 350px;
  }
}

@media (max-width: 992px) {
  .geovisor-main {
    flex-direction: column;
  }
  
  .panel-detalles {
    width: 100%;
    height: 400px;
    transform: translateY(420px);
  }
  
  .panel-detalles.visible {
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .geovisor-controles {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-group select {
    width: 100%;
  }
  
  .estadisticas-header {
    flex-direction: column;
  }
  
  .mapa-leyenda {
    bottom: 10px;
    right: 10px;
    font-size: 0.85rem;
  }
}
/* ==========================================================
   AJUSTES v2 — Mapa más alto + panel lateral tipo dashboard
   (estos estilos van al final para sobrescribir los anteriores)
   ========================================================== */
.geovisor-container {
  padding: 8px 12px 12px;
  height: auto;
  gap: 10px;
}

/* Fila principal: [ controles + mapa ]  |  [ resumen + panel de datos ] */
.geovisor-main {
  flex: none;
  display: flex;
  gap: 10px;
  align-items: stretch;
  height: calc(100vh - 195px);
  min-height: 520px;
}

.geo-col-mapa {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.geo-col-mapa .geovisor-controles {
  padding: 5px 10px;
  gap: 10px;
  border-radius: 8px;
}
.geo-col-mapa .control-group select { min-width: 100px; }

.geo-col-mapa .mapa-contenedor {
  flex: 1;
  min-height: 0;
  border-radius: 10px;
}

.geo-col-lateral {
  flex: 0 0 clamp(300px, 31vw, 430px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Resumen compacto (título + totales) alineado a la derecha */
.geo-resumen {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b6bf5 100%);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 3px 10px rgba(30, 58, 138, 0.25);
}
.geo-resumen-titulo { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.geo-resumen-titulo .geo-resumen-icono {
  width: 26px; height: 26px; border-radius: 7px; background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex: 0 0 26px;
}
.geo-resumen-titulo h2 { margin: 0; font-size: 1.15rem; font-weight: 800; line-height: 1.15; }
.geo-resumen-titulo small { font-size: .75rem; opacity: .8; }
.geo-resumen-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.geo-resumen-stat {
  background: rgba(255,255,255,.14); border-radius: 7px; padding: 4px 3px; text-align: center; min-width: 0;
}
.geo-resumen-stat i { font-size: 1rem; opacity: .9; }
.geo-resumen-stat b { display: block; font-size: 1.1rem; font-weight: 800; line-height: 1.1; }
.geo-resumen-stat small { font-size: .62rem; text-transform: uppercase; letter-spacing: .3px; opacity: .85; }

/* Panel de datos: siempre visible, ocupa el resto de la columna */
.panel-detalles {
  width: auto;
  flex: 1;
  min-height: 0;
  transform: none !important;
  background: #f4f7fe;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(30, 58, 138, 0.15);
}
.panel-detalles .empty-panel { padding: 20px; }
.panel-detalles .empty-panel i { font-size: 3rem; color: #3b6bf5; }
.panel-detalles .empty-panel p { font-size: .9rem; margin: 0; }

.detalles-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b6bf5 100%);
  padding: 8px 12px;
  align-items: flex-start;
}
.detalles-header h4 { font-size: 1.1rem; display: flex; align-items: center; gap: 5px; }
.detalles-badges { margin-top: 3px; display: flex; gap: 4px; flex-wrap: wrap; }
.detalles-badges .badge { font-size: .7rem; }
.detalles-contenido { padding: 8px; background: #f4f7fe; }

/* Tarjetas del panel */
.geo-card {
  background: #fff;
  border: 1px solid #e6ecfa;
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 8px;
  box-shadow: 0 2px 6px rgba(30, 58, 138, 0.05);
  animation: geoIn .5s ease both;
}
@keyframes geoIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.geo-card-titulo {
  font-size: .8rem; font-weight: 800; color: #64748b; text-transform: uppercase;
  letter-spacing: .3px; margin-bottom: 6px;
}
.geo-card-titulo i { color: #3b6bf5; margin-right: 3px; }
.geo-subtitulo { font-size: .75rem; font-weight: 700; color: #64748b; margin: 8px 0 3px; }

.geo-fila { display: flex; align-items: center; gap: 10px; }
.geo-fila-lado { flex: 1; min-width: 0; }
.geo-dona { position: relative; width: 96px; height: 96px; flex: 0 0 96px; }
.geo-dona.geo-dona-sm { width: 76px; height: 76px; flex-basis: 76px; }
.geo-dona canvas { width: 100% !important; height: 100% !important; }
.geo-dona-centro {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; pointer-events: none;
}
.geo-dona-centro b { font-size: 1.15rem; color: #1e293b; line-height: 1.1; }
.geo-dona-centro span { font-size: .6rem; color: #64748b; font-weight: 600; }

.geo-leyenda { display: flex; flex-direction: column; gap: 3px; }
.geo-leyenda > div { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: #334155; }
.geo-leyenda i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.geo-leyenda span { flex: 1; min-width: 0; }
.geo-leyenda b { color: #1e293b; }
.geo-mini { font-size: .7rem; color: #64748b; margin-top: 4px; }
.geo-nota { margin-top: 6px; font-size: .78rem; color: #475569; background: #f1f5fd; border-radius: 6px; padding: 4px 7px; }

.geo-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.geo-kpi { background: #f6f8ff; border: 1px solid #e6ecfa; border-radius: 7px; padding: 5px 4px; text-align: center; min-width: 0; }
.geo-kpi-valor { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.geo-kpi-etiqueta { font-size: .65rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .2px; margin-top: 1px; }
.geo-kpi-sub { font-size: .65rem; color: #94a3b8; }

.geo-barras { position: relative; width: 100%; }
.geo-barras canvas { width: 100% !important; height: 100% !important; }

.geo-anillos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 4px; }
.geo-anillo { text-align: center; min-width: 0; }
.geo-anillo-svg { position: relative; width: 48px; height: 48px; margin: 0 auto; }
.geo-anillo-svg svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.geo-anillo-svg circle { fill: none; stroke-width: 4.5; }
.geo-anillo-bg { stroke: #e3eafc; }
.geo-anillo-fg { stroke-linecap: round; animation: geoRing 1.1s ease-out both; }
@keyframes geoRing { from { stroke-dasharray: 0 100; } }
.geo-anillo-svg span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; color: #1e293b; }
.geo-anillo-titulo { font-size: .68rem; color: #475569; font-weight: 600; margin-top: 2px; line-height: 1.15; }

.geo-pie { text-align: center; font-size: .72rem; color: #94a3b8; padding: 2px 0 6px; }

/* Marcador seleccionado */
.marcador-activo .marcador-contenido {
  transform: rotate(-45deg) scale(1.2);
  box-shadow: 0 0 0 4px rgba(59, 107, 245, 0.45), 0 5px 15px rgba(0, 0, 0, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .geo-card, .geo-anillo-fg { animation: none !important; }
}

@media (max-width: 992px) {
  .geovisor-main { flex-direction: column; height: auto; min-height: 0; }
  .geo-col-mapa .mapa-contenedor { flex: none; height: 62vh; min-height: 380px; }
  .geo-col-lateral { flex: none; }
  .panel-detalles { min-height: 380px; height: auto; }
  .geo-dona { width: 84px; height: 84px; flex-basis: 84px; }
}

/* Botón "Mapa" del panel (solo en celulares/tablets) */
.detalles-acciones { display: flex; align-items: center; gap: 8px; }
.btn-ver-mapa {
  display: none; background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px; padding: 2px 8px; font-size: .8rem; font-weight: 700;
}
@media (max-width: 992px) {
  .btn-ver-mapa { display: inline-flex; align-items: center; gap: 4px; }
  .geo-col-mapa .mapa-contenedor { height: 60vh; min-height: 340px; }
}