/**
 * AutoParts Pro CEO Dashboard
 * Chart Styles
 * EDESSIS SRL - 2026
 */

/* ===== CHART CONTAINER ===== */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 160px;
    padding: var(--sp-4) 0;
}

.chart-container canvas {
    width: 100% !important;
    height: auto !important;
}

/* ===== CHART WRAPPER ===== */
.chart-wrapper {
    background: var(--sf2);
    border-radius: var(--radius-3xl);
    padding: var(--sp-6);
    border: 1px solid var(--gb);
    margin-bottom: var(--sp-5);
    transition: background var(--transition-smooth);
}

.chart-wrapper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-5);
}

.chart-wrapper-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    margin: 0;
}

.chart-wrapper-subtitle {
    font-size: var(--fs-sm);
    color: var(--t2);
    margin-top: var(--sp-1);
}

/* ===== CHART LEGEND ===== */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    justify-content: center;
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--gb);
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    color: var(--t2);
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.chart-legend-dot.primary { background: var(--chart-1); }
.chart-legend-dot.success { background: var(--chart-2); }
.chart-legend-dot.warning { background: var(--chart-3); }
.chart-legend-dot.danger { background: var(--chart-4); }
.chart-legend-dot.info { background: var(--chart-5); }
.chart-legend-dot.purple { background: var(--chart-6); }

/* ===== LINE CHART ===== */
.line-chart {
    position: relative;
}

.line-chart-grid {
    stroke: var(--gb);
    stroke-dasharray: 4 4;
}

.line-chart-axis {
    stroke: var(--t3);
    stroke-width: 1;
}

.line-chart-label {
    fill: var(--t3);
    font-size: 9px;
    font-family: var(--font-primary);
}

/* ===== BAR CHART ===== */
.bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 140px;
    gap: var(--sp-2);
    padding: var(--sp-2) 0;
}

.bar-chart-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
}

.bar-chart-bar {
    width: 100%;
    max-width: 32px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: var(--gradient-primary);
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.bar-chart-bar:hover {
    opacity: 0.85;
}

.bar-chart-bar::after {
    content: attr(data-value);
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--tx);
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.bar-chart-bar:hover::after {
    opacity: 1;
}

.bar-chart-label {
    font-size: var(--fs-xs);
    color: var(--t3);
    margin-top: var(--sp-2);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ===== PIE CHART ===== */
.pie-chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-6);
    flex-wrap: wrap;
}

.pie-chart {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.pie-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.pie-chart-center-value {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-extrabold);
    line-height: 1;
}

.pie-chart-center-label {
    font-size: var(--fs-xs);
    color: var(--t2);
}

.pie-chart-legend {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.pie-chart-legend-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.pie-chart-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.pie-chart-legend-text {
    flex: 1;
    font-size: var(--fs-sm);
    color: var(--t2);
}

.pie-chart-legend-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

/* ===== DONUT CHART ===== */
.donut-chart {
    position: relative;
    width: 140px;
    height: 140px;
}

.donut-chart svg {
    transform: rotate(-90deg);
}

.donut-chart-track {
    fill: none;
    stroke: var(--bg4);
    stroke-width: 12;
}

.donut-chart-progress {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.donut-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

/* ===== GAUGE CHART ===== */
.gauge-chart {
    position: relative;
    width: 160px;
    height: 90px;
    margin: 0 auto;
}

.gauge-chart svg {
    overflow: visible;
}

.gauge-chart-track {
    fill: none;
    stroke: var(--bg4);
    stroke-width: 14;
    stroke-linecap: round;
}

.gauge-chart-progress {
    fill: none;
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-chart-value {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.gauge-chart-value-number {
    font-size: var(--fs-4xl);
    font-weight: var(--fw-extrabold);
    line-height: 1;
}

.gauge-chart-value-label {
    font-size: var(--fs-xs);
    color: var(--t2);
}

.gauge-chart-min,
.gauge-chart-max {
    position: absolute;
    bottom: 5px;
    font-size: var(--fs-xs);
    color: var(--t3);
}

.gauge-chart-min { left: 0; }
.gauge-chart-max { right: 0; }

/* ===== SPARKLINE ===== */
.sparkline {
    display: inline-block;
    vertical-align: middle;
}

.sparkline-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sparkline-area {
    opacity: 0.15;
}

.sparkline-dot {
    r: 3;
}

/* ===== AREA CHART ===== */
.area-chart {
    position: relative;
    height: 160px;
}

.area-chart-gradient {
    opacity: 0.2;
}

/* ===== HORIZONTAL BAR ===== */
.h-bar-chart {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.h-bar-item {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.h-bar-label {
    width: 80px;
    font-size: var(--fs-sm);
    color: var(--t2);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.h-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg4);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.h-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.h-bar-value {
    width: 50px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    text-align: right;
    flex-shrink: 0;
}

/* ===== STACKED BAR ===== */
.stacked-bar {
    display: flex;
    height: 24px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.stacked-bar-segment {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.stacked-bar-segment:hover::after {
    content: attr(data-label) ': ' attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    color: var(--tx);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    white-space: nowrap;
    z-index: 10;
    margin-bottom: var(--sp-2);
    box-shadow: var(--card-sh);
}

/* ===== TREND INDICATOR ===== */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.trend-indicator-up {
    color: var(--ok);
}

.trend-indicator-down {
    color: var(--err);
}

.trend-indicator-neutral {
    color: var(--t3);
}

/* ===== MINI CHART ===== */
.mini-chart {
    width: 60px;
    height: 24px;
}

/* ===== COMPARISON CHART ===== */
.comparison-chart {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.comparison-chart-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.comparison-chart-bar.left {
    flex-direction: row-reverse;
}

.comparison-chart-fill {
    height: 18px;
    border-radius: var(--radius-sm);
    transition: width 0.6s ease;
}

.comparison-chart-value {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    min-width: 40px;
}

.comparison-chart-bar.left .comparison-chart-value {
    text-align: right;
}

.comparison-chart-divider {
    width: 2px;
    height: 30px;
    background: var(--gb);
    flex-shrink: 0;
}

/* ===== CHART TOOLTIP ===== */
.chart-tooltip {
    position: absolute;
    background: var(--bg);
    border: 1px solid var(--gb);
    border-radius: var(--radius-lg);
    padding: var(--sp-4) var(--sp-5);
    box-shadow: var(--card-sh);
    pointer-events: none;
    z-index: var(--z-tooltip);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.chart-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.chart-tooltip-title {
    font-size: var(--fs-sm);
    color: var(--t2);
    margin-bottom: var(--sp-2);
}

.chart-tooltip-value {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}

.chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
}

.chart-tooltip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* ===== CHART LOADING ===== */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.chart-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--bg4);
    border-top-color: var(--p);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== CHART EMPTY STATE ===== */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--t3);
}

.chart-empty i {
    font-size: 28px;
    margin-bottom: var(--sp-3);
}

.chart-empty p {
    font-size: var(--fs-sm);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .pie-chart-container {
        flex-direction: column;
    }
    
    .pie-chart-legend {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .bar-chart {
        height: 120px;
    }
    
    .bar-chart-bar {
        max-width: 24px;
    }
}