/* Signature électronique : styles communs aux pages Préparer, Signer, Suivi et Vérifier. */

.etape {
  margin: 22px 0 0; background: var(--surface); border: 1px solid var(--ligne); border-radius: 20px;
  box-shadow: var(--ombre); padding: 20px;
}
.etape > h2 { margin: 0 0 4px; font-size: 1.12rem; display: flex; align-items: center; gap: 10px; }
.etape > h2 .num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--marine); color: #fff;
  display: grid; place-items: center; font-size: .9rem;
}
:root[data-theme="dark"] .etape > h2 .num { background: var(--orange); color: #21160a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .etape > h2 .num { background: var(--orange); color: #21160a; } }
.etape > .aide { color: var(--doux); font-size: .9rem; margin: 0 0 14px; }
.etape.fermee { opacity: .55; }
.etape.fermee > :not(h2) { display: none; }

.champ { display: grid; gap: 6px; }
.champ > span { font-weight: 600; font-size: .92rem; }
.champ input, .champ textarea, .champ select {
  font: inherit; font-size: 16px; color: var(--texte); background: var(--surface);
  border: 2px solid var(--ligne); border-radius: 12px; min-height: 48px; padding: 0 12px; width: 100%;
}
.champ textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
.champ input:focus, .champ textarea:focus, .champ select:focus { border-color: var(--orange); outline: none; }
.champ small { color: var(--doux); font-size: .8rem; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 620px) { .grille-2 { grid-template-columns: 1fr; } }
.case { display: flex; align-items: flex-start; gap: 10px; font-size: .94rem; cursor: pointer; line-height: 1.45; }
.case input { width: 20px; height: 20px; accent-color: var(--orange); flex: none; margin-top: 1px; }
.btn-lien { font: inherit; background: none; border: 0; padding: 0; color: var(--orange); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.actions-ligne { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 0; }
.actions-ligne .btn { min-height: 48px; padding: 0 22px; }
.message { margin: 12px 0 0; font-size: .92rem; min-height: 1.4em; }
.message.erreur { color: var(--rouge); font-weight: 600; }
.message.ok { color: var(--vert); font-weight: 600; }
.tourne { animation: tourne 1s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* Dépôt de fichier */
.depot {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 34px 18px; border: 2px dashed var(--ligne);
  border-radius: 16px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.depot:hover, .depot.survol { border-color: var(--orange); background: color-mix(in srgb, var(--orange) 6%, var(--surface-2)); }
.depot svg { color: var(--orange); }
.depot strong { font-size: 1.05rem; }
.depot small { color: var(--doux); }
.depot input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.fichier-choisi { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fichier-choisi .nom { font-weight: 700; word-break: break-all; }
.fichier-choisi small { color: var(--doux); }

/* Signataires */
.signataires { display: grid; gap: 10px; }
.signataire {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: end;
  padding: 12px; border: 1px solid var(--ligne); border-radius: 14px; background: var(--surface-2);
}
.signataire .pastille { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .88rem; margin-bottom: 9px; }
.signataire .retirer { width: 44px; height: 48px; border-radius: 12px; border: 1px solid var(--ligne); background: var(--surface); color: var(--doux); cursor: pointer; display: grid; place-items: center; }
.signataire .retirer:hover { color: var(--rouge); border-color: var(--rouge); }
@media (max-width: 620px) {
  .signataire { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; }
  .signataire .champ-email { grid-column: 1 / -1; }
  .signataire > :last-child { grid-row: 1; grid-column: 4; }
}

/* Barre d'outils des zones */
.outils-zones {
  position: sticky; top: 64px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px; margin: 0 0 12px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px); border: 1px solid var(--ligne); border-radius: 14px;
}
.outils-zones .qui { display: flex; flex-wrap: wrap; gap: 6px; }
.outils-zones .qui button {
  font: inherit; font-size: .85rem; font-weight: 700; border-radius: 999px; padding: 6px 12px 6px 8px; cursor: pointer;
  border: 2px solid var(--ligne); background: var(--surface); color: var(--texte); display: inline-flex; align-items: center; gap: 6px;
}
.outils-zones .qui button i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.outils-zones .qui button[aria-pressed="true"] { border-color: currentColor; }
.outils-zones .sep { width: 1px; align-self: stretch; background: var(--ligne); margin: 0 4px; }
.outils-zones .type button {
  font: inherit; font-size: .88rem; font-weight: 700; border-radius: 10px; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--ligne); background: var(--surface); color: var(--texte); display: inline-flex; align-items: center; gap: 6px;
}
.outils-zones .type button[aria-pressed="true"] { background: var(--marine); color: #fff; border-color: var(--marine); }
.outils-zones .consigne { flex-basis: 100%; font-size: .84rem; color: var(--doux); margin: 2px 2px 0; }

/* Pages du document */
.document { position: relative; }
.document .page {
  position: relative; width: 100%; margin: 0 0 16px; background: #fff; box-shadow: 0 2px 14px rgba(1, 18, 61, .16);
  border-radius: 4px; overflow: hidden; touch-action: pan-y;
}
.document .page canvas { display: block; width: 100%; height: 100%; }
.document .page .calque { position: absolute; inset: 0; }
.document .page .numero {
  position: absolute; right: 8px; bottom: 8px; font-size: .72rem; font-weight: 700; color: #55618a;
  background: rgba(255, 255, 255, .85); border-radius: 999px; padding: 1px 8px; pointer-events: none;
}
.document.placement .page { cursor: crosshair; }
.chargement { text-align: center; color: var(--doux); padding: 24px 0; }

.zone {
  position: absolute; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--c);
  font-size: clamp(9px, 1.6vw, 13px); font-weight: 800; line-height: 1.1; text-align: center;
  touch-action: none; user-select: none; -webkit-user-select: none; --p: 10px;
}
.zone > span:first-child { overflow: hidden; max-width: 100%; max-height: 100%; }
.zone.mobile { cursor: move; }
.zone.mobile:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }
.zone .x {
  position: absolute; top: -1px; right: -1px; width: 22px; height: 22px; border: 0; border-radius: 0 4px 0 6px;
  background: var(--c); color: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
}
/* Poignées de redimensionnement : un petit carré visible, une zone de prise plus large autour */
.zone .poignee {
  position: absolute; z-index: 2; width: var(--p); height: var(--p); box-sizing: border-box;
  background: #fff; border: 2px solid var(--c); border-radius: 3px; box-shadow: 0 1px 3px rgba(1, 18, 61, .25);
}
.zone .poignee::before { content: ""; position: absolute; inset: -8px; }
.zone .p-nw, .zone .p-w, .zone .p-sw { left: calc(var(--p) / -2 - 1px); }
.zone .p-se, .zone .p-e { right: calc(var(--p) / -2 - 1px); }
.zone .p-n, .zone .p-s { left: calc(50% - var(--p) / 2); }
.zone .p-nw, .zone .p-n { top: calc(var(--p) / -2 - 1px); }
.zone .p-sw, .zone .p-s, .zone .p-se { bottom: calc(var(--p) / -2 - 1px); }
.zone .p-w, .zone .p-e { top: calc(50% - var(--p) / 2); }
.zone .p-nw, .zone .p-se { cursor: nwse-resize; }
.zone .p-sw { cursor: nesw-resize; }
.zone .p-n, .zone .p-s { cursor: ns-resize; }
.zone .p-w, .zone .p-e { cursor: ew-resize; }
@media (pointer: coarse) { .zone { --p: 14px; } }
.zone.a-moi { cursor: pointer; animation: pulse 1.6s ease-in-out infinite; }
.zone.a-moi:hover { background: color-mix(in srgb, var(--c) 24%, transparent); }
.zone.remplie { animation: none; background: rgba(255, 255, 255, .5); border-style: dashed; }
.zone.autre { opacity: .55; }
.zone img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.zone .texte { font-family: Helvetica, Arial, sans-serif; color: #1a3fb3; font-weight: 400; white-space: nowrap; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent); } }

/* Panneau d'état (signer, suivi) */
.carte-etat { margin: 22px 0 0; background: var(--surface); border: 1px solid var(--ligne); border-radius: 20px; box-shadow: var(--ombre); padding: 20px; }
.carte-etat h2 { margin: 0 0 6px; font-size: 1.15rem; }
/* page du signataire : le bouton fixe qui mène au panneau de signature */
.barre-vers { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 60%, transparent); pointer-events: none; }
.barre-vers .btn { pointer-events: auto; box-shadow: 0 10px 26px rgba(0, 0, 0, .25); }
#panneau { scroll-margin-top: 92px; }
@media print { .barre-vers { display: none; } }
.carte-etat .de { color: var(--doux); margin: 0; }
.carte-etat blockquote { margin: 12px 0 0; padding: 10px 14px; border-left: 4px solid var(--orange); background: var(--surface-2); border-radius: 0 10px 10px 0; white-space: pre-line; }
.liste-signataires { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.liste-signataires li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--ligne);
  border-radius: 12px; background: var(--surface-2);
}
.liste-signataires .pastille { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; }
.liste-signataires .qui { flex: 1; min-width: 160px; }
.liste-signataires .qui small { display: block; color: var(--doux); }
.etat-badge { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface); color: var(--doux); border: 1px solid var(--ligne); white-space: nowrap; }
.etat-badge.signe, .etat-badge.termine { background: color-mix(in srgb, var(--vert) 15%, transparent); color: var(--vert); border-color: transparent; }
.etat-badge.refuse, .etat-badge.annule, .etat-badge.expire { background: color-mix(in srgb, var(--rouge) 13%, transparent); color: var(--rouge); border-color: transparent; }
.etat-badge.ouvert, .etat-badge.a-finaliser { background: color-mix(in srgb, var(--ambre) 15%, transparent); color: var(--ambre); border-color: transparent; }

