/**
 * Scripts Chart CSS
 * Styles pour les visualisations : graphiques, podiums, légendes, etc.
 *
 * @package WP_Dix_Scripts
 */

/* ==========================================================================
   CONTAINER CHART
   ========================================================================== */

.dix-script[data-type="chart"] .dix-script__container,
.chart-container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    max-width: 1000px;
    margin: 0 auto;
}

/* ==========================================================================
   PODIUM / CLASSEMENT
   Utilisé pour : top aliments, top produits, rankings, etc.
   ========================================================================== */

.chart__podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 1rem 0;
}

.chart__podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
}

.chart__podium-item:hover {
    transform: translateY(-5px);
}

/* Icône/emoji au-dessus */
.chart__podium-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Nom de l'élément */
.chart__podium-name {
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 0.25rem;
    max-width: 90px;
    line-height: 1.2;
    color: var(--script-text);
}

/* Valeur */
.chart__podium-value {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--script-text-secondary);
}

/* Astuce/tip sous la valeur */
.chart__podium-tip {
    font-size: 0.7rem;
    color: var(--script-text-muted);
    text-align: center;
    max-width: 80px;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    font-style: italic;
}

/* Socle du podium */
.chart__podium-stand {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px 8px 0 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.9);
    position: relative;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

/* 1ère place - Or */
.chart__podium-item--1 .chart__podium-stand {
    height: 120px;
    background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
}

.chart__podium-item--1 .chart__podium-name {
    color: #ffd700;
}

.chart__podium-item--1 .chart__podium-value {
    color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
}

