/* ===================================================================
   RESET & BASE
=================================================================== */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg-app: #f4f4f5;
    --panel-bg: #ffffff;
    --accent: #18181b; /* Noir profond */
    --border: #e4e4e7; /* Gris très fin */
    --text-main: #18181b;
    --text-muted: #71717a;
    --spacing: 0.75rem; /* Réduction drastique des marges */
}

body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f4f4f4;
}

/* ===================================================================
   HEADER / LAYOUT PRINCIPAL / CARTE
=================================================================== */
#header {
    background: #1e3f20;
    color: white;
    padding: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    position: relative;
    height: 50px;
    z-index: 2000;
}

#main-container {
    display: flex;
    flex: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
}

#map {
    position: absolute;
    top: 50px;
    bottom: 0;
    width: 100%;
    z-index: 1;
}

/* ===================================================================
   SIDEBAR (v2)
=================================================================== */
.sidebar {
    top: 50px;
    bottom: 0;
    width: 320px; /* Un peu plus large pour le confort */
    border-right: 1px solid var(--border);
}

.sidebar-pane {
    background-color: var(--panel-bg) !important;
    padding: 0; /* On gère le padding dans les enfants */
}

.sidebar-header {
    background-color: var(--accent) !important; /* Noir pro */
    color: #ffffff !important;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 15px !important;
    border-radius: 0 !important;
}

/* Suppression des ombres inutiles */
.sidebar-tabs {
    background-color: #fafafa !important;
    border-right: 1px solid var(--border);
}

/* Style des icônes par défaut (Vert foncé) */
.sidebar-tabs ul > li > a {
    color: #1e3f20 !important; /* Vert foncé par défaut */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    transition: all 0.3s ease;
}

/* Survol : Fond vert très clair pour indiquer la cible */
.sidebar-tabs ul > li:hover {
    background-color: #f0f4f0;
}

/* Onglet ACTIF : Fond vert foncé, icône blanche */
.sidebar-tabs ul > li.active {
    background-color: #1e3f20 !important; /* Vert foncé activé */
}

.sidebar-tabs ul > li.active > a {
    color: #ffffff !important; /* Icône en blanc quand actif */
}

/* Ajustement fin des icônes */
.sidebar-tabs i {
    width: 24px;
    height: 24px;
    stroke-width: 1.8;
}

/* =========================================
   UI FILTRES - LOOK "PRO & INDESTRUCTIBLE"
   ========================================= */
.filter-container-pro {
    display: flex;
    flex-direction: column;
    color: #111827;
}

