/* === Corps de la page - Fond sombre et texte clair === */
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: linear-gradient(to bottom right, #121212, #1a1a1a);
  backdrop-filter: blur(10px);
  color: #f0f0f0;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  transition: background-color 0.4s ease, color 0.4s ease;
  user-select: none; /* Désactive la sélection de texte */
  -webkit-user-select: none;
  -ms-user-select: none;
}

/* === Header principal sombre === */
header {
  background: #1a1a1a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  transform-style: preserve-3d;
  perspective: 800px;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  transform: translateZ(0);
}

/* Effet 3D au survol du header */
header:hover {
  transform: rotateX(3deg) translateZ(15px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  cursor: default;
}

/* === Sections gauche et droite du header === */
.header-left {
  display: flex;
  align-items: center;
}

.name {
  font-size: 1.3rem;
  font-weight: bold;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px; /* Espace entre icônes */
}

/* Liens et bouton thème dans le header */
.header-right a,
#theme-toggle {
  text-decoration: none;
  border: none;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
  color: #f0f0f0; /* Texte clair */
  transition: color 0.4s ease, transform 0.4s ease;
}

/* Icônes dans header - taille et transition */
.header-right i,
#theme-toggle i {
  font-size: 28px;
  margin: 0;
  pointer-events: none; /* Ne pas recevoir les clics */
  transition: color 0.4s ease, transform 0.4s ease;
}

/* Icône thème spécifique */
#theme-toggle i {
  font-size: 24px;
  background: transparent;
  box-shadow: none;
  margin: 0;
}

/* Hover - agrandissement et couleur bleu vif */
.header-right a:hover i,
#theme-toggle:hover i {
  transform: scale(1.2);
  color: #007AFF;
}

/* Bouton thème style */
#theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
}

/* Icône thème couleur et transition */
#theme-toggle i {
  color: #f0f0f0;
  transition: color 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

/* === Contenu principal - disposition flex avec espaces === */
.main-content {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem;
  flex-wrap: wrap; /* Permet de passer en colonne sur petits écrans */
}

/* Colonne de gauche - services */
.left-services {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1 1 300px;
  max-width: 400px;
}

/* Colonne de droite - carte */
.right-map {
  flex: 1 1 500px;
}

