/* Style « appli » des formulaires (choisi le 2026-10-29, style « cartes douces ») :
   champs pleins et arrondis, libellé dans le champ, choix en pastilles, boutons arrondis,
   bouton principal collé en bas de l'écran sur téléphone, retour en bouton rond.
   Hors des couches de Tailwind : ces règles l'emportent sur les classes des gabarits. */

:root {
  --champ-fond: #eaf1f8;
  --champ-fond-erreur: #fef2f2;
  --accent: #0369a1;        /* sky-700, couleur principale de l'app */
  --accent-fonce: #075985;  /* sky-800 */
}

/* --- Champs ---------------------------------------------------------------------------- */
:is(input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=number],
    input[type=date], input[type=month], input[type=password], input[type=search], input[type=url]),
select, textarea {
  background-color: var(--champ-fond);
  border: 1px solid transparent;
  border-radius: 12px;
  color: #0f172a;
  transition: background-color .15s, border-color .15s;
}
:is(input, select, textarea):focus {
  outline: none;
  background-color: #fff;
  border-color: var(--accent);
  box-shadow: none;
}
:is(input, select, textarea)::placeholder { color: #94a3b8; }
:is(input, select, textarea).border-red-400 { background-color: var(--champ-fond-erreur); border-color: #f87171; }

select:not([multiple]) {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23475569'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  background-size: 1.1rem;
  padding-right: 2.2rem;
}

/* Libellé dans le champ : un libellé (ou le <span> d'un <label>) suivi directement de son champ pleine largeur
   forme avec lui une seule carte arrondie, libellé en petit en haut. */
:is(label:not(.sr-only), label > span:first-child:not(.sr-only)):has(+ :is(input, select, textarea).w-full) {
  display: block;
  margin: 0;
  padding: .5rem .9rem 0;
  background-color: var(--champ-fond);
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  font-size: .75rem;
  font-weight: 500;
  color: var(--accent);
  transition: background-color .15s, border-color .15s;
}
:is(label:not(.sr-only), label > span:first-child:not(.sr-only)) + :is(input, select, textarea).w-full {
  display: block;
  width: 100%;
  border-top: 0;
  border-radius: 0 0 14px 14px;
  padding: .15rem .9rem .6rem;
}
:is(label:not(.sr-only), label > span:first-child:not(.sr-only)) + select.w-full:not([multiple]) { padding-right: 2.2rem; background-position: right .7rem top .2rem; }
/* (!important : la règle du libellé ci-dessus est plus spécifique) */
:is(label, label > span):has(+ .w-full.border-red-400) { background-color: var(--champ-fond-erreur) !important; border-color: #f87171 !important; color: #b91c1c !important; }
:is(label, label > span):has(+ .w-full:focus) { background-color: #fff !important; border-color: var(--accent) !important; color: var(--accent) !important; }

/* Cases à cocher et fichiers */
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1.15rem; height: 1.15rem; }
input[type=file]::file-selector-button {
  margin-right: .75rem; border: 0; border-radius: 999px; padding: .5rem 1rem;
  background: #e0f2fe; color: var(--accent-fonce); font-weight: 500; cursor: pointer;
}

/* Choix en pastilles : <div class="puces"><label><input type="radio"> Libellé</label>… */
.puces { display: flex; flex-wrap: wrap; gap: .5rem; }
.puces label {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid #bae6fd;
  background: #fff; color: var(--accent-fonce); font-size: .9rem; user-select: none;
}
.puces label:has(:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.puces label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.puces input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* --- Cartes et boutons -------------------------------------------------------------------- */
form section.border { border-color: transparent; border-radius: 20px; box-shadow: 0 1px 3px rgb(15 23 42 / .06); }

:is(button, a, summary).rounded-md:not(.modifiable-valeur) { border-radius: 999px; }
:is(button, a).rounded-md:active { transform: scale(.98); }

/* Bouton principal d'un formulaire : plus grand ; sur téléphone, toute la largeur et collé
   en bas de l'écran pendant la saisie. */
.bouton-principal { padding: .7rem 1.75rem !important; font-size: 1rem; }
@media (max-width: 639px) {
  .bouton-principal {
    position: sticky; bottom: calc(.75rem + env(safe-area-inset-bottom)); z-index: 10;
    width: 100%; min-height: 3.25rem;
    box-shadow: 0 6px 16px rgb(3 105 161 / .3);
  }
}

/* --- Retour : bouton rond à gauche du titre ------------------------------------------------ */
main > a[data-retour] {
  display: inline-flex; margin-bottom: .5rem; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; margin-right: .75rem; border-radius: 999px;
  background: #e0f2fe; color: var(--accent-fonce); font-size: 0; text-decoration: none;
}
main > a[data-retour]::before { content: "←"; font-size: 1.25rem; line-height: 1; }
main > a[data-retour]:hover { background: #bae6fd; }
/* À gauche du titre quand il le suit directement (titre seul, ou en-tête en flex) */
/* (placé en absolu dans la marge du titre : un flottant rétrécit les en-têtes en flex) */
main { position: relative; }
main > a[data-retour]:has(+ :is(h1, div.flex)) { position: absolute; left: 1rem; top: 1.25rem; margin: 0; }
@media (min-width: 1024px) { main > a[data-retour]:has(+ :is(h1, div.flex)) { top: 2rem; } }
main > a[data-retour] + :is(h1, div.flex) { margin-top: 0; min-height: 2.5rem; padding-left: 3.25rem; }
main > a[data-retour] + h1 { display: flex; align-items: center; }
