/* Statistics.css */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 180px);
    width: min(1600px, calc(100% - 32px));
    margin: 0 auto 1.5rem;
    padding: 1rem 0 1.5rem;
    gap: 1rem;
    background: transparent;
}

.stats-filter-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
    align-items: end;
    gap: 0.9rem;
    padding: 1rem !important;
    border-radius: 0.9rem !important;
}

.stats-filter-bar .control-group label {
    display: block;
    margin-bottom: 0.35rem;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.stats-filter-bar select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 0.55rem;
    padding: 0 0.75rem;
    background: #fff;
    color: #0f172a;
    font-weight: 700;
}

.stats-compact-toggle {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.55rem;
    background: #fff;
    color: #334155;
    font-weight: 800;
}

/* Tabs */
.stats-tabs {
    display: flex;
    gap: 1rem;
    padding: 1rem !important;
    border-radius: 1rem !important;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    color: #1e293b;
}

.tab-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.subtabs {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem !important;
    border-radius: 1rem !important;
    flex-wrap: wrap;
}

.subtab-btn {
    padding: 0.65rem 1rem;
    border: none;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 0.85rem;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.subtab-btn.active {
    background: rgba(59, 130, 246, 0.18);
    color: var(--accent);
    border: 1px solid rgba(96, 165, 250, 0.32);
}

.tab-content {
    display: none;
    flex-grow: 1;
    overflow: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.stats-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem !important;
    border-radius: 0.9rem !important;
}

.stats-section-head h2,
.stats-section-head p {
    margin: 0;
}

.stats-section-head p {
    color: #64748b;
    font-weight: 600;
}

.subtab-content {
    display: none;
}

.subtab-content.active {
    display: block;
}

/* Overview Info Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem !important;
    border-radius: 1.25rem !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card:hover {
    transform: translateY(-5px) scale(1.02);
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.card-details h4 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
}

.card-details span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Card Themes */
.accent-blue { border-left: 5px solid #3b82f6 !important; }
.accent-blue .card-icon { background: #eff6ff; color: #3b82f6; }

.accent-purple { border-left: 5px solid #8b5cf6 !important; }
.accent-purple .card-icon { background: #f5f3ff; color: #8b5cf6; }

.accent-pink { border-left: 5px solid #ec4899 !important; }
.accent-pink .card-icon { background: #fdf2f8; color: #ec4899; }

.accent-orange { border-left: 5px solid #f59e0b !important; }
.accent-orange .card-icon { background: #fffbeb; color: #f59e0b; }

.accent-emerald { border-left: 5px solid #10b981 !important; }
.accent-emerald .card-icon { background: #ecfdf5; color: #10b981; }

.accent-gold { border-left: 5px solid #eab308 !important; }
.accent-gold .card-icon { background: #fefce8; color: #ca8a04; }

.accent-cyan { border-left: 5px solid #06b6d4 !important; }
.accent-cyan .card-icon { background: #ecfeff; color: #0891b2; }

.accent-teal { border-left: 5px solid #14b8a6 !important; }
.accent-teal .card-icon { background: #f0fdfa; color: #0f766e; }

.accent-rose { border-left: 5px solid #f43f5e !important; }
.accent-rose .card-icon { background: #fff1f2; color: #e11d48; }

.accent-indigo { border-left: 5px solid #6366f1 !important; }
.accent-indigo .card-icon { background: #eef2ff; color: #4f46e5; }

.accent-slate { border-left: 5px solid #64748b !important; }
.accent-slate .card-icon { background: #f8fafc; color: #475569; }

.feature-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.feature-metric-card {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    padding: 1rem;
    border-radius: 0.7rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.feature-metric-card__icon {
    width: 44px;
    height: 44px;
    border-radius: 0.65rem;
    display: grid;
    place-items: center;
    background: #eff6ff;
    color: #2563eb;
    font-size: 1.35rem;
}

.feature-metric-card strong {
    display: block;
    color: #0f172a;
    font-size: 1.35rem;
    line-height: 1.1;
}

.feature-metric-card span,
.feature-metric-card small {
    display: block;
}

.feature-metric-card span {
    color: #334155;
    font-weight: 800;
    margin-top: 0.15rem;
}

.feature-metric-card small {
    color: #64748b;
    font-weight: 600;
    margin-top: 0.25rem;
}

.feature-card-grid,
.ops-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.feature-card {
    padding: 1rem !important;
    border-radius: 0.7rem !important;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.8rem;
    align-items: center;
}

.feature-card i {
    grid-row: span 2;
    width: 42px;
    height: 42px;
    border-radius: 0.6rem;
    display: grid;
    place-items: center;
    background: #eff6ff;
    color: #2563eb;
    font-size: 1.3rem;
}

.feature-card strong {
    color: #0f172a;
    font-weight: 900;
}

.feature-card span {
    color: #64748b;
    font-weight: 600;
}

.chart-card {
    min-height: 330px;
}

.chart-card canvas {
    width: 100% !important;
    height: 250px !important;
}

.stats-list {
    display: grid;
    gap: 0.65rem;
}

.stats-list-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) 1fr auto;
    align-items: center;
    gap: 0.8rem;
    padding: 0.72rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    background: #fff;
}

.stats-list-row span {
    color: #64748b;
    font-weight: 800;
}

.stats-list-row strong {
    color: #0f172a;
}

.stats-list-row b {
    color: #2563eb;
}

.stats-empty,
.stats-error {
    color: #64748b;
    font-weight: 800;
}

.quality-score {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    margin-bottom: 0.85rem;
}

.quality-score strong {
    font-size: 2rem;
    color: #16a34a;
}

.quality-score span {
    color: #475569;
    font-weight: 800;
}

body.stats-compact .feature-metric-card,
body.stats-compact .feature-card,
body.stats-compact .stats-list-row {
    padding: 0.62rem !important;
}

body.stats-compact .feature-metric-card strong {
    font-size: 1.05rem;
}

/* Mini Stats */
.m-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.m-item span {
    float: right;
    font-weight: 700;
    color: #3b82f6;
}

/* Course Summary */
.segment-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
    background: color-mix(in srgb, var(--card-bg) 94%, white 6%);
    padding: 1.5rem;
    border-radius: 1rem;
}

.s-card {
    display: flex;
    flex-direction: column;
}

.s-card strong {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
}

.s-card span {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
}

.seg-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
}

.seg-list li {
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
}

.segment-text-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.segment-pill {
    min-width: 130px;
    padding: 0.7rem 0.85rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.24);
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    color: #0f172a;
    font-size: 0.84rem;
}

.segment-pill strong {
    font-size: 0.8rem;
}

.segment-pill span {
    font-weight: 800;
}

.segment-pill--empty {
    justify-content: center;
    color: #64748b;
}

.border-l { border-left: 1px solid #e2e8f0; }
.pl-4 { padding-left: 1.5rem; }

.dashboard-row {
    display: grid;
    gap: 1rem;
}

.dashboard-row--charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.distribution-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.distribution-card {
    padding: 1rem;
    min-height: 360px;
}

.distribution-card--wide {
    grid-column: span 2;
}

.distribution-card--wide .stats-data-grid {
    height: 320px;
}

.distribution-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.distribution-card__head h3 {
    margin: 0;
    color: #0f172a;
}

.mini-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 0.8rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 800;
    font-size: 0.78rem;
}

.stats-data-grid {
    height: 280px;
    width: 100%;
}

/* Matrix Matrix Controls */
.matrix-controls label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.4rem;
    display: block;
}

.matrix-controls input, .matrix-controls select {
    padding: 0.6rem 0.8rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 0.6rem;
    font-weight: 500;
}

/* Birthdays Sidebar */
.sidebar-picker h3 { margin: 0 0 0.5rem 0; color: #1e293b; }

/* AG Grid Kendo Like Styling */
.matrix-grid {
    height: 100%;
}

.ag-theme-kendo {
    --ag-grid-size: 8px;
    --ag-row-height: 48px;
    --ag-header-height: 54px;
    --ag-header-background-color: #f1f5f9;
    --ag-header-foreground-color: #475569;
    --ag-cell-horizontal-border: 1px solid #e2e8f0;
    --ag-odd-row-background-color: #f8fafc;
    --ag-selected-row-background-color: #dbeafe;
    --ag-font-family: 'Outfit', sans-serif;
    --ag-font-size: 14px;
    border: none !important;
}

.ag-header-cell {
    border-right: 1px solid #cbd5e1 !important;
}

.ag-header-cell-label {
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.ag-row {
    font-weight: 500;
}

/* Row specifically for TOTAL */
.ag-row[row-index="total"] {
    background: #e2e8f0 !important;
    font-weight: 800 !important;
}

/* Loader */
.inner-loader {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Utilities */
.gap-4 { gap: 1rem; }
.p-4 { padding: 1.5rem !important; }
.mt-4 { margin-top: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.border-b { border-bottom: 1px solid #f1f5f9; }
.pb-2 { padding-bottom: 0.5rem; }
.full-width { width: 100%; }

.badge {
    background: #3b82f6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
}

@media (max-width: 1180px) {
    .dashboard-row--charts,
    .distribution-grid,
    .segment-summary,
    .feature-card-grid,
    .ops-panels,
    .stats-filter-bar {
        grid-template-columns: 1fr;
    }

    .distribution-card--wide {
        grid-column: auto;
    }
}

@media (max-width: 820px) {
    .app-container {
        width: min(1600px, calc(100% - 20px));
    }

    .stats-tabs,
    .subtabs {
        gap: 0.5rem;
    }

    .tab-btn,
    .subtab-btn {
        width: 100%;
        justify-content: center;
    }
}
