/**************************************************************
 * V3.3 — STYLE COMPLET AVEC ICÔNES + ANTI-SUPERPOSITION
 **************************************************************/

/* =========================
   BASE
   ========================= */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0f1724;
}

#map {
  height: 100%;
  width: 100%;
}

/* =========================
   TOOLBAR
   ========================= */

.map-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 10px;
  z-index: 1200;
  flex-wrap: wrap;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  background: rgba(25, 36, 52, 0.95);
  color: #f4f7fb;
  border: 1px solid rgba(91, 103, 128, 0.6);
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
  transition: 0.2s;
}

.toolbar-btn:hover {
  background: #2b3a52;
  transform: translateY(-1px);
}

.toolbar-btn.active {
  background: linear-gradient(135deg, #7c4dff, #9c6dff);
  border-color: transparent;
  color: #ffffff;
}

.toolbar-icon {
  font-size: 15px;
  line-height: 1;
}

/* =========================
   PANNEAUX
   ========================= */

.map-panel {
  position: absolute;
  top: 70px;
  width: 320px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;

  background: rgba(18, 28, 42, 0.96);
  color: #f4f7fb;
  border: 1px solid rgba(93, 107, 133, 0.4);
  border-radius: 16px;

  padding: 18px;
  z-index: 1200;

  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
}

/* Panneaux à gauche */
#layersPanel,
#comparePanel,
#favoritesPanel {
  left: 16px;
}

/* Légende à droite */
#legendPanel {
  right: 16px;
  width: 320px;
  max-width: calc(100vw - 32px);
}

.map-panel h3 {
  margin: 0 0 14px;
  color: #ffffff;
  font-size: 17px;
  font-weight: 800;
}

.map-panel p,
.map-panel label,
.map-panel strong,
.map-panel div,
#legendContent,
#legendContent p,
#legendContent strong {
  color: #f4f7fb;
}

/* =========================
   LISTES
   ========================= */

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.layer-btn,
.overlay-toggle-btn,
.favorite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;

  background: #344055;
  border: 1px solid #4d5d78;
  border-radius: 12px;
  padding: 11px 12px;
  color: white;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.layer-btn:hover,
.overlay-toggle-btn:hover,
.favorite-btn:hover {
  background: #3f4d66;
  transform: translateY(-1px);
}

.layer-btn.active,
.overlay-toggle-btn.active,
.favorite-btn.active {
  background: linear-gradient(135deg, #7c4dff, #9c6dff);
  border-color: transparent;
  box-shadow: 0 8px 16px rgba(124, 77, 255, 0.28);
}

.layer-btn::before,
.overlay-toggle-btn::before,
.favorite-btn::before {
  font-size: 14px;
  line-height: 1;
}

/* Icônes automatiques des listes */
.layer-btn[data-icon="map"]::before,
.favorite-btn[data-icon="map"]::before {
  content: "🗺️";
}

.layer-btn[data-icon="history"]::before,
.favorite-btn[data-icon="history"]::before {
  content: "🕰️";
}

.overlay-toggle-btn[data-icon="overlay"]::before,
.favorite-btn[data-icon="overlay"]::before {
  content: "📌";
}

/* =========================
   FORM SELECT
   ========================= */

.field.compact {
  margin-bottom: 12px;
}

.field.compact label {
  display: block;
  margin-bottom: 6px;
  color: #d8e1ef;
}

.field.compact select {
  width: 100%;
  background: #344055;
  color: white;
  border: 1px solid #4b5a74;
  border-radius: 10px;
  padding: 10px;
  outline: none;
}

.field.compact select:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

/* =========================
   BOUTONS GÉNÉRIQUES
   ========================= */

.btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: #8b5cf6;
  color: white;
}

.btn-secondary {
  background: #344055;
  color: white;
  border: 1px solid #4d5d78;
}

.compare-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* =========================
   ÉTAT ACTIF
   ========================= */

.active-state-panel {
  position: absolute;
  bottom: 100px;
  right: 70px;
  z-index: 1200;

  background: rgba(18, 28, 42, 0.95);
  color: #f4f7fb;
  border: 1px solid rgba(93, 107, 133, 0.4);
  border-radius: 14px;

  padding: 10px 12px;
  min-width: 220px;
  max-width: 280px;

  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  backdrop-filter: blur(6px);

  font-size: 13px;
  line-height: 1.45;
}

.active-state-panel strong {
  color: #ffffff;
}

