/* REM Live · composants de base.
   Chaque composant est une classe simple (bouton, champ, carte…) avec ses variantes en « --variante ».
   Aucune couleur en dur : tout vient de tokens.css. */

/* ── Boutons ─────────────────────────────────────────────────────────────── */

.bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--e-2);
    min-height: 40px;
    padding: 0 var(--e-4);
    border: 1px solid var(--action);
    border-radius: var(--r-md);
    background: var(--action);
    color: var(--action-texte);
    font-size: var(--t-base);
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--duree-rapide) var(--courbe-douce), border-color var(--duree-rapide) var(--courbe-douce), box-shadow var(--duree-rapide) var(--courbe-douce), transform var(--duree-rapide) var(--courbe-douce);
}

.bouton:hover {
    background: var(--action-survol);
    border-color: var(--action-survol);
    color: var(--action-texte);
}

.bouton:active {
    transform: scale(0.98);
}

.bouton:focus-visible {
    outline: none;
    box-shadow: var(--anneau);
}

.bouton--secondaire {
    background: var(--surface);
    border-color: var(--bordure-forte);
    color: var(--texte);
    box-shadow: var(--ombre-1);
}

.bouton--secondaire:hover {
    background: var(--surface-2);
    border-color: var(--bordure-forte);
    color: var(--texte);
}

.bouton--fantome {
    background: transparent;
    border-color: transparent;
    color: var(--texte-2);
}

.bouton--fantome:hover {
    background: var(--surface-2);
    border-color: transparent;
    color: var(--texte);
}

.bouton--danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--danger-texte);
}

.bouton--danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--danger-texte);
    filter: brightness(0.92);
}

.bouton--petit {
    min-height: 32px;
    padding: 0 var(--e-3);
    font-size: var(--t-sm);
    border-radius: var(--r-sm);
}

.bouton--large {
    width: 100%;
    min-height: 46px;
    font-size: var(--t-md);
}

.bouton--icone {
    width: 40px;
    padding: 0;
}

.bouton--icone.bouton--petit {
    width: 32px;
}

.bouton[disabled],
.bouton[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.bouton[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.bouton[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--action-texte);
    border-right-color: transparent;
    border-radius: 50%;
    animation: rl-tourne 0.7s linear infinite;
}

.bouton--secondaire[aria-busy="true"]::after {
    border-color: var(--texte);
    border-right-color: transparent;
}

@keyframes rl-tourne {
    to {
        transform: rotate(360deg);
    }
}

.groupe-boutons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e-2);
}

/* ── Champs ──────────────────────────────────────────────────────────────── */

.champ {
    display: grid;
    gap: 6px;
    margin: 0 0 var(--e-5);
}

.champ > label,
.champ__libelle {
    font-size: var(--t-sm);
    font-weight: 600;
    color: var(--texte);
}

.champ input:not([type="checkbox"], [type="radio"]),
.champ select,
.champ textarea,
.saisie {
    width: 100%;
    min-height: 42px;
    padding: 0 var(--e-3);
    border: 1px solid var(--bordure-forte);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--texte);
    font-size: var(--t-base);
    transition: border-color var(--duree-rapide) var(--courbe-douce), box-shadow var(--duree-rapide) var(--courbe-douce);
}

.champ textarea {
    min-height: 104px;
    padding: var(--e-3);
    resize: vertical;
    line-height: var(--interligne);
}

.champ select {
    appearance: none;
    padding-right: var(--e-8);
    background-image: linear-gradient(45deg, transparent 50%, var(--texte-2) 50%), linear-gradient(135deg, var(--texte-2) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.champ input::placeholder,
.champ textarea::placeholder {
    color: var(--texte-3);
}

.champ input:hover,
.champ select:hover,
.champ textarea:hover {
    border-color: var(--texte-3);
}

.champ input:focus,
.champ select:focus,
.champ textarea:focus,
.saisie:focus {
    outline: none;
    border-color: var(--action);
    box-shadow: var(--anneau);
}

.champ__aide {
    font-size: var(--t-sm);
    color: var(--texte-2);
}

.champ__erreur {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--t-sm);
    color: var(--danger);
}

.champ--erreur input,
.champ--erreur select,
.champ--erreur textarea {
    border-color: var(--danger);
}

.champ--code input {
    font-size: var(--t-xl);
    letter-spacing: 0.3em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Cases, boutons radio, interrupteurs */

.case {
    display: flex;
    align-items: center;
    gap: var(--e-3);
    min-height: 32px;
    margin: 0 0 var(--e-4);
    font-size: var(--t-base);
    cursor: pointer;
}

.case input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--action);
    cursor: pointer;
}

