/* Interface du pharmacien — jetons de DESIGN.md (« L'enseigne fiable »). Pas d'ombre portée. */

:root {
  --officine-green: #0f6e56;
  --officine-green-deep: #085041;
  --night-green: #1d3b34;
  --sesame-brown: #8c5a1a;
  --mint-wash: #e8f1ec;
  --sage-mist: #cfe0d8;
  --amber-wait: #ba7517;
  --amber-wash: #faeeda;
  --amber-ink: #633806;
  --alert-red: #a32d2d;
  --alert-wash: #fcebeb;
  --alert-ink: #791f1f;
  --paper: #f6f4ee;
  --offline-wash: #eceae4;
  --surface: #ffffff;
  --hairline: #e3dfd3;
  --stone: #8a8578;
  --graphite: #5f5e5a;
  --ink: #1d1d1b;
  --titre: 'Sora Variable', 'Sora', sans-serif;
  --texte: 'Manrope Variable', 'Manrope', system-ui, sans-serif;
  --arabe: 'Cairo Variable', 'Cairo', sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 14px/1.4 var(--texte);
}

/* Titres sur deux lignes : coupure équilibrée ; paragraphes : pas de mot seul en dernière ligne. */
h1,
h2,
h3 {
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

/* Mesure de lecture : les textes d'aide ne courent pas sur toute la largeur d'un panneau de bureau. */
.panneau p,
.intro {
  max-width: 70ch;
}

a {
  color: var(--officine-green-deep);
}

:focus-visible {
  outline: 3px solid var(--officine-green);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Lien d'évitement : invisible jusqu'au premier Tab, puis premier arrêt de la page. */
.lien-evitement {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--officine-green-deep);
  font: 600 14px var(--texte);
  transform: translateY(-200%);
}

.lien-evitement:focus {
  transform: none;
}

.contenu:focus {
  outline: none;
}

/* ── Charpente : colonne de navigation (bureau), barre du haut et onglets (téléphone) ── */
.charpente {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.navigation {
  background: var(--night-green);
  color: var(--sage-mist);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.navigation .logo {
  display: block;
  padding: 4px 12px 20px;
}

.navigation .logo img {
  height: 30px;
}

.navigation a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--sage-mist);
  text-decoration: none;
}

.navigation :focus-visible {
  outline-color: var(--surface);
}

.navigation a[aria-current='page'] {
  background: var(--officine-green);
  color: var(--surface);
}

/* Liens réservés à l'administration, séparés des rubriques. */
.navigation-admin {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(207, 224, 216, 0.25);
}

.navigation .pied {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(207, 224, 216, 0.25);
}

.navigation .pied form {
  margin-top: 8px;
}

.navigation .pied button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--sage-mist);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
}

.contenu {
  padding: 32px 40px;
  max-width: 960px;
}

/* Attribution des données OpenStreetMap (FR-Q05), en bas de chaque page. */
.mentions {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 0.8125rem;
  color: var(--graphite);
}

.mentions a {
  color: inherit;
}

.barre-haut,
.onglets {
  display: none;
}

h1 {
  font: 600 26px/1.2 var(--titre);
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}

h2 {
  font: 600 17px/1.3 var(--titre);
  margin: 0 0 12px;
}

p {
  margin: 0 0 12px;
}

.discret {
  color: var(--graphite);
}

/* Espacements verticaux (remplacent les style="margin-…" en ligne). */
.mt-12 {
  margin-top: 12px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-24 {
  margin-bottom: 24px;
}

.icone-appli {
  border-radius: 7px;
  border: 1px solid var(--hairline);
}

.navigation .pied .discret {
  color: inherit;
}

/* ── Panneaux ── */
.panneau {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.ligne-etat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--hairline);
}

.ligne-etat:first-of-type {
  border-top: 0;
}

.ligne-etat > .pastille {
  flex: none;
  align-self: center;
}

