* {
    font-family: 'Inter', sans-serif;
}

/* Masquer les ascenseurs disgracieux sur html/body uniquement */
html,
body {
    overflow: hidden;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Masquer l'ascenseur sur le sélecteur de calques Leaflet */
.leaflet-control-layers-scrollbar::-webkit-scrollbar,
.leaflet-control::-webkit-scrollbar {
    display: none;
}

.leaflet-control-layers-scrollbar,
.leaflet-control {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Cacher complètement le sélecteur de calques quand il est fermé */
.leaflet-control-layers {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.leaflet-control-layers-toggle {
    width: 36px !important;
    height: 36px !important;
    background-color: rgba(15, 23, 42, 0.88) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.leaflet-control-layers-expanded {
    background: rgba(15, 23, 42, 0.95) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    padding: 8px !important;
    color: white !important;
}

.leaflet-control-layers-expanded label {
    color: white !important;
}

#map {
    height: 100vh;
    width: 100vw;
    z-index: 0;
}

/* Glassmorphism */
.glass-panel {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Viewer Animations */
#viewer-container {
    transition: opacity 0.5s ease-out, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.viewer-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(30px);
}

.viewer-visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* Panel Admin */
#creator-panel {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.panel-closed {
    transform: translateX(120%);
    opacity: 0;
}

.panel-open {
    transform: translateX(0);
    opacity: 1;
}

/* Tooltip Riche */
.leaflet-tooltip.rich-tooltip {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0;
    border-radius: 14px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    min-width: 240px;
    border-bottom: 3px solid #6366f1;
    /* Petite barre de rappel couleur Indigo */
}

.leaflet-tooltip.rich-tooltip::before,
.leaflet-tooltip.rich-tooltip::after {
    display: none !important;
}

/* Marqueurs & Pins (Nouveau Design) */
.custom-marker-wrapper {
    background: transparent;
    border: none;
}

.marker-pin-container {
    position: relative;
    width: 40px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* La forme de goutte (Pin) */
.marker-pin {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    /* Forme de goutte */
    transform: rotate(-45deg) translate(0, 0);
    /* Rotation pour avoir la pointe en bas */
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -16px;
    margin-top: -24px;
    border: 2px solid white;
    /* Ombre portée subtile pour le relief */
    box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(0, 0, 0, 0.2) !important;
}

/* L'icône à l'intérieur (doit rester droite) */
.marker-pin-container .marker-icon {
    position: absolute;
    top: 2px;
    /* Ajusté pour centrer parfaitement dans la partie circulaire */
    left: 0;
    width: 40px;
    /* Toute la largeur du conteneur pour un centrage horizontal facile */
    height: 32px;
    /* Hauteur de la partie ronde */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
}

.marker-pin-container .marker-icon i {
    font-size: 1.1rem;
    line-height: 1;
    display: block;
}

/* Ombre au sol (ellipse) */
.marker-shadow {
    position: absolute;
    width: 20px;
    height: 5px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    bottom: -2px;
    /* Sous la pointe */
    left: 50%;
    transform: translateX(-50%);
    filter: blur(2px);
    z-index: -1;
}

/* 🗺️ CLUSTERS PREMIUM (Modernisation & Correction) */
.custom-cluster-resource {
    background: transparent;
    border: none;
}

.cluster-premium-icon {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cluster-inner {
    position: relative;
    z-index: 10;
    width: 42px;
    height: 42px;
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.cluster-inner i {
    font-size: 11px;
    color: #6366f1;
    /* Indigo */
    margin-bottom: 2px;
}

.cluster-count {
    font-weight: 800;
    font-size: 14px;
    line-height: 1;
}

/* Le Halo lumineux derrière le groupe */
.cluster-glow {
    position: absolute;
    inset: 8px;
    background: #6366f1;
    border-radius: 50%;
    filter: blur(12px);
    opacity: 0.3;
    z-index: 1;
    animation: cluster-pulse 2s infinite ease-in-out;
}

@keyframes cluster-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }
}

.cluster-premium-icon:hover {
    transform: scale(1.1);
}

/* Animations spécifiques Cluster */
@keyframes pulse-cluster-green {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

@keyframes pulse-cluster-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(14, 165, 233, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0);
    }
}

@keyframes pulse-cluster-indigo {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
    }

    70% {
        box-shadow: 0 0 0 20px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

/* Small - Nature/Vert */
.marker-cluster-small {
    background-color: rgba(34, 197, 94, 0.3) !important;
    animation: pulse-cluster-green 2s infinite;
    border: none !important;
}

.marker-cluster-small div {
    background: linear-gradient(135deg, #4ade80 0%, #16a34a 100%) !important;
}

/* Medium - Eau/Bleu */
.marker-cluster-medium {
    background-color: rgba(14, 165, 233, 0.3) !important;
    animation: pulse-cluster-blue 2s infinite;
    border: none !important;
}

.marker-cluster-medium div {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%) !important;
}

/* Large - Urbain/Mixte (Indigo) */
.marker-cluster-large {
    background-color: rgba(99, 102, 241, 0.3) !important;
    animation: pulse-cluster-indigo 2s infinite;
    border: none !important;
}

.marker-cluster-large div {
    background: linear-gradient(135deg, #818cf8 0%, #4f46e5 100%) !important;
}

/* ANIMATIONS & UTILITAIRES */

/* Animation de flottement (Pour les pins) */
@keyframes floating {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-6px);
    }

    100% {
        transform: translateY(0px);
    }
}

.marker-floating {
    animation: floating 3s ease-in-out infinite;
}

.cursor-crosshair {
    cursor: crosshair !important;
}

/* Masquer les barres de défilement (ascenseurs) */
#creator-panel .flex-1::-webkit-scrollbar,
#creator-panel textarea::-webkit-scrollbar {
    display: none;
}

#creator-panel .flex-1,
#creator-panel textarea {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Décaler le sélecteur de calques pour éviter le header */
.leaflet-top.leaflet-right {
    margin-top: 70px !important;
    margin-right: 12px !important;
}

/* Loader */
.loader-spin {
    animation: spin 1s linear infinite;
}

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

/* Dropdown Menus (Catégories & Départements) */
#categories-dropdown,
#dept-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    /* Empêche de cliquer quand fermé */
}

