/* ========================================
   PAGE: CARTE LEAFLET (/map)
   Tous les styles liés à la carte et au sidepanel
   ======================================== */

/* ==========================================
   CONTENEUR DE LA CARTE
   ========================================== */

#map {
    height: 85vh;
    width: 100%;
    background-color: var(--bg-body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.page-content {
    padding: 0px;
}
/* ==========================================
   PERSONNALISATION LEAFLET (popups et tooltips)
   ========================================== */

.leaflet-popup-content-wrapper {
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    font-style: italic;
    line-height: 1.4;
    max-width: 250px;
}

.leaflet-popup-content {
    margin: 0;
    padding-right: 10px;
}

.leaflet-popup-tip {
    background: rgba(0, 0, 0, 0.8);
}

.leaflet-popup-close-button {
    top: 4px;
    right: 6px;
    color: var(--text-secondary);
    font-size: 1.2em;
}

.leaflet-tooltip {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    color: var(--text-primary);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    font-style: italic;
    line-height: 1.4;
    max-width: 250px;
    pointer-events: auto;
}

.leaflet-tooltip-content {
    margin: 0;
    padding-right: 10px;
}

.leaflet-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8);
    border-right-color: transparent;
    border-left-color: transparent;
    border-bottom-color: transparent;
}

.leaflet-tooltip-top::before {
    border-top-color: rgba(0,0,0,0.8);
}
.leaflet-tooltip-bottom::before {
    border-bottom-color: rgba(0,0,0,0.8);
}
.leaflet-tooltip-left::before {
    border-left-color: rgba(0,0,0,0.8);
}
.leaflet-tooltip-right::before {
    border-right-color: rgba(0,0,0,0.8);
}

/* ==========================================
   BARRE DE RECHERCHE ANIMÉE
   ========================================== */

.animated-search-box {
    background-color: var(--text-white);
    border-radius: 5px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    padding: 5px;
    border: 2px solid rgba(0,0,0,0.2);
    background-clip: padding-box;
}

.search-input {
    flex: 1;
    border: none;
    padding: 5px;
    outline: none;
    transition: width 0.3s;
    width: 0;
    overflow: hidden;
}

.search-input.active {
    width: 150px;
}

.search-icon {
    width: 25px;
    height: 25px;
    margin-right: 5px;
}

.search-icon img {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.ui-autocomplete {
    transform: translate(-50%, -50%) !important;
    z-index: 1000 !important;
}

/* ==========================================
   CONTRÔLE DE SAISON
   ========================================== */

#customControl {
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    line-height: 1.6;
    max-width: 280px;
    
    /* Amélioration lisibilité */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#customControl strong {
    color: var(--color-primary);
    font-weight: 600;
}

/* Responsive mobile */
@media (max-width: 768px) {
    #customControl {
        font-size: 12px;
        padding: 10px 12px;
        max-width: 200px;
        
        /* Mobile : éviter qu'il masque les contrôles zoom */
        margin-bottom: 60px;  /* Décale vers le haut */
    }
}

/* Si trop proche du bord sur petits écrans */
@media (max-width: 480px) {
    #customControl {
        font-size: 11px;
        padding: 8px 10px;
        max-width: 180px;
        margin-bottom: 70px;
    }
}

/* ==========================================
   LÉGENDES
   ========================================== */

