/* Página de estadísticas — dashboard institucional */
.estadisticas-page {
    background: var(--dark-bg);
}

.estadisticas-page .section {
    padding: 4rem 0;
}

/* Hero */
.stats-hero {
    margin-top: 70px;
    padding: 3rem 0 2.5rem;
    background:
        linear-gradient(180deg, rgba(225, 6, 19, 0.14) 0%, rgba(10, 10, 10, 0) 85%),
        radial-gradient(ellipse 80% 60% at 90% 0%, rgba(225, 6, 19, 0.18) 0%, transparent 55%),
        var(--dark-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-hero-inner {
    max-width: 1100px;
}

.stats-hero-eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--red-light);
    margin-bottom: 0.65rem;
}

.stats-hero h1 {
    font-size: clamp(2.25rem, 5.5vw, 3.75rem);
    line-height: 1.02;
    margin-bottom: 0.75rem;
}

.stats-hero h1 span {
    color: var(--red-light);
}

.stats-hero-lead {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 42rem;
    line-height: 1.65;
    margin: 0 0 1.5rem;
}

.stats-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.stats-hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.82rem;
    color: var(--text-muted);
}

.stats-hero-pill strong {
    color: #fff;
    font-weight: 700;
}

/* Navegación por secciones */
.stats-jump-nav-wrap {
    position: sticky;
    top: 70px;
    z-index: 40;
    padding: 0.75rem 0;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-jump-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.stats-jump-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.stats-jump-nav a:hover {
    color: #fff;
    border-color: rgba(225, 6, 19, 0.4);
    background: rgba(225, 6, 19, 0.1);
}

/* Secciones */
.stats-section-card {
    background: linear-gradient(145deg, rgba(22, 22, 22, 0.98) 0%, rgba(14, 14, 14, 0.99) 100%);
    border-radius: 22px;
    padding: 2.5rem 2.75rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.stats-section-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--red-dark), var(--red-light), var(--red-dark));
}

.stats-section-header {
    margin-bottom: 2.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-section-eyebrow {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 0.5rem;
}

.stats-section-header h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 700;
    color: #fff;
}

.stats-section-header p {
    font-size: 0.98rem;
    color: var(--text-secondary);
    margin: 0;
    max-width: 40rem;
}

/* KPI grid */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    width: 100%;
}

.stats-section-card .stat-card {
    min-height: 0 !important;
    padding: 1.5rem 1.25rem !important;
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    transition: all 0.25s ease !important;
    text-align: left !important;
    align-items: flex-start !important;
}

.stats-section-card .stat-card:hover {
    border-color: rgba(225, 6, 19, 0.35) !important;
    background: rgba(225, 6, 19, 0.06) !important;
    transform: translateY(-2px);
}

.stats-section-card .stat-card .stat-icon {
    font-size: 1.5rem !important;
    margin-bottom: 0.75rem !important;
    width: 44px;
    height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(225, 6, 19, 0.12);
}

