/* ========================================
   DASHBOARD.CSS - Version Finale Corrigée
   ======================================== */

/* --- CONTAINER GLOBAL --- */
.container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 40px;
}

.dashboard-layout {
    display: contents;
}

/* === SECTION HAUTE (2 COLONNES) === */
.dashboard-top-section {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: stretch;
}

/* --- COLONNE GAUCHE --- */
.dashboard-left-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    overflow-x: hidden;
}

/* --- COLONNE DROITE --- */
.dashboard-right-sidebar {
    position: sticky;
    top: 24px;
    height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

/* Panneau Indices */
.dashboard-indices-panel-full {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    height: 100%;
    overflow: hidden;
}

/* --- NOUVEAU HEADER INDICES (Titre + Status alignés) --- */
.indices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.indices-header .section-title-right {
    margin: 0;
    font-size: 13px;
    /* Légèrement plus grand */
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Style spécifique pour le badge Market Status intégré */
#market-status-container .market-status-compact {
    font-size: 11px !important;
    padding: 4px 8px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

/* Effet Néon sur le point de statut */
#market-status-container span[style*="border-radius"] {
    box-shadow: 0 0 8px currentColor;
}

.indices-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex: 1;
    padding-right: 10px;
    padding-left: 10px;
    padding-top: 20px;
    margin-top: 0;
    /* Ajusté car le margin est géré par le header maintenant */
}

.indices-list::-webkit-scrollbar {
    width: 4px;
}

.indices-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}


/* === BLOC 1 : KPI GRID === */
.dashboard-kpi-grid-v2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1400px) {

    /* Adjust to 1300px or 1350px if truncation starts earlier in your setup */
    .dashboard-kpi-grid-v2 {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns instead of 4 */
        grid-template-rows: repeat(2, auto);
        /* Explicit rows for clarity */
    }

    .kpi-card {
        min-height: 180px;
        /* Optional: Slightly reduce height to fit better vertically */
    }
}

/* Styles KPI */
.kpi-card {
    background: var(--bg-card);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    /* <-- Augmenté de 130px à 220px */
    transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-icon {
    opacity: 0.5;
}

.kpi-hero {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    min-height: 140px;
}

.kpi-hero .kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0;
}

.kpi-name-large {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-meta {
    font-size: 13px;
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: auto;
}

.kpi-change {
    font-weight: 600;
}

.kpi-change-pct {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.9;
}

.kpi-sector-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

.kpi-sector-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.kpi-sector-pct {
    font-size: 11px;
    color: var(--text-muted);
}

/* Asset Allocation */
#dashboard-allocation-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding-top: 10px;
}

.allocation-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    width: 100%;
}

.allocation-bar {
    display: flex;
    width: 100%;
    height: 12px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 4px;
    flex-shrink: 0;
}

.alloc-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.allocation-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.alloc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    width: 100%;
}

.alloc-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.alloc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.alloc-pct {
    font-weight: 700;
    color: var(--text-primary);
    min-width: 45px;
    margin-right: 4px;
}

.alloc-label {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    font-weight: 600;
    white-space: nowrap;
}

.alloc-right span {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Inter', monospace;
    text-align: right;
}


/* === BLOC 2 : CHART SECTION (CORRIGÉE) === */
.dashboard-chart-section {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* MODIF : Hauteur flexible avec un minimum pour éviter les coupures */
    height: 550px;
    min-height: 550px;
}

/* Wrapper interne du graphique */
.chart-wrapper.tall {
    flex: 1;
    /* Prend tout l'espace restant */
    height: auto;
    min-height: 350px;
    /* Hauteur minimale pour le canvas */
    position: relative;
    padding: 10px 20px;
    background: transparent;
}

