/* ===== TEMA ESCURO ===== */
:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --border-color: #2d3748;
    --card-bg: #1e1e2f;
    --shadow-color: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Navbar */
.navbar {
    z-index: 1001;
    box-shadow: 0 2px 10px var(--shadow-color);
    background: var(--bg-secondary) !important;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.3rem;
    color: #e94560 !important;
}

/* Mapa */
#map {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 280px;
    height: calc(100vh - 56px);
    background: var(--bg-secondary);
    box-shadow: 2px 0 10px var(--shadow-color);
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar.collapsed {
    transform: translateX(-280px);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h5 {
    margin: 0;
    color: var(--text-primary);
}

.sidebar-content {
    padding: 15px;
}

.filter-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.filter-section h6 {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

/* Form controls dark theme */
.form-check-label {
    color: var(--text-primary);
}

.form-select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-select:focus {
    background-color: var(--bg-tertiary);
    border-color: #e94560;
    color: var(--text-primary);
    box-shadow: 0 0 0 0.25rem rgba(233, 69, 96, 0.25);
}

.form-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-primary {
    background: linear-gradient(135deg, #e94560 0%, #c82333 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71d2a 100%);
}

/* Risk Badges */
.risk-badge {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 5px;
}

.risk-badge.critical { background: #dc3545; }
.risk-badge.high { background: #fd7e14; }
.risk-badge.medium { background: #ffc107; }
.risk-badge.low { background: #28a745; }

/* Legenda */
.map-legend {
    position: fixed;
    bottom: 30px;
    right: 20px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.map-legend h6 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.legend-item {
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.legend-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.legend-marker.critical { background: #dc3545; }
.legend-marker.high { background: #fd7e14; }
.legend-marker.medium { background: #ffc107; }
.legend-marker.low { background: #28a745; }

/* Stats Panel */
.stats-panel {
    position: fixed;
    bottom: 30px;
    left: 300px;
    background: var(--card-bg);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 1000;
    display: flex;
    gap: 30px;
    border: 1px solid var(--border-color);
}

.sidebar.collapsed ~ .stats-panel {
    left: 20px;
}

.stat-item {
    text-align: center;
}

.stat-item i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 5px;
}

.stat-item span {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-item small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Custom Markers */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.marker-critical { background: #dc3545; }
.marker-high { background: #fd7e14; }
.marker-medium { background: #ffc107; color: #333; }
.marker-low { background: #28a745; }

/* Popup customizado */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
}

.leaflet-popup-tip {
    background: var(--card-bg);
}

.popup-content {
    min-width: 200px;
}

.popup-content h5 {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.popup-content .info-row {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.popup-content .info-row i {
    width: 20px;
    margin-right: 8px;
    color: var(--text-secondary);
}

.popup-risk {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
}

.popup-risk.critical { background: #dc3545; }
.popup-risk.high { background: #fd7e14; }
.popup-risk.medium { background: #ffc107; color: #333; }
.popup-risk.low { background: #28a745; }

/* Alertas */
.alerta-item {
    padding: 15px;
    border-left: 4px solid #dc3545;
    background: rgba(220, 53, 69, 0.1);
    margin-bottom: 10px;
    border-radius: 0 8px 8px 0;
    color: var(--text-primary);
}

.alerta-item.high { border-color: #fd7e14; background: rgba(253, 126, 20, 0.1); }
.alerta-item.medium { border-color: #ffc107; background: rgba(255, 193, 7, 0.1); }

.alerta-item h6 {
    margin-bottom: 5px;
    color: var(--text-primary);
}

.alerta-item p {
    color: var(--text-secondary);
}

.alerta-item small {
    color: var(--text-secondary);
}

/* Toggle Button quando sidebar fechada */
.sidebar-toggle-btn {
    position: fixed;
    top: 70px;
    left: 10px;
    z-index: 1000;
    display: none;
}

.sidebar.collapsed ~ .sidebar-toggle-btn {
    display: block;
}

/* Responsivo */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .stats-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        justify-content: space-around;
    }
    
    .map-legend {
        right: 10px;
        bottom: 100px;
    }
}

/* Pulse animation para alertas ativos */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.marker-pulse {
    animation: pulse 2s infinite;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    text-align: center;
    color: var(--text-primary);
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Modal dark theme */
.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    color: var(--text-secondary);
}

.modal-body p {
    color: var(--text-secondary);
}

.btn-close {
    filter: invert(1);
}


/* ===== TEMPO REAL ===== */

/* Toast de notificação */
.toast-notification {
    position: fixed;
    top: 70px;
    right: 20px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(220, 53, 69, 0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    font-weight: 500;
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-notification i {
    font-size: 1.5rem;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Indicador de conexão */
.connection-status {
    position: fixed;
    bottom: 30px;
    left: 20px;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-status.connected {
    background: rgba(40, 167, 69, 0.9);
    color: white;
}

.connection-status.disconnected {
    background: rgba(220, 53, 69, 0.9);
    color: white;
}

.connection-status i {
    font-size: 1rem;
}

/* Marcador pulsante para novas ocorrências */
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.marker-pulse {
    animation: pulse 1.5s infinite;
}

/* Badge Fogo Cruzado no popup */
.popup-content .badge {
    font-size: 0.7rem;
}

/* Alerta item com fonte */
.alerta-item .badge {
    font-size: 0.65rem;
    vertical-align: middle;
}

/* Sidebar collapsed - ajustar indicador */
.sidebar.collapsed ~ .connection-status {
    left: 20px;
}

/* Responsivo */
@media (max-width: 768px) {
    .toast-notification {
        right: 10px;
        left: 10px;
        transform: translateY(-120%);
    }
    
    .toast-notification.show {
        transform: translateY(0);
    }
    
    .connection-status {
        bottom: 120px;
        left: 10px;
    }
}


/* ===== QR CODE BOX ===== */
.qrcode-box {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    z-index: 1000;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.qrcode-box.hidden {
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
}

.qrcode-box img {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: white;
    padding: 5px;
}

.qrcode-box p {
    margin: 0;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.qrcode-box small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.qrcode-close {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.qrcode-close:hover {
    color: var(--text-primary);
}

/* Responsivo - esconder QR em mobile */
@media (max-width: 768px) {
    .qrcode-box {
        display: none;
    }
}


/* ===== TEMA CLARO ===== */
body.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

body.light-theme {
    background: var(--bg-primary);
    color: var(--text-primary);
}

body.light-theme .navbar {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .navbar-brand {
    color: #dc3545 !important;
}

body.light-theme .nav-link {
    color: var(--text-primary) !important;
}

body.light-theme .sidebar {
    background: var(--bg-secondary);
    box-shadow: 2px 0 10px var(--shadow-color);
}

body.light-theme .sidebar-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .sidebar-header h5 {
    color: var(--text-primary);
}

body.light-theme .filter-section {
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .filter-section h6 {
    color: var(--text-secondary);
}

body.light-theme .form-check-label {
    color: var(--text-primary);
}

body.light-theme .form-select {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.light-theme .map-legend {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.light-theme .map-legend h6 {
    color: var(--text-primary);
}

body.light-theme .legend-item {
    color: var(--text-secondary);
}

body.light-theme .stats-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.light-theme .stat-item span {
    color: var(--text-primary);
}

body.light-theme .stat-item small {
    color: var(--text-secondary);
}

body.light-theme .qrcode-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

body.light-theme .qrcode-box p {
    color: var(--text-primary);
}

body.light-theme .qrcode-box small {
    color: var(--text-secondary);
}

body.light-theme .qrcode-close {
    color: var(--text-secondary);
}

body.light-theme .modal-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

body.light-theme .modal-header {
    border-bottom: 1px solid var(--border-color);
}

body.light-theme .modal-body {
    color: var(--text-primary);
}

body.light-theme .modal-body p {
    color: var(--text-secondary);
}

body.light-theme .btn-close {
    filter: none;
}

body.light-theme .alerta-item {
    background: rgba(220, 53, 69, 0.05);
    color: var(--text-primary);
}

body.light-theme .alerta-item h6 {
    color: var(--text-primary);
}

body.light-theme .alerta-item p {
    color: var(--text-secondary);
}

body.light-theme .alerta-item small {
    color: var(--text-secondary);
}

body.light-theme .leaflet-popup-content-wrapper {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

body.light-theme .leaflet-popup-tip {
    background: var(--card-bg) !important;
}

body.light-theme .popup-content h5 {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

body.light-theme .popup-content .info-row {
    color: var(--text-secondary);
}

body.light-theme .popup-content .info-row i {
    color: var(--text-secondary);
}

body.light-theme .connection-status.connected {
    background: rgba(40, 167, 69, 0.9);
}