.interrupteur {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--e-4);
    min-height: 52px;
    padding: var(--e-3) 0;
    border-bottom: 1px solid var(--bordure);
    cursor: pointer;
}

.interrupteur input {
    appearance: none;
    position: relative;
    flex: none;
    width: 44px;
    height: 26px;
    margin: 0;
    border-radius: var(--r-rond);
    background: var(--surface-3);
    border: 1px solid var(--bordure-forte);
    cursor: pointer;
    transition: background-color var(--duree) var(--courbe-douce), border-color var(--duree) var(--courbe-douce);
}

.interrupteur input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform var(--duree) var(--courbe-sortie);
}

.interrupteur input:checked {
    background: var(--action);
    border-color: var(--action);
}

.interrupteur input:checked::after {
    transform: translateX(18px);
}

.interrupteur input:focus-visible {
    outline: none;
    box-shadow: var(--anneau);
}

/* ── Cartes ──────────────────────────────────────────────────────────────── */

.carte {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    box-shadow: var(--ombre-1);
}

.carte__entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--e-3);
    padding: var(--e-5) var(--e-6) 0;
}

.carte__titre {
    font-size: var(--t-md);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.carte__corps {
    padding: var(--e-5) var(--e-6) var(--e-6);
}

.carte__pied {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--e-2);
    padding: var(--e-4) var(--e-6);
    border-top: 1px solid var(--bordure);
}

.carte--interactive {
    transition: border-color var(--duree) var(--courbe-douce), box-shadow var(--duree) var(--courbe-douce), transform var(--duree) var(--courbe-sortie);
}

.carte--interactive:hover {
    border-color: var(--bordure-forte);
    box-shadow: var(--ombre-2);
    transform: translateY(-1px);
}

/* ── Badges et pastilles ─────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 var(--e-2);
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--texte-2);
    font-size: var(--t-xs);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge .icone {
    width: 14px;
    height: 14px;
}

.badge--action {
    background: var(--action-doux);
    color: var(--action-doux-texte);
}

.badge--succes {
    background: var(--succes-doux);
    color: var(--succes);
}

.badge--attention {
    background: var(--attention-doux);
    color: var(--attention);
}

.badge--danger {
    background: var(--danger-doux);
    color: var(--danger);
}

.badge--info {
    background: var(--info-doux);
    color: var(--info);
}

/* « EN DIRECT » : point rouge qui pulse (immobile en mouvement réduit). */
.badge--direct {
    background: var(--direct-doux);
    color: var(--direct-texte);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.badge--direct::before,
.point-direct {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--direct);
    box-shadow: 0 0 0 0 var(--direct);
    animation: rl-pulse 1.6s var(--courbe-douce) infinite;
}

.badge--direct-plein {
    background: var(--direct);
    color: #FFFFFF;
}

.badge--direct-plein::before {
    background: #FFFFFF;
}

@keyframes rl-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(229, 32, 46, 0.5);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(229, 32, 46, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(229, 32, 46, 0);
    }
}

.statut {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--t-sm);
    font-weight: 500;
}

.statut::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--texte-3);
}

.statut--ok::before {
    background: var(--succes-vif);
}

.statut--attention::before {
    background: var(--attention);
}

.statut--ko::before {
    background: var(--danger);
}

.compteur {
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-rond);
    background: var(--surface-2);
    color: var(--texte-2);
    font-size: var(--t-xs);
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--action-doux);
    color: var(--action-doux-texte);
    font-size: var(--t-sm);
    font-weight: 700;
}

.kbd,
kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border: 1px solid var(--bordure);
    border-bottom-width: 2px;
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--texte-2);
    font-family: var(--police);
    font-size: var(--t-xs);
    font-weight: 600;
}

/* ── Messages ────────────────────────────────────────────────────────────── */

.message {
    display: flex;
    gap: var(--e-3);
    margin: 0 0 var(--e-5);
    padding: var(--e-3) var(--e-4);
    border: 1px solid var(--bordure);
    border-left: 3px solid var(--texte-3);
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: var(--t-base);
}

.message > .icone {
    margin-top: 2px;
}

.message p {
    margin: 0;
}

.message__titre {
    font-weight: 600;
}

.message--ok {
    border-left-color: var(--succes-vif);
    background: var(--succes-doux);
}

.message--ok > .icone {
    color: var(--succes);
}

.message--ko {
    border-left-color: var(--danger);
    background: var(--danger-doux);
}

.message--ko > .icone {
    color: var(--danger);
}