#activeBaseLabel,
#activeOverlaysLabel {
  color: #cdb8ff;
  font-weight: 700;
}

/* =========================
   ZOOM LEAFLET
   ========================= */

.leaflet-bottom.leaflet-right {
  margin-bottom: 16px;
  margin-right: 16px;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 12px 26px rgba(0,0,0,0.28) !important;
}

.leaflet-control-zoom a {
  background: rgba(18, 28, 42, 0.95) !important;
  color: white !important;
  border: 1px solid #4d5d78 !important;

  width: 42px !important;
  height: 42px !important;
  line-height: 42px !important;

  border-radius: 12px !important;
  transition: 0.2s;
}

.leaflet-control-zoom a:hover {
  background: #8b5cf6 !important;
}

.leaflet-control-zoom-in {
  margin-bottom: 6px;
}

/* =========================
   SCROLLBAR
   ========================= */

.map-panel::-webkit-scrollbar {
  width: 8px;
}

.map-panel::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}

.map-panel::-webkit-scrollbar-thumb {
  background: #8b5cf6;
  border-radius: 999px;
}

.map-panel {
  scrollbar-width: thin;
  scrollbar-color: #8b5cf6 rgba(255,255,255,0.05);
}

/* =========================
   SWIPE
   ========================= */

.leaflet-sbs-range {
  z-index: 1000;
  cursor: ew-resize;
}

.leaflet-sbs-divider {
  z-index: 1001;
  background: rgba(255,255,255,0.9);
  width: 2px;
}

/* =========================
   SPLIT
   ========================= */

.split-compare-container {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  z-index: 900;
}

.split-map {
  height: 100%;
}

/* =========================
   MODALE
   ========================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.58);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal {
  width: 420px;
  max-width: calc(100vw - 30px);
  background: #1b2638;
  border: 1px solid rgba(93, 107, 133, 0.4);
  border-radius: 16px;
  padding: 20px;
  color: #f4f7fb;
  box-shadow: 0 18px 42px rgba(0,0,0,0.38);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  color: #ffffff;
}

.coord-text {
  margin-top: 8px;
  color: #b7c5da;
  font-size: 13px;
}

.icon-btn {
  background: transparent;
  color: #d8e1ef;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: #d8e1ef;
}

.field input[type="text"],
.field input[type="date"],
.field textarea,
.field input[type="file"] {
  width: 100%;
  box-sizing: border-box;
  background: #344055;
  color: #eef4ff;
  border: 1px solid #4b5a74;
  border-radius: 12px;
  padding: 12px;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 100px;
}

.field input[type="text"]:focus,
.field input[type="date"]:focus,
.field textarea:focus,
.field input[type="file"]:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.photo-block {
  border: 1px dashed #4b5a74;
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
}

.preview {
  display: block;
  margin-top: 8px;
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
}

/* =========================
   CHIPS CATÉGORIES
   ========================= */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid #5b6780;
  background: #344055;
  color: #eef4ff;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
}

.chip.active {
  background: linear-gradient(135deg, #7c4dff, #9c6dff);
  border-color: transparent;
  color: white;
}

/* =========================
   POPUPS
   ========================= */

.popup-card {
  font-size: 14px;
  min-width: 250px;
}

.popup-card h3 {
  margin: 0 0 8px;
  color: #18263a;
}

.popup-meta {
  margin-bottom: 10px;
}

.category-badge {
  background: #8b5cf6;
  padding: 4px 8px;
  border-radius: 10px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.badge-sticker444bb {
  background: #2563eb;
}

.badge-stickerbrigade {
  background: #dc2626;
}

.popup-desc {
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.popup-photos {
  display: grid;
  gap: 10px;
}

.popup-photo-item img {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.popup-date {
  margin-top: 4px;
  font-size: 12px;
  color: #5a6a84;
}

/* =========================
   UTILITAIRE
   ========================= */

.hidden {
  display: none !important;
}

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

@media (max-width: 900px) {
  .map-toolbar {
    top: 12px;
    left: 12px;
    gap: 8px;
  }

  .toolbar-btn {
    padding: 9px 12px;
    font-size: 13px;
  }

  #layersPanel,
  #comparePanel,
  #favoritesPanel,
  #legendPanel {
    left: 12px;
    right: auto;
    width: min(320px, calc(100vw - 24px));
  }

  .active-state-panel {
    left: 12px;
    right: auto;
    bottom: 90px;
    width: min(300px, calc(100vw - 24px));
  }
}