/* =============================================================
   DIPRENA · Portal CMS — Mapa de Inversión
   Choropleth simplificado SVG + ranking lateral.
   ============================================================= */

.mapa-page { padding-bottom: 56px; }

.map-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Toggle de métrica (Ejecutado / Aprobado) */
.metric-toggle {
  display: inline-flex;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.metric-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  transition: .15s;
}
.metric-btn:hover { color: var(--blue); }
.metric-btn.is-active { background: var(--navy); color: var(--white); }

/* Layout principal */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-top: 16px;
}

.map-card { display: flex; flex-direction: column; }
.card__header--tight { padding: 16px 20px 12px; }

.legend-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-mute);
}
.legend-gradient {
  display: inline-block;
  width: 140px; height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #E6F0FB, #1D6FE0, #0B2451);
  border: 1px solid var(--border-soft);
}

/* SVG */
.map-canvas-wrap {
  position: relative;
  padding: 18px 22px 12px;
}
.map-canvas {
  width: 100%;
  height: auto;
  display: block;
}
.map-bg {
  fill: #F4F8FD;
  stroke: var(--border-soft);
  stroke-width: 1;
}
.map-compass-label,
.map-axis-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-faint);
  font-family: inherit;
  letter-spacing: .03em;
}

/* Provincias */
.prov-shape {
  fill: var(--blue-bg);
  fill-rule: evenodd;          /* MultiPolygons con anillos interiores */
  stroke: #fff;
  stroke-width: 0.8;
  stroke-linejoin: round;
  cursor: pointer;
  transition: stroke .15s, transform .15s;
  transform-origin: center;
  transform-box: fill-box;
}
.prov-shape:hover,
.prov-shape.is-hover,
.prov-shape.is-active {
  stroke: var(--navy);
  stroke-width: 1.6;
  filter: drop-shadow(0 2px 6px rgba(11,36,81,.18));
}
.prov-shape.is-comarca {
  stroke-dasharray: 2 3;
}

/* Marcador visual en filas "sin asignación territorial" del ranking */
.rank-row.is-unassigned .rank-name {
  color: var(--text-mute);
  font-style: italic;
}

/* Etiqueta de cada provincia (nombre + %) */
.prov-label {
  pointer-events: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  fill: var(--text);
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3;
  stroke-linejoin: round;
}
.prov-label--value {
  font-size: 11px;
  fill: var(--navy);
}

/* Tooltip flotante */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(11,36,81,.96);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 240px;
  box-shadow: 0 6px 18px rgba(11,36,81,.3);
  z-index: 10;
  transform: translate(-50%, -100%);
  transition: opacity .12s;
}
.map-tooltip strong { display: block; font-size: 13px; margin-bottom: 4px; }
.map-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.map-tooltip .tt-pct { color: #6AB7E8; font-weight: 700; }

.map-note {
  padding: 12px 22px 18px;
  font-size: 12px;
  color: var(--text-mute);
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
  line-height: 1.6;
}

/* Ranking lateral */
.map-ranking {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
}
.rank-list {
  list-style: none;
  padding: 0 4px 8px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .12s;
}
.rank-row:hover,
.rank-row.is-hover {
  background: var(--blue-bg);
}
.rank-row.is-active {
  background: var(--blue-bg);
  outline: 1px solid rgba(29,111,224,.25);
}
.rank-rank {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  flex-shrink: 0;
}
.rank-row.is-top .rank-rank {
  background: var(--navy);
  color: #fff;
}
.rank-body { flex: 1; min-width: 0; }
.rank-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.rank-bar {
  flex: 1;
  height: 4px;
  background: var(--border-soft);
  border-radius: 2px;
  overflow: hidden;
}
.rank-bar > span { display: block; height: 100%; background: var(--blue); }
.rank-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rank-amount {
  font-size: 11px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.rank-footer {
  display: flex; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--text-mute);
}
.rank-footer strong { color: var(--navy); font-variant-numeric: tabular-nums; }

/* Responsive */
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-ranking { position: static; max-height: none; }
}
