/* Éditeur visuel — habillage de l'outil.
 *
 * Volontairement sobre et sans personnalité : c'est la page ÉDITÉE qui doit
 * attirer l'œil dans la toile, pas le châssis autour. Gris graphite, un seul
 * accent, aucune police externe — l'outil doit s'ouvrir instantanément et
 * fonctionner même hors ligne.
 */

:root {
  --fond: #14161a;
  --fond-clair: #1b1e24;
  --fond-plus-clair: #22262e;
  --trait: #2e333d;
  --texte: #e6e9ee;
  --texte-terne: #8b939f;
  --accent: #4fd1c5;
  --accent-sombre: #2c9d94;
  --alerte: #e0a24b;
  --erreur: #e06c6c;
  --ajout: #6cc47f;

  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--fond);
  color: var(--texte);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif;
  overflow: hidden;
}

.ecran {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.ecran[hidden] { display: none; }

/* --- Boutons ------------------------------------------------------------ */

.btn {
  background: var(--fond-plus-clair);
  color: var(--texte);
  border: 1px solid var(--trait);
  border-radius: 5px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent-sombre); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primaire {
  background: var(--accent);
  border-color: var(--accent);
  color: #10221f;
  font-weight: 600;
}
.btn-primaire:hover { background: var(--accent-sombre); border-color: var(--accent-sombre); }

.btn-discret { background: transparent; border-color: transparent; color: var(--texte-terne); }
.btn-discret:hover { color: var(--texte); border-color: var(--trait); }

.btn-bloc { display: block; width: 100%; margin-top: 0.6rem; }

/* --- Écran d'import ----------------------------------------------------- */

#ecran-import {
  overflow-y: auto;
  padding: 2.5rem clamp(1rem, 5vw, 4rem) 3rem;
}

.import-tete h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sous-titre { margin: 0.35rem 0 2rem; color: var(--texte-terne); }

.import-grille {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  flex: 1;
  min-height: 0;
}

.champ { display: flex; flex-direction: column; min-height: 0; }
.champ label {
  font-weight: 600;
  margin-bottom: 0.4rem;
  display: block;
}
.champ label em {
  display: block;
  font-style: normal;
  font-weight: 400;
  color: var(--texte-terne);
  font-size: 0.85em;
  margin-top: 0.15rem;
}
.champ label code {
  font-family: var(--mono);
  font-size: 0.95em;
  background: var(--fond-plus-clair);
  padding: 0 0.25rem;
  border-radius: 3px;
}

textarea, input[type="url"] {
  background: var(--fond-clair);
  color: var(--texte);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}
textarea:focus, input[type="url"]:focus {
  outline: none;
  border-color: var(--accent-sombre);
}
#saisie-html, #saisie-css { min-height: 42vh; }

.import-pied {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  margin-top: 1.25rem;
}
.champ-ligne { flex: 1; }
.champ-ligne input { width: 100%; }

.import-note {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--alerte);
  background: var(--fond-clair);
  color: var(--texte-terne);
  border-radius: 0 5px 5px 0;
}
.import-note strong { color: var(--texte); }

.reprise {
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
  background: var(--fond-clair);
  border: 1px solid var(--trait);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.reprise p { margin: 0; }
.reprise div { display: flex; gap: 0.5rem; }

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

.barre {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.8rem;
  background: var(--fond-clair);
  border-bottom: 1px solid var(--trait);
  flex: none;
}

.chemin {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--texte-terne);
  overflow-x: auto;
  scrollbar-width: none;
}
.chemin::-webkit-scrollbar { display: none; }
.chemin button {
  background: none;
  border: none;
  color: var(--texte-terne);
  font: inherit;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
}
.chemin button:hover { background: var(--fond-plus-clair); color: var(--texte); }
.chemin button:last-child { color: var(--accent); }
.chemin .separateur { color: var(--trait); }

.barre-outils { display: flex; align-items: center; gap: 0.4rem; }