/* Actions Globales (Tout cocher / décocher) */
.filter-global-actions-pro {
    display: flex;
    background: #f3f4f6;
    border-bottom: 4px solid #e5e7eb; /* Bordure épaisse pour scinder le haut */
}
.filter-btn-pro {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
    border-right: 1px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.filter-btn-pro:last-child { border-right: none; }
.filter-btn-pro:hover { background: #e5e7eb; color: #000; }

/* Groupes de filtres */
.filter-group-pro {
    border-bottom: 4px solid #f3f4f6; /* Séparation nette entre les groupes */
}
.filter-group-header-pro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}
.filter-group-title-pro {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-group-btn-invert {
    font-size: 0.65rem;
    text-transform: uppercase;
    padding: 4px 8px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    color: #4b5563;
    font-weight: 700;
    cursor: pointer;
    transition: 0.1s;
}
.filter-group-btn-invert:hover { background: #e5e7eb; border-color: #9ca3af; }

/* Éléments individuels (Spots) */
.spot-item-pro {
    border-bottom: 1px solid #f3f4f6;
    background: #ffffff;
}
.spot-item-pro:last-child { border-bottom: none; }

.spot-item-header-pro {
    display: flex;
    align-items: center;
    padding: 6px 12px; /* Marges très réduites */
}
.spot-item-label-pro {
    display: flex;
    align-items: center;
    flex-grow: 1;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    gap: 10px;
    user-select: none;
}
.spot-item-label-pro input[type="checkbox"],
.subcat-label-pro input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #1e3f20; /* Ton vert foncé pour rappeler GlanR */
}

/* Bouton chevrons */
.spot-item-toggle-pro {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}
.spot-item-toggle-pro:hover { color: #111827; }
.spot-item-toggle-pro svg { transition: transform 0.2s ease; }

/* Sous-menus (Détails) */
.spot-details-pro {
    background: #f9fafb; /* Fond très légèrement grisé */
    padding: 6px 12px 10px 38px; /* Alignement parfait sous le texte du parent */
    border-top: 1px solid #f3f4f6;
    font-size: 0.85rem;
}
.spot-details-title-pro {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #9ca3af;
    margin: 8px 0 6px 0;
    letter-spacing: 0.05em;
}
.spot-details-title-pro:first-child { margin-top: 0; }

.subcat-label-pro {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 6px;
    color: #374151;
}
.subcat-select-pro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: #374151;
}
.subcat-select-pro select {
    font-size: 0.85rem;
    padding: 2px 4px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    outline: none;
}

/* ===================================================================
   MARQUEURS & CONTROLES LEAFLET
=================================================================== */
.map-emoji-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    color: white;
}

/* Change le curseur lors du survol du marqueur */
.leaflet-marker-icon {
    cursor: move; /* Ou 'all-scroll' pour avoir les 4 flèches */
    cursor: -webkit-grab;
    cursor: grab;
}

/* Pendant le déplacement */
.leaflet-dragging .leaflet-marker-icon {
    cursor: -webkit-grabbing;
    cursor: grabbing;
}

/* Div interne des markers Leaflet */
.custom-spot-marker {
    cursor: pointer !important;
}

/* Décalage des contrôles Leaflet standards (Zoom) */
.leaflet-top.leaflet-left {
    margin-left: 50px; /* Décale les boutons de zoom quand la sidebar est présente */
    margin-top: 10px;
}

/* Positionnement du bouton GPS (si en bottomleft) */
.leaflet-bottom.leaflet-left {
    margin-bottom: 20px;
    margin-left: 10px;
}

/* ===================================================================
   LEGENDE
=================================================================== */
.legend {
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
}
.legend.minimized { height: 35px; overflow: hidden; }
.legend-content { display: block; }
.legend.minimized .legend-content { display: none; }
.legend-toggle { font-weight: bold; color: #1e3f20; margin-bottom: 5px; display: block; }

/* ===================================================================
   BOUTON GPS / BOUTON ITINERAIRE
=================================================================== */
.gps-button {
    background: white;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.2);
    display: block;
}

.route-btn {
    display: block;
    margin-top: 10px;
    padding: 8px;
    background: #007bff;
    color: white !important;
    text-align: center;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
}
.route-btn:hover {
    background-color: #218838 !important; /* Effet de survol sur le bouton */
}

/* ===================================================================
   POPUPS
=================================================================== */
.custom-popup .leaflet-popup-content-wrapper {
    border-radius: var(--radius); /* Carré */
    border: 1px solid var(--accent);
    padding: 2px;
}

.custom-popup .leaflet-popup-tip {
    background: var(--accent); /* La pointe noire */
}

.popup-header {
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
    padding-bottom: 4px;
}
.popup-title { font-size: 1.1em; font-weight: bold; color: #2c3e50; }
.popup-desc { color: #555; line-height: 1.4; margin: 8px 0; font-size: 0.9em; }
.popup-meta { color: #888; font-size: 0.8em; margin-top: 10px; }

/* ===================================================================
   SWITCH / TOGGLE - version generique (.switch / .slider)
=================================================================== */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
}
.slider.round { border-radius: 20px; }
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* Etat coché (ON) */
input:checked + .slider { background-color: #1e3f20; }
input:checked + .slider:before { transform: translateX(20px); }

/* Etat désactivé (lecture seule) */
input:disabled + .slider {
    background-color: #ccc !important;
    cursor: default !important;
    opacity: 0.7;
}
input:disabled:checked + .slider {
    background-color: #1e3f20 !important;
    opacity: 0.7;
}

/* Focus / active neutralisés sur le switch générique */
.switch-container { background-color: transparent !important; }
.switch-container input:focus + .slider,
.switch-container input:active + .slider {
    box-shadow: none !important;
    outline: none !important;
    background-color: #ccc !important; /* Force une couleur neutre */
}

/* ===================================================================
   SWITCH / TOGGLE - variante "glanr" (.glanr-switch / .glanr-slider)
=================================================================== */
.glanr-switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.glanr-switch input { opacity: 0; width: 0; height: 0; }

.glanr-slider {
    position: relative;
    display: inline-block;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 40px;
    height: 20px;
    background-color: #ccc;
    border-radius: 20px;
    flex-shrink: 0; /* Empêche le slider de s'écraser dans un flex */
    margin-right: 10px; /* Espace entre le slider et le texte */
    transition: 0.4s;
}
.glanr-slider.round { border-radius: 20px; }
.glanr-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
}

input:checked + .glanr-slider { background-color: #1e3f20 !important; }
input:checked + .glanr-slider:before { transform: translateX(20px); }

/* Cacher le vrai checkbox (indispensable) */
.glanr-switch-box input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.glanr-switch-box {
    display: flex;
    align-items: center; /* Aligne le slider et le texte au centre */
    margin-bottom: 12px;
    background-color: transparent !important;
}

/* ===================================================================
   FORMULAIRES
=================================================================== */
.modern-form .form-group { margin-bottom: 15px; }
.modern-form label { display: block; font-weight: 600; margin-bottom: 5px; color: #333; font-size: 0.9em; }

.modern-form input,
.modern-form select,
.modern-form textarea {
    border-radius: var(--radius); /* devient 0px */
    border: 1px solid var(--border);
    padding: 10px;
    font-size: 0.9rem;
    box-sizing: border-box; /* Important pour ne pas dépasser */
}

.modern-form input:focus,
.modern-form select:focus,
.modern-form textarea:focus {
    border-color: var(--accent);
    outline: 1px solid var(--accent);
}

.tags-section {
    background: #f4f7f6;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #1e3f20;
    margin: 15px 0;
    color: #333 !important;
}

.tag-container {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    margin-bottom: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.label-text { font-size: 0.9rem; font-weight: 500; }

/* Bouton Enregistrer (style harmonisé avec le bouton Modifier) */
.btn-save {
    background: #219150;                 /* couleur par défaut (ancienne couleur hover) */
    color: #ffffff;
    border: none;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 10px 14px;
    transition: background-color 150ms ease, transform 120ms ease, box-shadow 150ms;
    cursor: pointer;
    display: inline-block;
    box-shadow: none;
}

/* Hover : fonce la couleur */
.btn-save:hover {
    background: #1e3f20;                 /* couleur au survol (ancienne couleur normale) */
}

/* Focus visible (accessibilité) */
.btn-save:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(33,145,80,0.14);
}

/* Etat disabled : grisé et non cliquable */
.btn-save:disabled,
.btn-save[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    background: #9ca3af;                 /* couleur neutre pour état désactivé */
    box-shadow: none;
}

/* ===================================================================
   BOUTON FLOTTANT (FAB)
=================================================================== */
.fab-plus {
    position: fixed;
    bottom: 60px; /* Remonté pour ne pas chevaucher d'autres éléments */
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: var(--accent);
    color: white;
    border-radius: var(--radius); /* Carré */
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    padding-bottom: 3px; /* Centrage visuel du "+" */
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1); /* Ombre décalée type "design suisse" */
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
}
.fab-plus:hover {
    transform: scale(1.1);
    background-color: #2a5a2e; /* Nuance plus claire au survol */
}

/* ===================================================================
   CUSTOM EMOJI
=================================================================== */
.custom-emoji-marker {
    transition: transform 0.2s ease-in-out;
    cursor: pointer; /* Indique que l'élément est cliquable */
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-emoji-marker:hover {
    transform: scale(1.3); /* Un peu plus grand pour bien voir l'effet */
    z-index: 1000 !important;
}

/* ===================================================================
   WELCOME BUBBLE
=================================================================== */
.welcome-bubble {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 9999;
  text-align: center;
  width: 320px;          /* largeur fixe au lieu de max-width */
  max-height: 80vh;      /* limite la hauteur */
  overflow-y: auto;      /* scroll si besoin */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.welcome-btn {
  margin-top: 12px;
  padding: 10px 24px;
  background: #3a9e6f;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.95em;
  flex-shrink: 0;        /* empêche le bouton de se faire écraser */
  width: 100%;
}
.welcome-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none; border: none;
  font-size: 1.2em; cursor: pointer; color: #888;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes clignotement {
    0% { opacity: 1; color: inherit; }
    50% { opacity: 0.3; color: #d9534f; } /* Rouge pour attirer l'attention */
    100% { opacity: 1; color: inherit; }
}

.filtre-alerte {
    animation: clignotement 1s infinite;
}

/* ===================================================================
   AJUSTEMENTS FICHE DETAILS (Look Pro & Alignement)
=================================================================== */

/* Optimisation du Header de la Sidebar (Désormais le nom du spot) */
#details .sidebar-header {
    font-size: 1.1rem; 
    font-weight: 800; 
    padding-left: 20px !important; /* Aligne le titre parfaitement avec le texte en dessous */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Ajoute "..." si le nom du spot est très long */
    padding-right: 50px; /* Empêche le texte de passer sous la croix de fermeture */
}

/* Réduction de l'espace vide entre le header et le contenu */
#details-content {
    padding-top: 10px !important; 
}
/* Favorites UI (coeur, persistant) */
.glanr-fav-divicon { pointer-events: none; }
.fav-overlay {
    font-size: 16px;
    line-height: 16px;
    color: #e75a73; /* couleur coeur rouge/rose */
    text-shadow: 0 1px 0 rgba(0,0,0,0.15);
    transform: translateY(-6px);
    filter: drop-shadow(0 1px 0 rgba(0,0,0,0.12));
    will-change: transform;
}

/* Button in popup */
.fav-toggle {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    font-weight: 700;
    cursor: pointer;
}
.fav-toggle:hover {
    background: #fffbe6;
}

/* Button in details (btn-fav-details) already inlined styles; fallback classes */
.btn-fav {
    background: #219150;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px;
}

/* Heart on marker — simple emoji shifted up-right inside the icon */
.marker-heart {
    position: absolute;
    left: 50%;
    top: 50%;
    /* move slightly right (less negative X) and more up (more negative Y) */
    transform: translate(-30%, -75%);
    font-size: 18px;            /* ajustable : 16/18/20 */
    line-height: 1;
    pointer-events: none;
    z-index: 6;
    transition: transform 180ms cubic-bezier(.2,.9,.2,1), opacity 180ms ease;
    opacity: 1;
    will-change: transform, opacity;

    /* keep only the emoji (no bg/border/shadow) */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: inherit;
}

/* Slightly larger if you want stronger visual */
.marker-heart.large { font-size: 20px; }

/* entry animation: subtle pop */
.marker-heart.added {
    transform: translate(-30%, -75%) scale(0.6);
    opacity: 0;
    animation: heartPopSimple 320ms cubic-bezier(.2,.9,.2,1) forwards;
}
@keyframes heartPopSimple {
    0%   { transform: translate(-30%, -75%) scale(0.6); opacity: 0; }
    60%  { transform: translate(-30%, -75%) scale(1.12); opacity: 1; }
    100% { transform: translate(-30%, -75%) scale(1.0); opacity: 1; }
}