/* ============================================================
   MOBILE — APERÇU GRAND + BARRE D'OUTILS FLOTTANTE
   ============================================================
   Retour utilisateur (09/10/2026) après test sur téléphone :
   « le visuel ne prends qu'une petite partie de l'écran sur
     mobile, l'idéal serait d'avoir des boutons flottants pour
     accéder aux différents outils »

   → ① L'aperçu passe de 26vh à ~40vh (et il est repliable)
   → ② BARRE D'OUTILS FLOTTANTE en bas : 6 accès directs aux
        outils (calques, illustrations, photos, texte, image,
        aperçu plein écran)
   ============================================================ */

/* ── APERÇU PLEIN ÉCRAN (conservé) ── */
.apercu-full {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.98);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.apercu-full.ouvert { display: flex; }
.apercu-full canvas,
.apercu-full img {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border-radius: 8px;
}
.apercu-full-barre {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.apercu-full-barre button {
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.apercu-full-barre button.fermer {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #172554;
}
.apercu-full-titre {
  color: #94a3b8;
  font-size: 12.5px;
  margin-bottom: 10px;
  text-align: center;
}

/* La barre d'outils et le bouton « agrandir » n'existent pas sur bureau */
.barre-outils { display: none; }
.apercu-rapide-btn { display: none; }
.preview-repli-btn { display: none; }

/* ═══════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {

  /* ── ① APERÇU GRAND ET COLLANT ── */
  .preview-panel {
    position: sticky !important;
    top: 0;
    z-index: 300;
    order: -1;
    background: #0f172a;
    border-bottom: 2px solid #f59e0b;
    padding: 5px 8px 7px !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  }

  /* ⬆️ AGRANDI : 26vh → 42vh */
  .preview-panel canvas {
    max-height: 42vh !important;
    width: auto !important;
    margin: 0 auto;
    display: block;
  }

  .preview-panel h2 {
    font-size: 12px !important;
    margin: 0 0 4px !important;
    text-align: center;
    color: #f59e0b;
  }

  .preview-panel .preview-actions,
  .preview-panel button {
    font-size: 11px !important;
    padding: 6px 9px !important;
  }

  /* Mode replié : l'aperçu devient une simple barre */
  .preview-panel.replie canvas { max-height: 90px !important; }
  .preview-panel.replie .preview-actions,
  .preview-panel.replie .preview-legende { display: none !important; }

  /* Bouton de repli, discret, en haut à droite de l'aperçu */
  .preview-repli-btn {
    display: block;
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 310;
    background: #1e293b;
    border: 1px solid #475569;
    color: #cbd5e1;
    border-radius: 8px;
    font-size: 15px;
    padding: 3px 9px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
  }

  .preview-panel { position: sticky !important; }
  .preview-panel > div, .preview-panel { position: relative; }

  /* ── ② BARRE D'OUTILS FLOTTANTE ── */
  .barre-outils {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 880;
    background: rgba(15, 23, 42, 0.97);
    border-top: 2px solid #f59e0b;
    padding: 6px 4px 8px;
    backdrop-filter: blur(8px);
    justify-content: space-around;
    align-items: flex-start;
  }
  .ot {
    flex: 1;
    background: none;
    border: none;
    color: #cbd5e1;
    font-family: inherit;
    font-size: 9.5px;
    line-height: 1.15;
    padding: 5px 2px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-radius: 8px;
    transition: background 0.15s;
    min-width: 0;
  }
  .ot:active { background: #1e293b; }
  .ot .ico { font-size: 20px; line-height: 1; }
  .ot.actif { color: #f59e0b; }
  .ot.actif .ico { filter: drop-shadow(0 0 5px rgba(245,158,11,.6)); }

  /* Dégage le bas de page pour que la barre ne recouvre rien */
  body { padding-bottom: 66px !important; }

  /* Le bouton d'aide se place AU-DESSUS de la barre d'outils */
  .aide-btn { bottom: 74px !important; right: 12px; width: 46px; height: 46px; font-size: 20px; }
  .aide-panneau {
    right: 8px; left: 8px; bottom: 128px;
    width: auto; max-height: calc(100vh - 160px);
  }

  /* L'ancien bouton flottant « agrandir » disparaît (repris par la barre) */
  .apercu-rapide-btn { display: none !important; }

  /* ── FORMULAIRE / OUTILS ── */
  .config-panel { width: 100% !important; }
  .app-main { grid-template-columns: 1fr !important; }

  .btn-action {
    flex: 1 1 46%;
    min-width: 0;
    font-size: 12px;
    padding: 11px 8px;
  }

  .calques-liste { max-height: 240px; }
  .visuels-grid { max-height: 240px; }
  .visuels-grid.mode-tout { max-height: 330px; }

  /* Anti-zoom iOS */
  .aide-pied input, .elem-textarea, .input, select { font-size: 16px !important; }

  /* Surlignage temporaire quand on saute vers une section */
  .surligne {
    animation: flash-section 1.6s ease-out;
  }
  @keyframes flash-section {
    0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.9); }
    60%  { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  }
}

/* ── TRÈS PETITS ÉCRANS ── */
@media (max-width: 420px) {
  .preview-panel canvas { max-height: 36vh !important; }
  .btn-action { flex: 1 1 100%; }
  .vcat { font-size: 10.5px; padding: 5px 7px; }
  .visuels-grid { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
  .ot { font-size: 8.5px; }
  .ot .ico { font-size: 18px; }
}
