:root {
  --theme-color: #a2b9ee;
  --sidebar-width: 250px;
  --dark-color: #343a40;
  --topbar-end-color: #f5f5f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f6f9;
  color: #212529;
}

/* =========================
   SIDEBAR
========================= */

#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--dark-color);
  color: white;
  transition: transform 0.3s ease;
  z-index: 3000;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar.hidden {
  transform: translateX(-100%);
}

.sidebar-toggle {
  width: 44px;
  height: 40px;
}

#listeBureaux .nav-link {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  transition: background 0.2s ease, opacity 0.2s ease;
}

#listeBureaux .nav-link:hover,
#listeBureaux .nav-link.active {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-global-link {
  font-weight: 700;
  margin-bottom: 12px !important;
  background: rgba(255, 255, 255, 0.10);
}

.bureau-inactif {
  color: #adb5bd !important;
  opacity: 0.65;
}

#openBtn {
  position: fixed;
  top: calc(85px / 2);
  left: 12px;
  transform: translateY(-50%);
  z-index: 4000;
  display: none;
  background-color: var(--dark-color);
  border-color: var(--dark-color);
}

/* =========================
   STRUCTURE
========================= */

#content {
  margin-left: var(--sidebar-width);
  padding-top: 85px;
  transition: margin-left 0.3s ease;
}

#content.full {
  margin-left: 0;
}

.topbar {
  height: 85px;
  background: linear-gradient(135deg, var(--theme-color), var(--topbar-end-color));
  color: white;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
}

#headerContent {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

#headerContent.full {
  margin-left: 70px;
}

.logo {
  width: 55px;
  height: 55px;
  object-fit: contain;
  border-radius: 12px;
  background: white;
  padding: 5px;
}

.site-title {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 1px;
}

.print-btn {
  background: transparent;
  border: none;
  color: rgb(82, 82, 82);
  font-size: 1.5rem;
}

.print-btn:hover,
.print-btn:focus {
  color: #d1d5db;
  background: transparent;
  box-shadow: none;
}

/* =========================
   INFOS SCRUTIN
========================= */

.election-infos {
  background: white;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.text-theme {
  color: var(--theme-color);
}

.label-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.info-text {
  font-size: 1.1rem;
}

.date-scrutin {
  text-align: right;
}

.secteur-select {
  max-width: 520px;
  min-width: 260px;
  font-size: 1.05rem;
}

/* =========================
   RESULTATS
========================= */

.result-card {
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.result-title {
  color: var(--theme-color);
  font-weight: 800;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  margin-bottom: 10px;
}

.bureaux-count {
  font-size: clamp(1.05rem, 1.5vw, 1.3rem);
  font-weight: 650;
  margin-bottom: 18px;
  color: #495057;
}

.bureaux-count strong {
  color: var(--theme-color);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.result-stat {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 9px 12px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-stat span {
  color: var(--theme-color);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.1;
}

.result-stat strong {
  font-size: 1rem;
  line-height: 1.2;
}

/* =========================
   CANDIDATS
========================= */

.candidat-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.candidat-photo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
}

.candidat-row-sans-photo {
  grid-template-columns: minmax(0, 1fr);
}

.candidat-row-sans-photo .bar-zone {
  width: 66%;
  max-width: 650px;
}

.candidat-result {
  width: 100%;
}

.candidat-nom {
  font-weight: 750;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.bar-zone {
  width: 66%;
  max-width: 650px;
}

.bar-labels {
  position: relative;
  height: 24px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.voix-label {
  position: absolute;
  left: 0;
}

.pourcentage-label {
  position: absolute;
  transform: translateX(6px);
  white-space: nowrap;
}

.progress-modern {
  width: 100%;
  height: 13px;
  background: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 900ms ease;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 992px) {

  #sidebar {
    transform: translateX(0);
  }

  #sidebar.hidden {
    transform: translateX(-100%);
  }

  #content,
  #content.full {
    margin-left: 0;
  }

  #headerContent,
  #headerContent.full {
    margin-left: 64px;
  }

  #openBtn {
    display: block;
  }

  main.container-fluid {
    padding-top: 20px !important;
  }

  .date-scrutin {
    text-align: left;
    width: 100%;
  }

  .secteur-select {
    width: 100%;
    min-width: 0;
  }

  /* ---------- Résultats ---------- */

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* ---------- Candidats ---------- */

  .candidat-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .candidat-photo {
    width: 64px;
    height: 64px;
  }

  .candidat-result {
    width: 100%;
    min-width: 0;
  }

  .bar-zone {
    width: 100%;
    max-width: none;
  }

  .bar-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    height: auto;
    margin-bottom: 8px;
  }

  .voix-label,
  .pourcentage-label {
    position: static;
    transform: none;
    white-space: nowrap;
  }

  /* Cas sans photo */

  .candidat-row-sans-photo {
    grid-template-columns: minmax(0, 1fr);
  }

}

@media (max-width: 576px) {
  #openBtn {
  top: calc(75px / 2);
  }

  .topbar {
    height: 75px;
  }

  .logo {
    width: 46px;
    height: 46px;
  }

  .site-title {
    font-size: 1.25rem;
  }

  .election-infos,
  .result-card {
    padding: 16px;
  }

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-stat {
    min-height: 54px;
    padding: 8px 10px;
  }

.candidat-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid #edf0f2;
  }

.candidat-row-sans-photo {
  display: block;
  padding-bottom: 20px;
  }

.candidat-row-sans-photo .bar-zone,
.bar-zone {
  width: 100%;
  max-width: none;
  }

.bar-labels {
  height: auto;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  }

.voix-label,
.pourcentage-label {
  position: static;
  transform: none;
  }
}

@media print {
  #sidebar,
  #openBtn,
  #toggleBtn,
  #printBtn {
    display: none !important;
  }

  #content,
  #content.full,
  #headerContent,
  #headerContent.full {
    margin-left: 0 !important;
  }

  body {
    background: white;
  }
}
