/* =========================================
   Charts — Pure CSS/Canvas charts
   ========================================= */

.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
}

canvas.chart-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Mini Sparkline */
.sparkline-container {
    width: 80px;
    height: 32px;
    position: relative;
}

.sparkline-container canvas {
    width: 100%;
    height: 100%;
}

/* Bar chart legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

/* Donut Chart */
.donut-wrapper {
    display: flex;
    align-items: center;
    gap: 24px;
}

.donut-chart {
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.donut-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}

.donut-legend-value {
    margin-left: auto;
    font-weight: 700;
    color: var(--text-primary);
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-slow);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2));
    border-radius: 3px;
}

/* Horizontal Bar */
.h-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.h-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.h-bar-label {
    width: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.h-bar-track {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.h-bar-fill {
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: white;
    transition: width 0.6s ease-out;
    min-width: fit-content;
}

.h-bar-value {
    font-size: 0.82rem;
    font-weight: 600;
    width: 70px;
    text-align: right;
    flex-shrink: 0;
}

/* Tooltip */
.chart-tooltip {
    position: absolute;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .chart-container {
        height: 200px;
    }

    .donut-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .donut-chart {
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }
}