/**
 * PHASE 6B : DATA VISUALIZATION - STYLES CSS
 * Le Bulletin Économique
 * Fichier: assets/css/charts.css
 * 
 * Styles pour graphiques économiques interactifs
 */

/* =============================================================================
   1. CONTENEUR PRINCIPAL DU GRAPHIQUE
   ============================================================================= */

.be-chart-wrapper {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin: 30px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.be-chart-wrapper:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}


/* =============================================================================
   2. EN-TÊTE DU GRAPHIQUE
   ============================================================================= */

.be-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f5f9;
}

.be-chart-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-primary, #0f172a);
    margin: 0;
    font-family: var(--font-heading, 'Inter', sans-serif);
}

.be-chart-controls {
    display: flex;
    gap: 10px;
}

.be-chart-export-png,
.be-chart-export-csv {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main, #334155);
    cursor: pointer;
    transition: all 0.2s ease;
}

.be-chart-export-png:hover,
.be-chart-export-csv:hover {
    background: var(--color-accent, #3b82f6);
    color: #ffffff;
    border-color: var(--color-accent, #3b82f6);
    transform: translateY(-2px);
}

.be-chart-export-png:active,
.be-chart-export-csv:active {
    transform: translateY(0);
}


/* =============================================================================
   3. CONTENEUR DU CANVAS
   ============================================================================= */

.be-chart-container {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

.be-chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

/* Loading state */
.be-chart-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--color-accent, #3b82f6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* =============================================================================
   4. PIED DU GRAPHIQUE (SOURCE)
   ============================================================================= */

.be-chart-footer {
    padding-top: 15px;
    border-top: 1px solid #f1f5f9;
}

.be-chart-source {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    font-style: italic;
}

.be-chart-source::before {
    content: '📊 ';
}


/* =============================================================================
   5. LÉGENDE PERSONNALISÉE (SI CHART.JS PAR DÉFAUT DÉSACTIVÉE)
   ============================================================================= */

.be-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.be-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text-main, #334155);
}

.be-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}


/* =============================================================================
   6. TOOLTIP PERSONNALISÉ CHART.JS
   ============================================================================= */

#chartjs-tooltip {
    opacity: 1;
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    border-radius: 8px;
    padding: 12px 16px;
    pointer-events: none;
    transform: translate(-50%, -110%);
    transition: all 0.1s ease;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
}

#chartjs-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.95);
}

.tooltip-title {
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tooltip-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}


/* =============================================================================
   7. COMPARATEUR MULTI-PAYS
   ============================================================================= */

.be-chart-wrapper.is-comparison {
    border-left: 4px solid var(--color-accent, #3b82f6);
}

.be-chart-wrapper.is-comparison .be-chart-title::before {
    content: '📊 ';
    opacity: 0.7;
}


/* =============================================================================
   8. ÉTATS DU GRAPHIQUE
   ============================================================================= */

/* État : Erreur */
.be-chart-error {
    text-align: center;
    padding: 60px 20px;
    color: #ef4444;
}

.be-chart-error svg {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* État : Aucune donnée */
.be-chart-no-data {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.be-chart-no-data svg {
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}


/* =============================================================================
   9. RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .be-chart-wrapper {
        padding: 16px;
        margin: 20px 0;
    }
    
    .be-chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .be-chart-title {
        font-size: 18px;
    }
    
    .be-chart-controls {
        width: 100%;
    }
    
    .be-chart-export-png,
    .be-chart-export-csv {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .be-chart-wrapper {
        padding: 12px;
        border-radius: 8px;
    }
    
    .be-chart-title {
        font-size: 16px;
    }
    
    .be-chart-export-png,
    .be-chart-export-csv {
        font-size: 12px;
        padding: 6px 12px;
    }
}


/* =============================================================================
   10. DARK MODE
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    .be-chart-wrapper {
        background: #1e293b;
        border-color: #334155;
    }
    
    .be-chart-title {
        color: #f1f5f9;
    }
    
    .be-chart-header {
        border-bottom-color: #334155;
    }
    
    .be-chart-export-png,
    .be-chart-export-csv {
        background: #334155;
        border-color: #475569;
        color: #e2e8f0;
    }
    
    .be-chart-export-png:hover,
    .be-chart-export-csv:hover {
        background: var(--color-accent, #3b82f6);
        color: #ffffff;
    }
    
    .be-chart-footer {
        border-top-color: #334155;
    }
    
    .be-chart-source {
        color: #94a3b8;
    }
}


/* =============================================================================
   11. PRINT STYLES
   ============================================================================= */

@media print {
    .be-chart-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .be-chart-controls {
        display: none !important;
    }
    
    .be-chart-container {
        page-break-inside: avoid;
    }
}


/* =============================================================================
   12. ANIMATIONS
   ============================================================================= */

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

.be-chart-wrapper {
    animation: fadeInChart 0.5s ease-out;
}


/* =============================================================================
   13. STYLES POUR PAGE ARCHIVE DES DONNÉES
   ============================================================================= */

.data-archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin: 40px 0;
}

.data-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.data-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.data-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary, #0f172a);
    margin-bottom: 10px;
}

.data-card-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 15px;
}

.data-card-preview {
    height: 120px;
    background: #f8fafc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.data-card-actions {
    display: flex;
    gap: 10px;
}

.data-card-btn {
    flex: 1;
    padding: 8px;
    text-align: center;
    background: var(--color-accent, #3b82f6);
    color: #ffffff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.data-card-btn:hover {
    background: var(--color-primary, #0f172a);
    transform: translateY(-2px);
}


/* =============================================================================
   14. BADGES & TAGS
   ============================================================================= */

.data-category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-accent, #3b82f6);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-country-tag {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}