/*
 * Global Chart Styles - Theme-Aware
 * Unified hover effects and animations for ECharts
 * Version: 1.0
 * Date: 2025-11-21
 */

/* ===== CHART CONTAINER BASE STYLES ===== */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
    background: var(--color-surface);
    border-radius: 0.75rem;
    border: 1px solid var(--color-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.chart-container-sm {
    min-height: 200px;
}

.chart-container-lg {
    min-height: 400px;
}

.chart-container-xl {
    min-height: 500px;
}

/* ===== HOVER EFFECTS ===== */
.chart-container:hover {
    box-shadow: 0 8px 25px rgba(0, 122, 255, 0.12);
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

[data-theme="dark"] .chart-container:hover {
    box-shadow: 0 8px 25px rgba(10, 132, 255, 0.2);
}

/* Subtle hover - less dramatic */
.chart-container-subtle:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ===== CHART HEADER ===== */
.chart-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background-secondary);
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.chart-subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
}

/* ===== CHART BODY ===== */
.chart-body {
    padding: 1rem;
    position: relative;
}

.chart-body-flush {
    padding: 0;
}

/* ===== CHART INNER (ECharts target) ===== */
.chart-inner {
    width: 100%;
    height: 100%;
    min-height: inherit;
}

/* ===== LOADING STATE ===== */
.chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    z-index: 10;
}

.chart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: chart-spin 0.8s linear infinite;
}

@keyframes chart-spin {
    to { transform: rotate(360deg); }
}

/* ===== EMPTY STATE ===== */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--color-text-tertiary);
    text-align: center;
    padding: 2rem;
}

.chart-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chart-empty-text {
    font-size: 0.875rem;
}

/* ===== ERROR STATE ===== */
.chart-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--color-error);
    text-align: center;
    padding: 2rem;
    background: var(--bg-error-light);
    border-radius: 0.5rem;
    margin: 1rem;
}

/* ===== CHART FOOTER / LEGEND ===== */
.chart-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-background-secondary);
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
}

/* ===== CHART GRID LAYOUT ===== */
.charts-grid {
    display: grid;
    gap: 1.5rem;
}

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

.charts-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.charts-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .charts-grid-3,
    .charts-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .charts-grid-2,
    .charts-grid-3,
    .charts-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ===== CHART CARD VARIANT ===== */
.chart-card {
    background: var(--color-surface);
    border-radius: 0.75rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s ease;
}

.chart-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

/* ===== TOOLTIP CUSTOM STYLES ===== */
.chart-tooltip {
    background: var(--color-surface-elevated) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 0.5rem !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0.75rem !important;
}

[data-theme="dark"] .chart-tooltip {
    background: var(--color-surface-elevated) !important;
    color: var(--color-text-primary) !important;
}

/* ===== ANIMATION UTILITIES ===== */
.chart-fade-in {
    animation: chartFadeIn 0.4s ease-out;
}

@keyframes chartFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-scale-in {
    animation: chartScaleIn 0.3s ease-out;
}

@keyframes chartScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
