/* =========================================================
   MUNICIPALES 2026 LIVE
   ========================================================= */

:root {
  --page-max-width: 1400px;

  --bg-page: #ffffff;
  --bg-card-light: #f7f7f7;
  --bg-card-blue: #5f879f;
  --bg-input: #ececec;

  --text-main: #262626;
  --text-soft: #707070;
  --text-muted: #8f8f8f;
  --text-white: #ffffff;

  --accent-blue: #5e8298;
  --accent-blue-dark: #4f7186;
  --accent-red: #995557;
  --accent-red-dark: #84494a;

  --border-soft: #e5e5e5;
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.08);

  --radius-card: 18px;
  --radius-small: 6px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;
  --space-6: 28px;
  --space-7: 32px;
}

/* =========================
   RESET
   ========================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0px 12px 0px 0px;
}

body {
  background: var(--bg-page);
  color: var(--text-main);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1;
}

img {
  max-width: 100%;
  height: auto;
}

button,
input {
  font: inherit;
}

/* =========================
   PAGE
   ========================= */

.page {
  width: min(100%, var(--page-max-width));
  margin: 0 auto;
  padding: 0px;
}

/* =========================
   BARRE DE RECHERCHE
   ========================= */

.search-section {
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  display: block;
  height: 52px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e3e8ec;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  overflow: hidden;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.search-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.08);
}

.search-box:focus-within {
  box-shadow: 0 0 0 2px rgba(94,130,152,0.25),
              0 10px 24px rgba(0,0,0,0.12);
}

.search-input {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 16px;
  padding: 0 52px 0 52px;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: #9aa3aa;
}

.search-icon-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 16px;
  pointer-events: none; /* décoratif seulement */
  padding: 0;
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #9aa3aa;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease;
  padding: 0;
}

.search-box.has-value .search-clear-btn {
  opacity: 1;
  pointer-events: auto;
}

.search-clear-btn:hover {
  color: #555;
}

@media (max-width: 700px) {
  .search-box {
    height: 50px;
  }

  .search-input {
    font-size: 15px;
    padding: 0 48px 0 48px;
  }

  .search-icon-btn,
  .search-clear-btn {
    width: 26px;
    height: 26px;
  }

  .search-icon-btn {
    left: 11px;
  }

  .search-clear-btn {
    right: 11px;
  }
}

/* =========================
   LAYOUT PRINCIPAL
   ========================= */

.main-layout {
  display: flex;
  gap: 28px;
  align-items: stretch;
  margin-bottom: 28px;
}

.map-panel {
  flex: 1 1 62%;
  min-width: 0;
}

.results-panel {
  flex: 0 0 38%;
  min-width: 0;
}

/* =========================
   CARTE
   ========================= */

.main-map {
  width: 100%;
  height: 720px;
  min-height: 520px;
  background: #dff3ff;
  overflow: hidden;
}

/* =========================
   RÉSULTATS À DROITE
   ========================= */
.resultat-main {
  min-width: 0;
  flex: 1 1 auto;
}

.resultats-liste {
  width: 100%;
  height: 720px;
  min-height: 520px;
  overflow-y: auto;
  padding: 4px 6px 4px 2px;
}

.commune-label {
  margin: 0 0 14px 0;
  text-align: center;
  color: var(--accent-blue);
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
}

.resultat-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 12px 0;
}

.resultat-bullet {
  width: 5px;
  min-width: 5px;
  border-radius: 999px;
  align-self: stretch;
}

.resultat-label {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.resultat-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: 999px;
  background: var(--trait-couleur, #cccccc);
}

.resultat-label h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  color: #202020;
}

.resultat-label p {
  margin: 6px 0 0 0;
  font-size: 14px;
  line-height: 1.25;
  color: #666666;
}

.resultat-scores {
  flex: 0 0 auto;
  min-width: 112px;
  text-align: right;
}

.resultat-percent {
  font-size: 18px;
  line-height: 1.1;
  font-weight: 700;
  color: #111827;
}

.resultat-meta {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.2;
  color: #6b7280;
}

.resultat-meta.provisional {
  font-style: italic;
  color: #9ca3af;
}

.resultats-liste::-webkit-scrollbar {
  width: 10px;
}

.resultats-liste::-webkit-scrollbar-track {
  background: transparent;
}

.resultats-liste::-webkit-scrollbar-thumb {
  background: rgba(94, 130, 152, 0.45);
  border-radius: 999px;
}