/* Header du graphique */
.chart-header-mini {
    padding: 16px 24px;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Contrôles Période */
.chart-controls-inline {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.chart-controls-inline .period-btn {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-controls-inline .period-btn:hover {
    color: var(--text-primary);
}

.chart-controls-inline .period-btn.active {
    background: var(--accent-blue);
    color: white;
}

/* Benchmark Select */
.benchmark-wrapper {
    position: relative;
}

#benchmark-select {
    appearance: none;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 24px 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    height: 26px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239fa6bc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

#benchmark-select:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

#benchmark-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* --- BARRE DE STATS CORRIGÉE (GRID) --- */
.chart-stats-bar {
    display: grid;
    /* MODIF : Grid adaptative pour éviter que ça dépasse */
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    align-items: start;

    margin: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    /* Uniformisation du fond */
    padding: 16px 24px;
}

/* Groupes de stats */
.stat-group-1,
.stat-group-2 {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    border-right: 1px solid var(--border-color);
    padding-right: 16px;
    min-width: auto;
    /* Supprime la largeur forcée */
}

.stat-group-3 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding-left: 16px;
    border-right: none;
    justify-content: start;
}

/* Styles individuels stats */
.stat {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.stat .label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat .value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Inter', monospace;
}

.stat .pct {
    font-size: 12px;
    margin-left: 4px;
    opacity: 0.9;
}

.stat-group-1 .value {
    font-size: 22px;
    margin-bottom: 2px;
}

.stat-group-1 .pct {
    font-size: 14px;
    font-weight: 500;
}


/* === ELEMENTS INDICES LISTE === */
.market-card {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 80px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.market-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.market-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.market-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.market-icon {
    font-size: 16px;
    opacity: 0.8;
}

.market-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Inter', monospace;
    margin-bottom: 2px;
}

.market-change-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}

.market-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.market-dot.open {
    background: #10b981;
}

.market-dot.closed {
    background: #ef4444;
}


/* === BLOC 3 : NEWS FEEDS (BAS) === */
.dashboard-feeds-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: 500px;
}

.feed-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.feed-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.feed-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feed-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.feed-content::-webkit-scrollbar {
    width: 6px;
}

.feed-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.news-item-compact {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
}

.news-item-compact:last-child {
    border-bottom: none;
}

.news-item-compact:hover {
    background: var(--bg-hover);
}

.news-meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 10px;
    color: var(--text-muted);
    align-items: center;
}

.news-title-compact {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
}

.news-ticker-tag {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-blue);
    font-weight: 700;
    font-size: 9px;
}

.btn-icon-small {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
}

.btn-icon-small:hover {
    color: var(--text-primary);
}


/* === MODAL === */
.news-modal-content {
    max-width: 700px;
    /* MODIFIÉ : Augmentation de la largeur */
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.news-modal-ticker {
    background: var(--accent-blue);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.modal-body h3 {
    font-size: 24px;
    /* MODIFIÉ : Titre plus grand */
    margin-bottom: 20px;
    /* MODIFIÉ : Marge plus grande */
    line-height: 1.4;
}

/* Entête du résumé AI + Bouton Contextuel */
.ai-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.news-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-size: 13px;
    /* Augmenté */
    font-weight: 600;
    padding: 6px 12px;
    /* Augmenté */
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
    transition: all 0.2s ease;
}

.ai-context-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    padding: 4px 8px;
    border-radius: 50%;
}

.ai-context-btn:hover {
    color: var(--accent-purple);
    transform: scale(1.1);
}

.news-summary-text {
    font-size: 16px;
    /* MODIFIÉ : Texte du résumé plus grand */
    color: var(--text-secondary);
    line-height: 1.8;
    /* MODIFIÉ : Interligne pour meilleure lecture */
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-height: 100px;
}

/* NOUVELLE SECTION DE CONTEXTE */
.news-context-box {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-blue);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.news-context-box.show {
    opacity: 1;
}

.context-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

.context-icon {
    font-size: 20px;
    color: var(--accent-blue);
}

.context-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.context-content {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
}

