
/*
  ELECCIONES 29N
  Ajustes del Congreso y visor del Senado.
*/

/* CONGRESO 2023: TARJETAS EN UNA SOLA FILA */

#congreso-historico-view .historical-seats {
  display: flex !important;
  flex-flow: row nowrap !important;
  gap: 0 !important;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: hidden;
  scrollbar-width: thin;
  overscroll-behavior-inline: contain;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

#congreso-historico-view
.historical-seats > .historical-party {
  flex: 0 0 120px !important;
  min-width: 120px !important;
  max-width: 120px;
  border-radius: 0 !important;
  border-right: 1px solid #e2e8f0 !important;
}

@media (min-width: 1200px) {
  #congreso-historico-view > p:first-child {
    white-space: nowrap;
    font-size: 0.8rem !important;
  }
}

@media (max-width: 1199px) {
  #congreso-historico-view > p:first-child {
    white-space: normal;
  }
}

/* CONGRESO HOY: TOOLTIP */

#national-map-tooltip {
  max-height: min(72vh, 590px);
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  overscroll-behavior: contain;
}

#national-map-tooltip .map-tooltip-party {
  gap: 8px;
}

#national-map-tooltip .map-tooltip-party-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

#national-map-tooltip .map-tooltip-party strong {
  white-space: nowrap;
  flex: none;
}

#national-map-tooltip .map-tooltip-last-seat-row {
  gap: 8px;
}

#national-map-tooltip
.map-tooltip-last-seat-row strong {
  white-space: nowrap;
  flex: none;
}

/* CONTENEDOR GENERAL DEL SENADO */

#electoral-pending-view:has(#senate-panel-29n) {
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
}

#senate-panel-29n {
  color: #0f172a;
  display: grid;
  gap: 24px;
}

.sn29-section {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 19px;
  background: #fff;
  min-width: 0;
}

.sn29-section-title h3,
.sn29-section h3 {
  font-size: 1rem;
  margin: 0 0 7px;
}

.sn29-section-title p,
.sn29-section > p {
  font-size: 0.83rem;
  line-height: 1.5;
  color: #64748b;
  margin: 0 0 14px;
}

/* SENADO: TARJETAS CON TOTALES POR PARTIDO */

.sn29-totals {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
}

.sn29-total-card {
  flex: 0 0 142px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sn29-total-card strong {
  font-size: 0.77rem;
  color: #475569;
}

.sn29-total-card b {
  font-size: 1.7rem;
  color: #0f172a;
}

.sn29-total-card small {
  font-size: 0.66rem;
  color: #64748b;
  line-height: 1.35;
}

/* SENADO: MAPA Y CÍRCULOS */

.sn29-map {
  position: relative;
  width: 100%;
  background: #f8fafc;
  border-radius: 12px;
  min-height: 390px;
}

.sn29-map-svg {
  width: 100%;
  height: auto;
  display: block;
}

.sn29-province {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 0.6;
}

.sn29-province:hover {
  fill: #d4dfea;
}

.sn29-borders {
  fill: none;
  stroke: #fff;
  stroke-width: 1;
  pointer-events: none;
}

.sn29-africa-label {
  font: 700 10px Arial, sans-serif;
  fill: #64748b;
}

.sn29-legend {
  color: #64748b;
  font-size: 0.75rem;
  margin-top: 9px;
}

/* TOOLTIP DEL SENADO */

.sn29-popover {
  position: absolute;
  display: none;
  z-index: 15;
  background: rgba(15, 23, 42, 0.97);
  color: #fff;
  padding: 14px;
  border-radius: 10px;
  width: 290px;
  max-height: 65vh;
  overflow-y: auto;
  font-size: 0.78rem;
  pointer-events: none;
  box-shadow: 0 16px 35px #0f172a38;
}

.sn29-popover h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #fff;
}

.sn29-popover .sn29-distribution {
  color: #cbd5e1;
  margin: 0 0 10px;
}

.sn29-district-name {
  margin: 9px 0 4px;
  font-weight: 800;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.sn29-result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}

.sn29-result-row span {
  display: flex;
  gap: 7px;
  align-items: center;
}

.sn29-result-row i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.sn29-missing {
  font-size: 0.7rem;
  color: #fbbf24;
  line-height: 1.4;
  margin: 12px 0 0;
}

/* SENADO: 58 CUADRADOS AUTONÓMICOS */

.sn29-ccaa-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
}

.sn29-ccaa {
  padding: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-width: 0;
}

.sn29-ccaa strong {
  display: block;
  font-size: 0.7rem;
  margin-bottom: 8px;
  color: #334155;
}

.sn29-squares {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 7px;
}

.sn29-square {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  display: block;
  border: 1px solid #ffffffa0;
}

.sn29-ccaa > span {
  font-size: 0.67rem;
  color: #64748b;
  line-height: 1.3;
  display: block;
}

/* SENADO HOY: LABORATORIO EDITABLE */

.sn29-edit-grid {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin: 14px 0;
}

.sn29-edit-grid label,
.sn29-seat-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
}

.sn29-edit-grid select,
.sn29-edit-grid textarea,
.sn29-edit-grid input,
.sn29-seat-fields select {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  padding: 9px;
  color: #0f172a;
  font: inherit;
}

.sn29-seat-fields {
  display: grid;
  grid-template-columns:
    repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.sn29-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.sn29-actions button,
#sn29-add-party {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 9px 12px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

#sn29-apply {
  background: #173d73;
  color: #fff;
  border-color: #173d73;
}

#sn29-editor-message {
  font-size: 0.8rem;
  color: #334155;
}

/* ADAPTACIÓN A MÓVILES */

@media (max-width: 600px) {
  .sn29-section {
    padding: 12px;
  }

  .sn29-total-card {
    flex-basis: 130px;
  }

  .sn29-popover {
    width: min(250px, 75vw);
  }

  .sn29-actions button {
    width: 100%;
  }
}
