:root {
    --primary: #007acc;
    /* VSCode Blue */
    --primary-dark: #0062a3;
}

/* Tema Escuro - VSCode Inspired */
[data-theme="dark"] {
    --bg-main: #1e1e1e;
    --bg-card: #252526;
    --bg-input: #3c3c3c;
    --border: #3e3e42;
    --text: #d4d4d4;
    --text-muted: #a0a0a0;
}

/* Tema Claro */
[data-theme="light"] {
    --bg-main: #f5f5f5;
    --bg-card: #ffffff;
    --bg-input: #e8e8e8;
    --border: #ddd;
    --text: #222;
    --text-muted: #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text);
    overflow: hidden;
}

/* Custom Scrollbar (VSCode Style) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #4f4f4f;
    border: 2px solid transparent;
    background-clip: content-box;
}



/* Crosshair */
/* Crosshair */
#map-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary);
    font-size: 24px;
    pointer-events: none;
    z-index: 900;
    /* Abaixo do modal (2000+), acima do mapa */
    text-shadow: 0 0 2px black;
}

/* Custom Clusters */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-clip: padding-box;
    border-radius: 20px;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px "Segoe UI", Arial, sans-serif;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

/* Small: Light Blue */
.marker-cluster-small {
    background-color: rgba(100, 181, 246, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(30, 136, 229, 0.9);
}

/* Medium: Yellow */
.marker-cluster-medium {
    background-color: rgba(255, 236, 179, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(255, 193, 7, 0.9);
}

/* Large: Red */
.marker-cluster-large {
    background-color: rgba(239, 154, 154, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(244, 67, 54, 0.9);
}


.container {
    display: flex;
    height: 100vh;
    height: 100dvh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 300px;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    z-index: 1100;
    transition: margin-left 0.35s ease;
}

/* No desktop, a sidebar "retrai" movendo sua margem */
@media (min-width: 769px) {
    .sidebar:not(.open) {
        margin-left: -300px;
        /* Puxa o sidebar para fora da tela, liberando espaço */
    }
}


.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 15px 5px 15px;
    margin-bottom: 5px;
}

.sidebar-group {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px 10px 15px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.logo span {
    color: var(--text);
}

.theme-toggle {
    background: var(--bg-input);
    border: none;
    border-radius: 10px;
    padding: 3px 12px;
    cursor: pointer;
    font-size: 16px;
}

/* ===== FILTROS ===== */
.filter-section {
    margin-bottom: 5px;
}

.filter-section h3 {
    color: var(--primary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border);
}

.filter-group {
    margin-bottom: 5px;
}

.filter-group label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.filter-group input[type="date"] {
    width: 100%;
    padding: 5px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 5px 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    background: var(--bg-input);
    border-radius: 17px;
    cursor: pointer;
    font-size: 11px;
}

.checkbox-item input {
    width: 12px;
    height: 12px;
    accent-color: var(--primary);
}

.checkbox-item.nature-filter-violent:has(input:checked) {
    border: 1px solid #ff4444;
    box-shadow: 0 0 5px rgba(255, 68, 68, 0.4);
    background: rgba(255, 68, 68, 0.1);
}

/* ===== BOTÕES ===== */
.btn {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
}

/* ===== STATS ===== */
.stats-box {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    font-size: 11px;
}

.stat-badge {
    font-weight: bold;
    margin: 0 4px;
}

.stats-breakdown {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    opacity: 0.9;
}

.stats-box h4 {
    color: var(--primary);
    font-size: 10px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-value {
    color: var(--primary);
    font-weight: 600;
}

/* ===== SIDEBAR FOOTER STATS ===== */
.sidebar-footer {
    margin-top: auto;
    padding: 15px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.footer-stat {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 5px;
}

.footer-stat span:last-child {
    font-weight: 600;
    color: var(--text);
}

/* ===== MAPA ===== */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1200;
    gap: 10px;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 35px;
    height: 35px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 12px;
    color: #888;
}

/* ===== BOTÕES FLUTUANTES ===== */
.float-btn {
    position: absolute;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    /* z-index removido - definido individualmente em cada botão */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.float-btn svg {
    color: var(--primary);
}

.float-btn:active {
    transform: scale(0.95);
    background: var(--primary);
}

.location-btn {
    bottom: 125px;
    right: 12px;
    z-index: 1050;
}

.location-btn.denied {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.2) !important;
}

.filter-btn {
    bottom: 290px;
    right: 12px;
    display: flex; /* Alterado para ser sempre visível */
    z-index: 1054; /* Mantém a ordem de empilhamento */
}

.search-btn {
    bottom: 180px;
    right: 12px;
    display: flex;
    z-index: 1052;
    /* Garante que o botão de busca esteja sempre visível */
}

.risk-btn {
    bottom: 235px;
    right: 12px;
    z-index: 1053 !important;
}

.share-btn {
    bottom: 345px;
    right: 12px;
    display: flex;
    z-index: 1055;
    /* Garante que o botão de compartilhamento esteja sempre visível */
}

/* ===== MODAL LARGE (Para Estatísticas) ===== */
.modal-large {
    max-width: 900px;
    max-height: 90vh;
}

@media (max-width: 768px) {
    .modal-large {
        max-width: 100%;
        max-height: 85vh;
    }
}

/* ===== ESTATÍSTICAS - CHARTS ===== */
.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 25px;
    background: var(--bg-input);
    padding: 15px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
    text-align: center;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-input);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border-left: 3px solid var(--primary);
}

.stat-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    /* Center by default (Desktop) */
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeInScale 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 5vh;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end;
        /* Bottom sheet on mobile */
        padding: 0;
    }

    .modal {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 15px 15px 0 0;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }
}

