/* ADEO — bons de prise en charge
   Direction : l'écran cite le document papier. Fond parchemin, bandeau ardoise
   (repris de FileMaker), en-têtes en serif comme sur le bon imprimé, libellés
   de champs en petites capitales alignés à droite comme dans l'ancienne base. */

:root {
  --ardoise: #33343a;
  --ardoise-clair: #4a4c55;
  --parchemin: #edeae0;
  --papier: #ffffff;
  --encre: #1f2124;
  --encre-douce: #6c6a63;
  --trait: #d6d1c4;
  --bleu: #2c6fa8;      /* bleu du logo ADEO */
  --ambre: #e8a12c;     /* jaune du logo ADEO */
  --vert: #3f7d54;
  --rouge: #b23b34;

  --rayon: 6px;
  --ombre: 0 1px 2px rgba(31, 33, 36, .08), 0 6px 18px rgba(31, 33, 36, .06);
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--parchemin);
  color: var(--encre);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body.connecte { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

a { color: var(--bleu); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- Navigation */
#nav {
  background: var(--ardoise);
  color: #f2f0ea;
  display: flex;
  flex-direction: column;
  padding: 18px 0 12px;
}
#nav .marque {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: .16em;
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
#nav .marque small {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #a8a49a;
  margin-top: 6px;
}
#nav button {
  all: unset;
  cursor: pointer;
  padding: 13px 20px;
  font-size: 15px;
  color: #ddd9d0;
  border-left: 3px solid transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav button[aria-current="page"] {
  background: rgba(255, 255, 255, .09);
  border-left-color: var(--ambre);
  color: #fff;
  font-weight: 600;
}
#nav .bas { margin-top: auto; padding: 12px 20px 0; font-size: 12.5px; color: #a8a49a; }
#nav .bas button { padding: 8px 0; font-size: 13px; color: var(--ambre); }

/* ------------------------------------------------------------- Contenu */
main { padding: 26px 30px 90px; max-width: 1180px; }

h1 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  margin: 0 0 4px;
}
h2 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  margin: 0 0 14px;
}
.sous-titre { color: var(--encre-douce); font-size: 14px; margin: 0 0 22px; }

.carte {
  background: var(--papier);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.barre {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.espace { flex: 1; }

/* ------------------------------------------------------------ Contrôles */
label.champ {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
label.champ > span {
  text-align: right;
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--encre-douce);
}
label.champ.large { grid-template-columns: 1fr; }
label.champ.large > span { text-align: left; }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* évite le zoom automatique sur iOS */
  color: var(--encre);
  background: #fff;
  border: 1px solid var(--trait);
  border-radius: 4px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--bleu);
  outline-offset: 1px;
}

.radios { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radios label, .case { display: flex; align-items: center; gap: 8px; font-size: 15px; min-height: 44px; }
.radios input, .case input { width: 20px; height: 20px; min-height: 0; }

.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }

button.bouton {
  all: unset;
  cursor: pointer;
  background: var(--ardoise);
  color: #fff;
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 14.5px;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
button.bouton:hover { background: var(--ardoise-clair); }
button.bouton.principal { background: var(--bleu); }
button.bouton.principal:hover { background: #245c8c; }
button.bouton.discret { background: transparent; color: var(--encre); border: 1px solid var(--trait); }
button.bouton.discret:hover { background: #f3f1ea; }
button.bouton.danger { background: transparent; color: var(--rouge); border: 1px solid #e2c8c6; }
button.bouton:disabled { opacity: .5; cursor: not-allowed; }

/* --------------------------------------------------------------- Listes */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--encre-douce);
  font-weight: 600;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--trait);
}
td { padding: 12px; border-bottom: 1px solid #ece9e0; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: #faf8f3; }

.etiquette {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--trait);
  background: #f7f5ee;
  white-space: nowrap;
}
.etiquette.encours { border-color: #e2cfa4; background: #fdf6e6; color: #8a6416; }
.etiquette.solde { border-color: #bcd8c4; background: #eef7f0; color: var(--vert); }
.etiquette.annule { border-color: #e2c8c6; background: #fbefee; color: var(--rouge); }

.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.chiffre { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 16px 18px; }
.chiffre b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 400; line-height: 1.1; }
.chiffre span { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-douce); }

/* ------------------------------------------------- Aperçu du bon papier */
.bon {
  border: 1.5px dashed var(--encre);
  background: #fff;
  padding: 18px 20px;
  font-size: 13px;
  line-height: 1.55;
}
.bon h3 {
  font-family: var(--serif);
  text-align: center;
  font-size: 21px;
  margin: 0 0 4px;
  letter-spacing: .01em;
}
.bon .mention { text-align: center; font-size: 11px; margin: 0; }
.bon .mention.forte { font-weight: 700; }
.bon hr { border: 0; border-top: 1px solid var(--encre); margin: 10px 0 12px; }
.bon .pied { text-align: center; font-size: 11px; margin-top: 16px; color: var(--encre-douce); }
.bon .vide { color: #b9b4a8; }

/* --------------------------------------------------------- Signature */
.signature { border: 1px solid var(--trait); border-radius: 4px; background: #fff; touch-action: none; width: 100%; max-width: 420px; height: 140px; display: block; }

/* -------------------------------------------------------- Notifications */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ardoise);
  color: #fff;
  padding: 13px 20px;
  border-radius: 6px;
  font-size: 14.5px;
  box-shadow: var(--ombre);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
  max-width: 90vw;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }
#toast.erreur { background: var(--rouge); }

/* -------------------------------------------------------------- Connexion */
#ecran-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
#ecran-login .carte { width: min(420px, 100%); }
#ecran-login .marque {
  font-family: var(--serif);
  font-size: 30px;
  letter-spacing: .18em;
  text-align: center;
  margin-bottom: 4px;
}
#ecran-login .marque + p { text-align: center; color: var(--encre-douce); font-size: 13.5px; margin: 0 0 24px; }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 860px) {
  body.connecte { grid-template-columns: 1fr; }
  #nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    flex-direction: row;
    padding: 0;
    overflow-x: auto;
  }
  #nav .marque, #nav .bas span { display: none; }
  #nav .bas { margin: 0; padding: 0; display: flex; }
  #nav button {
    border-left: 0;
    border-top: 3px solid transparent;
    padding: 12px 16px;
    white-space: nowrap;
    font-size: 13.5px;
  }
  #nav button[aria-current="page"] { border-top-color: var(--ambre); }
  main { padding: 18px 16px 96px; }
  label.champ { grid-template-columns: 1fr; gap: 4px; }
  label.champ > span { text-align: left; }
  .grille2 { grid-template-columns: 1fr; }
  table.compacte thead { display: none; }
  table.compacte tr { display: block; border-bottom: 1px solid var(--trait); padding: 6px 0; }
  table.compacte td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 4px; }
  table.compacte td::before { content: attr(data-col); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-douce); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  #nav, .barre, #toast { display: none !important; }
  body.connecte { display: block; }
  main { padding: 0; max-width: none; }
  .carte { border: 0; box-shadow: none; }
}
