/* ═══════════════════════════════════════
   chart.css — Charts & Graphs
   ═══════════════════════════════════════ */

/* ── Charts Section ── */
.charts-section {
    margin: 0 16px 16px 16px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* ── Chart Card ── */
.chart-card {
    background: white;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* ── Chart Header ── */
.chart-header-compact {
    padding: 8px 16px;
    background: #f0f4f8;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.chart-title-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

    .chart-title-group h6 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
    }

    .chart-title-group .mud-typography-body2 {
        font-size: 11px;
    }

.section-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-title-text {
    font-weight: 600;
    font-size: 15px;
    color: #1e293b;
}

.chart-subtitle {
    font-size: 11px !important;
    color: #94a3b8 !important;
}

/* ── Chart Body ── */
.chart-container {
    padding: 16px;
}

/* ── Bar Chart ── */
.sample-chart {
    padding: 12px 0;
    overflow-x: auto;
}

.chart-bars {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 8px;
    min-width: 700px;
    height: 220px;
    padding-bottom: 4px;
}

.bar-item-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 55px;
    min-width: 35px;
}

.bar-item {
    width: 100%;
    max-width: 45px;
    min-width: 28px;
    min-height: 30px;
    background: linear-gradient(180deg, #1f6392 0%, #42a5f5 100%);
    border-radius: 6px 6px 2px 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

    .bar-item:hover {
        transform: translateY(-3px);
        box-shadow: 0 4px 12px rgba(31, 99, 146, 0.3);
    }

.bar-value {
    color: white;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.2;
    text-align: center;
}

.bar-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-top: 6px;
    text-align: center;
    width: 100%;
}

/* ── Age Chart ── */
.age-chart-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8ecf1;
    width: 100%;
}

.age-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
}

.age-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.age-label {
    width: 90px;
    font-size: 12px;
    font-weight: 500;
    color: #334155;
    text-align: right;
    flex-shrink: 0;
}

.age-progress {
    flex: 1;
    height: 28px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.age-progress-bar {
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 10px;
    padding-right: 10px;
    transition: width 0.8s ease;
    min-width: 50px;
}

.age-count {
    font-size: 11px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.age-percent {
    width: 45px;
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
    flex-shrink: 0;
}

/* ── Gender Distribution Chart ── */
.gender-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 16px;
}

.gender-circle {
    display: flex;
    justify-content: center;
}

.gender-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 0 20px;
}

.gender-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #334155;
}

.gender-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.gender-dot-male { background: #1f6392; }
.gender-dot-female { background: #42a5f5; }

.gender-count {
    font-weight: 600;
}

.gender-count-male { color: #1f6392; }
.gender-count-female { color: #42a5f5; }

/* ── Distribution Bar Chart Rows (Diagnosis/Age) ── */
.dist-chart-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
}

.dist-chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dist-chart-label {
    width: 90px;
    font-size: 12px;
    color: #334155;
    text-align: right;
    font-weight: 500;
    flex-shrink: 0;
}

.dist-chart-track {
    flex: 1;
    height: 28px;
    background: #f1f5f9;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.dist-chart-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 10px;
}

    .dist-chart-fill span {
        font-size: 11px;
        color: white;
        font-weight: 600;
        white-space: nowrap;
    }

.dist-chart-percent {
    width: 45px;
    font-size: 12px;
    color: #1e293b;
    text-align: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── SVG Chart Wrapper ── */
.svg-chart-wrapper {
    width: 100%;
    height: 320px;
    position: relative;
    direction: rtl;
}

    .svg-chart-wrapper svg {
        width: 100%;
        height: 100%;
    }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .charts-section {
        margin: 0 12px 12px 12px;
    }

    .chart-bars {
        height: 180px;
        min-width: 500px;
        gap: 6px;
    }

    .bar-item {
        min-height: 25px;
        min-width: 24px;
    }

    .bar-value { font-size: 10px; }
    .bar-label { font-size: 11px; }

    .age-label {
        width: 75px;
        font-size: 12px;
    }

    .age-progress {
        height: 26px;
    }
}

@media (max-width: 480px) {
    .charts-section {
        margin: 0 8px 8px 8px;
    }

    .chart-header-compact {
        padding: 6px 12px;
    }

    .chart-container {
        padding: 12px;
    }

    .chart-bars {
        height: 150px;
        min-width: 360px;
        gap: 4px;
    }

    .bar-item {
        min-height: 20px;
        min-width: 20px;
        border-radius: 4px 4px 2px 2px;
    }

    .bar-value { font-size: 9px; }
    .bar-label { font-size: 10px; }

    .age-label {
        width: 60px;
        font-size: 11px;
    }

    .age-progress {
        height: 22px;
    }

    .age-count {
        font-size: 10px;
    }
}
