html, body {
    margin: 0;
    padding: 0;
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; /* evita scroll desnecessário */
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
}

.query-search-btn:hover {
    color:#FCEAD8;
    background-color: #A32C00!important;
    transform: translateY(-1px);
    border-color: #A32C00!important;
}
/* Container principal que vai conter a barra de cabeçalho e o conteúdo */
.main-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Container do conteúdo (painel + mapa) */
.content-container {
    display: flex;
    flex: 1;
    position: relative;
    transition: all 0.3s ease;
}

.mapa-wrapper {
    flex: 1;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: margin-left 0.3s ease;
    position: relative;
}

/* --- Estilos do Loader do Mapa --- */
.map-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Usando a cor de fundo da legenda para consistência */
    background: rgba(252, 234, 216, 0.85); 
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1003; /* Acima do mapa/legenda, abaixo do painel lateral */
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Bloqueia cliques no mapa enquanto carrega */
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #264263; /* Cor primária do tema */
    font-family: 'Barlow', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    background: #FCEAD8; /* Cor de fundo da legenda */
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Spinner CSS */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #477DB2; /* Cor secundária */
    border-top-color: #A32C00; /* Cor primária */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Classe para esconder o loader */
.map-loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Permite cliques no mapa quando escondido */
}
/* --- Fim dos Estilos do Loader --- */

/* Quando o painel está aberto, ajusta a margem do mapa */
.content-container.panel-open .mapa-wrapper {
    margin-left: 33.33%;
}

@media (max-width: 576px) {
    .content-container.panel-open .mapa-wrapper {
        margin-left: 75%;
    }

    .painel-lateral {
        width: 75%;
    }
    .card-container {
        grid-template-columns: 1fr;
    }
    
    .card-title {
        font-size: 1rem;
    }
    
    .card-text {
        font-size: 0.85rem;
    }
}

/* Em dispositivos móveis, margem maior */
@media (max-width: 880px) {
    .content-container.panel-open .mapa-wrapper {
        margin-left: 75%;
    }
}

#MetaFavela {
    width: 100%;
    height: 100%;
}

.leaflet-container {
    width: 100% !important;
    height: 100% !important;
    max-width: 100vw;
    max-height: 100%;
}

.leaflet-container {
    cursor: default !important; /* seta normal */
}

.leaflet-container.leaflet-grab {
    cursor: default !important; /* seta mesmo com grab */
}

.leaflet-container.leaflet-dragging {
    cursor: grabbing !important; /* mão durante o arraste */
}

.painel-lateral {
    position: fixed;
    top: 125px;
    left: 0;
    height: calc(100vh - 125px);
    background: #FCEAD8;
    overflow-y: auto;
    z-index: 1002;
    padding: 16px;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    font-family: 'Barlow', sans-serif;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(-100%);
    opacity: 0;
    width: 33.33%; /* padrão: 1/3 */
    pointer-events: auto;
}

/* Quando visível */
.painel-lateral.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Celulares */
@media (max-width: 880px) {
    .content-container.panel-open .mapa-wrapper {
        margin-left: 45%;
    }

    .painel-lateral {
        width: 45%;
    }

    .card.mb-3 {
    flex-direction: column !important;
    align-items: stretch !important;
    }

    .card-body {
        padding: 0.75rem !important;
    }

    .card-title {
        font-size: 0.95rem !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .card-text {
        font-size: 0.8rem !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .img-thumbnail {
        width: 100% !important;
        height: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0.5rem !important;
    }
}

#info-panel.show {
transform: translateX(0);
opacity: 1;
}

/* scroll bonitinho */
#info-panel::-webkit-scrollbar {
    height: calc(100% - 60px);
    width: 6px;
}

#info-panel::-webkit-scrollbar-track {
    height: calc(100% - 60px);
    background: #f1f1f1;
    border-radius: 10px;
}

#info-panel::-webkit-scrollbar-thumb {
    height: calc(100% - 60px);
    background: #aaa;
    border-radius: 10px;
}

#info-panel::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.btn-fechar-painel {
    position: absolute;
    top: 10px;
    right: 20px;
    background: transparent;
    border: none;
    font-size: 28px; 
    cursor: pointer;
    color: #264263;
    z-index: 9999 !important; 
    padding: 8px 12px; 
    line-height: 1;
    pointer-events: auto !important; 
    border-radius: 4px; 
    transition: all 0.2s ease;
    min-width: 44px; 
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-fechar-painel:hover {
    color: #A32C00;
}
.btn-fechar-painel {
    transition: color 0.2s ease;
}

.btn-fechar-painel:hover {
    transform: scale(1.15);
}

.conteudo-painel {
    height: calc(100% - 15px);
    padding-right: 15px !important; /* Gap entre conteúdo e scrollbar */
    box-sizing: border-box;
    overflow-y: auto;
    padding-top: 4px;
    margin-top: 10px;
}

canvas {
    image-rendering: auto;
}

#MetaFavela {
    width: 100%;
    height: 100%;
}

