/* mgsdesk.css — thème sombre sobre partagé par index.html, viewer.html et tests.html */

:root {
    --fond: #0e1320;
    --surface: #161d2e;
    --surface-2: #1d2639;
    --bordure: #2a3550;
    --texte: #dce4f2;
    --texte-doux: #8b98b3;
    --accent: #3b82f6;
    --accent-fonce: #1f5fc4;
    --danger: #e5484d;
    --succes: #3fb27f;
    --avert: #e0a800;
    --rayon: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--fond);
    color: var(--texte);
    font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

/* ---------------------------------------------------------------- index --- */

.index-corps {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.carte {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 28px 26px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, .45);
}

.carte h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: .3px;
}

.carte .sous-titre {
    margin: 0 0 20px;
    color: var(--texte-doux);
    font-size: 13px;
}

.champ {
    display: block;
    margin-bottom: 14px;
}

.champ span {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--texte-doux);
}

.champ input {
    width: 100%;
    padding: 10px 12px;
    background: var(--fond);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    outline: none;
}

.champ input:focus { border-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 9px 14px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: #24304a; }
.btn:disabled { opacity: .55; cursor: default; }

.btn-principal {
    width: 100%;
    justify-content: center;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 700;
    padding: 11px 14px;
}

.btn-principal:hover { background: var(--accent-fonce); }

.message {
    margin-top: 14px;
    min-height: 18px;
    font-size: 13px;
    white-space: pre-line;
}

.message.err { color: var(--danger); }
.message.info { color: var(--texte-doux); }
.message.warn { color: var(--avert); }

.historique { margin-top: 20px; }

.historique h2 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--texte-doux);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.historique h2 button {
    all: unset;
    cursor: pointer;
    color: var(--texte-doux);
    font-size: 11px;
}

.historique h2 button:hover { color: var(--danger); }

.histo-liste { display: flex; flex-direction: column; gap: 6px; }

.histo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--fond);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    cursor: pointer;
}

.histo-item:hover { border-color: var(--accent); }
.histo-item .id { font-weight: 700; letter-spacing: .5px; }
.histo-item .nom { color: var(--texte-doux); font-size: 12px; }
.histo-item .x {
    margin-left: auto;
    color: var(--texte-doux);
    cursor: pointer;
    padding: 0 4px;
}
.histo-item .x:hover { color: var(--danger); }
.histo-vide { color: var(--texte-doux); font-size: 12.5px; }

/* --------------------------------------------------------------- viewer --- */

.viewer-corps {
    position: relative;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.barre {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--bordure);
}

.barre.basse { border-bottom: 0; border-top: 1px solid var(--bordure); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.point {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--texte-doux);
    flex: none;
}

.point.live { background: var(--danger); animation: pulsation 1.6s ease-out infinite; }
.point.attente { background: var(--avert); }
.point.erreur { background: var(--danger); }

@keyframes pulsation {
    0%   { box-shadow: 0 0 0 0 rgba(229, 72, 77, .55); }
    70%  { box-shadow: 0 0 0 8px rgba(229, 72, 77, 0); }
    100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); }
}

.puce {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1;
    background: var(--accent);
    color: #fff;
    white-space: nowrap;
}