.modal-header {
    background: var(--primary);
    padding: 8px 15px;
    /* Reduced padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 13px;
    /* Slightly smaller */
    color: #fff;
    font-weight: 600;
    /* Less thick */
}

.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: block;
    /* Garante que o botão X seja sempre visível */
}

.modal-close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 10px 12px;
    overflow-y: auto;
    flex: 1;
    /* Takes remaining space */
}

/* ===== DETALHES ===== */
.detail-section {
    margin-bottom: 5px;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 8px;
    border: 1px solid var(--border);
}

.detail-section h4 {
    color: var(--primary);
    font-size: 11px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
}

.detail-card {
    background: var(--bg-input);
    padding: 6px 8px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
}

.detail-card.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    color: var(--text-muted);
    font-size: 9px;
    text-transform: uppercase;
    margin-bottom: 2px;
    font-weight: 500;
}

.detail-value {
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.2;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-consumado { background: rgba(76, 175, 80, 0.15); color: #4caf50; border: 1px solid #4caf50; }
.badge-tentado { background: rgba(255, 152, 0, 0.15); color: #ff9800; border: 1px solid #ff9800; }
.badge-flagrante { background: rgba(229, 57, 53, 0.15); color: #e53935; border: 1px solid #e53935; }
.badge-default { background: rgba(158, 158, 158, 0.15); color: #9e9e9e; border: 1px solid #9e9e9e; }


/* =================================== */
/* PAINEL DE BUSCA (Estilo VSCode)     */
/* =================================== */

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1100;
    /* Acima da sidebar */
    display: flex;
    align-items: flex-start;
    /* Alinha o modal no topo */
    justify-content: center;
    padding: 10vh 5vw;
    /* Espaçamento interno para o modal */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.search-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.search-modal {
    background-color: var(--bg-card);
    width: 90%;
    max-width: 550px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4), 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: fit-content;
    max-height: 80vh;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.search-overlay.visible .search-modal {
    transform: scale(1);
}

.search-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;    
    background: var(--primary);
    padding: 8px 15px;
}

.search-panel-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.search-panel-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-panel-close:hover {
    opacity: 0.8;
}

.search-panel-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.search-tabs {
    display: flex;
    margin-bottom: 12px;
}

.search-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.search-tab:hover {
    color: var(--text);
}

.search-tab.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
}

.search-tab-content {
    display: none;
    gap: 10px;
    flex-direction: column;
}

.search-tab-content.active {
    display: flex;
}

.search-input-group {
    position: relative;
    display: flex;
}

.search-tab-content input[type="text"],
.search-tab-content input[type="number"] {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-tab-content input[type="text"]:focus,
.search-tab-content input[type="number"]:focus {
    border-color: var(--primary);
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 0 5px;
    display: none;
    /* Hidden by default */
}

.clear-search-btn:hover {
    color: var(--text);
}

.search-results {
    font-size: 12px;
    color: var(--text-muted);
    padding: 5px;
    min-height: 22px;
}

.loading-spinner-mini {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* Remove a seta de incremento/decremento dos inputs de número */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

.object-card {
    background: var(--bg-input);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
}

.object-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

/* Pagination Buttons */
.objects-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 6px;
}

.pagination-counter {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.object-type {
    font-weight: 600;
    color: var(--primary);
    font-size: 12px;
}

.object-badge {
    background: var(--primary);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
    color: #fff;
}

.object-detail {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ===== PINS CUSTOMIZADOS ===== */
.pin-marker {
    position: relative;
    width: 28px;
    height: 36px;
}

.pin-marker svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text);
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 160px;
}

.leaflet-popup-tip {
    background: var(--bg-card);
}

.popup-mini {
    padding: 10px 12px;
}

.popup-mini h4 {
    color: var(--primary);
    font-size: 12px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.popup-mini p {
    font-size: 10px;
    color: var(--text-muted);
    margin: 2px 0;
}

.popup-mini .btn-details {
    width: 100%;
    padding: 6px;
    margin-top: 8px;
    background: var(--primary);
    border: none;
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}

/* =================================== */
/* Rodapé e Botão do Modal de Detalhes */
/* =================================== */

.detail-footer {
    padding: 10px 15px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-card);
    /* Garante consistência com o corpo do modal */
    margin-top: auto;
    /* Empurra para o final se o conteúdo for pequeno */
}

.btn-close-modal {
    width: 100%;
    padding: 10px;
    background: var(--bg-input);
    /* Cor sutil, como um botão secundário */
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-close-modal:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}


/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        /* Adiciona a transição específica para mobile */
        margin-left: 0;
        /* Garante que a margem do desktop seja resetada */
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1090;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* =================================== */
/* Estilos para Paginação no Modal     */
/* =================================== */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
    background-color: transparent;
    /* Remove o fundo do container */
    padding: 0;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-input);
    /* Cor de fundo sutil */
    border: 1px solid var(--border);
    color: var(--text);
    padding: 2px 10px;
    /* Mais baixo e largo */
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    line-height: 1;
    /* Remove altura extra */
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination-btn:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

.pagination-btn svg {
    vertical-align: middle;
}

/* =================================== */
/* NOVOS COMPONENTES (Risk, Share...)  */
/* =================================== */

/* Risk Indicator */
.risk-indicator {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}

.risk-indicator:hover {
    transform: translateX(-50%) scale(1.05);
    background: var(--bg-input);
}

.risk-indicator.hidden {
    display: none;
}

/* Rubrica Checkbox List (VSCode Style) */
.checkbox-list-container {
    width: 100%;
    height: 150px;
    /* Mais altura para lista */
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px;
    overflow-y: auto;
    font-size: 11px;
}

.checkbox-list-container .placeholder-text {
    color: var(--text-muted);
    padding: 5px;
    display: block;
    font-style: italic;
}

.rubrica-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 3px;
    color: var(--text);
    font-size: 9px;
    /* Reduced from default */
}

.rubrica-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.rubrica-item input {
    accent-color: var(--primary);
}

/* Header Actions (Share Button inside Sidebar) */
.header-actions {
    display: flex;
    gap: 5px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: var(--bg-input);
    color: var(--primary);
}

/* Modal Actions (Header buttons) */
.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Swipe Pagination Buttons (if using distinct class) */
.nav-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--primary);
}