#categories-dropdown.open,
#dept-dropdown.open {
    max-height: 70vh;
    /* Limite à 70% de la hauteur écran */
    overflow-y: auto;
    /* Active le scroll vertical */
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Scrollbar discrète pour les dropdowns */
#categories-dropdown::-webkit-scrollbar,
#dept-dropdown::-webkit-scrollbar {
    width: 4px;
}

#categories-dropdown::-webkit-scrollbar-track,
#dept-dropdown::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#categories-dropdown::-webkit-scrollbar-thumb,
#dept-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#categories-dropdown::-webkit-scrollbar-thumb:hover,
#dept-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive & Mobile Optimizations (100% Compatible Tablet/Cisco Phone) */
@media (max-width: 768px) {

    /* 📱 MOBILE HEADER LAYOUT GRID SYSTEM */
    .header-container {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 0.5rem !important;
    }

    /* Row 1: Logo & Search (Full Width) */
    .header-container>div:nth-child(1) {
        /* Logo */
        width: 100%;
        order: 1;
        justify-content: space-between;
        /* Spread content if needed */
    }

    .header-container>div:nth-child(2) {
        /* Search */
        width: 100%;
        order: 2;
        margin-bottom: 0.25rem;
    }

    /* Row 2: Categories & Depts (Side by Side) */
    .header-container>div:nth-child(3),
    /* Categories */
    .header-container>div:nth-child(4) {
        /* Departments */
        width: calc(50% - 0.25rem);
        /* Half width minus gap */
        order: 3;
    }

    /* Row 3: Action Buttons (Grouped) */
    .header-container>button {
        flex-grow: 1;
        /* Distribute remaining space */
        order: 4;
        justify-content: center;
        /* Center icons */
        padding: 0.5rem !important;
        /* Smaller hit area padding but keep size */
    }

    /* Optimized Glass Panel for Mobile */
    .header-container>.glass-panel {
        padding: 0.4rem 0.6rem !important;
    }

    /* 🗺️ MAP CONTROLS POSITIONING */
    /* Move controls down so they don't overlap with the stacked header */
    .leaflet-top.leaflet-right {
        margin-top: 220px !important;
        /* Adjust based on header height (~4 rows) */
        margin-right: 10px !important;
    }

    /* 🔧 CREATOR PANEL (Bottom Sheet) */
    #creator-panel {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        max-height: 50vh;
        /* Reduced height to keep map visible */
        border-radius: 20px 20px 0 0;
        z-index: 1200;
        /* Above header, below modals (2000+) */
    }

    .panel-closed {
        transform: translateY(110%);
    }

    .panel-open {
        transform: translateY(0);
    }

    /* 🏢 AGENCY DASHBOARD MOBILE */
    /* Force column layout and show sidebar */
    #agency-dashboard>div.flex-1 {
        flex-direction: column;
    }

    #agency-dashboard .w-64.hidden.md\:flex {
        display: flex !important;
        width: 100%;
        height: auto;
        max-height: 200px;
        overflow-x: auto;
        /* Horizontal scroll if tags overflow */
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 1rem;
    }

    /* 🍎 iOS INPUT ZOOM FIX */
    /* Prevent auto-zoom on inputs < 16px */
    input[type="text"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* 📱 LANDSCAPE MOBILE & SAFE AREAS */
@media (max-width: 900px) and (orientation: landscape) {
    .header-container {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: 100vh;
        overflow-y: auto;
        align-items: flex-start;
        /* Align top */
    }

    /* Revert widths for landscape */
    .header-container>div:nth-child(1),
    /* Logo */
    .header-container>div:nth-child(2) {
        /* Search */
        width: auto;
        flex-grow: 1;
        min-width: 200px;
    }

    .leaflet-top.leaflet-right {
        margin-top: 10px !important;
        margin-right: 60px !important;
    }
}

/* 🛡️ NOTCH & SAFE AREA SUPPORT */
.fixed.top-4 {
    top: max(1rem, env(safe-area-inset-top));
}

.fixed.bottom-4,
.fixed.bottom-6 {
    bottom: max(1rem, env(safe-area-inset-bottom));
}

/* 👆 TOUCH TARGET SIZE & UX */
button,
.filter-btn,
input,
select {
    min-height: 44px;
    /* Apple Human Interface Guidelines */
    touch-action: manipulation;
    /* Improves tap response */
}

/* Fix scrolling on iOS */
.overflow-y-auto,
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar Personnalisée */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}