/* =============================================================================
   PARTICIPA COMAS :: estilos del MAPA INTERACTIVO de zonales
   -----------------------------------------------------------------------------
   Usa los mismos tokens de diseño que estilos.css (con respaldo por si cambian).
   ⚠️ Prototipo de demostración · datos ficticios · límites aproximados.
   ============================================================================= */

.mapa-envoltura {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

/* ---------------------------------------------------------------- lienzo ---- */
.mapa-lienzo {
  position: relative;
  background: #fff;
  border: 1px solid var(--borde, #e7e7ea);
  border-radius: var(--radio, 14px);
  overflow: hidden;
  box-shadow: var(--sombra, 0 2px 10px rgba(24, 24, 27, .08));
  touch-action: pan-y;
  cursor: crosshair;
}

/* Capa que agrupa el esquema: es la que se escala y se desplaza con el zoom */
.mapa-capa {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

/* El esquema es un SVG propio: mantiene su proporción (viewBox) */
#mapa-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 74vh;
}

/* Silueta del distrito (datos abiertos de OpenStreetMap) */
.mapa-distrito {
  fill: #ffffff;
  stroke: var(--rojo-700, #8c0f1f);
  stroke-width: 2.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 10px rgba(24, 24, 27, .18));
  vector-effect: non-scaling-stroke;
}

.mapa-ref {
  fill: var(--ambar-500, #e8a52c);
  stroke: #fff;
  stroke-width: 1.4;
  cursor: help;
  vector-effect: non-scaling-stroke;
}

.mapa-barrio {
  font: 600 7.5px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  fill: #6b7280;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 2px;
}

.mapa-ubicacion {
  position: absolute;
  left: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--rojo-700, #8c0f1f);
  border: 2px solid var(--rojo-500, #c8102e);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
}

.mapa-ubicacion:hover { background: var(--rojo-050, #fff1f3); }

.mapa-zona {
  fill: rgba(200, 16, 46, .16);
  stroke: var(--rojo-500, #c8102e);
  stroke-width: 1.6;
  stroke-linejoin: round;
  cursor: pointer;
  transition: fill 160ms ease, stroke-width 160ms ease;
  vector-effect: non-scaling-stroke;
}

.mapa-zona:hover { fill: rgba(200, 16, 46, .34); stroke-width: 2.6; }
.mapa-zona--activa { fill: rgba(200, 16, 46, .45); stroke-width: 3; }
.mapa-zona--provisional { stroke-dasharray: 6 4; }
.mapa-zona--sin-datos { fill: rgba(120, 120, 128, .12); }
.mapa-zona:focus-visible { outline: 3px solid var(--rojo-700, #8c0f1f); outline-offset: 2px; }

.mapa-etiqueta {
  font: 700 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(140, 15, 31, .85);
  stroke-width: 3px;
  pointer-events: none;
  text-anchor: middle;
}

.mapa-pin { pointer-events: none; }
.mapa-pin circle { fill: var(--ambar-500, #e8a52c); stroke: #fff; stroke-width: 1.5; }
.mapa-pin circle.mapa-pin__pulso { fill: none; stroke: var(--ambar-500, #e8a52c); stroke-width: 1.5; opacity: .8; animation: mapa-pulso 1.8s ease-out infinite; }
.mapa-pin text { font: 700 11px system-ui, sans-serif; fill: #18181b; paint-order: stroke; stroke: #fff; stroke-width: 3px; }

@keyframes mapa-pulso {
  0% { r: 4; opacity: .9; }
  100% { r: 14; opacity: 0; }
}

/* Controles de zoom */
.mapa-controles {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mapa-controles button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--borde, #e7e7ea);
  border-radius: 10px;
  background: rgba(255, 255, 255, .95);
  font-size: 18px;
  font-weight: 800;
  color: var(--rojo-700, #8c0f1f);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.mapa-controles button:hover { background: var(--rojo-050, #fff1f3); }

.mapa-nota {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: min(70%, 420px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(24, 24, 27, .78);
  color: #fff;
  font-size: 11px;
  line-height: 1.35;
}

/* ---------------------------------------------------------------- panel ----- */
.mapa-panel { display: grid; gap: 14px; }

.mapa-buscador { display: grid; gap: 6px; }
.mapa-buscador label { font-size: .85rem; font-weight: 700; color: #3f3f46; }

#mapa-buscador {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid #d4d4d8;
  border-radius: 10px;
  width: 100%;
}

#mapa-buscador:focus { outline: 3px solid rgba(200, 16, 46, .18); border-color: var(--rojo-500, #c8102e); }

.mapa-resultados { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.mapa-resultados button {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  border: 1px solid var(--borde, #e7e7ea);
  border-left: 4px solid var(--rojo-500, #c8102e);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font: inherit;
}
.mapa-resultados button:hover { background: var(--rojo-050, #fff1f3); }
.mapa-resultados .mapa-res__nombre { font-weight: 700; font-size: .92rem; }
.mapa-resultados .mapa-res__meta { font-size: .78rem; color: var(--gris, #6b7280); }

/* Ficha de la zonal seleccionada */
.mapa-ficha__cabecera { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mapa-ficha__titulo { margin: 0; font-size: 1.15rem; font-weight: 800; color: var(--rojo-700, #8c0f1f); }
.mapa-ficha__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 10px; }
.mapa-ficha__dato { border: 1px solid var(--borde, #e7e7ea); border-radius: 10px; padding: 8px 10px; }
.mapa-ficha__dato span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .4px; color: var(--gris, #6b7280); }
.mapa-ficha__dato strong { font-size: 1.02rem; color: var(--rojo-700, #8c0f1f); font-variant-numeric: tabular-nums; }

/* Lista de las 14 zonales */
.mapa-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; max-height: 330px; overflow-y: auto; }
.mapa-lista button {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #fafafa;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.mapa-lista button:hover { background: var(--rojo-050, #fff1f3); border-color: #f6ccd3; }
.mapa-lista button[aria-current="true"] { background: var(--rojo-050, #fff1f3); border-color: var(--rojo-500, #c8102e); }
.mapa-lista .mapa-lista__n { font-weight: 800; color: var(--rojo-600, #b01029); font-variant-numeric: tabular-nums; }
.mapa-lista .mapa-lista__votos { font-size: .78rem; color: var(--gris, #6b7280); font-variant-numeric: tabular-nums; }

/* Barra comparativa por zonal dentro de la lista */
.mapa-lista__barra { grid-column: 1 / -1; height: 4px; border-radius: 999px; background: #ececef; overflow: hidden; }
.mapa-lista__barra > i { display: block; height: 100%; background: var(--rojo-500, #c8102e); }

/* --------------------------------------------------------- calibración ----- */
.mapa-calibracion { display: grid; gap: 8px; }
.mapa-calibracion .fila-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.mapa-calibracion .aviso-cal {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff7e6;
  border: 1px solid #f0d9a8;
  font-size: .82rem;
  color: #7a4b06;
}
.mapa-lienzo--calibrando { cursor: crosshair; box-shadow: 0 0 0 3px var(--ambar-500, #e8a52c) inset; }
.mapa-vertice {
  fill: #fff;
  stroke: var(--ambar-600, #b8710a);
  stroke-width: 2;
  cursor: grab;
  vector-effect: non-scaling-stroke;
}

/* ------------------------------------------------------------ responsive ---- */
@media (max-width: 900px) {
  .mapa-envoltura { grid-template-columns: 1fr; }
  .mapa-nota { position: static; max-width: none; border-radius: 0; }
  .mapa-ficha__grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .mapa-zona, .mapa-pin circle.mapa-pin__pulso { transition: none !important; animation: none !important; }
}