.message--att {
    border-left-color: var(--attention);
    background: var(--attention-doux);
}

.message--att > .icone {
    color: var(--attention);
}

.message--info {
    border-left-color: var(--info);
    background: var(--info-doux);
}

.message--info > .icone {
    color: var(--info);
}

/* ── Onglets ─────────────────────────────────────────────────────────────── */

.onglets {
    display: flex;
    gap: var(--e-1);
    overflow-x: auto;
    border-bottom: 1px solid var(--bordure);
    scrollbar-width: none;
}

.onglets::-webkit-scrollbar {
    display: none;
}

.onglet {
    position: relative;
    flex: none;
    padding: var(--e-3) var(--e-3) var(--e-4);
    border: 0;
    background: none;
    color: var(--texte-2);
    font-size: var(--t-base);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.onglet:hover {
    color: var(--texte);
}

.onglet[aria-selected="true"],
.onglet[aria-current="page"] {
    color: var(--texte);
}

.onglet[aria-selected="true"]::after,
.onglet[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: var(--e-3);
    right: var(--e-3);
    bottom: -1px;
    height: 2px;
    border-radius: 2px;
    background: var(--action);
}

.panneau-onglet[hidden] {
    display: none;
}

/* Choix segmenté (période, unité) */
.segmente {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--r-md);
    background: var(--surface-2);
}

.segmente button {
    min-height: 30px;
    padding: 0 var(--e-3);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--texte-2);
    font-size: var(--t-sm);
    font-weight: 500;
    cursor: pointer;
}

.segmente button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--texte);
    box-shadow: var(--ombre-1);
}

/* ── Tableaux ────────────────────────────────────────────────────────────── */

.tableau-cadre {
    overflow-x: auto;
    border-radius: var(--r-lg);
}

.tableau {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-base);
}

.tableau th {
    padding: var(--e-3) var(--e-4);
    border-bottom: 1px solid var(--bordure);
    background: var(--fond-doux);
    color: var(--texte-2);
    font-size: var(--t-sm);
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.tableau td {
    padding: var(--e-4);
    border-bottom: 1px solid var(--bordure);
    vertical-align: middle;
}

.tableau tbody tr:last-child td {
    border-bottom: 0;
}

.tableau tbody tr:hover td {
    background: var(--fond-doux);
}

.tableau .nombre {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tableau th button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.tableau th button .icone {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

.tableau th[aria-sort] button .icone {
    opacity: 1;
    color: var(--action);
}

.tableau__principal {
    font-weight: 600;
}

.tableau__secondaire {
    display: block;
    color: var(--texte-2);
    font-size: var(--t-sm);
}

/* ── Fenêtre de confirmation (<dialog> natif : focus et Échap gérés par le navigateur) ── */

.dialogue {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--bordure);
    border-radius: var(--r-xl);
    background: var(--surface);
    color: var(--texte);
    box-shadow: var(--ombre-3);
}

.dialogue::backdrop {
    background: var(--voile);
    backdrop-filter: blur(2px);
}

.dialogue[open] {
    animation: rl-apparait var(--duree) var(--courbe-sortie);
}

.dialogue__corps {
    padding: var(--e-6) var(--e-6) var(--e-5);
}

.dialogue__corps h2 {
    font-size: var(--t-lg);
    margin: 0 0 var(--e-2);
}

.dialogue__corps p {
    color: var(--texte-2);
}

.dialogue__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--e-2);
    padding: var(--e-4) var(--e-6);
    border-top: 1px solid var(--bordure);
    background: var(--fond-doux);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
}

@keyframes rl-apparait {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── États vides et squelettes ───────────────────────────────────────────── */

.etat-vide {
    display: grid;
    justify-items: center;
    gap: var(--e-2);
    padding: var(--e-9) var(--e-6);
    text-align: center;
}

.etat-vide__icone {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: var(--e-2);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    color: var(--texte-2);
}

.etat-vide h3 {
    font-size: var(--t-md);
}

.etat-vide p {
    max-width: 36ch;
    color: var(--texte-2);
}

.etat-vide .bouton {
    margin-top: var(--e-3);
}

.squelette {
    display: block;
    border-radius: var(--r-sm);
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: rl-reflet 1.4s linear infinite;
}

.squelette--ligne {
    height: 12px;
}

.squelette--titre {
    width: 40%;
    height: 20px;
}

.squelette--bloc {
    height: 120px;
    border-radius: var(--r-md);
}

@keyframes rl-reflet {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* ── Indicateurs (KPI) ───────────────────────────────────────────────────── */

.indicateurs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--e-4);
}

.indicateur {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--e-2) var(--e-3);
    padding: var(--e-5);
}

