:root {
    --primary-color: #0A8754; /* Verde Selva */
    --primary-light: #25A16F;
    --secondary-color: #0077B6; /* Azul Océano */
    --accent-color: #F4A261; /* Naranja/Tierra */
    --bg-color: #F8F9FA;
    --surface-color: #FFFFFF;
    --text-main: #2B2D42;
    --text-muted: #6C757D;
    --sidebar-bg: #FFFFFF;
    --sidebar-text: #2B2D42;
    --border-color: #E9ECEF;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 16px 32px rgba(0,0,0,0.12);
    
    --radius-md: 12px;
    --radius-lg: 20px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
}

/* Base Layout */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

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

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.nav-links li a i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-links li a:hover {
    background-color: rgba(10, 135, 84, 0.05);
    color: var(--primary-color);
}

.nav-links li a.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background-color: var(--bg-color);
}

.page-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.page-section.active {
    display: block;
}

/* Map Section Specials */
#maps.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#main-map {
    flex: 1;
    min-height: 500px;
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    z-index: 1;
    margin-top: 16px;
    border: 1px solid var(--border-color);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Historical Marker */
.custom-historical-icon {
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    border: 2px solid white;
    font-size: 14px;
}

/* Custom Popup Styles */
.custom-popup .leaflet-popup-content-wrapper {
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.custom-popup .leaflet-popup-content {
    margin: 0;
    width: 260px !important;
}

.popup-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    background-color: var(--border-color);
}

.popup-body {
    padding: 16px;
}

.popup-tag {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.70rem;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tag-historia-colonial { background-color: #e9ecef; color: #495057; }
.tag-patrimonio-cultural-y-musical { background-color: #e0f2fe; color: #0284c7; }
.tag-patrimonio-natural { background-color: #dcfce7; color: #166534; }
.tag-arquitectura-y-religion { background-color: #fef3c7; color: #d97706; }

.popup-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 8px 0;
    font-family: 'Outfit', sans-serif;
}

.popup-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
    font-family: 'Outfit', sans-serif;
}

/* Education Dashboard */
.education-dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-top: 24px;
}
.edu-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
}
.edu-card h3 {
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 1.2rem;
    color: var(--text-main);
}
.canvas-container {
    position: relative;
    width: 100%;
    height: 300px;
}

@media (max-width: 900px) {
    .education-dashboard {
        grid-template-columns: 1fr;
    }
}

/* Choropleth Legend */
.info.legend {
    background: white;
    padding: 10px 14px;
    font-family: 'Outfit', sans-serif;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 8px;
    line-height: 24px;
    color: #555;
}
.info.legend h4 {
    color: #333;
    font-size: 0.9rem;
    font-weight: 700;
}
.info.legend i {
    width: 18px;
    height: 18px;
    float: left;
    margin-right: 8px;
    opacity: 0.8;
}

/* Custom Leaflet UI (Control Layers) */
.leaflet-control-layers {
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
    padding: 12px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.leaflet-control-layers-list {
    font-family: 'Outfit', sans-serif !important;
}
.leaflet-control-layers-base label {
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
}
.leaflet-control-layers-overlays label {
    font-weight: 500;
    color: #475569;
    padding: 6px 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    font-size: 0.85rem;
}
.leaflet-control-layers-overlays label:last-child {
    border-bottom: none;
}
.leaflet-control-layers-separator {
    border-top: 2px solid #e2e8f0 !important;
    margin: 10px 0 !important;
}
/* Style checkboxes/radios neatly */
.leaflet-control-layers input[type="checkbox"], 
.leaflet-control-layers input[type="radio"] {
    margin-right: 12px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.section-header {
    margin-bottom: 32px;
}

.section-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.section-header p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    grid-auto-rows: minmax(160px, auto);
}

.bento-item {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.bento-item.feature-maps {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, white 0%, #f0fdf4 100%);
    border-color: #dcfce7;
}

@media (min-width: 1024px) {
    .bento-item.feature-maps {
        grid-column: span 2;
    }
}

.bento-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.bento-icon {
    font-size: 1.8rem;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.feature-games .bento-icon { color: var(--accent-color); }
.feature-materials .bento-icon { color: var(--secondary-color); }

.bento-item h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.bento-item p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.5;
}

/* Progress bar inside bento */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #E9ECEF;
    border-radius: 4px;
    margin: 16px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-light);
    border-radius: 4px;
}

/* Placeholder */
.placeholder-content {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 60px;
    text-align: center;
    border: 1px dashed #CED4DA;
    color: var(--text-muted);
}

.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }

/* --- Lightbox Modal --- */
#ecuagrafia-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
#ecuagrafia-lightbox img {
    max-height: 90vh;
    max-width: 90vw;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    user-select: none;
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 20px; right: 30px;
    color: white; font-size: 40px;
    font-weight: bold; cursor: pointer;
    user-select: none;
    z-index: 100000;
}
.lightbox-prev, .lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white; font-size: 50px;
    font-weight: bold; cursor: pointer;
    padding: 20px;
    user-select: none;
    transition: 0.2s;
    z-index: 100000;
}
.lightbox-prev:hover, .lightbox-next:hover { color: #0284c7; }
.lightbox-prev { left: 2vw; }
.lightbox-next { right: 2vw; }

/* --- Andeme Game UI --- */
.game-dashboard {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-top: 24px;
}
.andeme-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.andeme-level-badge {
    background: var(--primary-light);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.andeme-score-box {
    background: #f1f5f9;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-muted);
}
.andeme-canvas-wrapper {
    transition: transform 0.2s;
}
.andeme-feedback-circle {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 4px solid #10b981;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: popGreen 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}
.andeme-feedback-cross {
    position: absolute;
    color: #ef4444;
    font-size: 40px;
    font-weight: bold;
    transform: translate(-50%, -50%) scale(0);
    animation: popRed 0.3s forwards;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    pointer-events: none;
}
@keyframes popGreen {
    to { transform: translate(-50%, -50%) scale(1); }
}
@keyframes popRed {
    to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
