/* CSS Principal do WebGIS - Design Premium */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #1e293b;
    --primary-light: #334155;
    --accent-color: #0284c7;
    --accent-hover: #0369a1;
    --bg-sidebar: rgba(255, 255, 255, 0.95);
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 380px;
    --transition-speed: 0.3s;
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Painel Lateral Expansivo */
#sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    position: relative;
}

#sidebar.collapsed {
    transform: translateX(-100%);
}

/* Botão de recolhimento */
#toggle-sidebar {
    position: absolute;
    top: 50%;
    right: -40px;
    width: 40px;
    height: 60px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 1001;
    color: var(--text-main);
    transition: background-color var(--transition-speed);
}

#toggle-sidebar:hover {
    background-color: #f1f5f9;
}

#toggle-sidebar svg {
    transition: transform var(--transition-speed);
}

#sidebar.collapsed #toggle-sidebar svg {
    transform: rotate(180deg);
}

/* Header do painel */
.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-container {
    width: 100%;
    max-height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container img {
    max-width: 80%;
    max-height: 65px;
    object-fit: contain;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Área de Filtros */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Toggle Switch (PASSIVO) */
.switch-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.switch-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Múltipla Escolha - Chips e Listas */
.choices-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.choice-chip {
    display: none; /* Serão controlados por classe */
}

/* Checkbox estilizado como Chip */
.custom-checkbox-label {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.custom-checkbox-label:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.choices-container input[type="checkbox"] {
    display: none;
}

.choices-container input[type="checkbox"]:checked + .custom-checkbox-label {
    background: #e0f2fe;
    border-color: #bae6fd;
    color: var(--accent-color);
    font-weight: 600;
}

/* Legenda */
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.legend-item:last-child {
    margin-bottom: 0;
}

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

.legend-line {
    width: 24px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-poly {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1.5px solid;
}

/* Mapa */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Customizações do Leaflet */
.leaflet-bar {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-bar a {
    background-color: var(--bg-sidebar) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: background-color 0.2s;
}

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

/* Popups Estilizados */
.leaflet-popup-content-wrapper {
    background: var(--bg-sidebar) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 16px !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-main) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: 320px !important;
    font-family: 'Inter', sans-serif !important;
}

.popup-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.popup-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.popup-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.popup-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.popup-value {
    font-size: 13px;
    color: var(--text-main);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-alta { background-color: #fee2e2; color: #ef4444; }
.badge-media { background-color: #fef3c7; color: #f59e0b; }
.badge-baixa { background-color: #ecfdf5; color: #10b981; }

.badge-ambiental { background-color: #dbeafe; color: #2563eb; }
.badge-construtivo { background-color: #f3e8ff; color: #9333ea; }

/* Galeria de Fotos no Popup / Carrossel */
.popup-gallery {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gallery-container {
    position: relative;
    width: 100%;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
}

.gallery-slide {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    cursor: pointer;
    transition: transform 0.3s;
}

.gallery-slide:hover {
    transform: scale(1.03);
}

.gallery-slide.active {
    display: block;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    transition: background 0.2s;
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 1);
}

.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }

.gallery-indicator {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    z-index: 10;
}

/* Modal Lightbox para imagem expandida */
#lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

#lightbox.active {
    display: flex;
}

#lightbox-img {
    max-width: 90%;
    max-height: 85%;
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
}

#lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: color 0.2s;
}

#lightbox-close:hover {
    color: #e2e8f0;
}

/* Contador de Passivos no painel lateral */
.counter-box {
    margin-top: auto;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.counter-value {
    font-size: 24px;
    font-weight: 700;
}

.counter-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

/* Legenda Flutuante (Canto Inferior Direito) */
#legend-container {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000; /* Acima do mapa */
    pointer-events: auto; /* Permitir interação */
    width: 250px;
    transition: opacity 0.2s;
}

#legend-container:hover {
    background: #ffffff;
}

.legend-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

/* Gráficos de Pizza Mini */
.pie-chart-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    background: #cbd5e1;
    transition: background 0.4s ease;
    flex-shrink: 0;
}

.color-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Modal do PDF */
#pdf-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

#pdf-modal.active {
    display: flex;
}

#pdf-modal-content {
    background: #ffffff;
    width: 85%;
    height: 90%;
    border-radius: 16px;
    position: relative;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#pdf-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #64748b;
    cursor: pointer;
    z-index: 10001;
    transition: color 0.2s;
}

#pdf-modal-close:hover {
    color: #0f172a;
}

#pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Botão PDF no Popup */
.pdf-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s, transform 0.1s;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
}

.pdf-btn:hover {
    background-color: var(--accent-hover);
}

.pdf-btn:active {
    transform: scale(0.98);
}

