/* ==========================================================================
   INTELLIWEALTH • SALLE DES MARCHÉS WALLBOARD TV PLEIN ÉCRAN
   Design Haute Précision pour Écrans TV / Trading Desk (1080p / 4K)
   ========================================================================== */

#tradingFloorTvWallboard {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999999;
    background: radial-gradient(circle at 50% 10%, #0d1527 0%, #050811 100%);
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
}

#tradingFloorTvWallboard.active {
    display: flex;
}

/* 1. EN-TÊTE TV HAUTE LISIBILITÉ */
.tv-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1.75rem;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(51, 65, 85, 0.7);
    flex-shrink: 0;
}

.tv-header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tv-brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0284c7, #6366f1);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 0 16px rgba(2, 132, 199, 0.4);
}

.tv-brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tv-brand-tag {
    font-size: 0.65rem;
    font-weight: 800;
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.4);
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.5px;
}

.tv-header-center {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.tv-clock-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.05rem;
    font-weight: 800;
    color: #e2e8f0;
    background: rgba(30, 41, 59, 0.8);
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid rgba(71, 85, 105, 0.5);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tv-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-tv-exit {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-tv-exit:hover {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

/* 2. LIGNE VALEUR DU COMPTE (EQUITY) & RISQUE CRO */
.tv-equity-strip {
    display: grid;
    grid-template-columns: 1.3fr 1.1fr 1.3fr 1.1fr;
    gap: 1rem;
    padding: 0.75rem 1.75rem;
    background: rgba(10, 16, 29, 0.85);
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
    flex-shrink: 0;
}

.tv-equity-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 12px;
    padding: 0.65rem 1.1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.tv-equity-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #0284c7;
}

.tv-equity-card.card-equity::before { background: #10b981; }
.tv-equity-card.card-cash::before { background: #06b6d4; }
.tv-equity-card.card-sentinel::before { background: #6366f1; }
.tv-equity-card.card-cro::before { background: #f43f5e; }

.tv-card-label {
    font-size: 0.68rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.15rem;
}

.tv-card-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 1.65rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.tv-card-sub {
    font-size: 0.76rem;
    color: #94a3b8;
    font-weight: 600;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* 3. TRIPLE BARRE DÉFILANTE (STOCKS, CRYPTO, NEWS) */
.tv-tickers-stack {
    display: flex;
    flex-direction: column;
    background: #060913;
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
    flex-shrink: 0;
}

.tv-ticker-row {
    display: flex;
    align-items: center;
    height: 32px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    overflow: hidden;
}

.tv-ticker-row:last-child {
    border-bottom: none;
}

.tv-ticker-badge-col {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.9rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    height: 100%;
    z-index: 2;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.4);
}

.badge-stocks { background: #1e293b; color: #38bdf8; border-right: 2px solid #0284c7; }
.badge-crypto { background: #1e293b; color: #f59e0b; border-right: 2px solid #d97706; }
.badge-news { background: #1e293b; color: #10b981; border-right: 2px solid #059669; }

.tv-ticker-scroller {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.tv-ticker-track-anim {
    display: flex;
    align-items: center;
    gap: 2.25rem;
    white-space: nowrap;
    will-change: transform;
    animation: tvMarquee 120s linear infinite;
}

#tvTrackNews.tv-ticker-track-anim {
    animation-duration: 165s; /* Défilement apaisé et confortable pour lire chaque titre de dépêche FinGPT */
}

.tv-ticker-track-anim:hover {
    animation-play-state: paused;
}

.tv-ticker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.tv-ticker-sym {
    color: #f1f5f9;
}

.tv-ticker-price {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #e2e8f0;
}

.tv-ticker-chg {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.74rem;
    font-weight: 800;
}

.tv-ticker-chg.up { color: #34d399; }
.tv-ticker-chg.down { color: #f87171; }

.tv-news-item {
    font-size: 0.76rem;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tv-news-tag {
    font-size: 0.64rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
}

.tv-news-tag.bullish { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.tv-news-tag.bearish { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.tv-news-tag.neutral { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }

@keyframes tvMarquee {
    0% { transform: translateX(0%); }
    100% { transform: translateX(-50%); }
}

/* 4. CENTRE DE SURVEILLANCE EN 3 VOLETS DÉROULANTS RÉDUITS */
.tv-streams-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    padding: 1.25rem 1.75rem;
    overflow: hidden;
    box-sizing: border-box;
    background: #070b14;
}

.tv-stream-col {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.tv-stream-header {
    padding: 0.8rem 1.1rem;
    background: rgba(30, 41, 59, 0.6);
    border-bottom: 1px solid rgba(51, 65, 85, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.tv-stream-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tv-stream-pill {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.4);
}

/* Container du flux défilant vertical doux */
.tv-stream-viewport {
    flex: 1;
    position: relative;
    overflow-y: hidden;
    padding: 0.75rem;
    box-sizing: border-box;
}

.tv-stream-viewport:hover {
    overflow-y: auto;
}

.tv-stream-scroller {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    will-change: transform;
    animation: tvVerticalScroll 120s linear infinite; /* Défilement très doux, 2 minutes par boucle complète */
}

.tv-stream-scroller:hover,
.tv-compact-card:hover {
    animation-play-state: paused !important;
}

/* Modificateurs de vitesse TV interactifs */
.tv-paused .tv-ticker-track-anim,
.tv-paused .tv-stream-scroller {
    animation-play-state: paused !important;
}

.tv-speed-slow .tv-ticker-track-anim {
    animation-duration: 200s !important;
}
.tv-speed-slow #tvTrackNews.tv-ticker-track-anim {
    animation-duration: 240s !important;
}
.tv-speed-slow .tv-stream-scroller {
    animation-duration: 180s !important;
}

.tv-speed-normal .tv-ticker-track-anim {
    animation-duration: 120s !important;
}
.tv-speed-normal #tvTrackNews.tv-ticker-track-anim {
    animation-duration: 165s !important;
}
.tv-speed-normal .tv-stream-scroller {
    animation-duration: 120s !important;
}

@keyframes tvVerticalScroll {
    0% { transform: translateY(0%); }
    100% { transform: translateY(-50%); }
}

/* CARTES COMPACTES DÉROULANTES POUR LA TV */
.tv-compact-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: transform 0.2s, border-color 0.2s;
}

.tv-compact-card:hover {
    border-color: #38bdf8;
    transform: translateY(-2px);
    background: rgba(30, 41, 59, 0.8);
}

.tv-card-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tv-asset-badge {
    font-size: 0.95rem;
    font-weight: 900;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tv-pnl-chip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88rem;
    font-weight: 800;
}

.tv-pnl-chip.win { color: #34d399; }
.tv-pnl-chip.loss { color: #f87171; }

.tv-card-row-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.75);
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    margin-top: 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tv-detail-metric {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #cbd5e1;
    font-size: 0.75rem;
    font-weight: 500;
}

.tv-detail-metric strong {
    color: #38bdf8 !important; /* Cyan électrique haute visibilité */
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 800;
    font-size: 0.82rem;
}

.tv-sl-tp-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.74rem;
    margin-top: 0.35rem;
    padding-top: 0.45rem;
    border-top: 1px dashed rgba(51, 65, 85, 0.6);
}

.tv-sl-tag { color: #f87171 !important; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.tv-tp-tag { color: #34d399 !important; font-weight: 800; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

/* DÉCISIONS DES AGENTS */
.tv-decision-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tv-decision-badge-buy {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 800;
}

.tv-decision-badge-sell {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 800;
}

.tv-decision-thesis {
    font-size: 0.76rem;
    line-height: 1.4;
    color: #cbd5e1;
}

.tv-decision-committee {
    font-size: 0.68rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* =========================================================================
   PROTECTION DU MODE SOMBRE DU WALLBOARD TV CONTRE LE THÈME CLAIR GLOBAL
   (Empêche le texte noir #0f172a invisible sur fond sombre)
   ========================================================================= */
body.theme-clean-light #tradingFloorTvWallboard,
body #tradingFloorTvWallboard {
    background: #090d16 !important;
    color: #f1f5f9 !important;
}

body.theme-clean-light #tradingFloorTvWallboard strong,
body #tradingFloorTvWallboard strong,
#tradingFloorTvWallboard .tv-detail-metric strong {
    color: #38bdf8 !important; /* Cyan électrique très visible */
    font-weight: 800 !important;
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

body.theme-clean-light #tradingFloorTvWallboard .tv-card-row-details,
#tradingFloorTvWallboard .tv-card-row-details {
    background: rgba(15, 23, 42, 0.85) !important;
    border: 1px solid rgba(56, 189, 248, 0.25) !important;
}

body.theme-clean-light #tradingFloorTvWallboard .tv-detail-metric,
#tradingFloorTvWallboard .tv-detail-metric {
    color: #e2e8f0 !important;
    font-size: 0.76rem !important;
}

body.theme-clean-light #tradingFloorTvWallboard .tv-sl-tag {
    color: #f87171 !important;
}

body.theme-clean-light #tradingFloorTvWallboard .tv-tp-tag {
    color: #34d399 !important;
}