.bandeau {
  margin: 22px 0 0; padding: 16px 18px; border-radius: 16px; display: flex; gap: 14px; align-items: flex-start;
  background: color-mix(in srgb, var(--vert) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--vert) 40%, var(--ligne));
}
.bandeau.alerte { background: color-mix(in srgb, var(--ambre) 12%, var(--surface)); border-color: color-mix(in srgb, var(--ambre) 40%, var(--ligne)); }
.bandeau.erreur { background: color-mix(in srgb, var(--rouge) 10%, var(--surface)); border-color: color-mix(in srgb, var(--rouge) 40%, var(--ligne)); }
.bandeau svg { flex: none; margin-top: 2px; }
.bandeau strong { display: block; font-size: 1.05rem; }
.bandeau p { margin: 4px 0 0; }
.bandeau .actions-ligne { margin-top: 12px; }

.empreinte { font: .8rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; color: var(--doux); }
.code-saisie input { font: 700 1.5rem/1 ui-monospace, Consolas, monospace; letter-spacing: .35em; text-align: center; max-width: 220px; }

/* Journal (suivi) */
.journal { list-style: none; margin: 12px 0 0; padding: 0; border-left: 2px solid var(--ligne); }
.journal li { position: relative; padding: 0 0 12px 18px; font-size: .9rem; }
.journal li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
.journal time { display: block; color: var(--doux); font-size: .8rem; }

