/**
 * DIESELNET - Interactive Charts Library
 * Chart.js integration pentru dashboard-uri și analytics
 */

/* ============================================ */
/* CHART CONTAINER STYLES                      */
/* ============================================ */

.chart-container {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f1f5f9;
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    color: #06b6d4;
}

.chart-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    margin-top: 4px;
}

.chart-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chart-period-selector {
    display: flex;
    gap: 5px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
}

.chart-period-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-period-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
}

.chart-period-btn.active {
    background: white;
    color: #06b6d4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-canvas-wrapper {
    position: relative;
    height: 300px;
    margin-top: 20px;
}

.chart-canvas-wrapper.large {
    height: 400px;
}

.chart-canvas-wrapper.small {
    height: 200px;
}

/* Chart Legend Custom */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #64748b;
}

.chart-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.chart-legend-value {
    font-weight: 700;
    color: #0f172a;
    margin-left: 4px;
}

/* Chart Stats Grid */
.chart-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.chart-stat-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.chart-stat-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.chart-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
}

.chart-stat-change {
    font-size: 0.85rem;
    margin-top: 4px;
    font-weight: 600;
}

.chart-stat-change.positive {
    color: #10b981;
}

.chart-stat-change.negative {
    color: #ef4444;
}

/* Loading State */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #94a3b8;
}

.chart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f1f5f9;
    border-top-color: #06b6d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chart-loading-text {
    margin-top: 16px;
    font-size: 0.9rem;
}

/* Empty State */
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #94a3b8;
}

.chart-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chart-empty-text {
    font-size: 1rem;
    font-weight: 600;
}

/* Tooltip Custom */
.chartjs-tooltip {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 12px 16px;
    color: white;
    font-size: 0.85rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.chartjs-tooltip-title {
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.chartjs-tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Chart Grid Layout */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.charts-grid.single-column {
    grid-template-columns: 1fr;
}

.charts-grid.two-columns {
    grid-template-columns: repeat(2, 1fr);
}

/* Dark Mode Support */
body.dark-mode .chart-container {
    background: #1e293b;
}

body.dark-mode .chart-header {
    border-bottom-color: #334155;
}

body.dark-mode .chart-title {
    color: #f1f5f9;
}

body.dark-mode .chart-period-selector {
    background: #0f172a;
}

body.dark-mode .chart-period-btn {
    color: #cbd5e1;
}

body.dark-mode .chart-period-btn.active {
    background: #334155;
    color: #06b6d4;
}

body.dark-mode .chart-stat-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

body.dark-mode .chart-stat-value {
    color: #f1f5f9;
}

body.dark-mode .chart-legend {
    border-top-color: #334155;
}

body.dark-mode .chart-legend-value {
    color: #f1f5f9;
}

/* Responsive */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .chart-controls {
        width: 100%;
    }

    .chart-period-selector {
        width: 100%;
        justify-content: space-between;
    }

    .chart-canvas-wrapper {
        height: 250px;
    }

    .chart-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print Styles */
@media print {
    .chart-controls {
        display: none;
    }

    .chart-container {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
}

/* ============================================ */
/* SPECIFIC CHART TYPES                        */
/* ============================================ */

/* Revenue Chart */
.revenue-chart-container {
    background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
    border: 2px solid #5eead4;
}

.revenue-chart-container .chart-title {
    color: #0891b2;
}

/* Appointments Chart */
.appointments-chart-container {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #fbbf24;
}

.appointments-chart-container .chart-title {
    color: #d97706;
}

/* Performance Chart */
.performance-chart-container {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    border: 2px solid #a78bfa;
}

.performance-chart-container .chart-title {
    color: #7c3aed;
}

/* Comparison Chart */
.comparison-chart-container {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #fca5a5;
}

.comparison-chart-container .chart-title {
    color: #dc2626;
}