/*
 * app.css — Styles de l'application de retouche.
 * Thème sombre (neutre, pour juger les couleurs), mise en page :
 *   - ordinateur : image à gauche, panneau de réglages à droite ;
 *   - téléphone (< 800 px) : image en haut, panneau en dessous.
 */

:root {
  --fond: #1b1c1f;
  --fond-scene: #111214;
  --panneau: #232428;
  --surface: #2d2f34;
  --surface-survol: #383a40;
  --bordure: #3a3c42;
  --texte: #e8e8ea;
  --texte-discret: #9a9ca3;
  --accent: #4f9cf5;
  --accent-texte: #fff;
  --danger: #e5645a;
  --rayon: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--bordure);
  flex: none;
}
.barre h1 { font-size: 18px; margin: 0; font-weight: 600; letter-spacing: 0.02em; }
.titre-appli { display: flex; align-items: center; gap: 8px; }
.titre-appli span { font-weight: 400; color: var(--texte-discret); }
@media (max-width: 420px) { .titre-appli span { display: none; } }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  cursor: pointer;
  user-select: none;
  text-align: center;
}
.bouton:hover:not(:disabled) { background: var(--surface-survol); }
.bouton:disabled { opacity: 0.45; cursor: default; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.principal:hover:not(:disabled) { filter: brightness(1.1); }
.bouton[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.large { width: 100%; margin: 6px 0; }
.bouton:focus-visible, .onglets button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lien { color: var(--accent); text-decoration: underline; cursor: pointer; }
.discret { color: var(--texte-discret); font-size: 13px; }
.rangee { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.rangee .bouton { flex: 1 1 auto; }

/* ---------- Mise en page principale ---------- */
.espace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--fond-scene);
}

.outils-scene {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  flex-wrap: wrap;
}
.outils-scene .info { margin-left: auto; color: var(--texte-discret); font-size: 13px; }

.zone-apercu {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  overflow: hidden;
}

.accueil {
  text-align: center;
  border: 2px dashed var(--bordure);
  border-radius: 14px;
  padding: 32px 24px;
  max-width: 460px;
}
.accueil-titre { font-size: 18px; font-weight: 600; margin-top: 0; }

.cadre-apercu {
  position: relative;
  touch-action: none;            /* on gère l'appui long et le séparateur nous-mêmes */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cadre-apercu canvas {
  display: block;
  width: 100%;
  height: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.separateur {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
  cursor: ew-resize;
}
.separateur .poignee {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.etiquette {
  position: absolute;
  top: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  pointer-events: none;
}
.etiquette.gauche { left: 10px; }
.etiquette.droite { right: 10px; }
.etiquette.centre { left: 50%; transform: translateX(-50%); }

.chargement {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(17, 18, 20, 0.6);
  font-size: 14px;
}
.rond {
  width: 18px;
  height: 18px;
  border: 2px solid var(--texte-discret);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tourner 0.8s linear infinite;
}
@keyframes tourner { to { transform: rotate(360deg); } }

/* Bande des photos chargées */
.pellicule {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  flex: none;
  scrollbar-width: thin;
}
.pellicule:empty { display: none; }
.miniature {
  position: relative;
  flex: none;
  width: 72px;
  height: 56px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: var(--surface) center / cover no-repeat;
  padding: 0;
  cursor: pointer;
}
.miniature.active { border-color: var(--accent); }
.miniature .retirer {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 13px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
}

.astuce {
  margin: 0;
  padding: 0 16px 8px;
  font-size: 12px;
  color: var(--texte-discret);
  text-align: center;
}

/* ---------- Panneau ---------- */
.panneau {
  width: 340px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panneau);
  border-left: 1px solid var(--bordure);
  min-height: 0;
}

.onglets {
  display: flex;
  border-bottom: 1px solid var(--bordure);
  flex: none;
}
.onglets button {
  flex: 1;
  padding: 11px 4px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--texte-discret);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.onglets button[aria-selected="true"] { color: var(--texte); border-bottom-color: var(--accent); }

.contenu-onglet {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.contenu-onglet h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--texte-discret);
  margin: 18px 0 6px;
}

/* Un curseur de réglage : libellé + valeur sur une ligne, curseur dessous */
.reglage {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 4px 0 10px;
}
.reglage label { font-size: 14px; }
.reglage output {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--texte-discret);
  cursor: pointer;
  padding: 0 2px;
}
.reglage output.modifie { color: var(--accent); }
.reglage input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 4px 0 0; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--bordure); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--bordure); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: var(--texte); border: none;
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--texte); border: none; }

/* Presets */
.liste-presets { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.liste-presets li { display: flex; gap: 6px; }
.liste-presets .appliquer { flex: 1; justify-content: flex-start; text-align: left; }
.liste-presets .actif .appliquer { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.liste-presets .icone { width: 38px; padding: 0; flex: none; }
.badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--fond);
  color: var(--texte-discret);
}

.procedure { padding-left: 20px; font-size: 13px; color: var(--texte-discret); }
.procedure li { margin-bottom: 4px; }
.lut-active { background: var(--surface); border-radius: var(--rayon); padding: 4px 12px; margin: 8px 0; }

.progression progress { width: 100%; height: 10px; accent-color: var(--accent); }
.progression p { margin: 4px 0; font-size: 13px; }
.moteur { margin-top: 24px; }

/* Voile affiché pendant un glisser-déposer */
.glisser {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 156, 245, 0.18);
  border: 3px dashed var(--accent);
  pointer-events: none;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  padding: 16px;
}

/* Messages temporaires */
.message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  z-index: 20;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--rayon);
  background: #3a3d44;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.message.visible { opacity: 1; transform: translate(-50%, 0); }
.message.erreur { background: #6b2a26; }

/* ---------- Téléphone ---------- */
@media (max-width: 800px) {
  .espace { flex-direction: column; }
  .scene { flex: none; height: 52vh; height: 52dvh; }
  .zone-apercu { padding: 4px 8px; }
  .outils-scene { padding: 6px 8px; }
  .outils-scene .bouton { min-height: 34px; padding: 4px 10px; font-size: 14px; }
  .pellicule { padding: 6px 8px; }
  .miniature { width: 56px; height: 44px; }
  .astuce { display: none; }
  .panneau { width: auto; flex: 1; border-left: none; border-top: 1px solid var(--bordure); }
  .barre { padding: 6px 12px; }
}