/* Fenêtre de signature */
dialog.fenetre {
  width: min(640px, calc(100vw - 24px)); border: 0; border-radius: 20px; padding: 0; color: var(--texte); background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
dialog.fenetre::backdrop { background: rgba(1, 18, 61, .55); }
.fenetre .tete { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.fenetre .tete h2 { margin: 0; font-size: 1.1rem; }
.fenetre .fermer { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--ligne); background: var(--surface); color: var(--texte); cursor: pointer; display: grid; place-items: center; }
.fenetre .corps { padding: 14px 18px 18px; }
.onglets { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--ligne); border-radius: 999px; padding: 3px; margin: 0 0 12px; }
.onglets button { flex: 1; font: inherit; font-size: .9rem; font-weight: 700; border: 0; background: none; color: var(--doux); border-radius: 999px; padding: 8px 6px; cursor: pointer; }
.onglets button[aria-selected="true"] { background: var(--surface); color: var(--texte); box-shadow: 0 1px 4px rgba(1, 18, 61, .12); }
.pad {
  position: relative; width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 2px dashed #c8d0e2; border-radius: 14px;
  touch-action: none; overflow: hidden;
}
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pad .ligne-base { position: absolute; left: 8%; right: 8%; bottom: 26%; border-bottom: 1.5px solid #c8d0e2; pointer-events: none; }
.pad .indice { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #9aa6c4; pointer-events: none; font-size: .95rem; }
.apercu-ecrit { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 2px solid #c8d0e2; border-radius: 14px; display: block; }
.fenetre .pied-fenetre { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-top: 14px; }
.fenetre .pied-fenetre .btn { min-height: 46px; padding: 0 20px; }
.fenetre .note { color: var(--doux); font-size: .82rem; margin: 10px 0 0; }

.verif-resultat { margin: 22px 0 0; }
/* Explication du lien : jeton d'accès (bleu) et clé de chiffrement (orange) */
.carte-lien .lien-decoupe { margin: 14px 0 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--ligne); border-radius: 12px; font: .85rem/1.7 ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; color: var(--doux); }
.carte-lien .ld-jeton, .carte-lien .ld-cle { border-radius: 5px; padding: 1px 3px; font-weight: 700; }
.carte-lien .ld-jeton { background: color-mix(in srgb, #3b6fe0 16%, transparent); color: #3b6fe0; }
.carte-lien .ld-cle { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.lien-legende { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.lien-legende li { position: relative; padding-left: 22px; line-height: 1.55; }
.lien-legende li::before { content: ""; position: absolute; left: 0; top: .42em; width: 12px; height: 12px; border-radius: 4px; }
.lien-legende .ld-jeton-l::before { background: #3b6fe0; }
.lien-legende .ld-cle-l::before { background: var(--orange); }
/* Suppression des fichiers par l'expéditeur */
.btn-effacer { color: var(--rouge); border-color: color-mix(in srgb, var(--rouge) 45%, var(--ligne)); }
.btn-effacer:hover { background: color-mix(in srgb, var(--rouge) 10%, transparent); }
.conservation { margin-top: 12px !important; font-size: .9rem; }
/* Liens des signataires à transmettre soi-même */
.boutons-lien { display: flex; flex-wrap: wrap; gap: 6px; }
.boutons-lien .btn { min-height: 40px; padding: 0 14px; }
