/* ===========================
   VARIABLES Y RESET
=========================== */
:root {
    --primary-color: #6a1b9a;
    --primary-hover: #4a148c;
    --secondary-color: #8e24aa;
    --text-color: #2c3e50;
    --background-color: #f8f9fa;
    --border-color: #dee2e6;
    --sidebar-width: 320px;
    --navbar-height: 70px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

html {
    scroll-behavior: smooth;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===========================
   NAVBAR
=========================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--navbar-height);
    background-color: white;
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.navbar.hidden {
    transform: translateY(-100%);
}

.navbar-container {
    max-width: 100%;
    height: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.navbar-brand h1 {
    font-size: 1.3rem;
    color: var(--primary-color);
    font-weight: 700;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
    transition: all 0.3s ease;
    border-radius: 3px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.nav-dropdown {
    display: flex;
    gap: 2rem;
    align-items: center;
}

@media (min-width: 769px) {
    .hamburger {
        display: none;
    }
}

.nav-dropdown a {
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.nav-dropdown a:hover {
    color: var(--primary-color);
    background-color: rgba(106, 27, 154, 0.1);
}

/* ===========================
   MAIN CONTAINER
=========================== */
.main-container {
    display: flex;
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    scroll-margin-top: var(--navbar-height);
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    box-shadow: var(--shadow);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width) + 40px));
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background-color: var(--primary-color);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.toggle-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .toggle-sidebar span {
    transform: rotate(180deg);
    display: inline-block;
}

.sidebar-expand-btn {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 1rem 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transition: all 0.3s ease;
}

.sidebar-expand-btn:hover {
    background-color: var(--primary-hover);
    padding-right: 0.75rem;
}

.reset-map-btn {
    position: absolute;
    top: 90px;
    right: 10px;
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 500;
    transition: all 0.3s ease;
    font-weight: bold;
}

.reset-map-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: rotate(180deg);
}

.sidebar-content {
    padding: 1.5rem;
}

.layer-section {
    margin-bottom: 2rem;
}

.layer-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.layer-item {
    margin-bottom: 0.75rem;
}

.layer-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.layer-label:hover {
    background-color: rgba(106, 27, 154, 0.05);
}

.layer-label input[type="checkbox"] {
    margin-right: 0.75rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.layer-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.info-content {
    background-color: var(--background-color);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.info-content p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.info-content strong {
    color: var(--primary-color);
}

/* ===========================
   MAP SECTION
=========================== */
.map-section {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 1rem;
    font-family: 'Montserrat', sans-serif;
}

.leaflet-popup-content h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Leaflet Tooltip Customization */
.colonia-tooltip {
    background-color: rgba(106, 27, 154, 0.95);
    border: 2px solid white;
    border-radius: 6px;
    padding: 6px 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.colonia-tooltip::before {
    border-top-color: rgba(106, 27, 154, 0.95);
}

.point-tooltip {
    background-color: rgba(44, 62, 80, 0.95);
    border: 2px solid white;
    border-radius: 6px;
    padding: 4px 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.point-tooltip::before {
    border-top-color: rgba(44, 62, 80, 0.95);
}

/* Cluster Markers Customization */
.marker-cluster {
    border-radius: 50%;
}

.marker-cluster div {
    width: 34px;
    height: 34px;
    margin-left: 3px;
    margin-top: 3px;
    text-align: center;
    border-radius: 50%;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-cluster span {
    color: white;
    font-size: 13px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.5);
    -webkit-text-stroke: 0.5px black;
    text-stroke: 0.5px black;
}

.marker-cluster-small div {
    width: 34px;
    height: 34px;
}

.marker-cluster-small span {
    font-size: 12px;
}

.marker-cluster-medium div {
    width: 38px;
    height: 38px;
}

.marker-cluster-medium span {
    font-size: 14px;
}

.marker-cluster-large div {
    width: 42px;
    height: 42px;
}

.marker-cluster-large span {
    font-size: 15px;
    font-weight: 700;
}

/* ===========================
   CHARTS SECTION
=========================== */
.charts-section {
    background-color: white;
    padding: 3rem 0;
    border-top: 1px solid var(--border-color);
    scroll-margin-top: var(--navbar-height);
}

.charts-section h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-size: 2rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.charts-grid-main {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.chart-large {
    grid-column: span 2;
    border-bottom: 3px solid var(--border-color);
    padding-bottom: 2rem;
    margin-bottom: 1rem;
}

.chart-container {
    background-color: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.chart-container h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    text-align: center;
}

.chart-container canvas {
    max-height: 350px;
}

/* ===========================
   FOOTER
=========================== */
.footer {
    background-color: var(--primary-color);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.footer p {
    font-size: 0.9rem;
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .nav-dropdown {
        position: absolute;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        background-color: white;
        flex-direction: column;
        gap: 0;
        box-shadow: var(--shadow);
        display: none;
        padding: 1rem 0;
    }

    .nav-dropdown.show {
        display: flex;
    }

    .nav-dropdown a {
        width: 100%;
        padding: 1rem 2rem;
        border-radius: 0;
    }

    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-container {
        flex-direction: column;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid-main {
        grid-template-columns: 1fr;
    }

    .chart-large {
        grid-column: span 1;
    }

    .chart-container canvas {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .navbar-brand h1 {
        font-size: 1.2rem;
    }

    .sidebar {
        width: 280px;
    }

    .charts-section h2 {
        font-size: 1.5rem;
    }
}