/* ============================================================
   ANALYTICS.CSS — Premium Bento Analytics
   ============================================================ */

#analytics-pane {
    position: relative;
    background: var(--bg-primary);
}

/* Blueprint Grid Background */
#analytics-pane::before {
    content: '';
    position: absolute;
    inset: 0;
    background-size: 30px 30px;
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

.analytics-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
}

.analytics-dashboard {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 100%;
}

/* ── KPI Cards (Bento) ───────────────────────────────────── */

.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s;
}

.kpi-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.kpi-icon.red {
    background: rgba(255, 71, 87, 0.12);
    color: #ff4757;
}
.kpi-icon.green {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}
.kpi-icon.amber {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}
.kpi-icon.blue {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* ── Charts Grid (Compact Bento) ──────────────────────────── */

.analytics-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 240px; /* Altura compacta y uniforme para todos los gráficos */
    gap: 16px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.chart-card.wide {
    grid-column: span 2; /* Ocupa 2 columnas para gráficos de líneas/tiempo */
}

.chart-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    margin: 0;
}

.chart-header span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.chart-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 100%;
}

/* ── Section visibility ───────────────────────────────────── */
.analytics-section-pane {
    display: none;
}
.analytics-section-pane.active {
    display: block;
}

.analytics-small-muted {
    font-size: 12px;
    color: var(--text-muted);
}

.analytics-insights-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-insights-list li::marker {
    color: var(--accent);
}

/* ── Sidebar Styles (Rendered by JS) ──────────────────────── */
.analytics-sidebar-title {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding: 0 12px;
}

.analytics-section-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.analytics-section-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.analytics-section-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.analytics-section-btn.active {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.analytics-section-btn.active i {
    color: var(--accent);
}

/* Projects List inside Sidebar */
.analytics-projects-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analytics-project-item {
    text-align: left;
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.analytics-project-item:hover {
    background: var(--bg-tertiary);
}

.analytics-project-item.active {
    background: var(--bg-elevated);
    border-color: var(--border-light);
    box-shadow: 0 2px 8px var(--shadow);
}

.analytics-project-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.analytics-project-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1100px) {
    .analytics-charts {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .analytics-dashboard {
        padding: 16px;
    }

    .analytics-kpis {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-charts {
        grid-template-columns: 1fr;
        grid-auto-rows: 220px;
    }

    .chart-card.wide {
        grid-column: span 1;
    }
}