.indicateur__libelle {
    grid-column: 1 / -1;
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--texte-2);
}

.indicateur__valeur {
    font-size: var(--t-2xl);
    white-space: nowrap;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.indicateur__variation {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--t-sm);
    color: var(--texte-2);
}

.indicateur__courbe {
    grid-row: 2;
    grid-column: 2;
    width: 96px;
    height: 40px;
}

.variation {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.variation .icone {
    width: 14px;
    height: 14px;
}

.variation--bonne {
    color: var(--succes);
}

.variation--mauvaise {
    color: var(--danger);
}

.variation--stable {
    color: var(--texte-2);
}

/* Liste à barres (thèmes de questions, régions…) */
.barres {
    display: grid;
    gap: var(--e-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.barres li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px var(--e-3);
    font-size: var(--t-base);
}

.barres__valeur {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* La barre est un <progress> natif : sa longueur vient de l'attribut value, sans aucun style en ligne ni script. */
.barres progress {
    grid-column: 1 / -1;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: var(--r-rond);
    background: var(--surface-2);
    color: var(--action);
    overflow: hidden;
    appearance: none;
}

.barres progress::-webkit-progress-bar {
    border-radius: var(--r-rond);
    background: var(--surface-2);
}

.barres progress::-webkit-progress-value {
    border-radius: var(--r-rond);
    background: var(--action);
    transition: width var(--duree-lente) var(--courbe-sortie);
}

.barres progress::-moz-progress-bar {
    border-radius: var(--r-rond);
    background: var(--action);
}

/* Liste de détails (clé, valeur) */
.details {
    margin: 0;
    padding: 0;
}

.details > div {
    display: flex;
    justify-content: space-between;
    gap: var(--e-4);
    padding: var(--e-3) 0;
    border-bottom: 1px solid var(--bordure);
}

.details dt {
    color: var(--texte-2);
}

.details dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

/* Menu déroulant (sur <details> : fonctionne sans JavaScript) */
.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
    cursor: pointer;
}

.menu > summary::-webkit-details-marker {
    display: none;
}

.menu__liste {
    position: absolute;
    right: 0;
    z-index: 30;
    min-width: 220px;
    margin-top: var(--e-2);
    padding: var(--e-1);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--ombre-3);
    animation: rl-apparait var(--duree-rapide) var(--courbe-sortie);
}

.menu__element {
    display: flex;
    align-items: center;
    gap: var(--e-3);
    width: 100%;
    min-height: 38px;
    padding: 0 var(--e-3);
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--texte);
    font-size: var(--t-base);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu__element:hover {
    background: var(--surface-2);
    color: var(--texte);
}

.menu__element[aria-checked="true"] {
    color: var(--action);
    font-weight: 600;
}

.menu__separateur {
    height: 1px;
    margin: var(--e-1) 0;
    background: var(--bordure);
}

/* Compte à rebours (sites d'événement, « Ma chaîne ») : mis à jour par rl.js, sur l'heure du serveur. */
.decompte {
    display: flex;
    gap: var(--e-3);
    margin: var(--e-7) 0 0;
}

.decompte span {
    display: grid;
    justify-items: center;
    min-width: 76px;
    padding: var(--e-3) var(--e-2);
    border: 1px solid var(--bordure);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--texte-2);
    font-size: var(--t-xs);
}

.decompte strong {
    color: var(--texte);
    font-size: var(--t-2xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.decompte--grand span {
    min-width: 92px;
}

.decompte--grand strong {
    font-size: var(--t-3xl);
}

/* Choix de période ou de vue en liens (fonctionne sans JavaScript) */
.segmente__lien {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 var(--e-3);
    border-radius: var(--r-sm);
    color: var(--texte-2);
    font-size: var(--t-sm);
    font-weight: 500;
    text-decoration: none;
}

.segmente__lien:hover {
    color: var(--texte);
}

.segmente__lien[aria-current="page"] {
    background: var(--surface);
    color: var(--texte);
    box-shadow: var(--ombre-1);
}

/* Les filtres en tête de page (client, période) : un sélecteur aux couleurs du design system */
.tdb-filtres {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--e-3);
}

.tdb-filtres select {
    min-height: 38px;
    padding: 0 var(--e-7) 0 var(--e-3);
    border: 1px solid var(--bordure);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--texte);
    font: inherit;
    font-size: var(--t-sm);
    box-shadow: var(--ombre-1);
    cursor: pointer;
}

.tdb-filtres select:focus-visible {
    outline: none;
    border-color: var(--action);
    box-shadow: var(--anneau);
}