/* Ligne « texte + pastille » : sur téléphone la pastille passe sous le texte au lieu de l'écraser
   ou de sortir de l'écran. */
.ligne-etat.avec-pastille {
  flex-wrap: wrap;
  align-items: center;
}

.ligne-etat.avec-pastille > :first-child {
  flex: 1 1 14rem;
  min-width: 0;
}

.ligne-etat.avec-pastille > .pastille {
  max-width: 100%;
}

/* Choix de la méthode de double authentification (FR-039), dans l'ordre recommandé. */
.choix-methodes {
  margin: 0;
  padding-left: 22px;
}

.choix-methodes li {
  padding: 8px 0;
}

/* ── Pastilles d'état (toujours avec leur libellé) ── */
.pastille {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font: 600 13px/1.4 var(--texte);
}

.pastille::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pastille.ok {
  background: var(--mint-wash);
  color: var(--officine-green-deep);
}

.pastille.attente {
  background: var(--amber-wash);
  color: var(--amber-ink);
}

.pastille.neutre {
  background: var(--offline-wash);
  color: var(--graphite);
}

.pastille.alerte {
  background: var(--alert-wash);
  color: var(--alert-ink);
}

/* ── Encadrés ── */
.encadre {
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px solid;
}

.encadre.info,
.encadre.succes {
  background: var(--mint-wash);
  border-color: var(--officine-green);
  color: var(--officine-green-deep);
}

.encadre.attente {
  background: var(--amber-wash);
  border-color: var(--amber-wait);
  color: var(--amber-ink);
}

.encadre.erreur {
  background: var(--alert-wash);
  border-color: var(--alert-red);
  color: var(--alert-ink);
}

/* ── Formulaires ── */
.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

label,
.libelle {
  font: 600 13px/1.4 var(--texte);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='tel'],
input[type='date'],
input[type='search'],
input:not([type]),
select,
textarea {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--stone);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 500 14px var(--texte);
  width: 100%;
  max-width: 420px;
}

/* Mot de passe avec bouton « Afficher » (œil), zone de toucher de 44 px. */
.champ-mdp {
  position: relative;
  width: 100%;
  max-width: 420px;
}

.champ-mdp input {
  padding-right: 48px;
}

.afficher-mdp {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--graphite);
  cursor: pointer;
}

.afficher-mdp:hover {
  color: var(--ink);
}

.afficher-mdp svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.afficher-mdp .oeil-barre,
.afficher-mdp[aria-pressed='true'] .oeil-ouvert {
  display: none;
}

.afficher-mdp[aria-pressed='true'] .oeil-barre {
  display: block;
}

.lien-secondaire {
  margin: -8px 0 16px;
  font-size: 13px;
}

.pied-formulaire {
  margin-top: 20px;
}

input[aria-invalid='true'] {
  border-color: var(--alert-red);
  background: var(--alert-wash);
}

input.code {
  height: 48px;
  font: 17px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1px;
  max-width: 240px;
}

[lang='ar'],
input[dir='rtl'] {
  font-family: var(--arabe);
}

.aide {
  font-size: 13px;
  color: var(--graphite);
}

.message-erreur {
  font-size: 13px;
  color: var(--alert-ink);
}

/* ── Boutons : une seule action principale par zone ── */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 22px;
  border-radius: 10px;
  border: 1px solid var(--officine-green);
  background: var(--officine-green);
  color: var(--surface);
  font: 600 14px var(--texte);
  text-decoration: none;
  cursor: pointer;
}

.bouton:hover {
  background: var(--officine-green-deep);
  border-color: var(--officine-green-deep);
}

.bouton.secondaire {
  background: var(--surface);
  border-color: var(--stone);
  color: var(--ink);
  padding: 0 18px;
}

.bouton.secondaire:hover {
  background: var(--paper);
}