.groupe-appareils {
  display: flex;
  background: var(--fond-plus-clair);
  border: 1px solid var(--trait);
  border-radius: 5px;
  overflow: hidden;
  margin-right: 0.4rem;
}
.groupe-appareils button {
  background: none;
  border: none;
  color: var(--texte-terne);
  font: inherit;
  font-size: 12px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.groupe-appareils button:hover { color: var(--texte); }
.groupe-appareils button.est-actif { background: var(--accent); color: #10221f; font-weight: 600; }

/* --- Atelier : calques / toile / styles --------------------------------- */

.atelier {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  flex: 1;
  min-height: 0;
}

.volet {
  display: flex;
  flex-direction: column;
  background: var(--fond-clair);
  min-height: 0;
}
.volet-gauche { border-right: 1px solid var(--trait); }
.volet-droit { border-left: 1px solid var(--trait); }

.volet-onglets {
  display: flex;
  border-bottom: 1px solid var(--trait);
  flex: none;
}
.volet-onglet {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--texte-terne);
  font: inherit;
  font-size: 12px;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}
.volet-onglet:hover { color: var(--texte); }
.volet-onglet.est-actif { color: var(--accent); border-bottom-color: var(--accent); }

.volet-corps {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.toile { background: #0e1013; min-height: 0; position: relative; }

.aide {
  margin: 0.6rem 0.75rem;
  color: var(--texte-terne);
  font-size: 12px;
  line-height: 1.5;
}
.aide strong { color: var(--texte); }
.aide-erreur { color: var(--erreur); }

#css-brut {
  width: calc(100% - 1.5rem);
  margin: 0 0.75rem;
  min-height: 180px;
}
#btn-appliquer-brut { width: calc(100% - 1.5rem); margin: 0.6rem 0.75rem; }

/* --- Alertes de l'éditeur ----------------------------------------------- */

.alertes {
  position: fixed;
  bottom: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 20;
  pointer-events: none;
  max-width: min(620px, 90vw);
}
.alerte {
  background: var(--fond-plus-clair);
  border: 1px solid var(--alerte);
  border-left-width: 3px;
  color: var(--texte);
  padding: 0.55rem 0.85rem;
  border-radius: 5px;
  font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.alerte code {
  font-family: var(--mono);
  color: var(--alerte);
}

/* --- Écran d'export ----------------------------------------------------- */

.export-onglets {
  display: flex;
  gap: 0.25rem;
  padding: 0.6rem 0.8rem 0;
  background: var(--fond-clair);
  border-bottom: 1px solid var(--trait);
  flex: none;
}
.export-onglet {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--texte-terne);
  font: inherit;
  padding: 0.5rem 0.9rem;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.export-onglet:hover { color: var(--texte); }
.export-onglet.est-actif {
  background: var(--fond);
  border-color: var(--trait);
  color: var(--texte);
  margin-bottom: -1px;
}
.pastille {
  background: var(--accent);
  color: #10221f;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  padding: 0.05rem 0.4rem;
  min-width: 1.2rem;
  text-align: center;
}

.export-corps { flex: 1; overflow-y: auto; min-height: 0; }
.export-vue { margin: 0; padding: 1.25rem clamp(1rem, 4vw, 2.5rem); }
.export-vue[hidden] { display: none; }

pre.export-vue code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
  display: block;
  overflow-x: auto;
}

/* Le différentiel : une carte par règle touchée. */
.diff-groupe { margin-bottom: 1.4rem; }
.diff-groupe > h2 {
  font-size: 0.75rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--texte-terne);
  margin: 0 0 0.6rem;
  font-weight: 600;
}
.diff-regle {
  background: var(--fond-clair);
  border: 1px solid var(--trait);
  border-radius: 7px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.55rem;
}
.diff-selecteur {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 13px;
  word-break: break-all;
}
.diff-media {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--alerte);
  margin-left: 0.5rem;
}
.diff-lignes { margin: 0.5rem 0 0; padding: 0; list-style: none; }
.diff-lignes li {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 0.12rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.diff-prop { color: var(--texte-terne); }
.diff-avant { color: var(--erreur); text-decoration: line-through; opacity: 0.75; }
.diff-fleche { color: var(--texte-terne); }
.diff-apres { color: var(--ajout); }
.diff-note {
  margin: 0.5rem 0 0;
  font-size: 12px;
  color: var(--alerte);
}
.diff-note code { font-family: var(--mono); }

.diff-vide {
  color: var(--texte-terne);
  padding: 2rem 0;
  text-align: center;
}

/* --- Toast -------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  background: var(--accent);
  color: #10221f;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.toast[hidden] { display: none; }

/* --- Retouches sur les panneaux de GrapesJS ----------------------------- */
/* Le thème par défaut est clair et jure avec le reste : on le repeint sans
   toucher à son balisage, qui peut changer d'une version à l'autre. */

.gjs-one-bg { background-color: var(--fond-clair); }
.gjs-two-color { color: var(--texte); }
.gjs-three-bg { background-color: var(--accent); color: #10221f; }
.gjs-four-color, .gjs-four-color-h:hover { color: var(--accent); }

.gjs-sm-sector-title,
.gjs-clm-tags .gjs-clm-header,
.gjs-layer-title { background: var(--fond-plus-clair); }

.gjs-field {
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 4px;
}
.gjs-field input, .gjs-field select { color: var(--texte); }

.gjs-sm-label, .gjs-clm-label { color: var(--texte-terne); }

.gjs-layer.gjs-selected .gjs-layer-title { background: var(--fond); }
.gjs-layer-title:hover { background: var(--fond); }

@media (max-width: 1100px) {
  .atelier { grid-template-columns: 190px 1fr 260px; }
  .import-grille { grid-template-columns: 1fr; }
  #saisie-html, #saisie-css { min-height: 30vh; }
}

/* --- La recette de récupération, sur l'écran d'import -------------------- */
/* Sans elle, il faut aller pêcher la feuille compilée dans l'onglet Réseau :
   c'est le seul point de la manœuvre qui n'est pas évident. */

.recette {
  background: var(--fond-clair);
  border: 1px solid var(--trait);
  border-radius: 7px;
  padding: 0.7rem 1rem;
  margin-bottom: 1.5rem;
}
.recette summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.recette summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.recette ol { margin: 0.8rem 0; padding-left: 1.2rem; color: var(--texte-terne); }
.recette li { margin-bottom: 0.3rem; }
.recette li strong { color: var(--texte); }
.recette kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--fond-plus-clair);
  border: 1px solid var(--trait);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}

