/* Normbel Signature — papier blanc, encre bleu nuit, cire bordeaux. */

@font-face {
  font-family: "Spectral";
  src: url("/public/polices/spectral-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/public/polices/spectral-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/public/polices/spectral-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/public/polices/spectral-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/public/polices/hanken-grotesk-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  --papier: #ffffff;
  --encre: #14213d;
  --encre-douce: #24345a;
  --ardoise: #5b6478;
  --brume: #8a92a3;
  --filet: #e4e7ee;
  --filet-fort: #cdd2dd;
  --voile: #f6f7fa;
  --cire: #8a1c2b;
  --signe: #1e6b4f;
  --signe-voile: #e8f3ee;
  --attente: #9a5b00;
  --attente-voile: #fbf3e6;
  --erreur: #b42318;
  --erreur-voile: #fdf0ee;

  --serif: "Spectral", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --rayon: 6px;
  --largeur: 1120px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 400 16px/1.55 var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--encre); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--cire); }

:focus-visible { outline: 2px solid var(--encre); outline-offset: 3px; border-radius: 2px; }

h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.12; }
h2 { font-size: 21px; line-height: 1.3; }

/* ——— En-tête ——— */

.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 16px 28px; flex-wrap: wrap;
  max-width: var(--largeur); margin: 0 auto; padding: 22px 24px;
  border-bottom: 1px solid var(--filet);
}
.marque { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--encre); }
.marque:hover { color: var(--encre); }
.sceau { width: 34px; height: 34px; color: var(--cire); flex: none; }
.marque-nom { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.marque-produit { font-size: 15px; color: var(--ardoise); padding-left: 12px; border-left: 1px solid var(--filet-fort); line-height: 1.1; }

.navigation { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.navigation > a:not(.bouton) { text-decoration: none; color: var(--ardoise); font-weight: 500; padding: 6px 0; border-bottom: 1.5px solid transparent; }
.navigation > a:not(.bouton):hover { color: var(--encre); }
.navigation > a[aria-current="page"]:not(.bouton) { color: var(--encre); border-bottom-color: var(--encre); }
.navigation form { margin: 0; }

main { max-width: var(--largeur); margin: 0 auto; padding: 48px 24px 96px; }

/* ——— Éléments communs ——— */

.tete-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 32px; flex-wrap: wrap; margin-bottom: 40px; }
.tete-page > div:first-child { max-width: 680px; }
.chapeau { margin: 12px 0 0; font-size: 17px; color: var(--ardoise); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fil { margin: 0 0 14px; font-size: 14px; color: var(--brume); }
.fil a { color: var(--ardoise); text-decoration: none; }
.fil a:hover { color: var(--encre); text-decoration: underline; }
.note { color: var(--ardoise); font-size: 14px; margin: 16px 0 0; }
.facultatif { font-weight: 400; color: var(--brume); font-size: 13px; margin-left: 4px; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: var(--rayon);
  border: 1px solid var(--encre); background: var(--encre); color: #fff;
  font: 600 15px/1 var(--sans); letter-spacing: .005em; text-decoration: none; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.bouton:hover { background: var(--encre-douce); border-color: var(--encre-douce); color: #fff; }
.bouton.secondaire { background: var(--papier); color: var(--encre); border-color: var(--filet-fort); }
.bouton.secondaire:hover { border-color: var(--encre); background: var(--papier); color: var(--encre); }
.bouton.large { width: 100%; }
.bouton.petit { min-height: 36px; padding: 0 14px; font-size: 14px; }
.bouton:disabled { opacity: .45; cursor: not-allowed; }

.lien-discret, .lien-action, .lien-danger {
  background: none; border: 0; padding: 4px 0; font: 500 15px/1.4 var(--sans); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.lien-discret { color: var(--ardoise); text-decoration: none; }
.lien-discret:hover { color: var(--encre); text-decoration: underline; }
.lien-action { color: var(--encre); font-size: 14px; }
.lien-action:disabled { color: var(--brume); cursor: not-allowed; text-decoration: none; }
.lien-danger { color: var(--erreur); font-size: 14px; }

.avis {
  margin: 0 0 28px; padding: 14px 18px; border-radius: var(--rayon);
  background: var(--voile); border-left: 3px solid var(--encre); color: var(--encre);
}
.avis.erreur { background: var(--erreur-voile); border-left-color: var(--erreur); color: #7a1a12; }

.etat { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.etat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.etat.signe { color: var(--signe); }
.etat.attente { color: var(--attente); }
.etat.neutre { color: var(--ardoise); }
.date-envoi { font-size: 15px; color: var(--ardoise); }

/* Ligne de signature : la croix et le trait, motif de la marque. */
.ligne-signature { position: relative; border-bottom: 1px solid var(--filet-fort); height: 112px; max-width: 460px; }
.ligne-signature .croix { position: absolute; left: 0; bottom: 6px; font-family: var(--serif); font-size: 22px; color: var(--brume); line-height: 1; }
.ligne-signature .trait { position: absolute; left: 28px; bottom: 4px; width: calc(100% - 36px); height: auto; }
.ligne-signature .trait path {
  fill: none; stroke: var(--encre); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; animation: tracer 2.4s cubic-bezier(.45,.05,.25,1) .4s forwards;
}
.ligne-signature.petite { height: 44px; max-width: 220px; margin-bottom: 28px; }
@keyframes tracer { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .ligne-signature .trait path { animation: none; stroke-dashoffset: 0; }
  .bouton { transition: none; }
}

/* ——— Connexion ——— */

.page-connexion main { padding-top: 0; min-height: calc(100vh - 90px); display: grid; align-items: center; }
.page-connexion .accueil { padding: 48px 0 96px; }
.accueil { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 72px; align-items: center; }
.accueil-texte h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.06; max-width: 13em; }
.accueil-texte .chapeau { max-width: 34em; margin: 22px 0 44px; font-size: 18px; }
.accueil-formulaire { border-left: 1px solid var(--filet); padding-left: 56px; }
.accueil-formulaire h2 { margin-bottom: 24px; }
.champs { display: grid; gap: 20px; }

/* ——— Formulaires ——— */

label { display: grid; gap: 7px; font-weight: 600; font-size: 14px; color: var(--encre); }
input:not([type=checkbox]):not([type=file]), textarea {
  font: 400 16px/1.4 var(--sans); color: var(--encre);
  padding: 11px 13px; border: 1px solid var(--filet-fort); border-radius: var(--rayon); background: var(--papier); width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--brume); }
input:not([type=checkbox]):focus, textarea:focus { outline: none; border-color: var(--encre); box-shadow: 0 0 0 3px rgba(20,33,61,.12); }
input[readonly] { background: var(--voile); color: var(--ardoise); }
textarea { resize: vertical; }

.depot input[type=file] {
  font: 400 15px var(--sans); color: var(--ardoise); width: 100%;
  padding: 18px; border: 1px dashed var(--filet-fort); border-radius: var(--rayon); background: var(--voile); cursor: pointer;
}
.depot input[type=file]::file-selector-button {
  font: 600 14px var(--sans); color: var(--encre); background: var(--papier);
  border: 1px solid var(--filet-fort); border-radius: var(--rayon); padding: 8px 14px; margin-right: 14px; cursor: pointer;
}
.depot input[type=file]:hover { border-color: var(--encre); }

.formulaire { max-width: 920px; border-top: 1px solid var(--filet); }
.etape { border: 0; margin: 0; padding: 32px 0; border-bottom: 1px solid var(--filet); display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px 48px; }
.etape-tete { display: flex; gap: 14px; align-items: flex-start; padding: 0; float: left; width: 100%; }
.etape-numero {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--filet-fort);
  display: grid; place-items: center; font: 500 15px/1 var(--serif); color: var(--encre);
}
.etape-titre { display: block; font: 500 19px/1.3 var(--serif); }
.etape-aide { display: block; font-size: 14px; color: var(--ardoise); margin-top: 4px; }
.etape-corps { display: grid; gap: 18px; min-width: 0; }
.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.option {
  display: flex; align-items: flex-start; gap: 14px; font-weight: 400; font-size: 15px;
  padding: 14px 16px; border: 1px solid var(--filet); border-radius: var(--rayon); cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.option:hover { border-color: var(--filet-fort); }
.option:has(input:checked) { border-color: var(--encre); background: var(--voile); }
.option input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--encre); flex: none; }
.option strong { display: block; font-weight: 600; }
.option-aide { display: block; color: var(--ardoise); font-size: 14px; margin-top: 2px; }

.pied-formulaire { display: flex; justify-content: flex-end; gap: 12px; padding-top: 32px; flex-wrap: wrap; }

/* ——— Tableau de bord ——— */

.solde { min-width: 280px; max-width: 360px; padding-left: 24px; border-left: 1px solid var(--filet); }
.solde p { margin: 0; }
.solde-chiffre { font-size: 15px; color: var(--ardoise); }
.solde-chiffre strong { font: 500 34px/1 var(--serif); color: var(--encre); margin-right: 6px; font-variant-numeric: lining-nums; }
.solde-detail { font-size: 13px; color: var(--ardoise); margin-top: 8px !important; }
.solde form { margin-top: 10px; }

.registre { width: 100%; border-collapse: collapse; }
.registre th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--ardoise);
  padding: 0 16px 12px 0; border-bottom: 1px solid var(--filet-fort);
}
.registre td { padding: 20px 16px 20px 0; border-bottom: 1px solid var(--filet); vertical-align: top; }
.registre tbody tr { transition: background-color .15s ease; }
.registre tbody tr:hover { background: linear-gradient(90deg, var(--voile), transparent 85%); }
.col-titre a { font: 500 18px/1.35 var(--serif); text-decoration: none; }
.col-titre a:hover { text-decoration: underline; color: var(--encre); }
.sous-ligne { display: block; color: var(--ardoise); font-size: 14px; margin-top: 4px; }
.registre .col-date { text-align: right; white-space: nowrap; color: var(--ardoise); font-size: 14px; font-variant-numeric: tabular-nums; padding-right: 0 !important; }

.vide { padding: 32px 0 24px; max-width: 520px; border-top: 1px solid var(--filet); }
.vide h2 { font-size: 26px; }
.vide p { color: var(--ardoise); margin: 10px 0 26px; }

/* ——— Fiche d'un document ——— */

.fiche { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 64px; align-items: start; }
.fiche h2 { font-size: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--filet); }
.titre-historique { margin-top: 48px; }