.barra-cabecalho-mapa {
    width: 100vw;
    height: auto;
    display: block;
    margin: 0;
    position: absolute;
    left: 0;
    z-index: 1001;
    pointer-events: none 
}

/* Adicione esta regra para permitir interação com a legenda */
#map-legend-container * {
    pointer-events: auto;
}

/* #map-legend-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1001;
    max-width: 300px;
} */

.map-legend .form-check-label {
    font-size: 13px;
    color: #264263;
}

.tag-checkbox {
    cursor: pointer;
    transition: all 0.3s ease;
}

.tag-checkbox:checked {
background-color: #A32C00;
border-color: #A32C00;
}

#tag-filter-form {
transition: all 0.3s ease;
}

.loading {
opacity: 0.7;
pointer-events: none;
}

.card.mb-3 {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    overflow: visible; /* Garante que o conteúdo não seja cortado durante a escala */
}

.card.mb-3:hover {
    scale: 1.02;
    /* z-index: 2; */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Estilos para posicionar o geocoder acima dos controles de zoom */
.leaflet-topleft .leaflet-control-geocoder {
    margin-top: 10px !important;
    margin-left: 10px;
    z-index: 1001;
    transition: left 0.1s ease;
}

.leaflet-left {
    margin-top: 5px !important;
}

/* Ajustar a posição dos controles de zoom para não sobrepor */
.leaflet-topleft .leaflet-control-zoom {
    margin-top: 60px; /* Espaço para o geocoder acima */
    margin-left: 10px;
    transition: left 0.1s ease;
}

/* Aba de toggle da legenda para mobile */
.mobile-legend-toggle {
    display: none;
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(80%);
    z-index: 1050;
    border-radius: 8px 0 0 8px;
    padding: 12px 8px;
    background-color: #264263 !important;
    border: 1px solid #FCEAD8 !important;
    border-right: none;
    color: white;
    font-family: 'Barlow', sans-serif;
    font-size: 0.5rem;
    font-weight: 600;
    box-shadow: -2px 0 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    cursor: pointer;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-legend-toggle:hover {
    background-color: #A32C00;
    right: 2px;
    box-shadow: -4px 0 12px rgba(0,0,0,0.4);
}

.mobile-legend-toggle .close-text {
    display: none;
}

/* Quando a legenda está aberta em mobile */
.map-legend-container-open .mobile-legend-toggle {
    right: 85%;
    background-color: #A32C00;
}

.map-legend-container-open .mobile-legend-toggle .open-text {
    display: none;
}

.map-legend-container-open .mobile-legend-toggle .close-text {
    display: inline;
}

/* Estilo responsivo para mobile */
@media (max-width: 768px) {
    .leaflet-topleft .leaflet-control-geocoder {
        margin-top: 5px;
        margin-left: 5px;
        max-width: calc(100vw - 80px); /* Limita a largura em mobile */
        transition: left 0.1s ease;
    }
    
    .leaflet-topleft .leaflet-control-zoom {
        margin-top: 50px; /* Menor espaço em mobile */
        margin-left: 5px;
        transition: left 0.1s ease;
    }

    .mobile-legend-toggle {
            display: block;
            transform: translateY(80%);
        }
        
    /* Reposicionar a legenda para ser um painel móvel */
    #map-legend-container {
        position: fixed !important;
        top: 0 !important;
        right: -100%;
        width: 85% !important;
        height: 100% !important;
        max-height: 100% !important;
        max-width: 85% !important;
        transition: right 0.3s ease;
        z-index: 1002;
        padding: 20px 15px !important;
        background: #FCEAD8 !important;
        border-radius: 0 !important;
        box-shadow: -2px 0 12px rgba(0,0,0,0.2);
        overflow-y: auto;
    }
    
    #map-legend-container.map-legend-open {
        right: 0;
    }
    
    /* Ajustar o conteúdo da legenda para mobile */
    #map-legend-container .map-legend {
        max-height: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    /* Ajustar o botão de desenho para mobile */
    #draw-area-btn {
        font-size: 0.8rem;
        padding: 8px 10px;
    }
    
    /* Garantir que o painel lateral tenha prioridade */
    .painel-lateral {
        z-index: 1004;
    }
    
    /* Overlay quando a legenda está aberta */
    .map-legend-container-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1001;
        pointer-events: none;
    }
    
}
/* Ajustes para telas muito pequenas */
/* @media (max-width: 480px) {
    .mobile-legend-toggle {
        top: 130px;
        right: 10px;
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    #map-legend-container {
        width: 90% !important;
    }
} */
/* Ajustar o estilo do geocoder para melhor aparência */
.leaflet-control-geocoder {
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    background: #fff;
}

.leaflet-control-geocoder a {
    border-radius: 4px;
}

.leaflet-control-geocoder .leaflet-control-geocoder-form {
    margin: 0;
    padding: 0;
}

.leaflet-control-geocoder .leaflet-control-geocoder-form input {
    font-size: 14px;
    padding: 8px;
    border: none;
    border-radius: 4px;
    width: 250px;
}

.leaflet-control-geocoder .leaflet-control-geocoder-form input:focus {
    outline: none;
}