/* === Tuiles de services sombre === */
.tile {
  background: #181818;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: none !important;
  color: #f0f0f0;
  mix-blend-mode: normal !important;
  width: 100%;
  height: 90px;
  padding: 0.5rem;
  text-align: center;
  transition: all 0.3s ease;
  overflow: hidden;
  cursor: pointer;
  position: relative;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Hover tuiles - foncé plus profond et légère rotation/zoom */
.tile:hover {
  background: #121212;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  transform: scale(1.03) rotateX(2deg);
  z-index: 10;
}

/* Tuile étendue pour afficher détails */
.tile.expanded {
  height: 200px;
  background: #121212;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  cursor: default;
  transform: scale(1.03) rotateX(2deg);
  z-index: 10;
}

.tile.expanded .details {
  opacity: 1;
  max-height: 500px;
  pointer-events: auto;
  color: #f0f0f0;
}

/* Titres tuiles */
.tile .title {
  color: #f0f0f0;
  font-weight: bold;
  font-size: 1rem;
  margin-top: 6px;
}

/* Détails tuiles cachés par défaut, transition pour apparition */
.tile .details {
  color: #ccc;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, max-height 0.4s ease;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Icônes dans tuiles, couleur bleue et transition */
.tile i {
  color: #007AFF;
  transition: color 0.3s ease, transform 0.3s ease;
  mix-blend-mode: normal !important;
  font-size: 22px;
  margin: 0 4px;
  opacity: 1;
}

/* Hover icônes tuiles - bleu plus foncé et zoom */
.tile:hover i {
  color: #0051d4;
  transform: scale(1.2);
}

/* === Carte Leaflet sombre === */
#map {
  height: 450px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: all 0.4s ease;
  max-width: 100%;
  box-sizing: border-box;
  filter: none !important;
}

/* Cacher crédits Leaflet et logo */
.leaflet-control-attribution,
.leaflet-control-container .leaflet-control-logo {
  display: none !important;
}

/* Style popup sombre, translucide */
.leaflet-popup-content-wrapper {
  background: rgba(30, 30, 30, 0.85) !important;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  margin-bottom: 12px;
}

/* Supprime la flèche de popup */
.leaflet-popup-tip-container {
  display: none !important;
}

/* Texte popup clair */
.leaflet-popup-content {
  color: #ffffff !important;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* === Footer sombre === */
footer {
  background: linear-gradient(135deg, #1a1a1a, #333333);
  color: #ddd;
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.9rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  border-radius: 8px 8px 0 0;
  line-height: 1.6;
  letter-spacing: 0.02em;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Liens footer et popups */
footer a.footer-link,
footer a,
.popup-content a {
  color: #66ccff;
  text-decoration: none;
  font-weight: 600;
  margin-left: 0.4rem;
  transition: color 0.3s ease, transform 0.3s ease;
}

/* Hover liens footer */
footer a.footer-link:hover,
footer a:hover {
  color: #3399ff;
  text-decoration: underline;
  transform: scale(1.05);
}

/* Animation fade-in up pour footer */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

footer {
  animation: fadeInUp 0.8s ease forwards;
}

/* === Popup modale sombre === */
.popup {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: border-box;
}

.popup.fadeIn {
  animation: fadeInAnim 0.3s ease forwards;
}

.popup.fadeOut {
  animation: fadeOutAnim 0.3s ease forwards;
}

/* === Popup modale sombre allégée === */
.popup-content {
  background: #121212;
  backdrop-filter: blur(8px); /* Flou réduit */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Ombre plus douce */
  border-radius: 12px;
  padding: 1rem 1.2rem; /* Padding réduit */
  max-width: 600px;
  max-height: calc(85vh - env(safe-area-inset-bottom)); /* Hauteur un peu réduite */
  overflow-y: auto;
  position: relative;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 12px; /* Fixe une marge raisonnable */
}

/* Support pour navigateurs avec padding dynamique */
@supports(padding: max(env(safe-area-inset-bottom))) {
  .popup-content {
    max-height: calc(85vh - max(env(safe-area-inset-bottom)));
  }
}

/* Boutons fermer les popups, style identique */
.popup-close-btn,
#close-popup,
#close-apropos {
  position: absolute;
  width: 18px;
  height: 18px;
  background-color: rgba(255, 0, 0, 0.6);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 0, 0, 0.9);
  cursor: pointer;
  box-shadow:
    0 0 6px rgba(255, 0, 0, 0.8),
    0 0 10px rgba(255, 0, 0, 0.5);
  transition: box-shadow 0.3s ease;
  z-index: 1000;
}

/* Positionnement boutons fermer */
#close-popup,
#close-apropos {
  top: 15px;
  left: 15px;
}

.popup-close-btn {
  top: -10px;
  right: -20px;
}

/* Effet au survol des boutons fermer */
.popup-close-btn:hover,
#close-popup:hover,
#close-apropos:hover {
  box-shadow:
    0 0 10px rgba(255, 0, 0, 1),
    0 0 15px rgba(255, 0, 0, 0.7);
}

/* Classe utilitaire pour cacher un élément */
.hidden {
  display: none;
}

/* Animation d’apparition pour les popups */
@keyframes fadeInAnim {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Animation de disparition pour les popups */
@keyframes fadeOutAnim {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

/* === Responsive : ajustements pour écrans < 992px === */
@media screen and (max-width: 992px) {
  .main-content {
    flex-direction: column;
    padding-left: env(safe-area-inset-left, 1rem);
    padding-right: env(safe-area-inset-right, 1rem);
    padding-top: 1rem;
    padding-bottom: 2rem;
    gap: 2rem;
  }

  .tile,
  #map {
    width: calc(100vw - env(safe-area-inset-left, 1rem) - env(safe-area-inset-right, 1rem) - 2rem);
    max-width: 400px;
    margin: 0 auto;
    box-sizing: border-box;
  }

  .right-map {
    order: 2;
    flex: 1 1 auto;
    max-width: 100%;
  }

  .left-services {
    order: 1;
    max-width: 100%;
    flex: 1 1 auto;
  }

  .popup-content {
    max-width: 90vw;
    padding: 1.5rem 1rem;
    border-radius: 10px;
  }

  .popup-content i {
    margin-right: 6px;
    color: #007AFF;
    font-size: 1rem;
  }
}