/**
 * Styles pour les graphiques Chart.js
 */

/* Conteneur de graphique */
.chart-container {
    position: relative;
    width: 100%;
    margin: 1.5rem 0;
}

/* Canvas responsive */
.chart-canvas {
    max-width: 100%;
    height: auto;
}

/* Carte avec graphique */
.chart-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.chart-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.chart-card-subtitle {
    font-size: 0.875rem;
    color: #7f8c8d;
    margin: 0.25rem 0 0 0;
}

.chart-card-actions {
    display: flex;
    gap: 0.5rem;
}

.chart-card-body {
    position: relative;
    min-height: 300px;
}

/* Wrapper pour graphique avec hauteur fixe */
.chart-wrapper {
    position: relative;
    height: 300px;
    margin: 0 auto;
}

.chart-wrapper.large {
    height: 400px;
}

.chart-wrapper.small {
    height: 200px;
}

/* Boutons de contrôle des graphiques */
.chart-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.chart-control-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-control-btn:hover {
    background: #f8f9fa;
    border-color: #0066cc;
    color: #0066cc;
}

.chart-control-btn.active {
    background: #0066cc;
    border-color: #0066cc;
    color: white;
}

.chart-control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Message d'état */
.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #7f8c8d;
    text-align: center;
}

.chart-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chart-empty-state p {
    margin: 0;
    font-size: 1rem;
}

/* Légende personnalisée */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #495057;
}

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

/* Grille de graphiques */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

/* Stats rapides au-dessus des graphiques */
.chart-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.chart-stat-item {
    text-align: center;
}

.chart-stat-label {
    font-size: 0.75rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.chart-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.chart-stat-value.positive {
    color: #27ae60;
}

.chart-stat-value.negative {
    color: #e74c3c;
}

/* Loader pour graphiques */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.chart-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: chart-spin 1s linear infinite;
}

.chart-loading-text {
    margin-top: 1rem;
    color: #7f8c8d;
    font-size: 0.875rem;
}

@keyframes chart-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-card {
        padding: 1rem;
    }

    .chart-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .chart-card-title {
        font-size: 1.125rem;
    }

    .chart-wrapper {
        height: 250px;
    }

    .chart-wrapper.large {
        height: 300px;
    }

    .chart-controls {
        width: 100%;
    }

    .chart-control-btn {
        flex: 1;
        min-width: 80px;
    }

    .chart-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .chart-stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .chart-stat-label {
        text-align: left;
        margin-bottom: 0;
    }

    .chart-legend {
        justify-content: center;
    }
}

/* Mode sombre (préparation) */
@media (prefers-color-scheme: dark) {
    .chart-card {
        background: #2c3e50;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .chart-card-title {
        color: #ecf0f1;
    }

    .chart-card-subtitle {
        color: #95a5a6;
    }

    .chart-control-btn {
        background: #34495e;
        border-color: #4a5f7f;
        color: #ecf0f1;
    }

    .chart-control-btn:hover {
        background: #4a5f7f;
    }

    .chart-control-btn.active {
        background: #0066cc;
        border-color: #0066cc;
    }

    .chart-stats {
        background: #34495e;
    }

    .chart-stat-value {
        color: #ecf0f1;
    }

    .chart-empty-state {
        color: #95a5a6;
    }

    .chart-legend-item {
        color: #ecf0f1;
    }
}

/* Animations d'entrée */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-card.animate-in {
    animation: fadeInUp 0.4s ease-out;
}

/* Export/Print */
@media print {
    .chart-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .chart-controls,
    .chart-card-actions {
        display: none;
    }
}