.bouton.danger {
  background: var(--surface);
  border-color: var(--alert-red);
  color: var(--alert-ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* ── Sécurité ── */
.surtitre {
  font: 700 13px var(--texte);
  color: var(--officine-green);
  margin-bottom: 4px;
}

.codes-secours {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  max-width: 420px;
}

.codes-secours li {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 12px;
  font: 17px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1px;
  text-align: center;
}

/* ── Pages hors connexion (connexion, invitation) ── */
.page-seule {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 16px;
}

.page-seule .logo img {
  height: 40px;
  margin-bottom: 28px;
}

.page-seule .panneau {
  width: 100%;
  max-width: 440px;
  padding: 24px;
}

/* ── Application installable et notifications (DESIGN.md, « Install and notifications ») ── */
.bandeau-installation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font: 600 14px/1.4 var(--texte);
}

.bandeau-installation span {
  flex: 1 1 180px;
}

.bandeau-installation .bouton {
  height: 44px;
  width: auto;
}

.lien {
  background: none;
  border: 0;
  padding: 0 4px;
  min-height: 44px;
  color: var(--officine-green-deep);
  font: 600 14px var(--texte);
  text-decoration: underline;
  cursor: pointer;
}

/* Page gardée affichée hors ligne : contenu en lecture seule. */
.lecture-seule {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.interrupteur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
}

.interrupteur:first-of-type {
  border-top: 0;
}

.interrupteur .titre-choix {
  display: block;
  font: 700 16px/1.3 var(--texte);
}

.interrupteur .explication {
  display: block;
  font: 500 13px/1.4 var(--texte);
  color: var(--graphite);
}

.interrupteur input {
  appearance: none;
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 8px 4px;
  border-radius: 999px;
  background: var(--stone);
  cursor: pointer;
}

.interrupteur input::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s ease-out;
}

.interrupteur input:checked {
  background: var(--officine-green);
}

.interrupteur input:checked::before {
  transform: translateX(20px);
}

.interrupteur input:disabled {
  opacity: 0.5;
}

.etapes {
  list-style: none;
  counter-reset: etape;
  padding: 0;
  margin: 0 0 12px;
}

.etapes li {
  counter-increment: etape;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 4px 12px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
}

.etapes li:first-child {
  border-top: 0;
}

.etapes li::before {
  content: counter(etape);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--mint-wash);
  color: var(--officine-green-deep);
  font: 700 15px var(--texte);
}

.etapes .schema {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--graphite);
  font-size: 13px;
}

.etapes .schema svg {
  width: 28px;
  height: 28px;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .interrupteur input::before {
    transition: none;
  }
}

/* ── Téléphone ── */
@media (max-width: 760px) {
  /* Un élément qui prend le focus ne reste pas sous la barre d'onglets fixe. */
  html {
    scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body {
    font-size: 15px;
    line-height: 1.45;
  }

  .charpente {
    display: block;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .navigation {
    display: none;
  }

  .barre-haut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    padding: 10px 16px;
    min-height: 56px;
  }

  .barre-haut .titre {
    font: 600 20px var(--titre);
  }

  .barre-haut img {
    height: 22px;
  }

  .contenu {
    padding: 14px 16px;
  }

  .contenu > h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Barre du bas : hauteur partagée (--hauteur-onglets) avec les barres collées au-dessus d'elle,
     zone sûre de l'iPhone sous les libellés. Largeurs proportionnelles au libellé : « Ma pharmacie »
     tient sur une ligne sans réduire la taille du texte. */
  .onglets {
    --hauteur-onglets: calc(60px + env(safe-area-inset-bottom, 0px));
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    min-height: var(--hauteur-onglets);
    padding: 4px 4px env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--hairline);
  }

  .onglets a {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 4px;
    font: 500 13px/1.15 var(--texte);
    white-space: nowrap;
    color: var(--graphite);
    text-decoration: none;
  }

  .onglets a[aria-current='page'] {
    color: var(--officine-green);
    font-weight: 700;
  }

  .bouton {
    height: 48px;
    width: 100%;
  }

  .bouton.secondaire {
    height: 44px;
  }

  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='tel'],
  input[type='date'],
  input[type='search'],
  select {
    height: 44px;
    max-width: none;
  }
}

