/* Styles pour le contrôle de légende de MapLibre */

/* Styles pour le conteneur */
.legend-container {
    margin: 0 !important;
    border-radius: 4px;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* Position ajustée */
.maplibregl-ctrl-top-left .legend-container {
    margin-top: 50px !important;
    margin-left: 6px !important;
}

/* Styles du bouton de légende - version carrée avec coins arrondis */
.maplibregl-ctrl-legend {
    background-color: var(--bg-tertiary) !important;
    border: 0;
    border-radius: 4px !important; /* Coins légèrement arrondis au lieu de circulaire */
    cursor: pointer;
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px var(--shadow-color);
    box-sizing: border-box !important;
}

/* Effet hover - supprime la transparence */
.maplibregl-ctrl-legend:hover {
    background-color: var(--bg-hover) !important;
    box-shadow: 0 1px 4px var(--shadow-hover-color);
}

.maplibregl-ctrl-group .maplibregl-ctrl-legend {
    border-radius: 4px !important; /* Assure la cohérence pour le bouton dans un groupe */
}

/* Centrer parfaitement l'icône */
.maplibregl-ctrl-icon {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Ajustement de l'icône pour la taille réduite du bouton */
.maplibregl-ctrl-legend .maplibregl-ctrl-icon svg {
    width: 18px !important;
    height: 18px !important;
    stroke: var(--icon-color);
    fill: none;
    display: block !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    transition: all 0.2s ease;
}

.maplibregl-ctrl-legend:hover .maplibregl-ctrl-icon svg {
    stroke: var(--icon-hover-color);
    transform: scale(1.05);
}

.maplibregl-ctrl-legend.active {
    background-color: var(--bg-hover);
}

.maplibregl-ctrl-legend.active .maplibregl-ctrl-icon svg {
    stroke: var(--icon-hover-color);
}

/* Panneau de légende */
.maplibregl-legend-panel {
    position: absolute;
    left: 40px;
    top: 0;
    background: var(--bg-primary);
    border-radius: 4px;
    box-shadow: 0 0 0 2px var(--shadow-color);
    padding: 12px;
    /* Rendre la largeur adaptative avec un minimum et un maximum */
    width: auto !important;
    min-width: 200px !important;
    max-width: 300px !important;
    /* Rendre la hauteur adaptative avec un maximum */
    height: auto !important;
    max-height: 550px !important;
    overflow-y: auto;
    overflow-x: hidden; /* Éviter le défilement horizontal */
    transform: translateX(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.maplibregl-legend-panel:hover {
    background: var(--bg-hover) !important; /* Complètement opaque au survol */
    transition: background 0.2s ease; /* Transition douce */
}

/* Ajustement du panneau de légende pour la taille réduite du bouton */
.maplibregl-ctrl-top-left .maplibregl-legend-panel {
    left: 0;
    top: 28px; /* Ajusté pour la taille du bouton */
}

.maplibregl-legend-panel.visible {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

.maplibregl-legend-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.maplibregl-legend-group {
    margin-bottom: 16px;
}

.maplibregl-legend-group:last-child {
    margin-bottom: 0;
}

.maplibregl-legend-group-title {
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.maplibregl-legend-item {
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
    padding: 4px;
    border-radius: 4px;
}

.maplibregl-legend-item:last-child {
    margin-bottom: 0;
}

.maplibregl-legend-item:hover {
    background-color: var(--bg-hover);
}

.maplibregl-legend-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.maplibregl-legend-icon svg {
    width: 24px;
    height: 24px;
}

.maplibregl-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}

.maplibregl-legend-label {
    font-size: 13px;
    color: var(--text-color);
    line-height: 1.3;
}

/* Scrollbar styles */
.maplibregl-legend-panel::-webkit-scrollbar {
    width: 6px;
}

.maplibregl-legend-panel::-webkit-scrollbar-track {
    background: transparent;
}

.maplibregl-legend-panel::-webkit-scrollbar-thumb {
    background-color: var(--shadow-color);
    border-radius: 3px;
}

/* Étoile d'occupation animée */
.maplibregl-legend-star {
    display: inline-block;
    font-size: 22px;
    color: #ffe500;
    text-shadow: 0 0 1px #ff0000;
    transform-origin: center center;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: rotate-star 3s linear infinite, pulsate-star 2s ease-in-out infinite;
}






@keyframes rotate-star {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulsate-star {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Responsive */
@media (max-width: 768px) {
    .maplibregl-legend-panel {
        max-width: 240px !important;
        max-height: 450px !important;
    }
}