/* ================================
   CHARTS SECTION - Modern Data Visualization
   Designer #1's Analytics Suite - Phase 2
   ================================ */

/* ================================
   CHARTS CONTAINER - Grid Layout
   ================================ */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}

/* Mobile: Stack charts vertically */
@media (max-width: 768px) {
    .charts-section {
        grid-template-columns: 1fr; /* \u05e2\u05de\u05d5\u05d3\u05d4 \u05d0\u05d7\u05ea */
        gap: var(--space-4);
    }
}

/* ================================
   CHART CARD - Glass Container
   ================================ */
.chart-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    position: relative;
}

.chart-container:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

/* Mobile: Reduce padding */
@media (max-width: 768px) {
    .chart-container {
        padding: var(--space-4); /* \u05d4\u05e7\u05d8\u05e0\u05d4 \u05de-var(--space-8) */
    }
    
    .chart-container h3 {
        font-size: var(--font-size-base); /* \u05d9\u05d5\u05ea\u05e8 \u05e7\u05d8\u05df */
    }
    
    .chart-type-btn {
        padding: var(--space-1) var(--space-2); /* \u05d9\u05d5\u05ea\u05e8 \u05e7\u05d8\u05df */
        font-size: var(--font-size-xs);
    }
}

/* Chart Header */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.chart-container h3 {
    font-size: var(--font-size-xl);
    color: #111827 !important;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.chart-container h3 i {
    background: var(--bg-gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ================================
   CHART TYPE TOGGLE - Pie/Bar/Line
   ================================ */
.chart-type-toggle {
    display: flex;
    gap: var(--space-2);
    background: var(--color-neutral-100);
    padding: var(--space-1);
    border-radius: var(--radius-md);
}

.chart-type-btn {
    padding: var(--space-2) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Heebo', sans-serif;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    background: transparent;
    color: #1f2937; /* הסרנו !important */
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.chart-type-btn.active {
    background: white;
    color: var(--color-warning-600) !important; /* 🧡 כתום! */
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--color-warning-200); /* גבול כתום */
}

.chart-type-btn.active i {
    color: var(--color-warning-500); /* אייקון כתום */
}

.chart-type-btn:hover:not(.active) {
    color: #111827 !important;
    background: rgba(255, 255, 255, 0.5);
}

.chart-type-btn i {
    font-size: var(--font-size-base);
}

/* ================================
   CANVAS CONTAINER - Responsive
   ================================ */
.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 400px;
    margin-top: var(--space-4);
}

canvas {
    max-width: 100%;
    height: auto !important;
}

/* ================================
   CHART LEGEND - Custom Styling
   ================================ */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 2px solid var(--color-neutral-200);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-base);
    cursor: pointer;
}

.legend-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.legend-label {
    font-size: var(--font-size-sm);
    color: #1f2937 !important;
    font-weight: var(--font-weight-semibold);
}

.legend-value {
    font-size: var(--font-size-sm);
    color: #111827 !important;
    font-weight: var(--font-weight-bold);
    margin-right: var(--space-2);
}

/* ================================
   CHART INSIGHTS - Data Summary
   ================================ */
.chart-insights {
    margin-top: var(--space-6);
    padding: var(--space-5);
    background: var(--color-primary-50);
    border-radius: var(--radius-lg);
    border-right: 4px solid var(--color-primary-500);
}

.chart-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-4);
}

.insight-stat {
    text-align: center;
}

.insight-stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary-700);
    margin-bottom: var(--space-1);
}

.insight-stat-label {
    font-size: var(--font-size-xs);
    color: #1f2937 !important;
    font-weight: var(--font-weight-semibold);
}

/* ================================
   EMPTY CHART STATE
   ================================ */
.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--color-neutral-400);
}

.chart-empty-state i {
    font-size: var(--font-size-5xl);
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.chart-empty-state p {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: #374151 !important;
}

/* ================================
   LOADING STATE - Skeleton
   ================================ */
.chart-loading {
    height: 400px;
    background: linear-gradient(
        90deg,
        var(--color-neutral-100) 25%,
        var(--color-neutral-200) 50%,
        var(--color-neutral-100) 75%
    );
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    border-radius: var(--radius-lg);
}

@keyframes loading-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ================================
   CHART TOOLTIPS - Custom Style
   ================================ */
.chartjs-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md) !important;
    padding: var(--space-3) var(--space-4) !important;
    font-family: 'Heebo', sans-serif !important;
    font-size: var(--font-size-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

/* ================================
   EXPORT CHART BUTTON
   ================================ */
.chart-export-btn {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    padding: var(--space-2) var(--space-3);
    background: white;
    border: 2px solid var(--color-neutral-200);
    border-radius: var(--radius-md);
    color: var(--color-neutral-600);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    opacity: 0;
}

.chart-container:hover .chart-export-btn {
    opacity: 1;
}

.chart-export-btn:hover {
    background: var(--color-primary-500);
    color: white;
    border-color: var(--color-primary-500);
    transform: translateY(-2px);
}

/* ================================
   RESPONSIVE - Mobile Optimization
   ================================ */
@media (max-width: 768px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        padding: var(--space-5);
    }
    
    .chart-canvas-wrapper {
        height: 300px;
    }
    
    .chart-type-toggle {
        width: 100%;
        justify-content: space-between;
    }
    
    .chart-type-btn {
        flex: 1;
        justify-content: center;
    }
    
    .chart-legend {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .legend-item {
        justify-content: space-between;
    }
    
    .chart-export-btn {
        opacity: 1;
        position: static;
        width: 100%;
        margin-bottom: var(--space-4);
    }
}

/* ================================
   CHART ANIMATIONS - Entrance
   ================================ */
@keyframes chart-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chart-container {
    animation: chart-fade-in 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-container:nth-child(1) {
    animation-delay: 0.1s;
}

.chart-container:nth-child(2) {
    animation-delay: 0.2s;
}

/* ================================
   COMPARISON MODE - Side by Side
   ================================ */
.charts-comparison {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.comparison-chart {
    background: white;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.comparison-label {
    font-size: var(--font-size-sm);
    color: var(--color-neutral-600);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-3);
    text-align: center;
}

/* ================================
   ACCESSIBILITY
   ================================ */
.chart-type-btn:focus-visible {
    outline: 3px solid var(--color-accent-500);
    outline-offset: 2px;
}

.chart-export-btn:focus-visible {
    outline: 3px solid var(--color-primary-500);
    outline-offset: 2px;
}