/* ── Mes écrans ── */
.phrase-etat {
  font: 600 15px/1.35 var(--texte);
  color: var(--officine-green-deep);
}

h3 {
  font: 600 15px/1.3 var(--titre);
  margin: 16px 0 8px;
}

.apercu {
  margin: 12px 0;
}

.apercu summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--officine-green-deep);
}

.apercu img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--hairline);
}

.a-venir {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.a-venir li {
  display: grid;
  grid-template-columns: 8px auto 1fr;
  gap: 4px 10px;
  align-items: baseline;
  padding: 6px 0;
}

.a-venir .point {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sesame-brown);
}

.a-venir .discret {
  grid-column: 2 / 4;
}

/* Semaine ouverte depuis un lien de notification (`/app/gardes?semaine=`). */
.a-venir li.demandee strong {
  text-decoration: underline;
  text-decoration-color: var(--sesame-brown);
  text-underline-offset: 3px;
}

.choix fieldset {
  border: 0;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choix legend {
  margin-bottom: 8px;
}

.carte-choix {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--stone);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.carte-choix:has(input:checked) {
  border-color: var(--officine-green);
  background: var(--mint-wash);
}

.carte-choix input {
  width: 18px;
  height: 18px;
  accent-color: var(--officine-green);
}

.lien-rubrique {
  min-height: 44px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

/* Escalade : étapes faisables seul avant tout recours (DESIGN.md, Escalation). */
.etapes-depannage {
  margin: 4px 0 14px;
  padding: 0;
  list-style: none;
  counter-reset: etape;
}

.etapes-depannage li {
  counter-increment: etape;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 2px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline);
}

.etapes-depannage li:first-child {
  border-top: 0;
}

.etapes-depannage li::before {
  content: counter(etape);
  grid-row: 1 / 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--stone);
  display: grid;
  place-items: center;
  font: 700 13px var(--texte);
}

.etapes-depannage span {
  color: var(--graphite);
}

.carte-choix.indisponible {
  cursor: not-allowed;
  color: var(--graphite);
  background: var(--paper);
}

/* Gardes */
.paire-champs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
}

fieldset.choix {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

fieldset.choix > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Réglages avancés repliés (serveur d'envoi des emails). */
.avance {
  margin: 4px 0 20px;
}

.avance summary {
  cursor: pointer;
  font: 600 13px/44px var(--texte);
  color: var(--officine-green-deep);
}

/* ── Aide « i » : explication dépliable (Callouts : information) ── */
.info-lien {
  margin: 4px 0 12px;
}

.info-lien summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--officine-green);
  font: 600 13px/1.4 var(--texte);
  cursor: pointer;
  list-style: none;
  border-radius: 8px;
}

.info-lien summary::-webkit-details-marker {
  display: none;
}

.info-lien summary:hover {
  color: var(--officine-green-deep);
  text-decoration: underline;
}

.info-lien summary:focus-visible {
  outline: 3px solid var(--officine-green);
  outline-offset: 2px;
}

.info-icone {
  flex-shrink: 0;
}

.info-lien[open] summary {
  color: var(--officine-green-deep);
}

.info-contenu {
  padding: 12px 14px;
  border: 1px solid var(--officine-green);
  border-radius: 12px;
  background: var(--mint-wash);
  color: var(--officine-green-deep);
  font-size: 14px;
  line-height: 1.45;
}

.info-contenu p {
  margin: 0 0 8px;
}

.info-contenu p:last-child {
  margin-bottom: 0;
}

.info-contenu ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.info-contenu li {
  margin: 4px 0;
}

.info-contenu code {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* « Plus » : la déconnexion n'existe que là sur téléphone (la barre latérale y est masquée). */
.deconnexion-mobile {
  margin-top: 8px;
}

@media (min-width: 761px) {
  .deconnexion-mobile {
    display: none;
  }
}
