* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
}

/* ── Sidebar ── */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: #1a1f2e;
  color: #e8eaf0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px;
  overflow-y: auto;
  z-index: 1000;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#sidebar h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.github-link {
  color: #4a90e2;
  text-decoration: none;
}
.github-link:hover { text-decoration: underline; }

.lang-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #2e3650;
  background: #252c3f;
  color: #e8eaf0;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.lang-btn:hover { background: #2e3854; }

.subtitle {
  font-size: 0.78rem;
  color: #8b92a8;
  margin-top: -14px;
}

/* ── Filter ── */
.filter-section label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b92a8;
  margin-bottom: 6px;
}

#fuel-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2e3650;
  background: #252c3f;
  color: #e8eaf0;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

#fuel-select:focus {
  border-color: #4a90e2;
}

/* ── Stats ── */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-box {
  background: #252c3f;
  border-radius: 10px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b92a8;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.stat-value.green { color: #4caf82; }
.stat-value.red   { color: #e05252; }

/* ── Pulse animation ── */
.pulse-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(74, 144, 226, 0.25);
  border: 3px solid #4a90e2;
  animation: pulse 0.8s ease-out infinite;
}

@keyframes pulse {
  0%   { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.stat-box.clickable {
  cursor: pointer;
  transition: background 0.15s;
}
.stat-box.clickable:hover { background: #2e3854; }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #8b92a8;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #2e3650;
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.hidden { display: none !important; }

/* ── Error ── */
.error {
  background: #3d1f1f;
  border: 1px solid #7a2f2f;
  color: #f08080;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ── Legend ── */
/* ── Route section ── */
.route-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #2e3650;
  padding-top: 16px;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b92a8;
}

.autocomplete-wrap {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #1e2538;
  border: 1px solid #2e3650;
  border-top: none;
  border-radius: 0 0 8px 8px;
  list-style: none;
  z-index: 9999;
  max-height: 200px;
  overflow-y: auto;
}

.suggestions li {
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #c0c6d8;
  cursor: pointer;
  border-bottom: 1px solid #2e3650;
  line-height: 1.3;
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover { background: #252c3f; color: #fff; }

.route-section input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #2e3650;
  background: #252c3f;
  color: #e8eaf0;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.route-section input:focus { border-color: #4a90e2; }
.route-section input::placeholder { color: #555e78; }

.route-buttons {
  display: flex;
  gap: 8px;
}

#route-btn {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  border: none;
  background: #4a90e2;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
#route-btn:hover { background: #357abd; }

#route-clear {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #2e3650;
  background: transparent;
  color: #8b92a8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
#route-clear:hover { background: #252c3f; color: #e8eaf0; }

#route-stations {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-list-header {
  font-size: 0.72rem;
  color: #8b92a8;
  padding: 2px 0 4px;
}

.route-station-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #252c3f;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.route-station-item:hover { background: #2e3854; }

.route-rank {
  width: 20px;
  height: 20px;
  background: #f5a623;
  color: #1a1f2e;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.route-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.route-addr {
  font-size: 0.75rem;
  color: #c0c6d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: #4caf82;
}

.route-star-marker {
  width: 28px;
  height: 28px;
  background: #f5a623;
  color: #1a1f2e;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ── Locate button ── */
#locate-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: #4a90e2;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#locate-btn:hover  { background: #357abd; }
#locate-btn:active { background: #2a6099; }

/* ── Legend ── */
.legend {
  border-top: 1px solid #2e3650;
  padding-top: 16px;
}

.legend h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b92a8;
  margin-bottom: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.legend-gradient {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, rgb(0,200,40), rgb(128,100,40), rgb(255,0,40));
  margin-bottom: 4px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #8b92a8;
}

/* ── Footer ── */
.footer {
  margin-top: auto;
  font-size: 0.72rem;
  color: #555e78;
  border-top: 1px solid #2e3650;
  padding-top: 12px;
}

.footer a {
  color: #4a90e2;
  text-decoration: none;
}

/* ── Map ── */
#map {
  flex: 1;
  height: 100%;
}

/* Supprime le contour de focus Leaflet sur les polygones */
.leaflet-interactive:focus {
  outline: none;
}

/* ── Dept tooltip ── */
.dept-tooltip {
  background: rgba(26, 31, 46, 0.85);
  border: none;
  border-radius: 4px;
  color: #e8eaf0;
  font-size: 0.75rem;
  padding: 3px 7px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Popup header ── */
.popup-header {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.popup-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1f2e;
}

.popup-content address {
  font-style: normal;
  font-size: 0.75rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 8px;
}

/* ── Popup ── */
.leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.popup-content {
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-width: 180px;
}

.popup-content .address {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.4;
}


.popup-content .prices {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.price-row .fuel-name {
  color: #555;
}

.price-row .fuel-price {
  font-weight: 700;
  color: #1a1f2e;
}

.price-row.highlighted .fuel-price {
  color: #4a90e2;
  font-size: 0.95rem;
}

.popup-content .update-date {
  font-size: 0.68rem;
  color: #aaa;
  margin-top: 8px;
  border-top: 1px solid #f0f0f0;
  padding-top: 6px;
}

/* ── Sidebar toggle (mobile only, hidden on desktop) ── */
#sidebar-toggle {
  display: none;
}

.sidebar-handle {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  body { flex-direction: column; }

  #map {
    position: fixed;
    inset: 0;
    z-index: 1;
  }

  #sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-width: unset;
    max-height: 75vh;
    padding: 8px 16px 24px;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  #sidebar.open {
    transform: translateY(0);
  }

  .sidebar-handle {
    display: block;
    width: 40px;
    height: 4px;
    background: #555e78;
    border-radius: 2px;
    margin: 4px auto 12px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* Aperçu visible quand sidebar fermée : titre + filtre */
  #sidebar h1 { font-size: 1.1rem; }

  #sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 999;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #1a1f2e;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    cursor: pointer;
  }

  /* Touch targets plus grands */
  #fuel-select,
  #route-from,
  #route-to,
  #route-btn,
  #locate-btn {
    min-height: 44px;
    font-size: 1rem;
  }

  /* Popup plein largeur */
  .leaflet-popup-content-wrapper {
    width: 90vw;
    max-width: 360px;
  }
}
