/* ========================================
   PERU DECIDE 2026 - MAIN CSS
   Design System: Dark mode elite, Red primary
   ======================================== */

:root {
    --red:       #C8102E;
    --red-light: #FF2744;
    --red-dark:  #960020;
    --red-glow:  rgba(200, 16, 46, 0.3);

    --bg-base:    #07070F;
    --bg-surface: #0F0F1C;
    --bg-card:    #141428;
    --bg-hover:   #1A1A30;
    --bg-border:  #1E1E38;

    --text-primary:  #F0F0FA;
    --text-secondary: #9090B0;
    --text-muted:    #555575;

    --green:  #00C97F;
    --yellow: #FFB800;
    --blue:   #4D9EFF;
    --purple: #9B59FF;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 32px rgba(200, 16, 46, 0.15);
    --shadow-nav:  0 1px 0 rgba(30, 30, 56, 0.9), 0 4px 24px rgba(0,0,0,0.5);

    --transition: 0.2s ease;
    --transition-slow: 0.4s ease;

    --navbar-h: 64px;
    --hero-h:   88px;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul, ol { list-style: none; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--bg-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-dark); }

/* ========================================
   NAVBAR
   ======================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-h);
    background: rgba(7, 7, 15, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--bg-border);
    box-shadow: var(--shadow-nav);
    z-index: 1000;
}

.navbar-inner {
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    background: white;
    padding: 2px;
}

.nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: var(--red);
    letter-spacing: 0.05em;
}

.brand-sub {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.nav-live {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(200, 16, 46, 0.1);
    border: 1px solid rgba(200, 16, 46, 0.3);
    border-radius: 100px;
    padding: 4px 10px;
    flex-shrink: 0;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.live-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--red-light);
    letter-spacing: 0.12em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link i { font-size: 12px; }

.nav-cta {
    background: var(--red) !important;
    color: white !important;
    font-weight: 600;
    padding: 8px 18px;
    animation: cta-pulse 3s ease-in-out infinite;
}

@keyframes cta-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--red-glow); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

.nav-cta:hover {
    background: var(--red-light) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--red-glow);
}

.nav-admin {
    color: var(--text-muted) !important;
    font-size: 12px;
}

/* ========================================
   HERO STATS
   ======================================== */
.hero-stats {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--bg-border);
    z-index: 900;
    padding: 12px 20px;
}

.stats-grid {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--red-dark);
    transform: translateY(-2px);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(200, 16, 46, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    font-size: 16px;
    flex-shrink: 0;
}

.stat-card--green .stat-icon { background: rgba(0, 201, 127, 0.15); color: var(--green); }
.stat-card--yellow .stat-icon { background: rgba(255, 184, 0, 0.15); color: var(--yellow); }
.stat-card--blue .stat-icon { background: rgba(77, 158, 255, 0.15); color: var(--blue); }

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    transition: color 0.3s ease;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   MAIN LAYOUT
   ======================================== */
.main-layout {
    margin-top: calc(var(--navbar-h) + var(--hero-h) + 12px);
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    min-height: calc(100vh - var(--navbar-h) - var(--hero-h));
}

/* ========================================
   MAP SECTION
   ======================================== */
.map-section {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--bg-border);
    min-height: 600px;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--bg-border);
    flex-shrink: 0;
}

.map-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.map-legend {
    display: flex;
    gap: 16px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

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

.legend-dot--bajo   { background: #1A3A2A; border: 1px solid #2A6A4A; }
.legend-dot--medio  { background: #FFB800; }
.legend-dot--alto   { background: #FF6B2B; }
.legend-dot--critico { background: #C8102E; }

.map-container {
    flex: 1;
    min-height: 500px;
    background: var(--bg-base);
}

/* Leaflet override para dark mode */
.leaflet-container {
    background: #0A0A18 !important;
    font-family: 'Inter', sans-serif;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}

.leaflet-popup-tip { background: var(--bg-card); }

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--bg-border) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-hover) !important;
    color: var(--red) !important;
}

.map-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--bg-border);
    flex-shrink: 0;
}

.map-update-text {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.btn-refresh:hover {
    border-color: var(--red-dark);
    color: var(--red);
    background: rgba(200, 16, 46, 0.08);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-surface);
    overflow-y: auto;
    max-height: calc(100vh - var(--navbar-h) - var(--hero-h));
    position: sticky;
    top: calc(var(--navbar-h) + var(--hero-h));
}

/* CTA Banner */
.cta-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--red-dark) 0%, var(--red) 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: all var(--transition);
}

