/* ===================== ESTADÍSTICAS STYLES ===================== */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--green-500) 0%, var(--green-100) 100%);
    min-height: 100vh;
    padding-top: 80px;
    color: var(--white);
    line-height: 1.6;
}

/* LOADING */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--green-500), var(--green-100));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader {
    width: 70px;
    height: 70px;
    border: 6px solid rgba(13, 124, 102, 0.3);
    border-top: 6px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--white);
    margin-top: 25px;
    font-size: 1.2rem;
    font-weight: 700;
}

/* CONTENEDOR PRINCIPAL */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* HEADER DE PÁGINA */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-header h1 {
    color: var(--white);
    font-size: 2.8rem;
    margin-bottom: 1rem;
    font-weight: 900;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.page-header h1 i {
    color: var(--teal-200);
    margin-right: 15px;
}

.subtitle {
    color: var(--green-50);
    font-size: 1.2rem;
    font-weight: 500;
}

/* FILTROS DE TIEMPO */
.time-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.time-btn {
    background: rgba(22, 56, 50, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(13, 124, 102, 0.3);
    color: var(--white);
    padding: 15px 35px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.time-btn:hover {
    transform: translateY(-3px);
    border-color: var(--teal-200);
    box-shadow: 0 6px 20px rgba(13, 124, 102, 0.4);
}

.time-btn.active {
    background: linear-gradient(135deg, var(--teal-100), var(--teal-200));
    border-color: var(--teal-200);
    box-shadow: 0 6px 25px rgba(13, 124, 102, 0.6);
    transform: translateY(-3px);
}

.time-btn i {
    font-size: 1.2rem;
}

/* TARJETAS DE ESTADÍSTICAS */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 3rem;
}

.stat-card {
    background: rgba(22, 56, 50, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(13, 124, 102, 0.3);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--teal-200);
    box-shadow: 0 12px 35px rgba(13, 124, 102, 0.4);
}

.stat-icon {
    width: 70px;
    height: 70px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--white);
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stat-content {
    flex: 1;
}

.stat-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    color: var(--white);
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 5px;
    line-height: 1;
}

.stat-change {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-change.positive {
    color: var(--alert-green);
}

.stat-change.negative {
    color: var(--alert-red);
}

/* GRÁFICAS */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    margin-bottom: 3rem;
}

.chart-container {
    background: rgba(22, 56, 50, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(13, 124, 102, 0.3);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.chart-container:hover {
    border-color: var(--teal-200);
    box-shadow: 0 12px 35px rgba(13, 124, 102, 0.4);
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.chart-header h3 {
    color: var(--white);
    font-size: 1.3rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-header h3 i {
    color: var(--teal-200);
}

.chart-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

.chart-wrapper canvas {
    max-height: 100%;
}

/* TABLA DE DATOS */
.data-table-container {
    background: rgba(22, 56, 50, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(13, 124, 102, 0.3);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-header h3 {
    color: var(--white);
    font-size: 1.3rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-header h3 i {
    color: var(--teal-200);
}

.export-btn {
    background: linear-gradient(135deg, var(--teal-100), var(--teal-200));
    border: none;
    color: var(--white);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(13, 124, 102, 0.3);
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 124, 102, 0.5);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table thead {
    background: rgba(13, 124, 102, 0.2);
}

.data-table th {
    padding: 15px;
    text-align: left;
    color: var(--white);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(13, 124, 102, 0.4);
}

.data-table th i {
    margin-right: 8px;
    color: var(--teal-200);
}

.data-table tbody tr {
    border-bottom: 1px solid rgba(13, 124, 102, 0.2);
    transition: all 0.3s;
}

.data-table tbody tr:hover {
    background: rgba(13, 124, 102, 0.1);
}

.data-table td {
    padding: 15px;
    color: rgba(255, 255, 255, 0.9);
}

.loading-cell {
    text-align: center;
    padding: 40px !important;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
}

.loading-cell i {
    color: var(--teal-200);
    margin-right: 10px;
}

/* BADGES DE RIESGO */
.risk-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.risk-badge.bajo {
    background: rgba(0, 204, 68, 0.2);
    color: var(--alert-green);
    border: 1px solid var(--alert-green);
}

.risk-badge.moderado {
    background: rgba(255, 204, 0, 0.2);
    color: var(--alert-yellow);
    border: 1px solid var(--alert-yellow);
}

.risk-badge.alto {
    background: rgba(255, 153, 0, 0.2);
    color: #ff9900;
    border: 1px solid #ff9900;
}

.risk-badge.critico {
    background: rgba(255, 51, 51, 0.2);
    color: var(--alert-red);
    border: 1px solid var(--alert-red);
}

/* INFO BOX */
.info-box {
    background: rgba(13, 124, 102, 0.15);
    border: 2px solid rgba(13, 124, 102, 0.3);
    border-left: 4px solid var(--teal-200);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.info-box i {
    color: var(--teal-200);
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 3px;
}

.info-box div {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.7;
}

.info-box strong {
    color: var(--white);
}

/* RESPONSIVE */
@media (max-width: 968px) {
    .container {
        padding: 0 1.5rem;
    }

    .page-header h1 {
        font-size: 2.2rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        height: 250px;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .export-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 640px) {
    body {
        padding-top: 70px;
    }

    .container {
        margin: 1rem auto;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .time-filters {
        flex-direction: column;
    }

    .time-btn {
        width: 100%;
        justify-content: center;
    }

    .chart-wrapper {
        height: 220px;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }

    .stat-value {
        font-size: 1.7rem;
    }
}

/* ===================== RESPONSIVE MEJORADO - AGREGADO ===================== */

/* TABLET (768px - 968px) */
@media (max-width: 968px) {
    body {
        padding-top: 75px;
    }

    .container {
        padding: 0 1.5rem;
    }

    .page-header h1 {
        font-size: 2.2rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        height: 250px;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .export-btn {
        width: 100%;
        justify-content: center;
    }
}

/* MÓVIL GRANDE (481px - 768px) */
@media (max-width: 768px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }

    .time-filters {
        gap: 10px;
    }

    .time-btn {
        padding: 12px 25px;
        font-size: 0.9rem;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-legend {
        width: 100%;
    }
}

/* MÓVIL (< 640px) */
@media (max-width: 640px) {
    body {
        padding-top: 70px;
    }

    .container {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .time-filters {
        flex-direction: column;
        gap: 8px;
    }

    .time-btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .chart-wrapper {
        height: 220px;
    }

    .data-table {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }

    .chart-container,
    .data-table-container {
        padding: 15px;
    }

    .info-box {
        padding: 15px;
        flex-direction: column;
    }
}

/* MÓVIL PEQUEÑO (< 480px) */
@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .stat-icon {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }

    .stat-value {
        font-size: 1.7rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .chart-wrapper {
        height: 200px;
    }

    .chart-header h3 {
        font-size: 1.1rem;
    }

    .legend-item {
        font-size: 0.75rem;
    }

    .legend-color {
        width: 16px;
        height: 16px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 5px;
        font-size: 0.75rem;
    }

    .export-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    .risk-badge {
        font-size: 0.7rem;
        padding: 4px 10px;
    }
}

/* LANDSCAPE MÓVIL */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding-top: 70px;
    }

    .chart-wrapper {
        height: 180px;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}