/* --- CORPS --- */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

/* --- CARTE --- */
#map {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- BARRE DE RECHERCHE --- */
.leaflet-control-geocoder {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 280px;
}
.leaflet-control-geocoder-form input {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

/* --- MINIATURES FOND DE CARTE --- */
#miniatures {
    position: absolute;
    bottom: 20px;
    left: 15px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}
.btn-carte {
    width: 65px;
    height: 65px;
    border: 2px solid white;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 3px black;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 5px;
    transition: transform 0.2s, border-color 0.2s;
}
.btn-carte:hover { transform: scale(1.05); }
#btn-plan { background-image: url('https://a.tile.openstreetmap.org/9/257/174.png'); background-size: cover; }
#btn-sat  { background-image: url('https://mt1.google.com/vt/lyrs=s&x=257&y=174&z=9');  background-size: cover; }
.btn-carte.active { border: 3px solid #8B0000; }

/* --- BOUTONS OUTILS (glassmorphism) --- */
#custom-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    padding: 10px 20px;
    color: #333;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}
.glass-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.65);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.glass-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(200, 200, 200, 0.3);
}

/* Boutons Éditer / Supprimer — plus petits */
.glass-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    gap: 5px;
}

/* Bouton actif (outil sélectionné) */
.tool-btn.active-tool {
    background: rgba(139, 0, 0, 0.35);
    border-color: rgba(139, 0, 0, 0.7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139,0,0,0.25);
}
.tool-btn.active-tool svg { stroke: #fff; }

/* Séparateur vertical entre groupes de boutons */
.tool-separator {
    width: 1px;
    height: 32px;
    background: rgba(255,255,255,0.5);
    border-radius: 1px;
    margin: 0 2px;
}

.icon { display: flex; align-items: center; }

.valider-btn { padding-left: 25px; padding-right: 25px; }

/* --- LOADER SPINNER dans le bouton Valider --- */
.loader-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(50,50,50,0.3);
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* Spinner blanc pour boutons à fond sombre (ex: export PDF) */
#btn-export-pdf .loader-spinner {
    border-color: rgba(255,255,255,0.3);
    border-top-color: #ffffff;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* --- SIDEBAR --- */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background-color: #2c143d;
    color: #ffffff;
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    z-index: 2000;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
                visibility 0.4s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    border-radius: 8px 0 0 8px;
}

/* État caché — hors écran + invisible + non interactif */
#sidebar.hidden {
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
}

#sidebar h2 {
    background-color: #1a0b24;
    color: #ffffff;
    padding: 15px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    border-radius: 8px 0 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#close-sidebar {
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    opacity: 0.7;
    line-height: 1;
}
#close-sidebar:hover { opacity: 1; }

#sidebar p {
    margin: 10px 0;
    color: #e0e0e0;
    font-size: 15px;
}
#sidebar p strong {
    color: #f1c40f;
    font-weight: 600;
}
#sidebar h3 {
    color: #ffffff;
    padding: 0;
    margin: 0;
    font-size: 16px;
}

/* Onglet flèche collé au bord droit pour rouvrir la sidebar */
#btn-open-sidebar {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 1500;
    width: 22px;
    height: 56px;
    background: #2c143d;
    color: white;
    border: none;
    border-radius: 8px 0 0 8px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -3px 0 10px rgba(0,0,0,0.35);
    transition: width 0.2s, background 0.2s;
    line-height: 1;
}
#btn-open-sidebar:hover {
    background: #3d1f55;
    width: 28px;
}

canvas {
    max-width: 100%;
    margin-top: 15px;
    padding: 0 20px 10px 20px;
    box-sizing: border-box;
}

/* --- BOUTON EXPORT PDF --- */
#btn-export-pdf {
    background: rgba(139, 0, 0, 0.5) !important;
    border-color: rgba(139, 0, 0, 0.8) !important;
    color: #ffffff !important;
}
#btn-export-pdf:hover:not(:disabled) {
    background: rgba(139, 0, 0, 0.75) !important;
    box-shadow: 0 6px 20px rgba(139, 0, 0, 0.3) !important;
    transform: translateY(-2px);
}

/* --- BOUTON EXPORT CSV --- */
#btn-export-csv {
    background: rgba(34, 139, 34, 0.5) !important;
    border-color: rgba(34, 139, 34, 0.8) !important;
    color: #ffffff !important;
}
#btn-export-csv:hover:not(:disabled) {
    background: rgba(34, 139, 34, 0.75) !important;
    box-shadow: 0 6px 20px rgba(34, 139, 34, 0.4) !important;
    transform: translateY(-2px);
}

/* --- TABLEAU DETAILS KIVIAT --- */
.table-details {
    width: 100%;
    border-collapse: collapse;
    color: #e0e0e0;
    font-size: 13px;
}
.table-details th {
    text-align: left;
    padding: 6px;
    border-bottom: 1px solid #f1c40f;
    color: #f1c40f;
}
.table-details td {
    padding: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#btn-toggle-details:hover {
    background: #34495e;
}
/* --- LEAFLET DRAW EDITING ICON OVERRIDE --- */
.leaflet-editing-icon {
    background-color: #8B0000 !important;
    width: 11px !important;
    height: 11px !important;
    border-radius: 50% !important;
    border: 2px solid white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4) !important;
    /* Ajustement de l'ancrage depuis -4px vers -5.5px pour un centrage parfait de 11px */
    margin-left: -5.5px !important;
    margin-top: -5.5px !important;
}

/* ============================= */
/* Panneau Affichage             */
/* ============================= */

#panel-affichage {

    position: absolute;

    top: 80px;

    left: 10px;

    width: 180px;
   
    padding: 15px;

    z-index: 1200;

    background: rgba(30,30,30,0.75);

    backdrop-filter: blur(10px);

    color: white;

    border-radius: 12px;

    box-shadow: 0 4px 12px rgba(0,0,0,0.4);

}

#panel-affichage h4{


    margin-top:0;

    margin-bottom:15px;

    text-align:center;

}

#panel-affichage input[type="range"]{

    width:100%;

}

/* Décalage de l'échelle Leaflet au-dessus des boutons Plan/Satellite */

.leaflet-bottom.leaflet-left .leaflet-control-scale {

    margin-left: 10px !important;

    margin-bottom: 100px !important;