.cta-banner:hover {
    filter: brightness(1.1);
}

.cta-icon {
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.cta-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.cta-text strong {
    font-size: 13px;
    font-weight: 700;
    color: white;
}

.cta-text span {
    font-size: 11px;
    color: rgba(255,255,255,0.8);
}

.cta-arrow {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
}

/* Sidebar Cards */
.sidebar-card {
    padding: 16px;
    border-bottom: 1px solid var(--bg-border);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    color: var(--red);
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    animation: fadeIn 0.3s ease;
}

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

.leaderboard-item:hover {
    border-color: var(--red-dark);
    background: var(--bg-hover);
}

.lb-pos {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 700;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.lb-pos--1 { color: #FFD700; }
.lb-pos--2 { color: #C0C0C0; }
.lb-pos--3 { color: #CD7F32; }
.lb-pos--rest { color: var(--text-muted); }

.lb-info { flex: 1; min-width: 0; }
.lb-nombre {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-region {
    font-size: 10px;
    color: var(--text-muted);
}

.lb-puntos {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--yellow);
    flex-shrink: 0;
}

.lb-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 100px;
    letter-spacing: 0.05em;
}

.lb-badge--activa { background: rgba(0, 201, 127, 0.15); color: var(--green); }
.lb-badge--critico { background: rgba(200, 16, 46, 0.15); color: var(--red); }

.leaderboard-empty {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

/* Chart */
.chart-wrap {
    height: 120px;
    position: relative;
}

/* Feed de actividad */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.feed-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-border);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.feed-item:last-child { border-bottom: none; }

.feed-cat-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
}

.feed-body { flex: 1; min-width: 0; }
.feed-cat-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}
.feed-lugar {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-tiempo { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.feed-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 20px; }

/* Colores por categoria */
.cat--compra_votos { background: rgba(155, 89, 255, 0.15); color: var(--purple); }
.cat--intimidacion { background: rgba(255, 107, 43, 0.15); color: #FF6B2B; }
.cat--dano_material { background: rgba(255, 184, 0, 0.15); color: var(--yellow); }
.cat--problema_mesa { background: rgba(77, 158, 255, 0.15); color: var(--blue); }
.cat--violencia { background: rgba(200, 16, 46, 0.2); color: var(--red); }
.cat--otro { background: rgba(100, 100, 130, 0.2); color: var(--text-secondary); }

/* ========================================
   POPUP DETALLE
   ======================================== */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.popup-overlay.open { display: flex; }

.popup-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 90%;
    position: relative;
    animation: popIn 0.25s ease;
    box-shadow: var(--shadow-card);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition);
}

.popup-close:hover { background: var(--red); color: white; }

/* ========================================
   FAB
   ======================================== */
.fab-reportar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--red);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 20px var(--red-glow);
    z-index: 900;
    transition: all var(--transition);
}

.fab-reportar:hover {
    background: var(--red-light);
    transform: scale(1.1);
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--bg-border);
    padding: 16px 20px;
}

.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

.footer-sep { color: var(--bg-border); }

.footer-manifiesto {
    font-style: italic;
    color: var(--text-muted);
    font-size: 10px;
    opacity: 0.7;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr 320px;
    }
}

@media (max-width: 768px) {
    :root {
        --hero-h: 56px;
    }

    .main-layout {
        grid-template-columns: 1fr;
        margin-top: calc(var(--navbar-h) + var(--hero-h) + 8px);
    }

    .map-section {
        min-height: 50vh;
        border-right: none;
    }

    .sidebar {
        max-height: none;
        position: static;
        border-top: 1px solid var(--bg-border);
    }

    /* Tarjetas en fila horizontal compacta */
    .hero-stats {
        padding: 6px 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .stat-card {
        padding: 6px 8px;
        gap: 6px;
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-icon {
        width: 24px;
        height: 24px;
        font-size: 11px;
        border-radius: 6px;
    }

    .stat-num {
        font-size: 16px;
        line-height: 1;
    }

    .stat-label {
        font-size: 9px;
        letter-spacing: 0;
    }

    .brand-sub, .nav-admin { display: none; }
    .map-legend { display: none; }
    .fab-reportar { display: flex; }
    .nav-cta { display: none; }
}

@media (max-width: 480px) {
    .navbar-inner { padding: 0 12px; }
    .hero-stats { padding: 6px 10px; }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .stat-card {
        padding: 5px 6px;
    }

    .stat-icon {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .stat-num { font-size: 14px; }
    .stat-label { font-size: 8px; }
}