/* Adjust Sidebar Section for Rubrica */
.sidebar-section {
    margin-bottom: 8px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section h4 {
    color: var(--primary);
    font-size: 11px;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

/* Analysis Modal Styles */
.analysis-container {
    padding: 10px;
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-input);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.analysis-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.score-value {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.score-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 5px;
}

.analysis-level h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
}

.analysis-level span {
    font-size: 12px;
    color: var(--text-muted);
}

.recommendation-list {
    list-style: none;
    padding: 0;
}

.recommendation-list li {
    padding: 5px 0;
    font-size: 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.recommendation-list li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
}

/* ===== MODAL FOOTER STICKY ===== */
.modal-body {
    position: relative;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Make the content area scrollable */
.modal-content-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 12px 15px;
    /* Matches original padding */
}

.modal-footer-sticky {
    background: var(--bg-card);
    /* Match card bg */
    border-top: 1px solid var(--border);
    padding: 15px;
    width: 100%;
    /* text-align: right; */
    border-radius: 0 0 8px 8px;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}

/* ===== ACCORDIONS EM ESTILO PREMIUM ===== */
.accordion .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out, padding 0.2s ease-out;
    padding: 0;
}

.accordion.active .accordion-content {
    max-height: 350px;
    padding: 8px 0 12px 0;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}

