/* MyCam — styles communs : écran de la classe, téléphone, pages de connexion.
   Toutes les couleurs passent par les variables ci-dessous (thème « Nuit »). */
:root {
  --fond: #0d0f13;
  --surface: #161a21;
  --surface-2: #1f242d;
  --bord: #2c323d;
  --texte: #eef1f6;
  --texte-2: #a6aebb;
  --accent: #4d8dff;
  --accent-survol: #6a9fff;
  --sur-accent: #ffffff;
  --direct: #ff4545;
  --attente: #ffb020;
  --scene: #000000;
  --verre: rgba(18, 21, 27, 0.86);
  --verre-bord: rgba(255, 255, 255, 0.10);
  --degrade-haut: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  --voile: rgba(6, 7, 10, 0.84);
  --erreur-fond: rgba(255, 69, 69, 0.12);
  --erreur-bord: rgba(255, 69, 69, 0.35);
  --erreur-texte: #ffb3b3;
  --ombre: 0 18px 50px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
h1, h2 { line-height: 1.2; }
a { color: var(--accent); }
.icone { width: 22px; height: 22px; flex: none; display: block; }
.icone.grande { width: 34px; height: 34px; }

/* Marque */
.marque { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 19px; letter-spacing: 0.2px; }
.marque-centre { justify-content: center; }
.logo { width: 30px; height: 30px; flex: none; }
.logo-fond { fill: var(--accent); }
.logo-trait { fill: #fff; }
.logo-point { fill: var(--direct); }

/* Pages simples : connexion, mot de passe, téléphone non associé */
.centre { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.carte {
  width: 100%; max-width: 400px; padding: 28px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 20px; box-shadow: var(--ombre);
}
.carte h1 { margin: 20px 0 8px; font-size: 24px; }
.sous-titre { margin: 8px 0 22px; color: var(--texte-2); }
.info { color: var(--texte-2); font-size: 15px; }
.carte label { display: block; margin: 14px 0; font-size: 14px; color: var(--texte-2); }
.carte input:not([type=checkbox]):not([type=hidden]) {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  border: 1px solid var(--bord); border-radius: 12px; background: var(--fond); color: var(--texte);
  font: inherit; font-size: 16px;
}
.carte input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.carte input[readonly] { color: var(--texte-2); }
.carte label.case { display: flex; align-items: center; gap: 10px; color: var(--texte); font-size: 15px; }
.case input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.erreur {
  margin: 12px 0; padding: 10px 14px; border-radius: 12px; font-size: 15px;
  background: var(--erreur-fond); border: 1px solid var(--erreur-bord); color: var(--erreur-texte);
}

/* Boutons */
.bouton-principal {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin-top: 10px; padding: 13px 18px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--sur-accent); font-weight: 700; font-size: 16px; text-decoration: none;
}
.bouton-principal:hover { background: var(--accent-survol); }
.bouton-principal:disabled { opacity: 0.6; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px;
  border: 1px solid var(--bord); border-radius: 12px; background: var(--surface-2); color: var(--texte); font-weight: 600;
}
.bouton:hover { border-color: var(--accent); }
.bouton-discret {
  padding: 8px 12px; border: 1px solid var(--bord); border-radius: 10px;
  background: none; color: var(--texte-2); font-size: 14px;
}
.bouton-discret:hover { color: var(--texte); border-color: var(--texte-2); }
.bouton-discret.danger { color: var(--direct); border-color: var(--direct); }
.bouton-icone {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--bord); border-radius: 12px; background: var(--surface-2);
}
.petit { font-size: 14px; color: var(--texte-2); }

/* Étapes numérotées */
.etapes { list-style: none; counter-reset: etape; margin: 0 0 18px; padding: 0; }
.etapes li { counter-increment: etape; display: flex; align-items: flex-start; gap: 12px; margin: 12px 0; font-size: 17px; }
.etapes li::before {
  content: counter(etape); flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--bord);
  color: var(--accent); font-size: 14px; font-weight: 700;
}

