/* 
 * Style.css - WebGIS BR-135/MG
 * Design Moderno, Limpo, Profissional e Interativo
 */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);
    
    --flora: #10b981;
    --fauna: #f97316;
    --prad: #b45309;
    --arqueo: #d97706;
    --referencia: #64748b;
    
    --bg-dark: #0f172a;
    --bg-dark-hover: #1e293b;
    --bg-dark-border: #334155;
    
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #1e293b;
    --text-dark-muted: #64748b;
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.12);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    background-color: #f1f5f9;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

h1, h2, h3, h4, .font-title {
    font-family: 'Outfit', sans-serif;
}

/* Container Principal */
#app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Sidebar / Menu Lateral */
#sidebar {
    width: 320px;
    height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 6px 0 24px rgba(15, 23, 42, 0.2);
    transition: var(--transition-smooth);
    position: relative;
    flex-shrink: 0;
}

#sidebar.collapsed {
    margin-left: -320px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--bg-dark-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    color: var(--flora);
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.logo-area h2 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#toggle-sidebar-btn, #sidebar-open-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: var(--transition-smooth);
}

#toggle-sidebar-btn:hover {
    background-color: var(--bg-dark-hover);
    color: var(--text-light);
}

/* Botão para abrir o menu quando ocultado */
#sidebar-open-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background-color: var(--bg-dark);
    color: var(--text-light);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    z-index: 999;
    border: 1px solid var(--bg-dark-border);
}

#sidebar-open-btn:hover {
    background-color: var(--bg-dark-hover);
    transform: scale(1.05);
}

#sidebar-open-btn.hidden {
    display: none;
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom Scrollbar for Sidebar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-content::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--bg-dark-border);
    border-radius: 3px;
}
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Menu Sections */
.menu-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.small-icon {
    width: 1rem;
    height: 1rem;
}

/* Layer Tree */
.layer-tree {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tree-group {
    background-color: var(--bg-dark-hover);
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.group-header {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
}

.group-header:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.group-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
}

.color-flora { color: var(--flora); }
.color-fauna { color: var(--fauna); }
.color-prad { color: var(--prad); }
.color-arqueo { color: var(--arqueo); }
.color-referencia { color: var(--referencia); }

.group-name {
    font-size: 0.9rem;
    font-weight: 600;
    flex: 1;
}

.group-arrow {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.tree-group.collapsed .group-arrow {
    transform: rotate(-90deg);
}

/* Group Layers List */
.group-layers {
    list-style: none;
    padding: 0.5rem 0.75rem 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tree-group.collapsed .group-layers {
    display: none;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.375rem 0;
    transition: var(--transition-smooth);
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 2rem;
    cursor: pointer;
    font-size: 0.85rem;
    user-select: none;
    color: var(--text-light);
    flex: 1;
    line-height: 1.3;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 1.25rem;
    width: 1.25rem;
    background-color: var(--bg-dark);
    border: 2px solid var(--bg-dark-border);
    border-radius: 0.25rem;
    transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--text-muted);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

#layer-flora:checked ~ .checkmark { background-color: var(--flora); border-color: var(--flora); }
#layer-fauna-atropelada:checked ~ .checkmark { background-color: var(--fauna); border-color: var(--fauna); }
#layer-fauna-silvestre:checked ~ .checkmark { background-color: #eab308; border-color: #eab308; }
#layer-fauna-ictiofauna-pontos:checked ~ .checkmark { background-color: #a855f7; border-color: #a855f7; }
#layer-fauna-ictiofauna-sub:checked ~ .checkmark { background-color: #8b5cf6; border-color: #8b5cf6; }
#layer-passivos:checked ~ .checkmark { background-color: var(--prad); border-color: var(--prad); }
#layer-feicoes-erosivas:checked ~ .checkmark { background-color: #f97316; border-color: #f97316; }
#layer-arqueologia:checked ~ .checkmark { background-color: var(--arqueo); border-color: var(--arqueo); }

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.layer-label {
    transition: var(--transition-smooth);
}

.checkbox-container input:checked ~ .layer-label {
    font-weight: 500;
}

.layer-info-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.layer-info-btn:hover {
    background-color: var(--bg-dark-border);
    color: var(--text-light);
}

.layer-info-btn svg {
    width: 0.9rem;
    height: 0.9rem;
}

/* Filters Section */
.filters-section {
    border-top: 1px solid var(--bg-dark-border);
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

.no-layer-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: 0.5rem;
    border: 1px dashed var(--bg-dark-border);
    line-height: 1.4;
}

.filters-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-group {
    background-color: var(--bg-dark-hover);
    border-radius: 0.5rem;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.filter-input, .filter-select {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--bg-dark-border);
    border-radius: 0.375rem;
    padding: 0.5rem;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.filter-input:focus, .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--bg-dark-border);
    text-align: center;
}

.sidebar-footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Map Container */
#map-container {
    flex: 1;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 0.75rem;
    transition: var(--transition-smooth);
    z-index: 999;
}

/* Top Info Card */
#top-info-card {
    position: absolute;
    top: 1.25rem;
    left: 1.25rem;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: none;
}