.puce[hidden] { display: none; }
.puce.securise { background: var(--avert); color: #1f1700; }
.puce.e2e-hors { background: #55627e; }

.barre .poussee { margin-left: auto; }

.barre select, .barre .btn { padding: 7px 10px; }
.barre select {
    background: var(--fond);
    border: 1px solid var(--bordure);
    border-radius: 8px;
}

.barre .btn.actif { background: var(--accent); border-color: var(--accent); color: #fff; }

.info-barre {
    color: var(--texte-doux);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Route + RTT lissé (lot A) : « Relais TCP · 54 ms », couleur discrète selon la latence. */
.route-barre { flex: 0 0 auto; }
.route-barre:empty { display: none; }
.route-barre.bon { color: var(--succes); }
.route-barre.moyen { color: var(--avert); }
.route-barre.mauvais { color: var(--danger); }

.scene {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.scene canvas {
    display: block;
    flex: none;
    margin: auto;
    touch-action: none;
    background: #000;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, .55);
}

.overlay[hidden] { display: none; }

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: #fff;
    animation: tourner .9s linear infinite;
}

.spinner[hidden] { display: none; }
@keyframes tourner { to { transform: rotate(360deg); } }

.overlay .titre { font-size: 15px; font-weight: 700; }
.overlay .sous { font-size: 12.5px; color: rgba(255, 255, 255, .7); max-width: 460px; }
.overlay .sous[hidden] { display: none; }

/* Poste attaché à un autre relais du pool (annuaire de la gestion, MULTIRELAIS.md §6) */
.lien-relais {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.lien-relais:hover { background: var(--accent-fonce); }
.lien-relais[hidden] { display: none; }
.message .lien-relais { margin-top: 8px; }

/* Bandeau d'erreur serveur (rate-limited, e2e…) */
.banniere {
    flex: none;
    padding: 8px 14px;
    background: rgba(229, 72, 77, .15);
    border-bottom: 1px solid var(--danger);
    color: #ffb3b6;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.banniere[hidden] { display: none; }
.banniere button { all: unset; margin-left: auto; cursor: pointer; color: var(--texte-doux); }
.banniere button:hover { color: #fff; }

/* Panneau clavier déroulant */
.panneau-clavier {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 14;
    padding: 12px 14px 14px;
    background: var(--surface);
    border-top: 1px solid var(--bordure);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .5);
}

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

.panneau-clavier h6 {
    margin: 0 0 7px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .9px;
    text-transform: uppercase;
    color: var(--texte-doux);
}

.panneau-clavier h6:not(:first-child) { margin-top: 12px; }

.rangee-touches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rangee-combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }

.touche {
    border: 1px solid var(--bordure);
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--texte);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 10px 4px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.touche:hover { background: #24304a; }
.touche:active, .touche.maintenue { background: var(--accent); border-color: var(--accent); color: #fff; }
.touche.sas { border-color: var(--avert); color: var(--avert); }
.touche.sas.pulse { animation: pulsation 1.6s ease-out infinite; }

.note-clavier {
    margin: 12px 0 0;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--texte-doux);
}

/* ------------------------------------------------------- viewer : plus --- */

.etiquette-barre { color: var(--texte-doux); font-size: 12px; }
.btn { position: relative; }

/* Pastille « fichiers proposés » sur les boutons de transfert */
.pastille {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--avert);
    box-shadow: 0 0 0 2px var(--surface);
}
.pastille[hidden] { display: none; }

/* Taille réelle : la scène défile ; marge automatique de la toile = centrée tant qu'elle est plus petite */
.scene.echelle-reelle { overflow: auto; align-items: flex-start; justify-content: flex-start; }

/* ---- Plein écran : l'image occupe TOUT l'écran, barres masquées, barre flottante à la demande ---- */
.viewer-corps.plein-ecran { background: #000; }
.viewer-corps.plein-ecran > .barre { display: none; }
.viewer-corps.plein-ecran .banniere {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    backdrop-filter: blur(6px);
    background: rgba(60, 14, 18, .85);
}
.viewer-corps.pseudo-plein-ecran {
    position: fixed;
    inset: 0;
    z-index: 1000;
}
.viewer-corps:fullscreen { width: 100vw; height: 100vh; }

.barre-flottante {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, calc(-100% + 18px));
    transition: transform .18s ease, opacity .18s ease;
    opacity: .55;
}
.barre-flottante[hidden] { display: none; }
.barre-flottante.visible { transform: translate(-50%, 0); opacity: 1; }

.barre-flottante-corps {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px 6px 14px;
    border: 1px solid var(--bordure);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: rgba(22, 29, 46, .94);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
    white-space: nowrap;
}

.flottante-titre { font-size: 12.5px; font-weight: 700; margin-right: 6px; }
.flottante-sep { width: 1px; align-self: stretch; margin: 2px 6px; background: var(--bordure); }

.barre-flottante-poignee {
    all: unset;
    cursor: pointer;
    width: 46px;
    height: 18px;
    display: grid;
    place-items: center;
    font-size: 11px;
    color: var(--texte-doux);
    background: rgba(22, 29, 46, .94);
    border: 1px solid var(--bordure);
    border-top: 0;
    border-radius: 0 0 9px 9px;
}
.barre-flottante.visible .barre-flottante-poignee { transform: rotate(180deg); border: 0; background: none; }

.btn-icone {
    all: unset;
    position: relative;
    box-sizing: border-box;
    cursor: pointer;
    min-width: 34px;
    height: 32px;
    padding: 0 8px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    font-size: 15px;
    color: var(--texte);
}
.btn-icone:hover { background: rgba(255, 255, 255, .08); }
.btn-icone.actif { background: var(--accent); color: #fff; }
.btn-icone:focus-visible { outline: 2px solid var(--accent); }

/* ---- Notifications ---- */
.toasts {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 26;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    max-width: min(420px, calc(100% - 28px));
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: rgba(22, 29, 46, .96);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    font-size: 12.5px;
    animation: toast-entree .18s ease-out;
}
.toast.avert { border-color: var(--avert); }
.toast.succes { border-color: var(--succes); }
.toast button { padding: 5px 10px; font-size: 12px; }
@keyframes toast-entree { from { opacity: 0; transform: translateY(8px); } }

/* ---- Dépôt de fichiers sur l'image ---- */
.zone-depot {
    position: absolute;
    inset: 0;
    z-index: 24;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(14, 19, 32, .72);
    pointer-events: none;
}
.zone-depot[hidden] { display: none; }
.zone-depot-cadre {
    padding: 34px 40px;
    border: 2px dashed var(--accent);
    border-radius: 16px;
    text-align: center;
    background: rgba(22, 29, 46, .9);
}
.zone-depot-icone { font-size: 34px; line-height: 1; margin-bottom: 10px; color: var(--accent); }
.zone-depot .titre { font-weight: 700; font-size: 15px; }
.zone-depot .sous { color: var(--texte-doux); font-size: 12.5px; margin-top: 4px; }

/* ---- Popup de transfert ---- */
.dialogue {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 1px solid var(--bordure);
    border-radius: 14px;
    background: var(--surface);
    color: var(--texte);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .6);
    overflow: auto;
}
.dialogue::backdrop { background: rgba(5, 8, 15, .6); backdrop-filter: blur(2px); }
.dialogue-tete {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 12px 18px;
    border-bottom: 1px solid var(--bordure);
    background: var(--surface);
}
.dialogue-tete h2 { margin: 0; font-size: 15px; }
.dialogue-section { padding: 14px 18px 16px; }
.dialogue-section + .dialogue-section { border-top: 1px solid var(--bordure); }
.dialogue-section h3 {
    margin: 0 0 10px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .9px;
    text-transform: uppercase;
    color: var(--texte-doux);
}
.dialogue .note { margin: 10px 0 0; font-size: 12px; color: var(--texte-doux); }
.dialogue h3 + .note { margin-top: 0; }

.depot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 14px;
    border: 1.5px dashed var(--bordure);
    border-radius: 12px;
    background: var(--fond);
    text-align: center;
    transition: border-color .12s, background .12s;
}
.depot.survol { border-color: var(--accent); background: rgba(59, 130, 246, .08); }
.depot-texte { color: var(--texte-doux); font-size: 13px; }
.depot-boutons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dialogue .btn, .toast .btn { width: auto; white-space: nowrap; }

.transfert {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--surface-2);
}
.transfert[hidden] { display: none; }
.transfert-ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.transfert-libelle { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.transfert-detail { color: var(--texte-doux); font-size: 12px; white-space: nowrap; }
.transfert-message { color: var(--texte-doux); font-size: 12px; }
.transfert-message.succes { color: var(--succes); }
.transfert-message.err { color: var(--danger); }
.transfert-actions { display: flex; gap: 8px; margin-left: auto; }
.transfert-actions .btn { padding: 7px 12px; font-size: 12.5px; }
.transfert-actions .btn[hidden] { display: none; }
.transfert-liste {
    margin: 8px 0 0;
    padding: 0 0 0 18px;
    max-height: 110px;
    overflow: auto;
    font-size: 12px;
    color: var(--texte-doux);
}
.transfert-liste:empty { display: none; }
.transfert progress {
    display: block;
    width: 100%;
    height: 6px;
    margin: 10px 0;
    appearance: none;
    border: 0;
    border-radius: 3px;
    overflow: hidden;
    background: var(--fond);
}
.transfert progress[hidden] { display: none; }
.transfert progress::-webkit-progress-bar { background: var(--fond); }
.transfert progress::-webkit-progress-value { background: var(--accent); }
.transfert progress::-moz-progress-bar { background: var(--accent); }

.dialogue textarea {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 9px 11px;
    resize: vertical;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: var(--fond);
    font: 12.5px/1.45 ui-monospace, Consolas, monospace;
    outline: none;
}
.dialogue textarea:focus { border-color: var(--accent); }

/* ---------------------------------------------------------------- tests --- */

.tests-corps { padding: 24px; max-width: 900px; margin: 0 auto; }
.tests-corps h1 { font-size: 20px; margin: 0 0 6px; }
.tests-corps .intro { color: var(--texte-doux); font-size: 13px; margin-bottom: 18px; }

table.vecteurs {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    overflow: hidden;
}

table.vecteurs th, table.vecteurs td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--bordure);
    font-size: 13px;
    vertical-align: top;
}

table.vecteurs th {
    background: var(--surface-2);
    font-size: 11px;
    letter-spacing: .7px;
    text-transform: uppercase;
    color: var(--texte-doux);
}

table.vecteurs code {
    display: block;
    word-break: break-all;
    font: 11.5px/1.5 ui-monospace, Consolas, monospace;
    color: var(--texte-doux);
}

.etat { font-weight: 800; white-space: nowrap; }
.etat.pass { color: var(--succes); }
.etat.fail { color: var(--danger); }
.etat.attente { color: var(--texte-doux); }

@media (max-width: 640px) {
    .barre .btn .etiquette { display: none; }
    .etiquette-barre { display: none; }
    .flottante-titre, .barre-flottante .route-barre, .flottante-sep { display: none; }
    .info-barre { display: none; }
    .info-barre.route-barre:not(:empty) { display: inline; } /* la latence reste utile sur téléphone */
}