/* 2ème place - Argent */
.chart__podium-item--2 .chart__podium-stand {
    height: 90px;
    background: linear-gradient(180deg, #c0c0c0 0%, #808080 100%);
}

.chart__podium-item--2 .chart__podium-name {
    color: #c0c0c0;
}

.chart__podium-item--2 .chart__podium-value {
    color: #c0c0c0;
    background: rgba(192, 192, 192, 0.15);
}

/* 3ème place - Bronze */
.chart__podium-item--3 .chart__podium-stand {
    height: 60px;
    background: linear-gradient(180deg, #cd7f32 0%, #8b4513 100%);
}

.chart__podium-item--3 .chart__podium-name {
    color: #cd7f32;
}

.chart__podium-item--3 .chart__podium-value {
    color: #cd7f32;
    background: rgba(205, 127, 50, 0.15);
}

/* 4ème place et suivantes */
.chart__podium-item--4 .chart__podium-stand,
.chart__podium-item--other .chart__podium-stand {
    height: 30px;
    width: 70px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chart__podium-item--4 .chart__podium-icon,
.chart__podium-item--other .chart__podium-icon {
    font-size: 2rem;
}

.chart__podium-item--4 .chart__podium-name,
.chart__podium-item--other .chart__podium-name {
    color: var(--script-text-muted);
    font-size: 0.8rem;
    max-width: 70px;
}

.chart__podium-item--4 .chart__podium-value,
.chart__podium-item--other .chart__podium-value {
    color: var(--script-text-muted);
    font-size: 0.75rem;
}

/* ==========================================================================
   DONUT / PIE CHART SVG
   Utilisé pour : ratios, répartitions, comparaisons
   ========================================================================== */

.chart__donut {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.chart__donut svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.chart__donut-segment {
    fill: none;
    stroke-width: 40;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.chart__donut-segment:hover {
    filter: brightness(1.2);
}

/* Centre du donut */
.chart__donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
    background: var(--script-bg, rgba(30, 30, 40, 0.95));
    border-radius: 50%;
    text-align: center;
    pointer-events: none;
}

.chart__donut-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    transition: color 0.5s ease;
    color: var(--script-text);
}

.chart__donut-value.is-good {
    color: var(--script-result-optimal, #10b981);
}

.chart__donut-value.is-bad {
    color: var(--script-result-danger, #ef4444);
}

.chart__donut-label {
    font-size: 0.7rem;
    color: var(--script-text-muted);
    margin-top: 0.25rem;
}

/* ==========================================================================
   LÉGENDE
   Utilisé pour : tous les graphiques avec couleurs
   ========================================================================== */

.chart__legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.chart__legend--vertical {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.chart__legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--script-text-secondary);
}

.chart__legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.chart__legend-value {
    font-weight: 600;
    margin-left: 0.25rem;
    transition: all 0.5s ease;
}

/* Couleurs prédéfinies */
.chart__legend-color--primary { background: var(--script-color-primary, #1e3a8a); }
.chart__legend-color--optimal { background: var(--script-result-optimal, #10b981); }
.chart__legend-color--warning { background: var(--script-result-warning, #f59e0b); }
.chart__legend-color--danger { background: var(--script-result-danger, #ef4444); }
.chart__legend-color--good { background: var(--script-result-good, #3b82f6); }
.chart__legend-color--purple { background: #8b5cf6; }

/* ==========================================================================
   HISTOGRAMME / BARRES
   Utilisé pour : comparatifs, classements visuels
   ========================================================================== */

.chart__histogram {
    position: relative;
    padding: 1rem 1rem 1rem 3.5rem;
    min-height: 380px;
}

/* Axe Y */
.chart__y-axis {
    position: absolute;
    left: 0;
    top: 1rem;
    height: 300px;
    width: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 0.5rem;
}

.chart__y-tick {
    font-size: 0.75rem;
    color: var(--script-text-muted);
    position: relative;
}

.chart__y-tick::after {
    content: '';
    position: absolute;
    right: -0.75rem;
    top: 50%;
    width: 0.5rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.chart__y-label {
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: left center;
    font-size: 0.8rem;
    color: var(--script-text-secondary);
    white-space: nowrap;
}

/* Grille horizontale */
.chart__grid-lines {
    position: absolute;
    left: 3.5rem;
    right: 1rem;
    top: 1rem;
    height: 300px;
    pointer-events: none;
}

.chart__grid-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* Zone des barres */
.chart__bars-area {
    position: relative;
    height: 300px;
}

.chart__bars {
    display: flex;
    justify-content: space-around;
    height: 100%;
    position: relative;
}

/* Wrapper pour chaque barre */
.chart__bar-wrapper {
    position: relative;
    flex: 1;
    max-width: 80px;
    cursor: pointer;
    height: 100%;
    transition: transform 0.3s ease;
}

/* Emoji au-dessus de la barre */
.chart__bar-emoji {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    transition: transform 0.3s ease;
    z-index: 2;
}

.chart__bar-wrapper:hover .chart__bar-emoji {
    transform: translateX(-50%) scale(1.2) rotate(-5deg);
}

/* La barre elle-même */
.chart__bar {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    border-radius: 6px 6px 0 0;
    transition: all 0.4s ease;
    min-height: 4px;
}

.chart__bar-wrapper:hover .chart__bar {
    filter: brightness(1.2);
    box-shadow: 0 0 20px rgba(0, 115, 230, 0.4);
}

.chart__bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    border-radius: 6px 6px 0 0;
    pointer-events: none;
}

/* Labels sous les barres */
.chart__bar-labels {
    display: flex;
    justify-content: space-around;
    margin-top: 0.75rem;
}

.chart__bar-label {
    flex: 1;
    max-width: 80px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: var(--script-text-secondary);
    line-height: 1.3;
}

/* ==========================================================================
   TOOLTIP
   Utilisé pour : informations au survol
   ========================================================================== */

.chart__tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid var(--script-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--script-text);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    max-width: 220px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chart__tooltip.is-visible {
    opacity: 1;
}

.chart__tooltip-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--script-border);
}

.chart__tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.chart__tooltip-label {
    color: var(--script-text-secondary);
}

.chart__tooltip-value {
    font-weight: 700;
    color: var(--script-color-primary);
}

.chart__tooltip-sources {
    font-size: 0.75rem;
    color: var(--script-text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   ÉTAT BON/MAUVAIS
   Utilisé pour : comparaisons avant/après, good/bad
   ========================================================================== */

.chart__state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    transition: all 0.5s ease;
    width: fit-content;
    margin: 0 auto;
}

.chart__state--bad {
    color: var(--script-result-danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.chart__state--good {
    color: var(--script-result-optimal, #10b981);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.chart__state-icon {
    font-size: 1rem;
}

/* ==========================================================================
   FLOW / CONVERSION / ÉTAPES
   Utilisé pour : processus, conversions, étapes
   ========================================================================== */

.chart__flow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--script-radius-sm);
    border: 1px solid var(--script-border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chart__flow-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.chart__flow-arrow {
    color: var(--script-text-muted);
    font-size: 0.9rem;
}

.chart__flow-rate {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.25rem;
}

.chart__flow-rate--low {
    color: var(--script-result-danger, #ef4444);
    background: rgba(239, 68, 68, 0.15);
}

.chart__flow-rate--medium {
    color: var(--script-result-warning, #f59e0b);
    background: rgba(245, 158, 11, 0.15);
}

.chart__flow-rate--high {
    color: var(--script-result-optimal, #10b981);
    background: rgba(16, 185, 129, 0.15);
}

/* ==========================================================================
   CERCLES COLORÉS (CATÉGORIES/TYPES)
   Utilisé pour : types, catégories, étapes
   ========================================================================== */

.chart__circles {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.chart__circle-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 140px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chart__circle-item:hover {
    transform: translateY(-5px);
}

.chart__circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.chart__circle-item:hover .chart__circle {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

/* Tailles */
.chart__circle--sm {
    width: 70px;
    height: 70px;
}

.chart__circle--lg {
    width: 120px;
    height: 120px;
}

/* Couleurs */
.chart__circle--primary {
    background: linear-gradient(135deg, var(--script-color-primary) 0%, var(--script-color-primary-hover) 100%);
    border-color: rgba(30, 58, 138, 0.5);
}

.chart__circle--optimal {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: rgba(16, 185, 129, 0.5);
}

.chart__circle--good {
    background: linear-gradient(135deg, #0073e6 0%, #0056b3 100%);
    border-color: rgba(0, 115, 230, 0.5);
}

.chart__circle--purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    border-color: rgba(139, 92, 246, 0.5);
}

.chart__circle--warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-color: rgba(245, 158, 11, 0.5);
}

.chart__circle--danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: rgba(239, 68, 68, 0.5);
}

/* Contenu du cercle */
.chart__circle-acronym {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.chart__circle-emoji {
    font-size: 1.2rem;
    margin-top: 0.25rem;
}

/* Labels sous le cercle */
.chart__circle-name {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    margin-top: 0.75rem;
    color: var(--script-text);
    line-height: 1.3;
}

.chart__circle-source {
    font-size: 0.7rem;
    color: var(--script-text-muted);
    text-align: center;
    margin-top: 0.25rem;
    font-style: italic;
}

/* ==========================================================================
   BOUTONS DE TRI / FILTRES
   ========================================================================== */

.chart__sort-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.chart__sort-label {
    font-size: 0.9rem;
    color: var(--script-text-secondary);
}

.chart__sort-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chart__sort-btn {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--script-border);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--script-text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.chart__sort-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.chart__sort-btn.is-active {
    background: var(--script-color-primary);
    border-color: var(--script-color-primary);
    color: white;
}

/* ==========================================================================
   NOTE / MESSAGE SCALE
   ========================================================================== */

.chart__scale-note {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 115, 230, 0.1);
    border-radius: var(--script-radius-sm);
    font-size: 0.85rem;
    color: var(--script-text-secondary);
    text-align: center;
}

/* ==========================================================================
   MODE CLAIR (Light mode)
   ========================================================================== */

[data-theme="light"] .chart__donut-center {
    background: var(--script-bg, #ffffff);
}

[data-theme="light"] .chart__tooltip {
    background: rgba(255, 255, 255, 0.98);
    border-color: var(--script-border);
}

[data-theme="light"] .chart__y-tick::after {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .chart__grid-line {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chart__flow {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .chart__scale-note {
    background: rgba(0, 115, 230, 0.06);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    /* Podium */
    .chart__podium {
        gap: 0.25rem;
    }

    .chart__podium-stand {
        width: 65px;
    }

    .chart__podium-item--4 .chart__podium-stand,
    .chart__podium-item--other .chart__podium-stand {
        width: 60px;
    }

    .chart__podium-icon {
        font-size: 2rem;
    }

    .chart__podium-item--4 .chart__podium-icon,
    .chart__podium-item--other .chart__podium-icon {
        font-size: 1.5rem;
    }

    .chart__podium-name {
        font-size: 0.75rem;
        max-width: 65px;
    }

    .chart__podium-value {
        font-size: 0.7rem;
    }

    .chart__podium-tip {
        font-size: 0.6rem;
        max-width: 60px;
    }

    .chart__podium-item--1 .chart__podium-stand { height: 100px; }
    .chart__podium-item--2 .chart__podium-stand { height: 75px; }
    .chart__podium-item--3 .chart__podium-stand { height: 50px; }
    .chart__podium-item--4 .chart__podium-stand { height: 25px; }

    /* Donut */
    .chart__donut {
        width: 180px;
        height: 180px;
    }

    .chart__donut-center {
        width: 90px;
        height: 90px;
    }

    .chart__donut-value {
        font-size: 1.5rem;
    }

    /* Legend */
    .chart__legend {
        gap: 1.5rem;
    }

    .chart__legend-item {
        font-size: 0.8rem;
    }

    /* Histogramme */
    .chart__histogram {
        padding: 1rem 0.5rem 1rem 2.5rem;
        min-height: 320px;
        overflow-x: auto;
    }

    .chart__y-axis {
        width: 2rem;
        height: 250px;
    }

    .chart__grid-lines {
        height: 250px;
    }

    .chart__bars-area {
        min-width: 500px;
        height: 250px;
    }

    .chart__bar {
        width: 40px;
    }

    .chart__bar-emoji {
        font-size: 1.2rem;
    }

    .chart__bar-label {
        font-size: 0.65rem;
        max-width: 55px;
    }

    /* Cercles */
    .chart__circles {
        gap: 1rem;
    }

    .chart__circle-item {
        max-width: 100px;
    }

    .chart__circle {
        width: 80px;
        height: 80px;
    }

    .chart__circle-acronym {
        font-size: 1.2rem;
    }

    .chart__circle-emoji {
        font-size: 1rem;
    }

    .chart__circle-name {
        font-size: 0.65rem;
    }

    .chart__circle-source {
        font-size: 0.6rem;
    }

    /* Flow */
    .chart__flow {
        font-size: 0.75rem;
    }

    .chart__flow-item {
        font-size: 0.75rem;
    }

    /* Sort */
    .chart__sort-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .chart__tooltip {
        max-width: 180px;
        font-size: 0.75rem;
    }

    .chart__circle {
        width: 70px;
        height: 70px;
    }

    .chart__circle-acronym {
        font-size: 1rem;
    }
}