#top-info-card span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

#top-info-card svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

/* Custom Base Map Selector */
#basemap-selector {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    padding: 0.375rem;
    display: flex;
    gap: 0.25rem;
}

.basemap-option {
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark-muted);
    transition: var(--transition-smooth);
}

.basemap-option:hover {
    background-color: rgba(15, 23, 42, 0.05);
    color: var(--text-dark);
}

.basemap-option.active {
    background-color: var(--bg-dark);
    color: var(--text-light);
}

.basemap-option svg {
    width: 1rem;
    height: 1rem;
}

/* Legend Card */
#legend-card {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 280px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.legend-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legend-header h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

#toggle-legend-btn {
    background: transparent;
    border: none;
    color: var(--text-dark-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.25rem;
    transition: var(--transition-smooth);
}

#toggle-legend-btn:hover {
    background-color: rgba(15, 23, 42, 0.05);
}

#legend-card.collapsed #toggle-legend-btn {
    transform: rotate(180deg);
}

#legend-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: var(--transition-smooth);
}

#legend-card.collapsed #legend-content {
    max-height: 0;
    padding: 0;
    border: none;
}

.no-layers-active {
    font-size: 0.8rem;
    color: var(--text-dark-muted);
    text-align: center;
    font-style: italic;
    padding: 0.5rem 0;
}

/* Legend Item Styling */
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-symbol {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border-radius: 50%;
}

.legend-symbol.line {
    width: 1.25rem;
    height: 0.25rem;
    border-radius: 0;
}

.legend-symbol.polygon {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
}

.legend-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dark);
}

.legend-subitems {
    padding-left: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.25rem;
}

.legend-subitem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-subitem-symbol {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}

.legend-subitem-text {
    font-size: 0.75rem;
    color: var(--text-dark-muted);
}

/* Custom Leaflet Styling */
.leaflet-bar {
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--glass-shadow) !important;
    border-radius: 0.5rem !important;
    overflow: hidden;
}

.leaflet-bar a {
    background-color: var(--glass-bg) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.05) !important;
    color: var(--text-dark) !important;
    transition: var(--transition-smooth);
}

.leaflet-bar a:hover {
    background-color: #f1f5f9 !important;
}

.leaflet-control-zoom {
    margin-top: 5rem !important; /* Move down so it doesn't overlap info card */
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 0.75rem;
    padding: 0.25rem;
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    font-size: 0.85rem;
    line-height: 1.5;
}

.leaflet-popup-tip {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.popup-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.375rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.popup-details {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.popup-label {
    font-weight: 600;
    color: var(--text-dark-muted);
}

.popup-value {
    text-align: right;
    font-weight: 400;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 1.5rem;
    animation: modal-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    padding-bottom: 0.75rem;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-dark-muted);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-smooth);
}

.close-modal-btn:hover {
    background-color: rgba(15, 23, 42, 0.05);
    color: var(--text-dark);
}

.modal-body {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-dark-muted);
}

.modal-body p {
    margin-bottom: 0.75rem;
}

.modal-body ul {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsividade */
@media (max-width: 768px) {
    #sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
    }
    
    #sidebar.collapsed {
        margin-left: -320px;
    }
    
    #sidebar-open-btn {
        display: flex;
    }
    
    #sidebar-open-btn.hidden {
        display: none;
    }
    
    #top-info-card {
        display: none;
    }
    
    #legend-card {
        left: 1.5rem;
        right: 1.5rem;
        width: auto;
    }
}