@keyframes pulse-text {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

.loading-text {
    animation: pulse-text 1.5s infinite;
    color: var(--text-muted);
}

/* Ajustement du bouton en bas */
.modal-body .btn-primary {
    font-size: 14px;
    /* MODIFIÉ : Police du bouton */
    padding: 12px 24px;
    /* MODIFIÉ : Taille du bouton */
}

/* === RESPONSIVE === */
@media (max-width: 1400px) {

    /* Passage en 2 colonnes pour les stats graph sur écran moyen */
    .chart-stats-bar {
        grid-template-columns: 1fr 1fr;
    }

    .stat-group-1,
    .stat-group-2 {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 12px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .stat-group-3 {
        grid-column: span 2;
        padding-left: 0;
        padding-top: 12px;
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {

    /* 1. Force l'empilement vertical 1x1 */
    .dashboard-top-section {
        grid-template-columns: 1fr;
        /* Important: supprimez la hauteur pour que le conteneur s'adapte */
    }

    /* 2. Annule la position sticky et la hauteur forcée pour la colonne des indices */
    .dashboard-right-sidebar {
        position: static;
        height: auto;
    }

    /* 3. Assurez-vous que le panneau des indices peut se réduire naturellement */
    .dashboard-indices-panel-full {
        height: auto;
        /* Ajout d'une marge pour le séparer visuellement du bloc en dessous */
        margin-bottom: 24px;
    }

    /* 4. Corrige la disposition horizontale des cartes indices (si elles étaient en ligne) */
    .indices-list {
        flex-direction: row;
        overflow-x: auto;
        /* Permet le scroll horizontal si trop d'indices */
        padding-bottom: 12px;
    }
}

@media (max-width: 768px) {
    .stat-group-3 {
        grid-template-columns: 1fr 1fr;
        /* Retour sur 2 lignes mobile */
    }
}

/* === ICONS OPENMOJI === */
.market-icon img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    transition: transform 0.2s ease;
}

.market-card:hover .market-icon img {
    transform: scale(1.1) rotate(5deg);
}

/* ========================================
   NOUVEAU : LISTES KPI (TOP 3)
   ======================================== */

/* Conteneur de la liste qui remplace le gros texte */
.kpi-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    flex: 1;
    /* Occupe l'espace restant */
}

/* Une ligne (un actif) */
.kpi-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.kpi-list-row:last-child {
    border-bottom: none;
}

/* Partie gauche (Ticker + Nom) */
.kpi-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

/* Badge Ticker */
.kpi-ticker-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 45px;
    text-align: center;
}

/* Nom (coupé si trop long) */
.kpi-row-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 12px;
    max-width: 100px;
}

/* Partie droite (Valeur / %) */
.kpi-row-right {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

/* Valeur secondaire (ex: montant en € sous le %) */
.kpi-sub-value {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    display: block;
}

/* === NOUVELLE LIGNE HERO (3 COLONNES) === */
.dashboard-hero-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3 colonnes égales */
    gap: 16px;
}

/* Réutilisation du style 'summary-card-primary' de investments.css */
.summary-card-primary {
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.15) 100%) !important;
}

/* Responsive : passer à 1 colonne sur mobile */
@media (max-width: 768px) {
    .dashboard-hero-row {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   TAILLES TEXTE - LIGNE HERO (3 CARTES)
   ======================================== */

/* 1. Le Titre (ex: Total Value) */
.dashboard-hero-row .kpi-label {
    font-size: 13px !important;
    /* Plus grand (était ~11px) */
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 2. L'Icône à côté du titre */
.dashboard-hero-row .kpi-icon {
    font-size: 16px !important;
    opacity: 0.7;
}

/* 3. La Valeur Principale (ex: €30,615.72) */
.dashboard-hero-row .kpi-value {
    font-size: 36px !important;
    /* Beaucoup plus grand (était ~24px) */
    font-weight: 700;
    letter-spacing: -1px;
    margin: 8px 0 6px 0 !important;
    /* Un peu d'espace autour */
    line-height: 1.1;
}

/* 4. Les Sous-titres et Pourcentages (ex: Invested, +11.90%) */
.dashboard-hero-row .kpi-meta,
.dashboard-hero-row .kpi-change-pct,
.dashboard-hero-row .meta-info {
    font-size: 15px !important;
    /* Plus lisible (était ~12px) */
    font-weight: 500;
}

/* Ajustement spécifique pour le texte "Invested:" pour qu'il soit gris clair */
#dashboard-invested-subtitle {
    font-size: 14px !important;
    color: var(--text-secondary);
    opacity: 0.9 !important;
}

/* DANS css/dashboard.css */

/* Ajustement pour la ligne du bas des cartes indices */
.market-change-row {
    margin-top: 4px;
    align-items: center;
}

/* Petit badge de statut (Futures/Direct/Clôture) */
.market-status-label {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ========================================
   INTERACTION INDICES & NAVIGATION
   ======================================== */

/* Rendre les cartes indices interactives */
.market-card {
    cursor: pointer;
    position: relative;
}

/* Effet de sélection sur la carte active */
.market-card.active-index {
    border-color: var(--accent-blue) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* Bouton pour fermer la vue indice et revenir au portfolio */
.chart-reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
}

.chart-reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-1px);
}

/* FIXER LA HAUTEUR DU CANVAS POUR ÉVITER LE SAUT DE MISE EN PAGE */
#historical-portfolio-chart {
    height: 100% !important;
    width: 100% !important;
}