.leaflet-control-geocoder .leaflet-control-geocoder-alternatives {
    width: 100%;
    border-radius: 0 0 4px 4px;
}

#draw-area-btn {
    width: 100%;
    background-color: #264263;
    border: transparent;
    color: #FCEAD8;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Barlow', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#draw-area-btn:hover {
    background-color: #A32C00;
    border-color: #A32C00;
    transform: translateY(-1px);
}

#draw-area-btn:active {
    transform: translateY(0);
}

#draw-area-btn.active {
    background-color: #A32C00;
    border-color: #A32C00;
}

#draw-area-btn:disabled {
    background-color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Ícone para o botão */
.draw-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Esconder o controle original do leaflet-draw */
.leaflet-draw {
    display: none !important;
}

/* */
/* Estilos para o filtro de período */
.filtro-periodo {
    margin-bottom: 0px;
}

.filtro-periodo label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #264263;
}


/* Estilos para o slider customizado */
.custom-slider-container {
    margin: 10px 0;
}

.custom-slider {
    position: relative;
    height: 6px;
    background: #dee2e6;
    border-radius: 3px;
    margin: 20px 0;
}

.custom-slider-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #dee2e6;
    border-radius: 3px;
}

.custom-slider-range {
    position: absolute;
    top: 0;
    height: 100%;
    background: #264263;
    border-radius: 3px;
    z-index: 2;
}

.custom-slider-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: #FCF5EE;
    border: 2px solid #264263;
    border-radius: 50%;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.custom-slider-handle:hover {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.custom-slider-handle.active {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.custom-slider-values {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

/* Botão de geolocalização */
.leaflet-control-geolocation {
    background: white;
    border-radius: 4px;
    border: 2px solid rgba(0,0,0,0.2);
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.leaflet-control-geolocation a {
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23264263'%3E%3Cpath d='M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z'/%3E%3C/svg%3E");
    background-size: 16px 16px;
    background-repeat: no-repeat;
    background-position: center;
    width: 30px;
    height: 30px;
    display: block;
    text-align: center;
    text-decoration: none;
    color: transparent;
    font-size: 18px;
    line-height: 30px;
}

.leaflet-control-geolocation a:hover {
    background-color: #f4f4f4;
}

.leaflet-control-geolocation.active a {
    background-color: #264263;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z'/%3E%3C/svg%3E");
}

.leaflet-control-geolocation.loading a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23264263'%3E%3Cpath d='M12 2A10 10 0 1 0 22 12A10 10 0 0 0 12 2Zm0 18A8 8 0 1 1 20 12A8 8 0 0 1 12 20Z' opacity='.15'/%3E%3Cpath d='M12 2A10 10 0 0 0 2 12A10 10 0 0 0 12 22A10 10 0 0 0 12 2Zm0 18A8 8 0 1 1 20 12A8 8 0 0 1 12 20Z'/%3E%3C/svg%3E");
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Marcador da localização do usuário */
.user-location-marker {
    background: transparent !important;
    border: none !important;
}

/* Estilos para o toggle de filtros */
.filtros-toggle-section .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.filtros-toggle-section .btn[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.filtros-content {
    border-left: 2px transparent;
    padding-left: 15px;
    padding-right: 15px;
}

.period-filter .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.8em;
}

.period-filter .btn[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* Ajustes para mobile */
@media (max-width: 768px) {
    .filtros-content {
        border-left: none;
        padding-left: 0;
    }
}

.filtros-toggle {
    background-color: #264263 !important;
    color: #FCEAD8 !important;
    font-weight: 700;
    border-color: #264263 !important;
    border-radius: 6px;
    font-size: 0.95rem;
}

.filtros-toggle:hover {
    background-color: #A32C00 !important;
    border-color: #A32C00 !important;
    transform: translateY(-1px);
    color: #fff !important;
}

.periodo-toggle {
    background-color: #FCF5EE !important;
    color: #264263 !important;
    border-color:transparent !important;
    border-width: 1px;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 6px;
}

.periodo-toggle:hover {
    background-color: #e7d1bb !important;
    border-color: transparent !important;
}

/* --- Corrigir rolagem dupla nas tags --- */
#tag-radios {
    max-height: none !important;
    overflow-y: visible !important;
}

/* Estilos para os form-switch das tags */
.form-check-input.tag-checkbox {
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #FCF5EE !important;
    border-color: #264263 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23264263'/%3e%3c/svg%3e") !important;
}

.form-check-input.tag-checkbox:checked {
    background-color: #264263 !important;
    border-color: #264263 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23FCF5EE'/%3e%3c/svg%3e") !important;
}

/* Estilo específico para form-switch */
.form-switch .form-check-input.tag-checkbox {
    width: 2em;
    margin-left: -2.5em;
    background-position: left center;
    border-radius: 2em;
    transition: all 0.3s ease;
}

.form-switch .form-check-input.tag-checkbox:focus {
    border-color: #264263;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(38, 66, 99, 0.25);
}

.form-switch .form-check-input.tag-checkbox:checked {
    background-position: right center;
}