.recette-code {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
}
.recette-code code {
  flex: 1;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--texte);
  word-break: break-all;
  user-select: all;
}
.btn-sm { padding: 0.3rem 0.6rem; font-size: 12px; }

.recette-note { margin: 0.7rem 0 0; color: var(--texte-terne); font-size: 12.5px; }

@media (max-width: 640px) {
  .recette-code { flex-direction: column; }
}

/* Le HTML d'un conteneur remanié, dans le différentiel. Décrire la structure
   en phrases perdait l'ordre, les suppressions et les textes réécrits : on
   rend donc le contenu réel. */
.diff-html {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.7rem;
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--texte);
  max-height: 22rem;
  overflow: auto;
  white-space: pre;
}

/* --- Barre de l'élément sélectionné ------------------------------------- */
/* Monter, descendre, sortir, dupliquer, supprimer : les gestes qu'on fait le
   plus souvent, en boutons plutôt qu'en glisser-déposer. */

.barre-element {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0.8rem;
  background: var(--fond-plus-clair);
  border-bottom: 1px solid var(--trait);
  flex: none;
}
.barre-element[hidden] { display: none; }
.barre-element-cible {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--texte-terne);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.barre-element-actions { display: flex; gap: 0.35rem; flex: none; }
.btn-danger { border-color: var(--erreur); color: var(--erreur); }
.btn-danger:hover { background: var(--erreur); color: var(--fond); border-color: var(--erreur); }

/* --- Panneau de style : plus lisible, plus aéré -------------------------- */

.gjs-sm-sector-title {
  padding: 0.55rem 0.7rem;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--trait);
}
.gjs-sm-properties { padding: 0.5rem 0.6rem; }
.gjs-sm-property { margin-bottom: 0.55rem; }
.gjs-sm-label {
  font-size: 11.5px;
  margin-bottom: 0.25rem;
  text-transform: none;
  letter-spacing: 0;
}

/* Le curseur : c'est lui qu'on tire, il doit être visible et confortable. */
.gjs-field-range input[type="range"] {
  accent-color: var(--accent);
  height: 18px;
}
.gjs-field-integer input, .gjs-field input[type="text"] { font-family: var(--mono); }

/* La pastille de couleur, assez grande pour être cliquée sans viser. */
.gjs-field-color-picker {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--trait);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

/* Les poignées de redimensionnement autour de l'élément sélectionné. */
.gjs-resizer-h {
  background: var(--accent);
  border: 1px solid var(--fond);
  border-radius: 2px;
  width: 9px;
  height: 9px;
}
.gjs-badge { background: var(--accent); color: #10221f; font-weight: 600; }

/* --- Briques à déposer -------------------------------------------------- */
.gjs-blocks-c { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; padding: 0 0.6rem 0.6rem; }
.gjs-block {
  background: var(--fond-plus-clair);
  border: 1px solid var(--trait);
  border-radius: 6px;
  color: var(--texte);
  font-size: 11.5px;
  min-height: 0;
  padding: 0.55rem 0.4rem;
  box-shadow: none;
}
.gjs-block:hover { border-color: var(--accent-sombre); color: var(--accent); }
.gjs-block__media { display: none; }
.gjs-block-category .gjs-title { background: var(--fond-plus-clair); font-size: 11px; }

/* Le mode placement libre, signalé sur son bouton. */
#btn-libre.est-actif {
  background: var(--alerte);
  border-color: var(--alerte);
  color: var(--fond);
  font-weight: 600;
}

/* --- Poignée de rotation ------------------------------------------------ */
/* GrapesJS sait redimensionner, pas faire tourner : celle-ci est à nous. Elle
   vit dans le document de l'outil et se place au-dessus de l'élément. */
.poignee-rotation {
  position: fixed;
  z-index: 40;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #10221f;
  border: 2px solid var(--fond);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.poignee-rotation[hidden] { display: none; }
.poignee-rotation:active { cursor: grabbing; }
.poignee-rotation svg { width: 15px; height: 15px; }

/* --- Aperçus des briques ------------------------------------------------ */
/* Un carré portant le nom de la brique oblige à imaginer le résultat. */
.gjs-block { display: grid; gap: 0.35rem; justify-items: center; }
.gjs-block__media {
  display: block;
  width: 100%;
  height: 40px;
  color: var(--texte-terne);
}
.gjs-block__media svg { width: auto; max-width: 100%; height: 40px; }
.gjs-block:hover .gjs-block__media { color: var(--accent); }
.gjs-block__label { font-size: 11px; line-height: 1.2; }
