/* ═══════════════════════════════════════════════════════════════
   VALUES MODULE V5.3 - CSS Namespace val-*
   Styles isolés pour l'onglet Valeurs + Chart.js
   ═══════════════════════════════════════════════════════════════ */

/* Variables CSS pour les couleurs */
:root {
    --val-positive: #28a745;
    --val-negative: #dc3545;
}

/* ───────────────────────────────────────────────────────────────
   HEADER
   ─────────────────────────────────────────────────────────────── */
.val-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.val-title h4 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: #fff;
}

.val-subtitle {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

.val-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.val-actions .btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

/* ───────────────────────────────────────────────────────────────
   GRAND TOTAL
   ─────────────────────────────────────────────────────────────── */
.val-grand-total {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.val-total-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.val-total-content {
    flex: 1;
}

.val-total-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.val-total-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    background: linear-gradient(90deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.val-total-breakdown {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.5rem;
}

.val-total-plusvalue {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.val-plusvalue {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.val-plusvalue.val-positive {
    color: #28a745;
    background: rgba(40, 167, 69, 0.15);
}

.val-plusvalue.val-negative {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.15);
}

/* Badges de comparaison 24h/7j/30j */
.val-comparison-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.val-comparison-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.val-comparison-badge.val-positive {
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
}

.val-comparison-badge.val-negative {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

/* ───────────────────────────────────────────────────────────────
   SECTION ÉVOLUTION DE LA VALEUR (Chart.js)
   ─────────────────────────────────────────────────────────────── */
.val-evolution-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.val-evolution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.val-evolution-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.val-period-select {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23ffffff80' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: all 0.2s ease;
}

.val-period-select:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.val-period-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.val-period-select option {
    background: #1e1e28;
    color: #fff;
}

/* KPIs Row */
.val-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.val-kpi {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.val-kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.val-kpi-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 0.25rem;
}

/* Chart Container */
.val-chart-container {
    height: 200px;
    position: relative;
}

.val-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.val-no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    font-size: 0.9rem;
}

/* ───────────────────────────────────────────────────────────────
   TOP MOVERS (gainers/losers)
   ─────────────────────────────────────────────────────────────── */
.val-top-movers {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.val-movers-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 0.75rem;
}

.val-movers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.val-movers-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.val-movers-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.val-movers-label.val-positive {
    color: #28a745;
}

.val-movers-label.val-negative {
    color: #dc3545;
}

.val-mover-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.val-mover-name {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.val-mover-change {
    font-size: 0.8rem;
    font-weight: 600;
}

.val-mover-change.val-positive {
    color: #28a745;
}

.val-mover-change.val-negative {
    color: #dc3545;
}

/* ───────────────────────────────────────────────────────────────
   SECTIONS (Catégories)
   ─────────────────────────────────────────────────────────────── */
.val-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.val-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease;
}

.val-section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.val-title-block h5 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.val-section-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.val-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.val-section-total {
    font-size: 1.25rem;
    font-weight: 600;
    color: #667eea;
}

.val-chevron {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.3s ease;
}

.val-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.val-section.val-collapsed .val-content {
    max-height: 0;
}

/* ───────────────────────────────────────────────────────────────
   FILTRE PAR SÉRIE
   ─────────────────────────────────────────────────────────────── */
.val-filter-container {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
}

.val-filter-select {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23ffffff80' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: all 0.2s ease;
}

.val-filter-select:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.val-filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.val-filter-select.val-filtered {
    border-color: #667eea;
    background-color: rgba(102, 126, 234, 0.15);
}

.val-filter-select option {
    background: #1e1e28;
    color: #fff;
    padding: 0.5rem;
}

/* ───────────────────────────────────────────────────────────────
   LISTE D'ITEMS
   ─────────────────────────────────────────────────────────────── */
.val-items-list {
    padding: 0.5rem 0;
}

.val-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.val-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.val-item:last-child {
    border-bottom: none;
}

/* Ranks */
.val-item.val-rank-1 {
    background: rgba(255, 215, 0, 0.05);
}

.val-item.val-rank-2 {
    background: rgba(192, 192, 192, 0.05);
}

.val-item.val-rank-3 {
    background: rgba(205, 127, 50, 0.05);
}

.val-rank {
    font-size: 1.1rem;
    min-width: 2rem;
    text-align: center;
}

.val-info {
    flex: 1;
    min-width: 0;
}

.val-name {
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.val-id {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
}

.val-details {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.15rem;
}

.val-purchase {
    color: #17a2b8;
}

.val-no-value {
    color: #ffc107;
    font-style: italic;
}

.val-qty {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    min-width: 2.5rem;
    text-align: center;
}

.val-prices {
    text-align: right;
    min-width: 5rem;
}

.val-unit {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.val-item-total {
    font-weight: 600;
    color: #667eea;
}

/* Actions */
.val-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.val-item:hover .val-item-actions {
    opacity: 1;
}

.val-history-btn,
.val-edit-btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.8rem !important;
}

/* Needs value highlight */
.val-item.val-needs-value {
    border-left: 3px solid #ffc107;
}

/* ───────────────────────────────────────────────────────────────
   INDICATEURS DE TENDANCE
   ─────────────────────────────────────────────────────────────── */
.val-trend {
    display: inline-block;
    font-weight: 700;
    font-size: 0.9em;
    margin-left: 0.25rem;
}

.val-trend-up {
    color: #28a745;
}

.val-trend-down {
    color: #dc3545;
}

.val-item:hover .val-trend {
    transform: scale(1.1);
}

/* ───────────────────────────────────────────────────────────────
   TOGGLE BUTTONS
   ─────────────────────────────────────────────────────────────── */
.val-toggle-btns {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ───────────────────────────────────────────────────────────────
   ÉTATS VIDE / LOADING / ERREUR
   ─────────────────────────────────────────────────────────────── */
.val-empty {
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.val-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.6);
}

.val-error {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.7);
}

.val-error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.val-error h5 {
    margin-bottom: 0.5rem;
}

.val-error p {
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 1rem;
}

/* ───────────────────────────────────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .val-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .val-actions {
        width: 100%;
        justify-content: space-between;
    }

    .val-actions .btn {
        flex: 1;
    }

    .val-grand-total {
        flex-direction: column;
        text-align: center;
    }

    .val-total-icon {
        font-size: 2rem;
    }

    .val-total-value {
        font-size: 1.5rem;
    }

    .val-total-breakdown {
        flex-direction: column;
        gap: 0.25rem;
    }

    /* KPIs responsive */
    .val-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .val-kpi-value {
        font-size: 1rem;
    }

    .val-chart-container {
        height: 180px;
    }

    /* Movers responsive */
    .val-movers-grid {
        grid-template-columns: 1fr;
    }

    .val-item {
        flex-wrap: wrap;
    }

    .val-info {
        flex-basis: calc(100% - 4rem);
    }

    .val-prices {
        margin-left: auto;
    }

    .val-filter-container {
        padding: 0.5rem 0.75rem;
    }

    .val-filter-select {
        font-size: 0.8rem;
        padding: 0.4rem 1.5rem 0.4rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .val-section-header {
        padding: 0.75rem 1rem;
    }

    .val-section-total {
        font-size: 1rem;
    }

    .val-item {
        padding: 0.5rem 0.75rem;
    }

    .val-name {
        font-size: 0.9rem;
    }

    .val-item-actions {
        opacity: 1;
    }

    /* Évolution section mobile */
    .val-evolution-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .val-period-select {
        width: 100%;
    }

    .val-kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .val-kpi {
        padding: 0.5rem;
    }

    .val-kpi-value {
        font-size: 0.95rem;
    }

    .val-kpi-label {
        font-size: 0.6rem;
    }

    .val-chart-container {
        height: 150px;
    }
}