.legend-map ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.legend-map ul li {
    width: calc(50% - 10px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-columns-map {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 300px;
    padding-left: 0;
    margin-top: 10px;
}

.legend-columns-map li {
    flex: 1 1 45%;
    list-style: none;
    display: flex;
    align-items: center;
}

.level-box-map {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 3px;
}

/* Couleurs par niveau */
.level-box-map.level-50 {
    background-color: #A9C9D6;
}

.level-box-map.level-100 {
    background-color: #F2E2A0;
}

.level-box-map.level-150 {
    background-color: #F4B686;
}

.level-box-map.level-200 {
    background-color: #F28C8C;
}

.level-box-map.level-250 {
    background-color: #B9A0D1;
}

.toggle-icon-map {
    display: inline-block;
    transition: transform 0.3s ease;
    margin-right: 5px;
}

.legend-map.open .toggle-icon-map {
    transform: rotate(90deg);
}

.img-row {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 10px 20px;
    align-items: center;
    margin-bottom: 30px;
}

.img-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.img-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap; /* empêche le split image/texte */
}

.img-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
/* ==========================================
   SIDEPANEL
   ========================================== */

.leaflet-sidepanel {
    width: 350px;
    display: flex;
    max-width: 90vw;
    overflow-y: auto;
}

.leaflet-sidepanel-content {
    overflow-y: auto;
    padding-bottom: 1rem;
}

/* Switch dans le sidepanel - disposition verticale */
.sidepanel-content .switch {
    display: flex;
    align-items: center;
    margin: 8px 0;
    cursor: pointer;
    gap: 12px;
}

.sidepanel-content .switch input {
    display: none;
}

.switch-label-map {
    flex: 1;
    font-size: 14px;
    color: #ddd;
    user-select: none;
}

.sidepanel-content .slider {
    position: relative;
    width: 40px;
    height: 20px;
    background-color: var(--border-medium);
    border-radius: 34px;
    transition: background-color 0.3s;
    flex-shrink: 0;
}

.sidepanel-content .slider.round {
    border-radius: 34px;
}

.sidepanel-content .slider.round::before {
    border-radius: 50%;
}

.sidepanel-content .slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.sidepanel-content .switch input:checked + .slider {
    background-color: var(--color-primary);
}

.sidepanel-content .switch input:checked + .slider::before {
    transform: translateX(20px);
}

.sidepanel-content h4 {
    margin-top: 20px;
    margin-bottom: 12px;
    color: var(--text-white);
    font-size: 1em;
    border-bottom: 1px solid var(--border-medium);
    padding-bottom: 5px;
}

.sidepanel-content h4:first-child {
    margin-top: 0;
}

.sidepanel-content #filters {
    margin: 10px 0 15px 0;
    display: none;
}

.sidepanel-content #filters.active {
    display: flex;
}

/* ==========================================
   SIDEPANEL RESPONSIVE MOBILE
   ========================================== */

@media (max-width: 768px) {
    .leaflet-sidepanel {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
    }

    .leaflet-sidepanel-content {
        overflow-y: auto;
        max-height: 100%;
        padding: 1em;
    }
}

/* ==========================================
   ANIMATION BOUTON SIDEPANEL
   ========================================== */

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 0px rgba(0, 170, 255, 0);
    }
    50% {
        box-shadow: 0 0 12px rgba(0, 170, 255, 0.6);
    }
}

.sidepanel-toggle-button {
    animation: glow 2s ease-in-out 7 forwards;
}

.sidepanel-toggle-button:hover,
.sidepanel-open .sidepanel-toggle-button {
    animation: none;
    box-shadow: none;
}

.meteo-error-message {
    display: none;
    text-align: center;
    padding: 2em;
}

/* ==========================================
   NOTES
   ========================================== */

/* La page map utilise:
 * - Leaflet custom styles (popups, tooltips)
 * - Search box animée
 * - Season control (prochaine saison)
 * - Sidepanel avec switches
 * - Légendes avec niveaux de zones
 * - Segmented control (hérite de common.css)
 */

/* ==========================================
   OVERLAY DE CHARGEMENT
   ========================================== */

#map-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-body);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.7s ease-out;
    pointer-events: all;
}

#map-overlay.map-overlay-out {
    opacity: 0;
    pointer-events: none;
}

.map-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.map-overlay-compass-wrapper {
    position: relative;
    width: 320px;
    height: 320px;
}

.map-overlay-compass {
    width: 320px;
    height: 320px;
    object-fit: contain;
    opacity: 0;
    animation: overlayFadeIn 0.6s ease-out 0.1s forwards;
}

canvas#map-sparkle {
    position: absolute;
    top: 0; left: 0;
    width: 320px; height: 320px;
    pointer-events: none;
}

.map-overlay-text {
    color: var(--text-disabled);
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0;
    animation: overlayFadeIn 0.6s ease-out 0.4s forwards;
}

@keyframes overlayFadeIn {
    to { opacity: 1; }
}

.pet-container {
    margin-bottom: 8px;
}

.bar-container {
    width: 100px;
    height: 1px;
    background: #444;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2px;
    margin-bottom: 2px;
}

.bar-fill {
    height: 100%;
}

.bar-red {
    background-color: #ff4444;
    /*background-color: #cc3333;
    background-color: #aa2222;*/
}

.bar-orange {
    background-color: #ff8c00;
    /*background-color: #e67e22;
    background-color: #f39c12;*/
}

.bar-green {
    background-color: #00aaff;
}

.pet-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
}