/* Voiles et messages */
.voile { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 24px 16px; background: var(--voile); }
.voile-carte {
  width: 100%; max-width: 400px; padding: 26px; text-align: center;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 22px; box-shadow: var(--ombre); color: var(--texte);
}
.voile-carte h1, .voile-carte h2 { margin: 16px 0 8px; font-size: 22px; }
.voile-carte p { margin: 0 0 16px; color: var(--texte-2); }
.voile.erreur h1 { color: var(--erreur-texte); }
.toast {
  position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; text-align: center;
  background: var(--verre); border: 1px solid var(--verre-bord); color: var(--texte);
  font-size: 15px; font-weight: 600; box-shadow: var(--ombre); backdrop-filter: blur(10px);
}

/* Pastille et badge d'état */
.badge, .pastille {
  display: inline-flex; align-items: center; gap: 9px; border-radius: 999px; font-weight: 650;
  backdrop-filter: blur(8px); white-space: nowrap;
}
.point { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--direct); }
.direct .point, .pastille.attente .point { animation: battement 1.6s ease-in-out infinite; }
.pause .point, .pastille.attente .point { background: var(--attente); }
.fige .point { background: var(--accent); }
.pastille.eteinte .point { background: #8a919c; }
@keyframes battement { 50% { opacity: 0.25; } }

/* ===== Écran de la classe ===== */
body.ecran { overflow: hidden; height: 100vh; height: 100dvh; }
.scene { position: fixed; inset: 0; overflow: hidden; background: var(--scene); touch-action: none; user-select: none; -webkit-user-select: none; }
.media { position: absolute; left: 50%; top: 50%; display: block; max-width: none; transform-origin: 50% 50%; }
.media.cache { visibility: hidden; }
video.media { object-fit: fill; }
.scene.zoome { cursor: grab; }
.scene.glisse { cursor: grabbing; }

.barre-haut { position: fixed; top: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: center; gap: 12px; padding: 14px 18px; transition: opacity 0.35s; }
body.en-direct .barre-haut { background: var(--degrade-haut); }
.espace { flex: 1; }
.badge { padding: 7px 14px; font-size: 14px; background: var(--verre); border: 1px solid var(--verre-bord); }
.appareil-actuel { padding: 7px 12px; border-radius: 12px; font-size: 14px; color: var(--texte-2); background: var(--verre); border: 1px solid var(--verre-bord); }
.bouton-barre {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--verre-bord); background: var(--verre); color: var(--texte); font-size: 14px; font-weight: 600;
  backdrop-filter: blur(8px);
}
.bouton-barre:hover { border-color: var(--accent); }
.bouton-barre .icone { width: 18px; height: 18px; }
.deconnexion { margin: 0; }
.bandeau {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 7; margin: 0;
  padding: 8px 14px; border-radius: 12px; background: var(--attente); color: #1a1200; font-size: 14px; font-weight: 650;
}

.outils {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: stretch; gap: 2px; max-width: calc(100vw - 24px); overflow-x: auto;
  padding: 8px; border-radius: 20px; background: var(--verre); border: 1px solid var(--verre-bord);
  box-shadow: var(--ombre); backdrop-filter: blur(12px); transition: opacity 0.35s;
}
.outil {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 72px; padding: 9px 8px 7px;
  border: 0; border-radius: 13px; background: transparent; color: var(--texte-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.outil:hover { background: var(--surface-2); color: var(--texte); }
.outil.actif { background: var(--accent); color: var(--sur-accent); }
.outil.attente { animation: battement 1s ease-in-out infinite; }
.outil .si-fige, .outil.actif .si-direct, .outil .si-plein, body.plein .outil .si-normal { display: none; }
.outil.actif .si-fige, body.plein .outil .si-plein { display: block; }
.separateur { width: 1px; margin: 8px 4px; flex: none; background: var(--verre-bord); }
body.calme { cursor: none; }
body.calme .barre-haut, body.calme .outils { opacity: 0; pointer-events: none; }

.attente { position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; padding: 84px 20px 24px; overflow-y: auto; background: var(--fond); }
body.en-direct .attente { display: none; }
body.qr-modal .attente { display: grid; z-index: 8; background: var(--voile); }
.carte-qr {
  display: grid; grid-template-columns: auto minmax(0, 360px); align-items: center; gap: 40px; max-width: 920px; padding: 34px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 26px; box-shadow: var(--ombre);
}
.qr { width: min(54vh, 420px); aspect-ratio: 1 / 1; overflow: hidden; border-radius: 18px; background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }
.carte-qr h1 { margin: 0 0 18px; font-size: 32px; }
.carte-attente {
  max-width: 520px; padding: 36px; text-align: center;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 26px; box-shadow: var(--ombre);
}
.carte-attente h1 { margin: 16px 0 10px; font-size: 28px; }
.carte-attente p { margin: 0 0 22px; color: var(--texte-2); font-size: 17px; }
.anneau { display: inline-grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--bord); color: var(--accent); }
.anneau.actif { animation: battement 1.6s ease-in-out infinite; }

.panneau {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 9; width: min(420px, 100vw); padding: 20px 22px; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--bord); box-shadow: var(--ombre);
}
.panneau-tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panneau-tete h2 { margin: 0; font-size: 20px; }
.liste-appareils { list-style: none; display: grid; gap: 10px; margin: 16px 0; padding: 0; }
.liste-appareils li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--bord); }
.liste-appareils .infos { flex: 1; min-width: 0; display: grid; gap: 2px; }
.liste-appareils strong { font-size: 15px; }
.en-ligne { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--direct); }
.raccourcis { margin-top: 22px; }

