:root {
    /* Color Palette - Dark Premium Theme */
    --bg-dark: #0f172a;
    --sidebar-bg: rgba(15, 23, 42, 0.85);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Brand Colors (Morena/General Political style) */
    --primary-color: #be123c; /* Cherry / Guinda */
    --primary-hover: #9f1239;
    --accent-color: #38bdf8; /* Light Blue for highlights */
    
    /* UI Elements */
    --border-color: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(255, 255, 255, 0.05);
    --font-main: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-main);
    background-color: var(--bg-dark);
    overflow: hidden; /* Evitar scroll en toda la app */
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- SIDEBAR (Glassmorphism) --- */
.sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 1000; /* Por encima del mapa de Leaflet */
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    overflow-y: auto;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main);
}

.sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- STATS --- */
.stats-cards {
    margin-top: 32px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(190, 18, 60, 0.2), rgba(0, 0, 0, 0.1));
    border: 1px solid rgba(190, 18, 60, 0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(190, 18, 60, 0.4);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* --- FILTERS --- */
.filters-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.filter-group select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
    appearance: none;
}

.filter-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(190, 18, 60, 0.25);
}

.filter-group select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

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

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

/* --- LEGEND --- */
.legend-section {
    margin-top: auto;
    padding-top: 32px;
}

.legend-section h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 12px;
}

/* --- MAP AREA --- */
.map-wrapper {
    flex-grow: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #1e1e1e; /* Color base oscuro antes de que carguen los tiles */
}

/* Leaflet Overrides para Dark Mode */
.leaflet-popup-content-wrapper {
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.leaflet-popup-tip {
    background: var(--bg-dark);
}
.leaflet-popup-content {
    margin: 16px;
}
.popup-title {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 4px;
    font-size: 1.1rem;
}
.popup-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Custom Marker Styles */
.custom-div-icon {
    background: transparent;
    border: none;
}
.marker-pin {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: 3px solid white;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: transform 0.2s ease;
}
.marker-pin:hover {
    transform: scale(1.3);
}

/* --- ADMIN UI --- */
.admin-toggle {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.admin-toggle input {
    margin-right: 5px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    color: var(--text-main);
    font-size: 0.9rem;
}
.admin-table th, .admin-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.admin-table th {
    color: var(--primary-color);
    font-weight: 600;
}
.btn-delete {
    background: #ef4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.btn-delete:hover {
    background: #dc2626;
}

/* --- BUTTONS --- */
.btn-success {
    width: 100%;
    padding: 12px;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.btn-success:hover {
    filter: brightness(1.1);
}

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

/* --- MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(190, 18, 60, 0.25);
}

.form-group input[type="color"] {
    width: 55px !important;
    height: 38px !important;
    padding: 2px !important;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.form-group input[type="color"]:hover {
    transform: scale(1.05);
    border-color: var(--accent-color);
}

/* --- RESPONSIVE MOBILE --- */
.mobile-menu-btn {
    display: none;
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10000;
    background: var(--surface-light);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        position: absolute;
        left: -100%;
        top: 0;
        height: 100%;
        z-index: 9999;
        transition: left 0.3s ease;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(15px);
        width: 85%;
        max-width: 320px;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .map-wrapper {
        width: 100%;
        height: 100vh;
    }
    
    .leaflet-control-zoom {
        display: none; /* Hide zoom on mobile to save space */
    }
}