/* =========================
   RÉSULTATS dans carte
   ========================= */

.commune-state {
  margin: 8px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.commune-state.pending {
  background: #fff3cd;
  color: #8a6d3b;
}

.commune-state.non-concerne {
  background: #eef1f4;
  color: #58636f;
}

.resultat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.candidate-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.candidate-badge.elected-t1 {
  background: #fdeaea;
  color: #b42318;
}

.candidate-badge.qualified-t2 {
  background: #e8f1ff;
  color: #175cd3;
}

.candidate-badge.eliminated {
  background: #f2f4f7;
  color: #667085;
}

.hover-popup-meta {
  margin-top: 2px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #667085;
}

.hover-popup-state {
  font-size: 12px;
  font-weight: 600;
}

.hover-popup-state.pending {
  color: #8a6d3b;
}

.hover-popup-state.non-concerne {
  color: #58636f;
}

.hover-popup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hover-popup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 8px;
  font-size: 12px;
}

.hover-popup-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-width: 0;
  font-weight: 700;
  color: #111827;
  line-height: 1.3;
}

.hover-popup-name-text {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.hover-popup-score {
  justify-self: end;
  text-align: right;
  white-space: nowrap;
  color: #344054;
}

.hover-popup-percent {
  display: inline-block;
  color: #344054;
  white-space: nowrap;
}

/* =========================
   CARTOUCHES BASSES
   ========================= */

.info-cards {
  display: flex;
  gap: 28px;
  align-items: stretch;
}

.info-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 28px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.council-card {
  background: var(--bg-card-light);
  color: var(--text-main);
}

.voting-card {
  background: var(--bg-card-blue);
  color: var(--text-white);
}

.card-title {
  margin: 0 0 26px 0;
  text-align: center;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

/* =========================
   CARTE CONSEIL MUNICIPAL
   ========================= */

.info-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.info-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 16px;
  text-align: left;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.35;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}

.info-icon {
  width: 20px;
  flex: 0 0 20px;
  text-align: center;
  color: var(--accent-blue);
}

.info-label {
  color: var(--text-soft);
}

.info-value {
  color: var(--text-soft);
  flex: 0 1 auto;
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}

.epci-meta {
  color: var(--text-soft);
  opacity: 0.8;
  white-space: nowrap;
}

#EPCI,
#NBCC {
  flex: 0 0 auto;
}

#NBCC {
  margin-left: 4px;
}

/* =========================
   CARTE DÉTAILS DU SCRUTIN
   ========================= */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 44px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 16px;
  color: var(--text-white);
  white-space: nowrap;
}

.stat-icon {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  color: var(--text-white);
}

.stat-label,
.stat-value {
  color: var(--text-white);
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 1100px) {
  .main-map,
  .resultats-liste {
    height: 640px;
  }
}

@media (max-width: 920px) {
  .main-layout {
    flex-direction: column;
    margin-bottom: 0;
    gap: 10px;
  }

  .map-panel,
  .results-panel {
    flex: 1 1 auto;
    width: 100%;
  }

  .info-cards {
    flex-direction: column;
  }

  .main-map {
    height: 520px;
    min-height: 400px;
  }

  .resultats-liste {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-right: 0;
    padding-left: 0;
  }

  .commune-label{
    margin: 0 0 0 0;
  }
}

@media (max-width: 700px) {
  .page {
    padding: 18px 14px 24px;
  }

  .main-map {
    height: 420px;
    min-height: 320px;
  }

  .info-card {
    padding: 22px 18px;
  }

  .card-title {
    font-size: 22px;
    margin-bottom: 22px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .info-row {
    gap: 4px 10px;
  }

  #EPCI {
    flex: 1 1 140px;
    min-width: 0;
    margin-left: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
  }

  #NBCC {
    flex-basis: 100%;
    margin-left: 30px;
  }

}

@media (max-width: 480px) {
  .commune-label {
    font-size: 20px;
  }

  .resultat-item {
    gap: 12px;
  }

  .resultat-scores {
    min-width: 86px;
  }

  .resultat-label h4 {
    font-size: 15px;
  }

  .resultat-label p,
  .resultat-meta,
  .info-row,
  .stat-item {
    font-size: 14px;
  }
}

/* =========================
   LOADER CARTE
   ========================= */

.map-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