@media (max-width: 780px) {
  .carte-qr { grid-template-columns: 1fr; gap: 22px; padding: 22px; }
  .qr { width: min(82vw, 380px); justify-self: center; }
  .carte-qr h1 { font-size: 26px; }
  .barre-haut { padding: 10px 12px; gap: 8px; }
  .bouton-barre span, .appareil-actuel { display: none; }
  .outil { min-width: 60px; }
}

/* ===== Téléphone ===== */
body.camera { overflow: hidden; height: 100vh; height: 100dvh; background: #000; }
#apercu { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#apercu.miroir { transform: scaleX(-1); }
.camera .haut {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: grid; justify-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px; pointer-events: none;
}
.pastille { padding: 8px 15px; font-size: 15px; color: #fff; background: rgba(0, 0, 0, 0.58); border: 1px solid rgba(255, 255, 255, 0.14); }
.aide-ecran { margin: 0; padding: 8px 12px; border-radius: 12px; font-size: 14px; text-align: center; color: #e9ecf1; background: rgba(0, 0, 0, 0.58); }
.camera .bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 14px 12px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
}
.commandes { display: flex; justify-content: space-around; gap: 6px; }
.commande { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 64px; padding: 0; border: 0; background: none; color: #fff; font-size: 12px; font-weight: 600; }
.commande .rond {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.2); backdrop-filter: blur(8px);
}
.commande.actif .rond { background: var(--accent); border-color: transparent; }
.commande:disabled { opacity: 0.45; }
.commande .si-pause, .commande.actif .si-direct { display: none; }
.commande.actif .si-pause { display: block; }
.bloc-zoom { display: flex; align-items: center; gap: 10px; margin: 0 10px 14px; color: #fff; }
.bloc-zoom input { flex: 1; accent-color: var(--accent); }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-height: 85vh; overflow-y: auto;
  padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: var(--surface); color: var(--texte); border-top: 1px solid var(--bord); border-radius: 22px 22px 0 0; box-shadow: var(--ombre);
}
.feuille h2 { margin: 0 0 4px; font-size: 20px; }
.etiquette { margin: 16px 0 8px; font-size: 14px; font-weight: 650; color: var(--texte-2); }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--fond); border: 1px solid var(--bord); }
.choix label { position: relative; }
.choix input { position: absolute; opacity: 0; pointer-events: none; }
.choix span { display: block; padding: 10px 8px; border-radius: 10px; text-align: center; font-size: 15px; font-weight: 650; color: var(--texte-2); }
.choix input:checked + span { background: var(--accent); color: var(--sur-accent); }
.choix input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Téléphone tenu à l'horizontale : commandes sur le côté droit */
@media (orientation: landscape) and (max-height: 540px) {
  .camera .haut { justify-items: start; padding-left: calc(env(safe-area-inset-left, 0px) + 16px); padding-right: 120px; }
  .camera .bas {
    left: auto; top: 0; display: flex; align-items: center;
    padding: 12px calc(env(safe-area-inset-right, 0px) + 12px) 12px 18px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.66), rgba(0, 0, 0, 0));
  }
  .commandes { flex-direction: column; justify-content: center; gap: 10px; }
  .commande .rond { width: 50px; height: 50px; }
  .bloc-zoom { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(50vw, 380px); margin: 0; }
  .toast { bottom: 64px; }
}
