/* ═══════════════════════════════════════════════════════════
   V5.10.d — Auto-refresh UI (indicator + toast)
   À placer en bas de app.css OU dans _riders-autorefresh.css
   ═══════════════════════════════════════════════════════════ */

/* ─── Indicateur de statut (haut de page) ───────────────────── */
.autorefresh-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: #f5f7fa;
    border: 1px solid #e3e8ee;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 12px;
    color: #4a5568;
}

.autorefresh-bar .autorefresh-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.autorefresh-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #95a5a6;
    flex-shrink: 0;
    transition: background-color 0.2s;
    position: relative;
}

/* ─── États du dot indicator (V5.10.d.9) ─────────────────────
   Sémantique : vert = ça marche, orange = avertissement, rouge = problème.
   - idle      : vert fixe (tout va bien, en attente du prochain poll)
   - polling   : vert qui clignote (requête en cours)
   - changes   : vert qui flash plusieurs fois (nouvelles données détectées)
   - warning   : orange qui clignote (réponse partielle, source inactive, etc.)
   - error     : rouge fixe avec pulse lent (panne réseau, 500, etc.)
   - disabled  : rouge fixe sans animation (autorefresh désactivé pour ce show)
*/
.autorefresh-indicator.idle {
    background: #27ae60;
}
.autorefresh-indicator.polling {
    background: #27ae60;
    animation: autorefresh-pulse 1.2s infinite;
}
.autorefresh-indicator.changes {
    background: #27ae60;
    animation: autorefresh-flash 0.6s 3;
}
.autorefresh-indicator.warning {
    background: #f39c12;
    animation: autorefresh-pulse 1.5s infinite;
}
.autorefresh-indicator.error {
    background: #e74c3c;
    animation: autorefresh-pulse-error 2s infinite;
}
.autorefresh-indicator.disabled {
    background: #e74c3c;
    opacity: 0.6;
}

@keyframes autorefresh-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(1.2); }
}

@keyframes autorefresh-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.5); }
    50%      { box-shadow: 0 0 0 8px rgba(39, 174, 96, 0); }
}

@keyframes autorefresh-pulse-error {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

.autorefresh-label {
    color: #6b7785;
    white-space: nowrap;
}

#autorefresh-last-check {
    font-weight: 600;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

.btn-run-popcheck {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    color: #2c3e50;
    border: 1px solid #d6dde5;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn-run-popcheck:hover:not(:disabled) {
    background: #f5f7fa;
    border-color: #3498db;
    color: #2980b9;
}

.btn-run-popcheck:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-run-popcheck .fa {
    font-size: 12px;
}

/* ─── Toast notifications ──────────────────────────────────── */
.autorefresh-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    padding: 12px 18px;
    border-radius: 6px;
    background: #2c3e50;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 380px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}

.autorefresh-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.autorefresh-toast-success { background: #27ae60; }
.autorefresh-toast-warning { background: #f39c12; }
.autorefresh-toast-error   { background: #e74c3c; }
.autorefresh-toast-info    { background: #3498db; }

/* ─── V5.10.d.2 : Badge source dans la barre autorefresh ───── */
.autorefresh-source {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 10px;
    margin-left: 4px;
    border: 1px solid transparent;
    line-height: 1.4;
}

.autorefresh-source.source-email {
    background: #e3edfa;
    color: #1f4e79;
    border-color: #b8c9e0;
}
.autorefresh-source.source-fei {
    background: #e8f8f0;
    color: #186a3b;
    border-color: #b6e0c8;
}
.autorefresh-source.source-manual {
    background: #ecf0f1;
    color: #2c3e50;
    border-color: #bdc3c7;
}
.autorefresh-source.source-none {
    background: #fdecea;
    color: #b94545;
    border-color: #f5c2bc;
}

/* ═══════════════════════════════════════════════════════════
   V5.10.d.8 — Mode compact (à droite du titre du show)
   
   Pour utilisation dans `.header-section .header-top-row` où
   le <h3> et la barre autorefresh sont sur la même ligne.
   ═══════════════════════════════════════════════════════════ */

/* Le container parent : titre à gauche, autorefresh à droite */
.header-section .header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.header-section .header-top-row h3 {
    margin: 0;
    flex: 0 1 auto;
}

/* La barre en mode compact : mêmes couleurs que .info-box (bleu foncé + accent #3498db) */
.autorefresh-bar.autorefresh-bar-compact {
    margin-bottom: 0;
    padding: 4px 10px 4px 12px;
    font-size: 11px;
    background: #34495e;
    border: 1px solid #2c3e50;
    border-left: 3px solid #3498db;
    color: #ecf0f1;
    flex: 0 0 auto;
    gap: 10px;
    border-radius: 14px;
}

.autorefresh-bar-compact .autorefresh-info {
    gap: 6px;
    flex: 0 0 auto;
}

.autorefresh-bar-compact .autorefresh-indicator {
    width: 7px;
    height: 7px;
}

.autorefresh-bar-compact .autorefresh-label {
    color: #bdc3c7;
    font-size: 10.5px;
}

.autorefresh-bar-compact #autorefresh-last-check {
    font-size: 11px;
    color: #fff;
    font-weight: 600;
}

.autorefresh-bar-compact .autorefresh-source {
    font-size: 9.5px;
    padding: 1px 6px;
    margin-left: 2px;
    border-radius: 8px;
    letter-spacing: 0.3px;
}

/* Bouton "Vérifier maintenant" en version compacte (sur fond foncé) */
.autorefresh-bar-compact .btn-run-popcheck {
    padding: 3px 9px;
    font-size: 11px;
    border-radius: 12px;
    gap: 4px;
    background: rgba(255, 255, 255, 0.10);
    color: #ecf0f1;
    border: 1px solid rgba(255, 255, 255, 0.20);
}

.autorefresh-bar-compact .btn-run-popcheck:hover:not(:disabled) {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}

.autorefresh-bar-compact .btn-run-popcheck:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.autorefresh-bar-compact .btn-run-popcheck .fa {
    font-size: 10px;
}

/* Sur petit écran, on cache le texte du bouton (juste l'icône) */
@media (max-width: 900px) {
    .autorefresh-bar-compact .btn-run-popcheck .btn-text {
        display: none;
    }
    .autorefresh-bar-compact .btn-run-popcheck {
        padding: 3px 7px;
    }
}

/* Sur très petit écran, la barre passe sous le titre */
@media (max-width: 700px) {
    .header-section .header-top-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .autorefresh-bar.autorefresh-bar-compact {
        align-self: stretch;
    }
}