.signataires { list-style: none; margin: 0; padding: 0; }
.signataire { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 18px; padding: 24px 0 8px; }
.signataire + .signataire::before {
  content: ""; position: absolute; left: 15.5px; top: -8px; height: 32px; width: 1px; background: var(--filet-fort);
}
.signataire-rang {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--filet-fort); background: var(--papier);
  display: grid; place-items: center; font: 500 15px/1 var(--serif); color: var(--encre);
}
.signataire.fait .signataire-rang { background: var(--signe); border-color: var(--signe); color: #fff; }
.signataire-rang svg { width: 16px; height: 16px; }
.signataire-corps p { margin: 0; }
.signataire-nom { font: 500 19px/1.3 var(--serif); }
.signataire-detail { color: var(--ardoise); font-size: 14px; margin-top: 2px !important; }
.signataire-statut { display: inline-block; margin-top: 10px !important; font-size: 14px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.signataire-statut.signe { color: var(--signe); background: var(--signe-voile); }
.signataire-statut.attente { color: var(--attente); background: var(--attente-voile); }
.lien-signature { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.lien-signature input { flex: 1 1 240px; font-size: 13px !important; padding: 8px 10px !important; }

.journal { list-style: none; margin: 0; padding: 0; }
.journal li { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--filet); font-size: 15px; }
.journal time { color: var(--ardoise); font-size: 14px; font-variant-numeric: tabular-nums; }

.fiche-actions { position: sticky; top: 24px; }
.fiche-actions .actions { display: grid; gap: 10px; margin-top: 20px; }
.fiche-actions .actions form { margin: 4px 0 0; }
.fiche-actions > form { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--filet); }

/* ——— Placement des signatures ——— */

.placement { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 48px; align-items: start; }
.placement-panneau { position: sticky; top: 24px; display: grid; gap: 28px; max-height: calc(100vh - 48px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; scrollbar-color: var(--filet-fort) transparent; }
.bloc-panneau { display: grid; gap: 12px; }
.placement-panneau h2 { font-size: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--filet); }
.aide-panneau { margin: -2px 0 0; font-size: 14px; color: var(--ardoise); line-height: 1.45; }
.choix { display: grid; gap: 8px; }
.choix-signataire {
  display: grid; gap: 3px; padding: 12px 14px 12px 16px; color: var(--encre);
  background: var(--papier); border: 1px solid var(--filet); border-left: 3px solid var(--couleur); border-radius: var(--rayon);
  transition: border-color .15s ease, background-color .15s ease;
}
.choix-signataire strong { font: 500 17px/1.3 var(--serif); }
.choix-signataire .discret { font-size: 13px; color: var(--ardoise); }
.choix-signataire.actif, .choix-signataire.en-attente { border-color: var(--couleur); background: var(--voile); box-shadow: inset 0 0 0 1px var(--couleur); }
.actions-carte { display: flex; gap: 16px; align-items: center; margin-top: 6px; }
.actions-carte .lien-discret, .champ .lien-discret { font-size: 13px; padding: 2px 0; text-decoration: underline; }
.outils { display: flex; flex-wrap: wrap; gap: 8px; }
.outils .en-attente { border-color: var(--encre); box-shadow: inset 0 0 0 1px var(--encre); }
.liste-champs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.liste-champs:empty { display: none; }
.champ { display: grid; gap: 8px; padding: 10px 12px 12px; border: 1px solid var(--filet); border-left: 3px solid #5b6478; border-radius: var(--rayon); }
.champ.actif { background: var(--voile); border-color: #5b6478; }
.champ-entete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.champ-type { font-size: 13px; color: var(--ardoise); }
.champ input[type=text] { min-height: 36px; padding: 6px 10px; font-size: 15px; }
.champ-obligatoire { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ardoise); font-weight: 400; }
.champ-obligatoire input { width: auto; min-height: 0; margin: 0; }
#envoi { margin-top: -4px; }

.pages-colonne { min-width: 0; }
.consigne {
  position: sticky; top: 0; z-index: 3; margin: 0 0 4px; padding: 10px 14px; text-align: center;
  font-size: 14px; color: var(--ardoise); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--filet);
  backdrop-filter: blur(4px);
}
.consigne.active { color: var(--encre); font-weight: 600; border-bottom-color: var(--encre); }
.pages { min-width: 0; padding: 4px 0 24px; }
.page {
  position: relative; margin: 0 auto 10px; background: #fff; max-width: 100%;
  border: 1px solid var(--filet); box-shadow: 0 1px 2px rgba(20,33,61,.04), 0 12px 32px -12px rgba(20,33,61,.14);
}
.en-pose .page { cursor: crosshair; }
.page canvas { display: block; }
.numero-page { text-align: center; color: var(--brume); font-size: 13px; margin: 22px 0 8px; font-variant-numeric: tabular-nums; }
.chargement { color: var(--ardoise); }

.cadre, .fantome {
  position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden;
  border: 1.5px solid var(--couleur); border-radius: 3px;
  background: color-mix(in srgb, var(--couleur) 9%, rgba(255,255,255,.7));
  color: var(--couleur); font: 500 13px/1.2 var(--serif); padding: 2px 6px;
}
.cadre { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.cadre:hover { background: color-mix(in srgb, var(--couleur) 14%, rgba(255,255,255,.7)); }
.cadre.en-mouvement { cursor: grabbing; box-shadow: 0 8px 24px -8px rgba(20,33,61,.35); z-index: 2; }
.cadre.actif, .cadre:focus-visible { outline: 2px solid var(--couleur); outline-offset: 2px; z-index: 1; }
.cadre:focus { outline: 2px solid var(--couleur); outline-offset: 2px; }
.cadre-texte, .cadre-date { justify-content: flex-start; font: 500 12px/1 var(--sans); padding: 0 6px; }
.cadre-texte .cadre-libelle, .cadre-date .cadre-libelle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cadre .cadre-libelle { pointer-events: none; }
.poignee {
  position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--couleur) 50%); border-bottom-right-radius: 2px;
}
.fantome { pointer-events: none; border-style: dashed; opacity: .85; }

