/* ==========================================================
   public/css/cosechasMapa4.css
   MAPA 4 — PLANIFICACIÓN MUNICIPAL
   ========================================================== */

.panel-mapa4 {
  width: 380px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  background: #f5f6f8;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  color: #1f2937;
}

.m4-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1c3557;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px 10px 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}

.m4-titulo {
  font-weight: 700;
  font-size: 16px;
}

.m4-cerrar {
  background: #fff;
  color: #1c3557;
  border: 0;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
}

.m4-contenido {
  padding: 12px;
}

.m4-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.m4-card h3 {
  font-size: 15px;
  margin: 0 0 8px;
  display: inline;
}

.m4-card p {
  margin: 6px 0;
  line-height: 1.4;
}

.m4-descripcion {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 8px;
}

/* Metas */
.m4-meta {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  margin: 8px 0;
}

.m4-fila {
  display: flex;
  gap: 6px;
  margin: 4px 0;
}

.m4-fila select,
.m4-fila input,
.m4-campo input,
.m4-campo select {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.m4-quitar {
  border: 0;
  background: #fee2e2;
  color: #b91c1c;
  border-radius: 6px;
  width: 30px;
  cursor: pointer;
}

.m4-campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  font-weight: 600;
  font-size: 13px;
}

.m4-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  cursor: pointer;
}

.m4-subtitulo {
  font-weight: 600;
  margin-top: 8px;
}

.m4-aldeas {
  max-height: 200px;
  overflow-y: auto;
}

.m4-aldea {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.m4-aldea select {
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
}

/* Botones */
.m4-boton {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: #1c3557;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.m4-boton:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.m4-boton-secundario {
  width: 100%;
  padding: 7px;
  background: #eef2f7;
  color: #1c3557;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Plegables */
.m4-plegable {
  margin-top: 8px;
}

.m4-plegable > summary,
.m4-plegable-card > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.m4-plegable > summary::-webkit-details-marker,
.m4-plegable-card > summary::-webkit-details-marker {
  display: none;
}

.m4-plegable > summary::before {
  content: "▸ ";
  color: #6b7280;
}

.m4-plegable[open] > summary::before {
  content: "▾ ";
}

.m4-plegable-card > summary::after {
  content: "▸";
  float: right;
  color: #6b7280;
}

.m4-plegable-card[open] > summary::after {
  content: "▾";
}

/* Resultados */
.m4-linea {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
}

.m4-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}

.m4-tabla th,
.m4-tabla td {
  text-align: left;
  padding: 5px 4px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

.m4-tabla .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.m4-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}

.m4-barra {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 8px;
}

.m4-barra > div {
  height: 100%;
  background: #2e7d32;
}

.m4-alerta {
  border-left: 4px solid #93c5fd;
  background: #eff6ff;
  padding: 6px 8px;
  border-radius: 6px;
  margin: 6px 0;
  font-size: 13px;
}

.m4-alerta.advertencia {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.m4-alerta .m4-descripcion {
  margin: 2px 0 0;
}

.m4-error {
  border-left: 4px solid #c62828;
  background: #fdecea;
}

.m4-aviso {
  background: #fff8e1;
  border-left: 4px solid #f9a825;
  font-size: 13px;
}


/* ---------- Bloqueo con spinner ---------- */
.panel-mapa4 {
  position: relative;
}

.m4-bloqueo {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(245, 246, 248, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  border-radius: 10px;
  cursor: wait;
}

.m4-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d1d5db;
  border-top-color: #1c3557;
  border-radius: 50%;
  animation: m4-girar 0.8s linear infinite;
}

.m4-bloqueo-texto {
  color: #1f2937;
  font-weight: 600;
  font-size: 14px;
  max-width: 260px;
}

/* Capa transparente sobre el mapa: bloquea clics, deja ver el mapa.
   Queda por encima de las capas del mapa y por debajo de los controles. */
.m4-bloqueo-mapa {
  position: absolute;
  inset: 0;
  z-index: 750;
  background: rgba(255, 255, 255, 0.05);
  cursor: wait;
}

@keyframes m4-girar {
  to {
    transform: rotate(360deg);
  }
}

.panel-mapa4.m4-bloqueado {
  overflow: hidden;
}

/* ---------- 6b: decidir el área disponible ---------- */
.m4-boton-chico {
  flex: 1;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: #1c3557;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.m4-boton-chico.gris {
  background: #e5e7eb;
  color: #1f2937;
}

.m4-zona {
  background: #eef2f7;
  border-left: 4px solid #1c3557;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 13px;
}

.m4-zona .m4-fila {
  margin-top: 6px;
}

.m4-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: #374151;
}

.m4-leyenda span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.m4-leyenda i {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

.m4-leyenda i.rayado {
  background: repeating-linear-gradient(45deg, #8b3a3a 0 2px, #f3e8e8 2px 5px);
  border: 1px dashed #8b3a3a;
}

.m4-leyenda i.borde {
  background: #8b3a3a;
  border: 2px solid #111827;
}

/* ---------- Reparto de metas de grupo ---------- */
.m4-reparto {
  margin-top: 6px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 4px;
}

.m4-reparto-fila {
  display: grid;
  grid-template-columns: 1fr 64px 14px 80px;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  margin: 3px 0;
}

.m4-reparto-fila input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  text-align: right;
}

.m4-reparto-fila input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
}

.m4-reparto-cant {
  text-align: right;
  color: #374151;
  font-variant-numeric: tabular-nums;
}

.m4-reparto-suma {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.m4-reparto-suma.ok { color: #2e7d32; }
.m4-reparto-suma.mal { color: #c62828; }

.m4-sub {
  margin-left: 16px;
  font-size: 13px;
  color: #374151;
}

.m4-aviso-aldea {
  border-left: 4px solid #1c3557;
  background: #eef2f7;
  font-size: 13px;
}