.chart-wrapper.tall {
    position: relative;
    /* S'assurer que le wrapper est relatif pour que le canvas absolu fonctionne */
    flex: 1;
    /* Conserver l'espace flexible */
    min-height: 350px;
    /* Conserver une hauteur minimale de sécurité */
}

/* market-card est déjà défini */
.market-card {
    /* ... (règles existantes) ... */
    position: relative;
    /* Nécessaire si on veut positionner des éléments au survol */
    overflow: hidden;
    /* Empêche le débordement des éléments du graphique */
    min-height: 100px;
    /* Assure que le graphique a de la place */
}

/* Conteneur du mini-graphique (Sparkline) */
.market-chart-mini {
    position: absolute;
    bottom: 30px;
    /* Au-dessus du pied de page */
    left: 0;
    width: 100%;
    height: 30px;
    opacity: 0.25;
    /* Rendre le graphique d'arrière-plan discret */
    transition: opacity 0.2s ease;
}

.market-card:hover .market-chart-mini {
    opacity: 0.6;
    /* Le rendre plus visible au survol */
}

.market-chart-mini svg polyline {
    stroke-linecap: round;
    stroke-linejoin: round;
    /* On utilise la couleur du stroke déterminée dans JS */
}

/* Positionnement du prix et du changement au-dessus du graphique */
.market-price,
.market-change-row {
    position: relative;
    z-index: 2;
}

.market-card.active-index {
    border: 1px solid #22c55e !important;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5) !important;
    transform: translateY(-2px) !important;
    z-index: 10;
}

/* === INTERACTION INDICES & NAVIGATION === */

/* Effet de sélection sur la carte active (GENERAL) */
.market-card.active-index {
    /* Base de l'effet d'activation/sélection */
    border-color: var(--accent-blue) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* NOUVEAU : RÈGLE POUR LES CARTES ACTIVES EN BAISSE */
.market-card.stat-negative.active-index {
    border: 1px solid var(--accent-red) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5) !important;
    /* Rayonnement Rouge */
    background: rgba(239, 68, 68, 0.1) !important;
}



/* Partie droite (Valeur / %) */
.kpi-row-right {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

/* Valeur secondaire (ex: montant en € sous le %) */
.kpi-sub-value {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    display: block;
}

/* === NOUVELLE LIGNE HERO (3 COLONNES) === */
.dashboard-hero-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3 colonnes égales */
    gap: 16px;
}

/* Réutilisation du style 'summary-card-primary' de investments.css */
.summary-card-primary {
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.15) 100%) !important;
}

