/* ==========================================================================
   imprimerie.ma — Éditeur de design
   --------------------------------------------------------------------------
   Application plein écran : pas d'en-tête ni de pied de page du site, la
   place appartient au plan de travail. La disposition tient en quatre zones
   fixes et une seule qui s'étire — le canevas — de sorte qu'aucun panneau ne
   se déplace quand on change d'outil.

       ┌──────────────────── barre supérieure ────────────────────┐
       │ rail │  panneau   │        canevas        │ propriétés   │
       │ 76px │   300px    │        1fr            │    280px     │
       └──────────────────────────────────────────────────────────┘

   Les outils sont à gauche, comme partout ; les propriétés de l'objet
   sélectionné sont à droite, dans un panneau fixe plutôt que dans une barre
   flottante qui recouvre le dessin — c'est la principale différence avec le
   modèle de référence, et elle évite de masquer ce qu'on est en train de
   régler.
   ========================================================================== */

.ed {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: 76px 300px minmax(0, 1fr) 280px;
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas:
    "top  top   top    top"
    "rail panel scene  props";
  background: var(--ink-50); overflow: hidden;
}

/* --- Barre supérieure ---------------------------------------------------- */

.ed__top {
  grid-area: top; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--ink-900); color: #fff;
}
.ed__brand { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 290px; flex: none; }
.ed__brand img { height: 30px; width: auto; }
.ed__titles { min-width: 0; line-height: 1.2; }
.ed__titles b { display: block; font-size: .92rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.ed__titles span { display: block; font-size: .72rem; color: rgba(255,255,255,.62);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ed__tools {
  display: flex; align-items: center; gap: 3px; margin-inline: auto;
  min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.ed__tools::-webkit-scrollbar { display: none; }
.ed__zoomval {
  min-width: 52px; text-align: center; font-size: .78rem;
  color: rgba(255,255,255,.82); font-variant-numeric: tabular-nums;
}
.ed__facenom {
  font-size: .78rem; color: rgba(255,255,255,.82); padding: 0 2px;
  min-width: 44px; text-align: center;
}
.ed__sep { width: 1px; height: 24px; background: rgba(255,255,255,.16); margin: 0 6px; }

.ed__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; min-width: 34px; padding: 0 9px; border: 0; cursor: pointer;
  border-radius: 8px; background: transparent; color: #fff;
  font: inherit; font-size: .82rem;
  transition: background .15s ease, opacity .15s ease;
}
.ed__btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ed__btn:hover:not(:disabled) { background: rgba(255,255,255,.13); }
.ed__btn:disabled { opacity: .32; cursor: default; }
.ed__btn.is-on { background: rgba(255,255,255,.2); }
.ed__btn--go { background: var(--em-600); padding-inline: 16px; font-weight: 600; }
.ed__btn--go:hover:not(:disabled) { background: var(--em-500); }

/* --- Rail d'outils ------------------------------------------------------- */

.ed__rail {
  grid-area: rail; background: var(--ink-800); display: flex;
  flex-direction: column; gap: 2px; padding: 8px 6px; overflow-y: auto;
}
.ed__tool {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: rgba(255,255,255,.72);
  font: inherit; font-size: .68rem; letter-spacing: .01em;
  transition: background .15s ease, color .15s ease;
}
.ed__tool svg { width: 21px; height: 21px; stroke: currentColor; fill: none;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ed__tool:hover { background: rgba(255,255,255,.1); color: #fff; }
.ed__tool.is-on { background: var(--em-600); color: #fff; }

/* --- Panneau de l'outil actif -------------------------------------------- */

.ed__panel {
  grid-area: panel; background: #fff; border-right: 1px solid var(--ink-200);
  overflow-y: auto; padding: 16px 15px 26px;
}
.ed__panel h2 { margin: 0 0 4px; font-size: 1rem; }
.ed__panel .hint { margin: 0 0 16px; font-size: .78rem; color: var(--ink-500); }
.ed__group { margin-bottom: 22px; }
.ed__group > h3 {
  margin: 0 0 9px; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-500);
}

.ed__stack { display: grid; gap: 8px; }
.ed__row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed__row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.ed__add {
  display: block; width: 100%; padding: 11px 12px; cursor: pointer;
  border: 1px solid var(--ink-200); border-radius: 10px; background: #fff;
  text-align: left; font: inherit; color: var(--ink-900);
  transition: border-color .15s ease, background .15s ease;
}
.ed__add:hover { border-color: var(--em-400); background: var(--em-50); }
.ed__add b { display: block; }
.ed__add span { font-size: .76rem; color: var(--ink-500); }

.ed__shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ed__shape {
  aspect-ratio: 1; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--ink-200); border-radius: 10px; background: #fff;
  color: var(--ink-700);
}
.ed__shape svg { width: 22px; height: 22px; }
.ed__shape:hover { border-color: var(--em-400); background: var(--em-50); }

.ed__swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.ed__swatch {
  aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(0,0,0,.12);
}
.ed__swatch.is-on { box-shadow: 0 0 0 2px var(--em-600); }

.ed__drop {
  border: 2px dashed var(--ink-300); border-radius: 12px; padding: 22px 14px;
  text-align: center; color: var(--ink-500); font-size: .84rem; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.ed__drop:hover, .ed__drop.is-over { border-color: var(--em-500); background: var(--em-50); }

.ed__thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ed__thumbs button {
  aspect-ratio: 1; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--ink-200); border-radius: 9px; background: #fff;
}
.ed__thumbs img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ed__thumbs button:hover { border-color: var(--em-400); }

/* --- Scène --------------------------------------------------------------- */

.ed__scene {
  grid-area: scene; position: relative; overflow: auto;
  display: grid; place-items: center; padding: 28px;
  background:
    linear-gradient(45deg, #E7EDF5 25%, transparent 25%) 0 0/18px 18px,
    linear-gradient(-45deg, #E7EDF5 25%, transparent 25%) 0 9px/18px 18px,
    linear-gradient(45deg, transparent 75%, #E7EDF5 75%) 9px -9px/18px 18px,
    linear-gradient(-45deg, transparent 75%, #E7EDF5 75%) -9px 0/18px 18px,
    var(--ink-50);
}
.ed__paper {
  position: relative; background: #fff;
  box-shadow: 0 10px 40px rgba(22,41,79,.18), 0 2px 6px rgba(22,41,79,.10);
}
.ed__paper canvas { display: block; }

/* Repères de coupe et zone de sécurité, dessinés par-dessus le canevas.
   Ils ne font pas partie du dessin : le client ne peut ni les sélectionner
   ni les exporter par erreur. */
.ed__guides { position: absolute; inset: 0; pointer-events: none; }
.ed__guide { position: absolute; }
.ed__guide--bleed { border: 1px dashed rgba(214,25,125,.85); }
.ed__guide--safe  { border: 1px dashed rgba(30,144,210,.75); }
.ed__legend {
  position: absolute; left: 0; bottom: -26px; display: flex; gap: 16px;
  font-size: .72rem; color: var(--ink-500); white-space: nowrap;
}
.ed__legend i { display: inline-block; width: 14px; height: 0;
  border-top: 1px dashed; margin-right: 5px; vertical-align: middle; }

.ed__faces {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; display: flex; gap: 6px;
  background: #fff; border: 1px solid var(--ink-200); border-radius: 999px;
  padding: 4px; box-shadow: var(--shadow-sm);
}
.ed__face {
  border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: .8rem; padding: 5px 14px; border-radius: 999px; color: var(--ink-600);
}
.ed__face.is-on { background: var(--ink-900); color: #fff; }

/* --- Propriétés et calques ----------------------------------------------- */

.ed__props {
  grid-area: props; background: #fff; border-left: 1px solid var(--ink-200);
  overflow-y: auto; padding: 16px 15px 26px;
  display: flex; flex-direction: column; gap: 20px;
}
.ed__empty { color: var(--ink-500); font-size: .82rem; line-height: 1.6; }

.ed__field { display: grid; gap: 5px; }
.ed__field label { font-size: .74rem; color: var(--ink-500); }
.ed__field input[type="text"], .ed__field input[type="number"],
.ed__field select, .ed__field textarea {
  width: 100%; padding: 7px 9px; font: inherit; font-size: .85rem;
  border: 1px solid var(--ink-200); border-radius: 8px; background: #fff;
}
.ed__field input[type="color"] {
  width: 100%; height: 34px; padding: 2px; border: 1px solid var(--ink-200);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.ed__field input[type="range"] { width: 100%; }

.ed__seg { display: flex; gap: 4px; }
.ed__seg button {
  flex: 1; padding: 7px 0; cursor: pointer; font: inherit; font-size: .82rem;
  border: 1px solid var(--ink-200); border-radius: 8px; background: #fff;
  color: var(--ink-700);
}
.ed__seg button.is-on { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }

.ed__layers { display: grid; gap: 5px; }
.ed__layer {
  display: flex; align-items: center; gap: 4px; padding: 6px 7px; cursor: pointer;
  border: 1px solid var(--ink-200); border-radius: 9px; background: #fff;
  font-size: .8rem;
}
.ed__layer.is-on { border-color: var(--em-600); background: var(--em-50); }
.ed__layer span { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ed__layer button {
  border: 0; background: transparent; cursor: pointer; padding: 1px;
  color: var(--ink-400); line-height: 1; font-size: .78rem; flex: none;
}
.ed__layer button:hover { color: var(--ink-900); }

/* --- Divers -------------------------------------------------------------- */

.ed__toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink-900); color: #fff; padding: 11px 18px;
  border-radius: 10px; font-size: .86rem; box-shadow: var(--shadow);
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.ed__toast.is-on { opacity: 1; }
.ed__toast--warn { background: var(--or-600); }
.ed__toast--err  { background: var(--red-500); }

.ed__modal {
  position: fixed; inset: 0; background: rgba(22,41,79,.55); z-index: 70;
  display: grid; place-items: center; padding: 20px;
}
.ed__modal[hidden] { display: none; }
.ed__sheet {
  background: #fff; border-radius: 16px; padding: 22px; max-width: 560px;
  width: 100%; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg);
}
.ed__sheet h2 { margin: 0 0 10px; }
.ed__sheet kbd {
  display: inline-block; min-width: 22px; text-align: center; padding: 2px 6px;
  border: 1px solid var(--ink-200); border-bottom-width: 2px; border-radius: 5px;
  background: var(--ink-50); font: inherit; font-size: .78rem;
}
.ed__keys { width: 100%; border-collapse: collapse; font-size: .86rem; }
.ed__keys td { padding: 6px 4px; border-top: 1px solid var(--ink-100); }
.ed__keys td:last-child { text-align: right; white-space: nowrap; }

/* ==========================================================================
   Règles graduées
   --------------------------------------------------------------------------
   Le zéro est posé sur le trait de coupe, pas sur le bord du canevas : la
   seule mesure qui intéresse quelqu'un qui compose, c'est la distance au
   format fini. Les valeurs négatives sont donc le fond perdu, et cela se
   comprend sans explication.
   ========================================================================== */

.ed__rule { position: absolute; background: #fff; border: 1px solid var(--ink-200);
  color: var(--ink-500); font-size: 9px; overflow: hidden; }
.ed__rule--h { top: -21px; left: 0; height: 18px; }
.ed__rule--v { left: -21px; top: 0; width: 18px; }
.ed__rule i { position: absolute; background: var(--ink-300); }
.ed__rule--h i { top: 10px; width: 1px; height: 7px; }
.ed__rule--v i { left: 10px; height: 1px; width: 7px; }
.ed__rule b { position: absolute; font-weight: 500; line-height: 1; }
.ed__rule--h b { top: 2px; }
.ed__rule--v b { left: 1px; transform: translateY(-1px); }

/* --- Onglets, pastilles, mini-boutons ------------------------------------ */

.ed__tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--ink-200); }
.ed__tabs button {
  border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: .8rem; padding: 8px 10px; color: var(--ink-500);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.ed__tabs button.is-on { color: var(--ink-900); border-bottom-color: var(--em-600); font-weight: 600; }

.ed__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ed__chips button {
  border: 1px solid var(--ink-200); background: #fff; cursor: pointer; font: inherit;
  font-size: .78rem; padding: 5px 10px; border-radius: 999px; color: var(--ink-700);
}
.ed__chips button:hover { border-color: var(--em-600); color: var(--em-600); }

.ed__mini {
  border: 1px solid var(--ink-200); background: #fff; cursor: pointer; font: inherit;
  font-size: .76rem; padding: 7px 4px; border-radius: 8px; color: var(--ink-700);
}
.ed__mini:hover { border-color: var(--ink-900); }

.ed__check { display: flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--ink-700); }

/* --- Modèles ------------------------------------------------------------- */

.ed__gabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ed__gab {
  border: 1px solid var(--ink-200); background: #fff; border-radius: 10px;
  padding: 8px; cursor: pointer; font: inherit; display: grid; gap: 6px;
  justify-items: center; transition: border-color .15s ease, box-shadow .15s ease;
}
.ed__gab:hover { border-color: var(--em-600); box-shadow: var(--shadow-sm); }
.ed__gab span { font-size: .74rem; color: var(--ink-600); }
.ed__gabsvg { width: 100%; height: 96px; display: block; }

/* --- Décors -------------------------------------------------------------- */

.ed__shapes--orn { grid-template-columns: repeat(4, 1fr); }
.ed__orn { width: 100%; height: 26px; color: var(--ink-700); }

/* --- Contrôles avant impression ------------------------------------------ */

.ed__avert { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 8px; }
.ed__avert li {
  padding: 9px 12px 9px 34px; border-radius: 9px; font-size: .84rem;
  line-height: 1.5; position: relative;
}
.ed__avert li::before { position: absolute; left: 12px; top: 9px; font-weight: 700; }
.ed__avert li.is-warn { background: #FDF3E3; color: #7A4B00; }
.ed__avert li.is-warn::before { content: "!"; color: #B26A00; }
.ed__avert li.is-err  { background: #FCECEA; color: #8C2018; }
.ed__avert li.is-err::before { content: "×"; color: #C4372E; }
.ed__avert-err { background: #FCECEA; color: #8C2018; padding: 10px 12px;
  border-radius: 9px; font-size: .86rem; }
.ed__ok { background: #EAF6F1; color: #0B5B43; padding: 10px 12px;
  border-radius: 9px; font-size: .86rem; margin: 0 0 14px; }

.ed__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ed__actions .ed__btn { background: var(--ink-900); text-decoration: none; }
.ed__actions .ed__btn--go { background: var(--em-600); }

.ed__progress { height: 8px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.ed__progress i { display: block; height: 100%; background: var(--em-600);
  transition: width .4s ease; }

.ed__fini { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: start; }
.ed__fini img { width: 100%; border: 1px solid var(--ink-200); border-radius: 8px; }
.ed__fini p { margin: 0 0 8px; font-size: .86rem; line-height: 1.6; color: var(--ink-700); }

.ed__face--copie { color: var(--em-600); font-weight: 600; }
.ed__layer.is-locked span { color: var(--ink-400); font-style: italic; }

/* --- Écrans étroits ------------------------------------------------------
   Un éditeur de mise en page au doigt sur 375 px n'est pas raisonnable : on
   affiche un message plutôt qu'une interface inutilisable, et on renvoie
   vers le dépôt de fichier, qui lui fonctionne très bien sur téléphone. */
.ed__mobile { display: none; }
@media (max-width: 900px) {
  .ed { display: none; }
  .ed__mobile {
    display: grid; place-items: center; min-height: 100vh; padding: 32px 22px;
    text-align: center; gap: 14px;
  }
  .ed__mobile h1 { margin: 0; font-size: 1.3rem; }
  .ed__mobile p { margin: 0; color: var(--ink-500); max-width: 42ch; line-height: 1.6; }
  .ed__mesure { font-size: .8rem; color: var(--ink-400); }
}

.ed__check--gros {
  display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px;
  border: 1px solid var(--ink-200); border-radius: 10px; background: var(--ink-50);
  font-size: .84rem; line-height: 1.5; cursor: pointer;
}
.ed__actions .ed__btn:disabled { opacity: .45; cursor: not-allowed; }

/* La liste des polices : chaque nom écrit dans sa police, et de la place
   pour les voir. Une liste où tout est en Helvetica n'aide personne. */
.ed__police { font-size: .95rem; line-height: 1.6; }
.ed__police optgroup { font-family: var(--font); font-size: .74rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); }
.ed__police option { font-size: 1.02rem; padding: 3px 0; }

/* Grille de la banque de photos : trois colonnes, vignettes carrées
   recadrées au centre — on juge une photo sur son sujet, pas sur ses
   proportions, qui de toute façon changeront une fois posée. */
.ed__photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 14px; }
.ed__photos button {
  aspect-ratio: 1; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--ink-200); border-radius: 8px; background: var(--ink-50);
}
.ed__photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed__photos button:hover { border-color: var(--em-500); }
.ed__photos p { grid-column: 1 / -1; }

/* ==========================================================================
   PROXIPACK — TRACÉ DE DÉCOUPE
   --------------------------------------------------------------------------
   Le gabarit de la boîte, dessiné par-dessus le canevas, dans la même couche
   que les repères de fond perdu et de sécurité (.ed__guides, pointer-events
   none) : le client le voit, il ne peut pas le toucher, et il ne se retrouve
   pas dans son fichier d'impression.

   Le SVG est posé en `inset` du fond perdu : il occupe donc exactement le
   format fini, celui que l'atelier découpe.

   Les deux natures de trait sont distinguées comme sur un plan d'atelier —
   le rouge coupe, le bleu plie. C'est la convention que le client retrouvera
   sur le PDF du gabarit qu'il a téléchargé, et sur la boîte elle-même.
   ========================================================================== */
.ed__decoupe { position: absolute; }
.ed__decoupe svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ed__decoupe .pp-cut  { fill: none; stroke: rgba(214, 25, 125, .9); stroke-width: .35mm;
                        vector-effect: non-scaling-stroke; }
.ed__decoupe .pp-fold { fill: none; stroke: rgba(30, 144, 210, .8); stroke-width: .3mm;
                        stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