.stats-section-card .stat-card .stat-value {
    font-size: clamp(2rem, 4vw, 2.75rem) !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    margin: 0 0 0.5rem !important;
    background: linear-gradient(135deg, var(--red-light) 0%, var(--red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: left !important;
}

.stats-section-card .stat-card .stat-label {
    font-size: 0.82rem !important;
    line-height: 1.45 !important;
    margin-top: 0 !important;
    color: var(--text-muted) !important;
    text-align: left !important;
}

/* Desglose por tipo (resumen) */
.stats-tipo-breakdown {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-tipo-breakdown h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 1rem;
}

.stats-tipo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

.stats-tipo-item {
    display: block;
    padding: 1rem 0.75rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    text-decoration: none;
    color: inherit;
    transition: all 0.25s ease;
    text-align: center;
}

.stats-tipo-item:hover {
    border-color: rgba(225, 6, 19, 0.35);
    background: rgba(225, 6, 19, 0.06);
    color: inherit;
    transform: translateY(-2px);
}

.stats-tipo-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--red-light);
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stats-tipo-pct {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.stats-tipo-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

/* Proyección */
.projection-banner {
    background: linear-gradient(135deg, rgba(225, 6, 19, 0.12) 0%, rgba(18, 18, 18, 0.6) 100%);
    border: 1px solid rgba(225, 6, 19, 0.35);
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin-top: 1.75rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.25rem;
    align-items: start;
}

.projection-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(225, 6, 19, 0.15);
    font-size: 1.35rem;
    flex-shrink: 0;
}

.projection-info h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.projection-info p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

.projection-info strong {
    color: var(--red-light);
    font-weight: 700;
}

.variacion-positiva { color: #10b981; }
.variacion-negativa { color: #ef4444; }

/* Gráficos */
.stats-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.chart-card,
.chart-card-full {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.chart-card-full {
    padding: 1.75rem;
    margin-top: 1.25rem;
}

.chart-card:hover {
    border-color: rgba(225, 6, 19, 0.25);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

.chart-card-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chart-card-header h3 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.chart-card-header p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.chart-container {
    position: relative;
    min-height: 300px;
    max-height: 400px;
    width: 100%;
    box-sizing: border-box;
}

.chart-card-full .chart-container {
    min-height: 400px;
    max-height: 500px;
}

#chartUnidadesPorTipo {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chart-card-full #chartUnidadesPorTipo-container {
    min-height: 500px;
    max-height: 600px;
    width: 100%;
    box-sizing: border-box;
}

#chartTipoPie,
#chartTipoAnio,
#chartUnidadesPorAnio {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chart-card canvas,
.chart-card-full canvas {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* CTA socio */
.stats-socio-cta {
    display: grid;
    grid-template-columns: 1.35fr auto;
    gap: 2rem;
    align-items: center;
    padding: 2rem 2.25rem;
    border-radius: 20px;
    border: 1px solid rgba(225, 6, 19, 0.35);
    background: linear-gradient(135deg, rgba(225, 6, 19, 0.14) 0%, rgba(18, 18, 18, 0.95) 45%, rgba(12, 12, 12, 0.98) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
}

.stats-socio-cta::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--red-dark), var(--red-light), var(--red-dark));
}

.stats-socio-cta-eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #ffb4b4;
    margin-bottom: 0.65rem;
}

.stats-socio-cta h2 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: #fff;
}

.stats-socio-cta p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--text-secondary);
    max-width: 42rem;
}

.stats-socio-cta-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex-shrink: 0;
}

.stats-socio-cta-actions .btn {
    white-space: nowrap;
    justify-content: center;
    min-width: 200px;
}

.stats-charts-grid-spaced {
    margin-top: 1.25rem;
}

.estadisticas-page [id] {
    scroll-margin-top: 130px;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-tipo-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-section-card {
        padding: 2rem;
    }

    .stats-charts-grid {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .chart-card canvas,
    .chart-card-full canvas {
        padding: 0 !important;
        margin: 0 !important;
    }

    .chart-card .chart-container,
    .chart-card-full .chart-container {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .estadisticas-page .section {
        padding: 3rem 0;
    }

    .stats-hero {
        padding: 2rem 0 1.5rem;
    }

    .stats-jump-nav-wrap {
        top: 70px;
        padding: 0.5rem 0;
    }

    .stats-jump-nav {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .stats-jump-nav a {
        flex-shrink: 0;
    }

    .stats-grid-4,
    .stats-tipo-grid {
        grid-template-columns: 1fr;
    }

    .stats-tipo-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-section-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .stats-section-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .stats-charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-card,
    .chart-card-full {
        padding: 1rem;
    }

    .chart-card-header h3 {
        font-size: 1rem;
    }

    .chart-container {
        min-height: 400px;
        max-height: 500px;
    }

    #chartAnual-container,
    #chartMensual-container {
        min-height: 450px !important;
        max-height: 550px !important;
    }

    #chartTipoPie-container {
        min-height: 500px !important;
        max-height: 600px !important;
    }

    #chartTipoBar-container {
        min-height: 500px !important;
        max-height: 600px !important;
    }

    #chartHorario-container,
    #chartDias-container {
        min-height: 500px !important;
        max-height: 600px !important;
    }

    #chartUnidades-container {
        min-height: 500px !important;
        max-height: 600px !important;
    }

    #chartUnidadesPorTipo-container {
        min-height: 600px !important;
        max-height: 700px !important;
    }

    .projection-banner {
        grid-template-columns: 1fr;
    }

    .stats-socio-cta {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        padding: 1.5rem;
    }

    .stats-socio-cta-actions {
        width: 100%;
    }

    .stats-socio-cta-actions .btn {
        width: 100%;
        min-width: 0;
    }

    .stats-section-card .stat-card .stat-value {
        font-size: clamp(1.75rem, 6vw, 2.5rem) !important;
    }
}