/* ——— Erreur ——— */

.erreur-page { max-width: 560px; padding-top: 24px; }
.erreur-page .chapeau { margin-bottom: 28px; }

/* ——— Petits écrans ——— */

@media (max-width: 900px) {
  .accueil { grid-template-columns: 1fr; gap: 48px; }
  .accueil-formulaire { border-left: 0; padding-left: 0; border-top: 1px solid var(--filet); padding-top: 36px; }
  .etape { grid-template-columns: 1fr; }
  .fiche, .placement { grid-template-columns: 1fr; gap: 40px; }
  .fiche-actions, .placement-panneau { position: static; }
  .solde { border-left: 0; padding-left: 0; max-width: none; }
}

@media (max-width: 640px) {
  .entete { padding: 16px; }
  .marque-produit { display: none; }
  .navigation { gap: 16px; width: 100%; justify-content: space-between; }
  .navigation > a:not(.bouton) { display: none; }
  main { padding: 32px 16px 72px; }
  .page-connexion main { min-height: 0; }
  .page-connexion .accueil { padding: 32px 0 56px; }
  .tete-page { margin-bottom: 28px; }
  .grille { grid-template-columns: 1fr; }
  .registre thead { display: none; }
  .registre, .registre tbody, .registre tr, .registre td { display: block; width: 100%; }
  .registre tr { padding: 16px 0; border-bottom: 1px solid var(--filet); }
  .registre td { border: 0; padding: 3px 0; }
  .registre .col-date { text-align: left; }
  .journal li { grid-template-columns: 1fr; gap: 2px; }
  .pied-formulaire .bouton { flex: 1 1 100%; }
}
