/* Boîte à outils et fenêtres d'outils (app/ui/fenetres.js).
   Plans : présentation 2000 · vidéo 2400 · brouillon 2500 · barre vidéo 2550 ·
   FENÊTRES 2600 · BOÎTE 2650 · visite 2700 · invite d'écran 2900 · laser 3000. */

#fenetres { position: fixed; inset: 0; z-index: 2600; pointer-events: none; }

.fenetre {
  position: absolute; pointer-events: auto;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--panel); box-shadow: var(--shadow);
}
.fenetre.devant { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
/* Pendant un glisser, un cadre avalerait le geste. */
#fenetres.en-geste .fen-cadre { pointer-events: none; }

.fen-barre {
  flex: none; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 4px 0 12px;
  background: var(--panel); color: var(--text); border-bottom: 1px solid var(--hairline);
  cursor: grab; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#fenetres.en-geste .fen-barre { cursor: grabbing; }
.fenetre.est-grande .fen-barre { cursor: default; }
.fen-emoji { flex: none; font-size: 17px; line-height: 1; }
.fen-titre { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fen-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 10px; border: 0; border-radius: 11px;
  background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.fen-btn:hover { background: var(--panel-2); }
.fen-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fen-btn svg { width: 17px; height: 17px; }

.fen-cadre { flex: 1; min-height: 0; width: 100%; border: 0; background: var(--bg); }

.fen-coin {
  position: absolute; right: 0; bottom: 0; width: 30px; height: 30px;
  cursor: nwse-resize; touch-action: none;
}
.fen-coin::after {
  content: ""; position: absolute; right: 5px; bottom: 5px; width: 11px; height: 11px;
  border-right: 2px solid var(--text-faint); border-bottom: 2px solid var(--text-faint); border-bottom-right-radius: 5px;
}
.fenetre.est-grande .fen-coin { display: none; }

#boite-outils { position: fixed; inset: 0; z-index: 2650; }
#boite-outils[hidden] { display: none; }
.bt-panneau {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  width: min(600px, calc(100vw - 16px));
  max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px);
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg);
  -webkit-user-select: none; user-select: none;
}
.bt-tete { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 18px; font-size: 16px; }
.bt-grille {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr)); gap: 8px;
  padding: 6px 12px 12px;
}
.bt-tuile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; min-width: 0; padding: 10px 6px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card); color: var(--text); font: inherit; text-align: center; cursor: pointer;
  touch-action: manipulation;
}
button.bt-tuile:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); }
.bt-tuile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bt-emoji { font-size: 27px; line-height: 1; }
.bt-titre { font-size: 13px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.bt-tuile.is-soon { background: var(--panel-2); color: var(--text-faint); cursor: default; }
.bt-tuile.is-soon .bt-emoji { filter: grayscale(1); opacity: .55; }
.bt-bientot { font-size: 10.5px; font-weight: 700; }
.bt-page {
  flex: none; min-height: 44px; border: 0; border-top: 1px solid var(--hairline); background: none;
  color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Réviser, Fournisseurs : le site dans une fenêtre, réduit à sa page (app/ui/cadre.js). */
html.site-en-fenetre #topbar,
html.site-en-fenetre #sidebar,
html.site-en-fenetre #sidebar-backdrop,
html.site-en-fenetre #sidebar-hotzone,
html.site-en-fenetre #tele-btn { display: none !important; }

@media (max-width: 540px) {
  .bt-grille { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bt-tuile { min-height: 84px; }
  .bt-titre { font-size: 12px; }
}
@media print { #fenetres, #boite-outils { display: none !important; } }