/* Responsive : passer à 1 colonne sur mobile */
@media (max-width: 768px) {
    .dashboard-hero-row {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   TAILLES TEXTE - LIGNE HERO (3 CARTES)
   ======================================== */

/* 1. Le Titre (ex: Total Value) */
.dashboard-hero-row .kpi-label {
    font-size: 13px !important;
    /* Plus grand (était ~11px) */
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 2. L'Icône à côté du titre */
.dashboard-hero-row .kpi-icon {
    font-size: 16px !important;
    opacity: 0.7;
}

/* 3. La Valeur Principale (ex: €30,615.72) */
.dashboard-hero-row .kpi-value {
    font-size: 36px !important;
    /* Beaucoup plus grand (était ~24px) */
    font-weight: 700;
    letter-spacing: -1px;
    margin: 8px 0 6px 0 !important;
    /* Un peu d'espace autour */
    line-height: 1.1;
}

/* 4. Les Sous-titres et Pourcentages (ex: Invested, +11.90%) */
.dashboard-hero-row .kpi-meta,
.dashboard-hero-row .kpi-change-pct,
.dashboard-hero-row .meta-info {
    font-size: 15px !important;
    /* Plus lisible (était ~12px) */
    font-weight: 500;
}

/* Ajustement spécifique pour le texte "Invested:" pour qu'il soit gris clair */
#dashboard-invested-subtitle {
    font-size: 14px !important;
    color: var(--text-secondary);
    opacity: 0.9 !important;
}

/* DANS css/dashboard.css */

/* Ajustement pour la ligne du bas des cartes indices */
.market-change-row {
    margin-top: 4px;
    align-items: center;
}

/* Petit badge de statut (Futures/Direct/Clôture) */
.market-status-label {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ========================================
   INTERACTION INDICES & NAVIGATION
   ======================================== */

/* Rendre les cartes indices interactives */
.market-card {
    cursor: pointer;
    position: relative;
}

/* Effet de sélection sur la carte active */
.market-card.active-index {
    border-color: var(--accent-blue) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* Bouton pour fermer la vue indice et revenir au portfolio */
.chart-reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
}

.chart-reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-1px);
}

/* FIXER LA HAUTEUR DU CANVAS POUR ÉVITER LE SAUT DE MISE EN PAGE */
#historical-portfolio-chart {
    height: 100% !important;
    width: 100% !important;
}

.chart-wrapper.tall {
    position: relative;
    /* S'assurer que le wrapper est relatif pour que le canvas absolu fonctionne */
    flex: 1;
    /* Conserver l'espace flexible */
    min-height: 350px;
    /* Conserver une hauteur minimale de sécurité */
}

/* market-card est déjà défini */
.market-card {
    /* ... (règles existantes) ... */
    position: relative;
    /* Nécessaire si on veut positionner des éléments au survol */
    overflow: hidden;
    /* Empêche le débordement des éléments du graphique */
    min-height: 100px;
    /* Assure que le graphique a de la place */
}

/* Conteneur du mini-graphique (Sparkline) */
.market-chart-mini {
    position: absolute;
    bottom: 30px;
    /* Au-dessus du pied de page */
    left: 0;
    width: 100%;
    height: 30px;
    opacity: 0.25;
    /* Rendre le graphique d'arrière-plan discret */
    transition: opacity 0.2s ease;
}

.market-card:hover .market-chart-mini {
    opacity: 0.6;
    /* Le rendre plus visible au survol */
}

.market-chart-mini svg polyline {
    stroke-linecap: round;
    stroke-linejoin: round;
    /* On utilise la couleur du stroke déterminée dans JS */
}

/* Positionnement du prix et du changement au-dessus du graphique */
.market-price,
.market-change-row {
    position: relative;
    z-index: 2;
}

.market-card.active-index {
    border: 1px solid #22c55e !important;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5) !important;
    transform: translateY(-2px) !important;
    z-index: 10;
}

/* === INTERACTION INDICES & NAVIGATION === */

/* Effet de sélection sur la carte active (GENERAL) */
.market-card.active-index {
    /* Base de l'effet d'activation/sélection */
    border-color: var(--accent-blue) !important;
    background: rgba(59, 130, 246, 0.1) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* NOUVEAU : RÈGLE POUR LES CARTES ACTIVES EN BAISSE */
.market-card.stat-negative.active-index {
    border: 1px solid var(--accent-red) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5) !important;
    /* Rayonnement Rouge */
    background: rgba(239, 68, 68, 0.1) !important;
}

/* RÈGLE AJOUTÉE PRÉCÉDEMMENT (MAINTENANT LÉGÈREMENT MODIFIÉE POUR LE VERT) */
.market-card.active-index:not(.stat-negative) {
    /* Utilise la couleur verte si ce n'est pas stat-negative (i.e. stat-positive ou neutre) */
    border: 1px solid var(--accent-green) !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5) !important;
    /* Rayonnement Vert */
    background: rgba(16, 185, 129, 0.1) !important;
}

/* === LOADER SVG (Porté depuis investments.css) === */
.chart-loading {
    display: none;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 20, 30, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10;
    border-radius: 12px;
    transition: opacity 0.3s ease;
}

.svg-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader-svg {
    width: 48px;
    height: 48px;
    animation: rotate 2s linear infinite;
}

.loader-svg-path {
    stroke: #3498db;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

.loader-text {
    color: #e0e0e0;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }

    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}