.map-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 38, 44, 0.42);
  backdrop-filter: blur(1.5px);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.map-loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.map-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.10);
}

.map-loading-spinner {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(255, 255, 255, 0.28);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: mapSpin 0.9s linear infinite;
}

.map-loading-text {
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-align: center;
}

@keyframes mapSpin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   FILTER
   ========================= */

.filter-marker-popup {
  min-width: 220px;
}

.filter-marker-popup__commune {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.filter-marker-popup__meta {
  margin-top: 2px;
  font-size: 12px;
  color: #6b7280;
}

.filter-marker-popup__tag {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.filter-marker-popup__tag.elected-t1 {
  background: #fdeaea;
  color: #b42318;
}

.filter-marker-popup__tag.qualified-t2 {
  background: #e8f1ff;
  color: #175cd3;
}

.filter-marker-popup__name {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #101828;
}

.filter-marker-popup__score {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  color: #175cd3;
}

.filter-marker-popup__nuance {
  margin-top: 4px;
  font-size: 12px;
  color: #667085;
}

.map-filter-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 18px 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f5f7f8;
  border: 1px solid #e3e8ec;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}

.map-filter-toolbar__title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.map-filter-toolbar__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.map-filter-chip {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #dbe3ea;
  background: #ffffff;
  color: #0f172a;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  margin: 0;
  box-shadow: none;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.map-filter-chip span {
  display: block;
}

.map-filter-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.map-filter-chip:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.28);
  outline-offset: 2px;
}

.map-filter-chip.is-active,
.map-filter-chip[aria-pressed="true"] {
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.map-filter-chip--patriote.is-active,
.map-filter-chip--patriote[aria-pressed="true"] {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
}

.map-filter-chip--lfi.is-active,
.map-filter-chip--lfi[aria-pressed="true"] {
  background: linear-gradient(135deg, #991b1b, #b91c1c);
}

.map-filter-chip--elected.is-active,
.map-filter-chip--elected[aria-pressed="true"] {
  background: linear-gradient(135deg, #0f766e, #0d9488);
}

@media (max-width: 900px) {
  .map-filter-toolbar {
    align-items: flex-start;
  }

  .map-filter-toolbar__title {
    width: 100%;
  }

  .map-filter-toolbar__row {
    width: 100%;
  }

  .map-filter-chip {
    min-height: 20px;
    font-size: 0.8rem;
  }
}

.hover-popup-state.provisional {
  color: #667085;
  font-style: italic;
}

.mun-info-label {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f7f7f8;
  border: 1px solid #e5e7eb;
}

.mun-info-label h4 {
  margin: 0 0 6px 0;
  font-size: 15px;
  line-height: 1.2;
  color: #111827;
}

.mun-info-label p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: #6b7280;
}

.hover-popup {
  min-width: 180px;
  max-width: 340px;
  overflow-wrap: anywhere;
  width: max-content;
}

.hover-popup-percent {
  color: #344054;
  white-space: nowrap;
  flex: 0 0 auto;
}

.hover-popup-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  flex: 0 0 auto;
}

.hover-popup-badge.elected-t1 {
  background: #fdeaea;
  color: #b42318;
}

.hover-popup-badge.qualified-t2 {
  background: #e8f1ff;
  color: #175cd3;
}

.hover-popup-badge.eliminated {
  background: #f2f4f7;
  color: #667085;
}

.candidate-badge sup,
.hover-popup-score sup,
.filter-marker-popup__tag sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.filter-marker-popup__commune-name {
  color: #111827;
  font-weight: 700;
}

.filter-marker-popup__commune-meta {
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
}

.filter-marker-popup__score.is-patriote {
  color: #175cd3;
}

.filter-marker-popup__score.is-lfi {
  color: #c1121f;
}

.filter-marker-popup__tag.is-lfi.qualified-t2 {
  background: #fdecec;
  color: #c1121f;
}

.filter-marker-popup__tag.is-patriote.qualified-t2 {
  background: #e8f1ff;
  color: #175cd3;
}

.filter-marker-popup__score sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.hover-popup-title {
  display: block;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 4px;
  row-gap: 2px;
  line-height: 1.3;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}

.hover-popup-title__commune {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.hover-popup-title__dep {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  white-space: normal;
  overflow-wrap: anywhere;
}

.filter-marker-popup__commune-dep {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
}

.hover-popup-title__depcode {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
}