/**
 * =======================================================
 * TICKER ÉCONOMIQUE - STYLES
 * Barre d'indicateurs en temps réel
 * =======================================================
 */

/* ============================================
   CONTENEUR PRINCIPAL
   ============================================ */
.economic-ticker-wrapper {
    position: fixed;
    width: 100%;
    background: linear-gradient(135deg, var(--be-primary) 0%, #1a3a6b 100%);
    color: #ffffff;
    height: 48px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-bottom: 2px solid var(--be-accent-gold);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: var(--be-font-mono);
    font-size: 0.875rem;
    z-index: 999;
}

/* ============================================
   LABEL FIXE "MARCHÉS EN DIRECT"
   ============================================ */
.ticker-label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    height: 100%;
    background: var(--be-accent-gold);
    color: var(--be-primary);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
}

.ticker-icon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ticker-label-text {
    display: inline-block;
}

/* ============================================
   ZONE DE DÉFILEMENT
   ============================================ */
.ticker-container {
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* La piste qui défile */
.ticker-track {
    display: flex;
    align-items: center;
    height: 100%;
    width: max-content; /* Largeur automatique selon le contenu */
    
    /* Animation infinie - GPU accelerated */
    animation: ticker-scroll 60s linear infinite;
    will-change: transform;
}

/* Pause au survol */
.economic-ticker-wrapper:hover .ticker-track {
    animation-play-state: paused;
}

/* Animation de défilement */
@keyframes ticker-scroll {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        /* On déplace de 33.333% car on a dupliqué le contenu 3x */
        transform: translate3d(-33.333%, 0, 0);
    }
}

/* ============================================
   ITEMS DU TICKER
   ============================================ */
.ticker-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 24px;
    height: 100%;
    white-space: nowrap;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    transition: background-color 0.2s ease;
    cursor: default;
}

.ticker-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   ÉLÉMENTS INTERNES DU TICKER
   ============================================ */

/* Symbole/Code */
.ticker-symbol {
    font-weight: 700;
    font-size: 0.875rem;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Séparateur */
.ticker-separator {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 2px;
}

/* Valeur principale */
.ticker-value {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #ffffff;
    font-variant-numeric: tabular-nums; /* Aligne bien les chiffres */
}

/* Variation (avec couleurs) */
.ticker-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 700;
    font-size: 0.8125rem;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

/* Icône de tendance */
.ticker-change-icon {
    font-size: 1rem;
    line-height: 1;
}

/* COULEURS SELON LA TENDANCE */

/* Hausse - Vert */
.ticker-change.trend-up {
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.15);
}

.ticker-item:hover .ticker-change.trend-up {
    background-color: rgba(16, 185, 129, 0.25);
}

/* Baisse - Rouge */
.ticker-change.trend-down {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.15);
}

.ticker-item:hover .ticker-change.trend-down {
    background-color: rgba(239, 68, 68, 0.25);
}

/* Stable - Gris */
.ticker-change.trend-stable {
    color: #94a3b8;
    background-color: rgba(148, 163, 184, 0.15);
}

.ticker-item:hover .ticker-change.trend-stable {
    background-color: rgba(148, 163, 184, 0.25);
}

/* ============================================
   TOOLTIP (INFO AU SURVOL)
   ============================================ */
.ticker-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: var(--be-primary);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: normal;
    min-width: 220px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 100;
}

/* Flèche du tooltip */
.ticker-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--be-primary);
}

/* Afficher au survol */
.ticker-item:hover .ticker-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   BOUTON REFRESH
   ============================================ */
.ticker-refresh {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.ticker-refresh:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.ticker-refresh:active {
    transform: translateY(-50%) scale(0.95);
}

/* Animation lors du refresh */
.ticker-refresh.spinning svg {
    animation: spin 1s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    .economic-ticker-wrapper {
        height: 44px;
        font-size: 0.8125rem;
    }
    
    /* Cacher le texte du label, garder juste l'icône */
    .ticker-label-text {
        display: none;
    }
    
    .ticker-label {
        padding: 0 12px;
    }
    
    .ticker-item {
        padding: 0 16px;
        gap: 4px;
    }
    
    .ticker-symbol {
        font-size: 0.8125rem;
    }
    
    .ticker-value {
        font-size: 0.875rem;
    }
    
    .ticker-change {
        font-size: 0.75rem;
        padding: 2px 6px;
    }
    
    /* Tooltip plus compact sur mobile */
    .ticker-tooltip {
        min-width: 180px;
        font-size: 0.6875rem;
        padding: 10px 12px;
    }
    
    /* Cacher le bouton refresh sur très petits écrans */
    @media (max-width: 480px) {
        .ticker-refresh {
            display: none;
        }
    }
}

/* ============================================
   ANIMATIONS D'ENTRÉE
   ============================================ */
.economic-ticker-wrapper {
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ÉTATS SPÉCIAUX
   ============================================ */

/* Ticker en chargement */
.economic-ticker-wrapper.loading .ticker-track {
    opacity: 0.6;
    filter: blur(2px);
}

/* Message d'erreur (si pas de données) */
.ticker-error {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

/* Focus visible pour navigation clavier */
.ticker-refresh:focus {
    outline: 2px solid var(--be-accent-gold);
    outline-offset: 2px;
}

/* Réduire les animations pour les utilisateurs qui le demandent */
@media (prefers-reduced-motion: reduce) {
    .ticker-track {
        animation-duration: 120s; /* Plus lent */
    }
    
    .ticker-icon {
        animation: none;
    }
    
    .ticker-refresh.spinning svg {
        animation-duration: 2s; /* Plus lent */
    }
}

/* ============================================
   PRINT (masquer à l'impression)
   ============================================ */
@media print {
    .economic-ticker-wrapper {
        display: none;
    }
}
