/* ── Charts: Bar, Pie, Sparkline ── */

/* Bar Chart */
.bar-chart {
    display: inline-block;
}

.bar-chart-svg {
    overflow: visible;
}

.bar-chart-grid {
    stroke: var(--chart-grid, #e5e7eb);
    stroke-width: 1;
}

.bar-chart-y-label {
    font-size: 11px;
    text-anchor: end;
    fill: var(--chart-label, #6b7280);
    dominant-baseline: middle;
}

.bar-chart-x-label {
    font-size: 11px;
    text-anchor: middle;
    fill: var(--chart-label, #6b7280);
}

.bar-chart-val {
    font-size: 11px;
    text-anchor: middle;
    fill: #fff;
    font-weight: 600;
}

.bar-chart-bar {
    transition: opacity 0.15s;
    cursor: pointer;
}

.bar-chart-bar:hover {
    opacity: 0.8;
}

/* Pie / Donut Chart */
.pie-chart {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pie-chart-svg {
    overflow: visible;
}

.pie-chart-slice {
    transition: opacity 0.15s, transform 0.15s;
    cursor: pointer;
    transform-origin: center;
}

.pie-chart-slice:hover {
    opacity: 0.85;
}

.pie-chart-label {
    font-size: 12px;
    text-anchor: middle;
    fill: #fff;
    font-weight: 600;
    pointer-events: none;
    dominant-baseline: middle;
}

.pie-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.pie-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--chart-label, #6b7280);
}

.pie-chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pie-chart-legend-value {
    font-weight: 600;
    color: var(--chart-text, #111827);
}

/* Sparkline */
.sparkline {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.sparkline-svg {
    overflow: visible;
}

/* ── Area Chart ── */
.jsgui-area-chart {
    display: inline-block;
}

.area-chart-svg {
    overflow: visible;
}

.area-chart-fill {
    transition: opacity 0.2s;
}

.area-chart-line {
    transition: stroke-width 0.2s;
}

.area-chart-dots circle {
    transition: r 0.15s;
}

.area-chart-dots circle:hover {
    r: 5;
}

/* ── Gauge ── */
.jsgui-gauge {
    display: inline-block;
}

.gauge-svg {
    overflow: visible;
}

.gauge-track {
    opacity: 0.3;
}

.gauge-fill {
    transition: stroke-dashoffset 0.6s ease-out;
}

.gauge-value {
    font-variant-numeric: tabular-nums;
}

/* ── Theme Variables ── */
@layer components {

    .bar-chart,
    .pie-chart,
    .sparkline,
    .jsgui-area-chart,
    .jsgui-gauge {
        --chart-grid: #e5e7eb;
        --chart-label: #6b7280;
        --chart-text: #111827;
    }

    :is(.jsgui-dark-mode, [data-theme="dark"]) .bar-chart,
    :is(.jsgui-dark-mode, [data-theme="dark"]) .pie-chart,
    :is(.jsgui-dark-mode, [data-theme="dark"]) .sparkline,
    :is(.jsgui-dark-mode, [data-theme="dark"]) .jsgui-area-chart,
    :is(.jsgui-dark-mode, [data-theme="dark"]) .jsgui-gauge {
        --chart-grid: #374151;
        --chart-label: #9ca3af;
        --chart-text: #f9fafb;
    }
}