.accordion-header h4 {
    margin: 0;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--primary);
}

.accordion-icon {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.accordion.active .accordion-icon {
    transform: rotate(0deg);
}

/* Toggle Group de Períodos */
.period-toggle-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
}

.period-toggle-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.period-toggle-btn:hover {
    background: var(--border);
    color: var(--text);
}

.period-toggle-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(229, 57, 53, 0.3);
}

/* Busca de Objetos - Tree View */
.tree-view-container {
    max-height: 250px;
    overflow-y: auto;
    font-size: 12px;
    margin-top: 5px;
    padding-right: 5px;
}

/* Scrollbar fina para o tree-view */
.tree-view-container::-webkit-scrollbar { width: 4px; }
.tree-view-container::-webkit-scrollbar-track { background: transparent; }
.tree-view-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tree-node {
    margin-bottom: 2px;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    user-select: none;
}

.tree-node-header:hover {
    background: var(--bg-hover);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-children {
    padding-left: 20px;
    border-left: 1px solid var(--border);
    margin-left: 7px;
    display: none;
    margin-top: 2px;
}

.tree-children.expanded {
    display: block;
}

.tree-leaf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
}

.tree-leaf:hover {
    color: var(--primary);
}

.tree-leaf input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.leaf-label {
    flex: 1;
    color: var(--text);
}

.leaf-count {
    color: var(--text-muted);
    font-size: 10px;
    background: var(--bg-hover);
    padding: 2px 4px;
    border-radius: 4px;
}

/* Rubricas Alinhamento e Badge */
.rubrica-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.rubrica-item:last-child {
    border-bottom: none;
}

.rubrica-icon {
    font-size: 14px;
    line-height: 1.2;
    flex-shrink: 0;
}

.rubrica-text {
    flex: 1;
    line-height: 1.4;
    color: var(--text);
}

.rubrica-badge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* Botões da Sidebar */
.buttons-section {
    border-bottom: none !important;
    padding-top: 10px;
}

.buttons-section .btn {
    margin-bottom: 8px;
}

/* ===== LEAFLET DARK MODE OVERRIDES ===== */

/* Fundo do mapa enquanto tiles carregam */
[data-theme="dark"] .leaflet-container {
    background: #1e1e1e;
    font-family: 'Segoe UI', 'Inter', sans-serif;
}

/* Botões de zoom */
[data-theme="dark"] .leaflet-bar a {
    background-color: #252526;
    border-bottom-color: #3e3e42;
    color: #d4d4d4;
}
[data-theme="dark"] .leaflet-bar a:hover,
[data-theme="dark"] .leaflet-bar a:focus {
    background-color: #3c3c3c;
    color: #ffffff;
}
[data-theme="dark"] .leaflet-bar a.leaflet-disabled {
    background-color: #1e1e1e;
    color: #555;
}

/* Barra de atribuição (© OSM © CARTO) */
[data-theme="dark"] .leaflet-container .leaflet-control-attribution {
    background: rgba(30, 30, 30, 0.85);
    color: #a0a0a0;
}
[data-theme="dark"] .leaflet-control-attribution a {
    color: #007acc;
}

/* Popups */
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
    background: #252526;
    color: #d4d4d4;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button {
    color: #a0a0a0;
}
[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button:hover {
    color: #ffffff;
}

/* Tooltips */
[data-theme="dark"] .leaflet-tooltip {
    background-color: #252526;
    border-color: #3e3e42;
    color: #d4d4d4;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .leaflet-tooltip-top:before {
    border-top-color: #3e3e42;
}
[data-theme="dark"] .leaflet-tooltip-bottom:before {
    border-bottom-color: #3e3e42;
}
[data-theme="dark"] .leaflet-tooltip-left:before {
    border-left-color: #3e3e42;
}
[data-theme="dark"] .leaflet-tooltip-right:before {
    border-right-color: #3e3e42;
}
