/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #1a1a2e;
}

/* ============================================================
   ÉCRAN PRINCIPAL
   Flex colonne plein écran : top-bar (fixe) + content-zone (flex-grow)
============================================================ */
.screen {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   BARRE DU HAUT
   [ Flashez le QR Code ]           [ 🚨 Girophare ]
============================================================ */
.top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(2px, 2.5vh, 4px) clamp(14px, 4vw, 24px);
  background: rgba(10, 10, 40, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.page-title {
  color: #ffffff;
  font-size: clamp(1.05rem, 4.8vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ============================================================
   BOUTON GIROPHARE (haut droite)
============================================================ */
.btn-girophare {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
}

.btn-girophare:hover,
.btn-girophare:focus {
  transform: scale(1.12);
  outline: none;
}

.btn-girophare:active {
  transform: scale(0.93);
}

.icon-girophare {
  width:  clamp(36px, 9vw, 54px);
  height: clamp(36px, 9vw, 54px);
  object-fit: contain;
  display: block;
}

/* ============================================================
   ZONE DE CONTENU PRINCIPALE
   Flex colonne centrée, scroll vertical si besoin
============================================================ */
.content-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  /* Padding horizontal minimal : le scanner doit prendre toute la largeur */
  padding: clamp(2px, 1.5vh, 4px) 0;
  gap: clamp(2px, 1.5vh, 4px);
}

/* Le texte et l'image gardent leur marge latérale */
.indice-text,
.img-poste {
  padding-left:  clamp(2px, 4vw, 4px);
  padding-right: clamp(2px, 4vw, 4px);
}

/* ============================================================
   TEXTE INDICE
============================================================ */
.indice-text {
  flex-shrink: 0;
  color: #dde0f4;
  font-size: clamp(0.9rem, 3.8vw, 1.15rem);
  font-style: italic;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   IMAGE DU POSTE (pic1V.jpg, pic2V.jpg…)
============================================================ */
.img-poste {
  flex-shrink: 0;
  max-height: clamp(110px, 35vh, 310px);
  max-width:  min(62vw, 310px);
  width:  auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   WRAPPER DU SCANNER
   Prend tout l'espace vertical restant.
   La vidéo s'y affiche en cover, le canvas de traitement
   reste caché.
============================================================ */
.scanner-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 180px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6);
}

/* Flux vidéo de la caméra */
.scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Canvas de traitement jsQR — invisible */
.scanner-canvas {
  display: none;
}

/* ============================================================
   OVERLAY DE VISÉE — cadre carré + ligne de balayage
============================================================ */
.scanner-frame-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Cadre de visée (bords animés) */
.scanner-frame {
  position: relative;
  width:  clamp(140px, 58%, 230px);
  aspect-ratio: 1;
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  /* Assombrissement des zones hors cadre */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.38);
  animation: framePulse 2.4s ease-in-out infinite;
  overflow: hidden;
}

/* Ligne de balayage animée */
.scanner-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent 0%,
    #00e676 35%,
    #00e676 65%,
    transparent 100%
  );
  animation: scanLine 2s linear infinite;
}

/* Statut scanner (bas de la zone) */
.scanner-status {
  position: absolute;
  bottom: clamp(8px, 1.5vh, 14px);
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(0.72rem, 2.8vw, 0.88rem);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  padding: 0 10px;
}

/* ============================================================
   MODALE GÉNÉRIQUE (résultat scan + girophare)
============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.60);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #ffffff;
  border-radius: 14px;
  padding: clamp(20px, 6vw, 36px) clamp(22px, 7vw, 40px);
  max-width: min(92vw, 390px);
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: popIn 0.22s cubic-bezier(.22, .68, 0, 1.2) both;
}

.modal-titre {
  font-size: clamp(1rem, 4.5vw, 1.35rem);
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
  line-height: 1.3;
}

.modal-msg {
  font-size: clamp(0.88rem, 3.5vw, 1.05rem);
  color: #333355;
  line-height: 1.55;
  margin-bottom: 4px;
}

/* Bouton OK unique */
.modal-close {
  display: block;
  margin: 18px auto 0;
  background: #2979ff;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 11px 36px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.modal-close:hover,
.modal-close:focus {
  background: #1c54b2;
  outline: none;
}

.modal-close:active {
  transform: scale(0.96);
}

/* ============================================================
   MODALE GIROPHARE — champ saisie + deux boutons
============================================================ */
.input-code {
  display: block;
  margin: 12px auto;
  width: clamp(120px, 50%, 180px);
  padding: 10px 14px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  border: 2px solid #c0c0d0;
  border-radius: 8px;
  color: #1a1a2e;
  background: #f4f4ff;
  outline: none;
  transition: border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.input-code:focus {
  border-color: #2979ff;
}

.erreur-msg {
  min-height: 1.3em;
  font-size: 0.85rem;
  color: #d32f2f;
  margin-bottom: 2px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

.modal-btn-annuler {
  flex: 1;
  max-width: 130px;
  padding: 10px 0;
  border: 2px solid #c0c0d0;
  border-radius: 8px;
  background: #ffffff;
  color: #555575;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}

.modal-btn-annuler:hover,
.modal-btn-annuler:focus {
  background: #f0f0f8;
  outline: none;
}

.modal-btn-annuler:active { transform: scale(0.96); }

.modal-btn-valider {
  flex: 1;
  max-width: 130px;
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  background: #2979ff;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}

.modal-btn-valider:hover,
.modal-btn-valider:focus {
  background: #1c54b2;
  outline: none;
}

.modal-btn-valider:active { transform: scale(0.96); }

/* ============================================================
   OVERLAY DE TRANSITION (fondu de sortie)
============================================================ */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: scale(1);    }
}

/* Pulsation verte du cadre de visée */
@keyframes framePulse {
  0%, 100% { border-color: rgba(255, 255, 255, 0.85); }
  50%       { border-color: rgba(0, 230, 118, 0.95);  }
}

/* Ligne de balayage de bas en haut */
@keyframes scanLine {
  0%   { top: 6%;  opacity: 0; }
  8%   {           opacity: 1; }
  92%  {           opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

/* ============================================================
   RESPONSIVE — PAYSAGE MOBILE (hauteur ≤ 450px)
============================================================ */
@media (max-height: 450px) and (orientation: landscape) {
  .img-poste    { max-height: 80px; }
  .top-bar      { padding: 6px 14px; }
  .content-zone { gap: 5px; padding: 6px 14px; }
  .indice-text  { font-size: 0.78rem; }
}

/* ============================================================
   RESPONSIVE — TABLETTE (≥ 600px)
============================================================ */
@media (min-width: 600px) {
  .content-zone {
    max-width: 800px;
    margin: 0 auto;
  }
}
