/* Hamdam (همدم) — styles. Sobre, chaleureux, lisible ; aucune ressource externe. */
@font-face { font-family: "Vazirmatn"; src: url("/assets/fonts/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/assets/fonts/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/IBMPlexSans-400-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; src: url("/assets/fonts/IBMPlexSans-400-latin-ext.woff2") format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --fond: #fbf6ef;
  --surface: #ffffff;
  --texte: #2b1d17;
  --texte-doux: #5e4a40;
  --ligne: #e6d9cb;
  --primaire: #7a3b2e;
  --primaire-fonce: #5c2a20;
  --accent: #d9734e;
  --bulle-moi: #f3e3d3;
  --medical: #1f6b5c;
  --medical-clair: #e2f1ec;
  --erreur: #a3261b;
  --erreur-clair: #fbe7e4;
  --ombre: 0 1px 3px rgba(60, 30, 20, .12);
  --rayon: 16px;
  --cible: 52px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font-family: "Vazirmatn", "IBM Plex Sans", system-ui, sans-serif;
  font-size: 21px; line-height: 1.7;
}
html[lang="fr"] body { font-family: "IBM Plex Sans", "Vazirmatn", system-ui, sans-serif; line-height: 1.55; }
body.taille-normale { font-size: 18px; }
body.taille-grande { font-size: 21px; }
body.taille-tres_grande { font-size: 25px; }
@media (max-width: 400px) { body.taille-tres_grande .saisie .ligne { flex-direction: column-reverse; } }

button, input, textarea, select { font: inherit; color: inherit; }
/* Au moins 16 px dans les champs : pas de zoom automatique de Safari iOS */
input, textarea, select { font-size: max(16px, 1em); }
a { color: var(--primaire); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.chargement { margin: auto; padding: 2rem; color: var(--texte-doux); text-align: center; }

/* Boutons */
.bouton {
  min-height: var(--cible); min-width: var(--cible); padding: .5em 1.1em;
  border: 2px solid var(--primaire); border-radius: 999px; background: var(--primaire); color: #fff;
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  touch-action: manipulation;
}
.bouton:hover { background: var(--primaire-fonce); border-color: var(--primaire-fonce); }
.bouton:disabled { opacity: .55; cursor: default; }
.bouton.secondaire { background: transparent; color: var(--primaire); }
.bouton.secondaire:hover { background: var(--bulle-moi); }
.bouton.danger { background: var(--erreur); border-color: var(--erreur); }
.bouton.large { width: 100%; font-size: 1.1em; min-height: 60px; }
.bouton.petit { min-height: 48px; min-width: 48px; padding: .25em .8em; font-size: .85em; }
.bouton-icone { min-width: var(--cible); min-height: var(--cible); border: 0; background: transparent; color: var(--primaire); border-radius: 12px; cursor: pointer; font-size: 1.3em; line-height: 1; }
.bouton-icone:hover { background: var(--bulle-moi); }

/* Écrans simples (connexion, invitation, information) */
.carte { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1.4rem; margin: 1rem; }
.carte-centre { max-width: 34rem; width: calc(100% - 2rem); margin: auto; text-align: center; }
.carte-centre h1 { color: var(--primaire); margin: .2em 0 .4em; font-size: 1.6em; line-height: 1.3; }
.carte-centre p { margin: .6em 0 1.2em; }
.logo { width: 88px; height: 88px; border-radius: 22px; display: block; margin: 0 auto .6rem; }
.aide { color: var(--texte-doux); font-size: .85em; }
.texte-info { text-align: start; background: var(--fond); border-radius: 12px; padding: 1rem 1.1rem; border-inline-start: 5px solid var(--accent); }
.message-etat { margin: .8em 0; padding: .7em 1em; border-radius: 12px; }
.message-etat.erreur { background: var(--erreur-clair); color: var(--erreur); }
.message-etat.ok { background: var(--medical-clair); color: var(--medical); }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .5rem;
  padding: max(.4rem, env(safe-area-inset-top)) .6rem .4rem; background: var(--fond); border-bottom: 1px solid var(--ligne);
}
.entete h1 { margin: 0; font-size: 1.15em; color: var(--primaire); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete img { width: 36px; height: 36px; border-radius: 9px; }

/* Conversation */
.fil { flex: 1; overflow-y: auto; padding: 1rem .8rem 1.5rem; display: flex; flex-direction: column; gap: .9rem; }
.accueil { text-align: center; color: var(--texte-doux); margin: auto 0; padding: 1rem; }
.accueil strong { display: block; color: var(--primaire); font-size: 1.25em; margin-bottom: .4em; }
.bulle { max-width: 92%; padding: .75em 1em; border-radius: var(--rayon); box-shadow: var(--ombre); overflow-wrap: anywhere; }
.bulle p { margin: 0 0 .6em; }
.bulle p:last-child { margin-bottom: 0; }
.bulle ul, .bulle ol { margin: .3em 0 .6em; padding-inline-start: 1.4em; }
.bulle li { margin: .2em 0; }
.bulle.moi { align-self: flex-end; background: var(--bulle-moi); border-end-end-radius: 6px; }
.bulle.ia { align-self: flex-start; background: var(--surface); border-end-start-radius: 6px; }
.bulle.ia.medical { border-inline-start: 5px solid var(--medical); }
.bulle.erreur { align-self: center; background: var(--erreur-clair); color: var(--erreur); box-shadow: none; text-align: center; }
.bulle.attente { align-self: flex-start; background: var(--surface); color: var(--texte-doux); }
.points::after { content: ""; animation: points 1.4s steps(4, end) infinite; }
@keyframes points { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@media (prefers-reduced-motion: reduce) { .points::after { animation: none; content: "…"; } }
.signature { display: block; margin-top: .5em; font-size: .72em; color: var(--texte-doux); }
.sources { margin-top: .7em; padding-top: .5em; border-top: 1px solid var(--ligne); font-size: .8em; }
.sources h2 { font-size: 1em; margin: 0 0 .3em; color: var(--texte-doux); }
.sources ol { margin: 0; padding-inline-start: 1.3em; }
.sources a { display: inline-block; padding: .55em 0; min-height: 48px; word-break: break-word; }
.sources .domaine { color: var(--texte-doux); }
.cadre-suggestions { width: 100%; height: 76px; border: 0; margin-top: .4em; display: block; }

/* Zone de saisie */
.saisie {
  position: sticky; bottom: 0; background: var(--fond); border-top: 1px solid var(--ligne);
  padding: .6rem .6rem max(.6rem, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .5rem;
}
.saisie textarea {
  width: 100%; min-height: 3.2em; max-height: 40vh; resize: none; padding: .6em .8em; border: 2px solid var(--ligne);
  border-radius: 14px; background: var(--surface); line-height: 1.5;
}
.saisie textarea:focus { border-color: var(--primaire); outline: none; }
.saisie .ligne { display: flex; gap: .5rem; align-items: stretch; }
.saisie .ligne .bouton { flex: 1 1 0; min-width: 0; padding-inline: .6em; line-height: 1.25; }
.saisie .ligne .bouton:not(.medical) { flex-grow: 1.25; }
.bouton.medical { background: var(--surface); color: var(--medical); border-color: var(--medical); font-size: .9em; }
.bouton.medical[aria-pressed="true"] { background: var(--medical); color: #fff; }
.note-medicale { font-size: .8em; color: var(--medical); margin: 0; }
.compteur { font-size: .75em; color: var(--texte-doux); margin: 0; text-align: end; }
.compteur.trop { color: var(--erreur); font-weight: 700; }

/* Panneaux (menu, à propos, administration) */
.panneau { position: fixed; inset: 0; z-index: 20; background: var(--fond); display: flex; flex-direction: column; overflow: hidden; }
.panneau .corps { flex: 1; overflow-y: auto; padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.liste button.element {
  width: 100%; min-height: var(--cible); text-align: start; padding: .6em .9em; border: 1px solid var(--ligne); border-radius: 14px;
  background: var(--surface); cursor: pointer; display: flex; justify-content: space-between; gap: .6em; align-items: center;
}
.liste button.element:hover { border-color: var(--primaire); }
.liste .date { color: var(--texte-doux); font-size: .78em; white-space: nowrap; }
.groupe-boutons { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.section-titre { font-size: 1em; color: var(--texte-doux); margin: 1.4em 0 .5em; }

/* Fenêtre de confirmation */
.voile { position: fixed; inset: 0; z-index: 40; background: rgba(43, 29, 23, .45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.dialogue { background: var(--surface); border-radius: var(--rayon); padding: 1.3rem; max-width: 30rem; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.dialogue p { margin: 0 0 1rem; }
.dialogue .actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.dialogue .actions .bouton { flex: 1; }
.notif { position: fixed; inset-inline: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 50; background: var(--texte); color: #fff; border-radius: 12px; padding: .7em 1em; text-align: center; }

/* Administration */
.onglets { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem 1rem 0; border-bottom: 1px solid var(--ligne); }
.onglets button { border: 0; background: none; padding: .6em .9em; min-height: 48px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; color: var(--texte-doux); }
.onglets button[aria-selected="true"] { color: var(--primaire); border-color: var(--primaire); font-weight: 700; }
.formulaire { display: flex; flex-direction: column; gap: .8rem; max-width: 40rem; }
.formulaire label { display: flex; flex-direction: column; gap: .25rem; font-size: .9em; }
.formulaire label.case { flex-direction: row; align-items: center; gap: .6rem; }
.formulaire input[type="text"], .formulaire input[type="number"], .formulaire textarea, .formulaire select {
  padding: .5em .7em; border: 2px solid var(--ligne); border-radius: 10px; background: var(--surface); min-height: 48px; width: 100%;
}
.formulaire input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--primaire); }
.formulaire textarea { min-height: 5em; }
.formulaire textarea.code { font-family: ui-monospace, Menlo, monospace; font-size: 14px; min-height: 14em; direction: ltr; text-align: left; }
.tableau { width: 100%; border-collapse: collapse; font-size: .85em; background: var(--surface); }
.tableau th, .tableau td { padding: .5em .6em; border-bottom: 1px solid var(--ligne); text-align: start; }
.defile { overflow-x: auto; }
.lien-invitation { direction: ltr; text-align: left; word-break: break-all; background: var(--fond); padding: .6em; border-radius: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.qr { display: block; margin: .8rem auto; width: 220px; height: 220px; image-rendering: pixelated; background: #fff; }
.pastille { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 999px; background: var(--erreur); color: #fff; font-size: .7em; text-align: center; }
.ligne-objet { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .5em 0; border-bottom: 1px solid var(--ligne); flex-wrap: wrap; }
.nom-fichier { font-family: ui-monospace, Menlo, monospace; font-size: .9em; unicode-bidi: isolate; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .fil, .saisie { padding-inline: calc((100% - 52rem) / 2); }
  .panneau .corps { padding-inline: calc((100% - 52rem) / 2); }
}

/* Étape B2 : mention médicale, mode test (restrictions désactivées) */
.mention-medicale { margin: .7em 0 0 !important; font-size: .78em; line-height: 1.45; color: var(--medical); }
.bandeau-test { margin: .6em 0 0; padding: .5em .8em; border-radius: 10px; background: #fff3cd; color: #6b4a00; border: 1px solid #e8c766; font-size: .8em; line-height: 1.45; }
.bandeau-haut { display: flex; flex-wrap: wrap; gap: .2em .6em; align-items: baseline; padding: .45em 1rem; background: #fff3cd; color: #6b4a00; border-bottom: 1px solid #e8c766; font-size: .78em; line-height: 1.45; }
.badge-test { display: inline-block; padding: .05em .6em; border-radius: 999px; background: #6b4a00; color: #fff; font-size: .95em; }
.formulaire label.case.interrupteur input { width: 1.4em; height: 1.4em; }

/* Voix : bouton micro, « Écouter », écran de conversation vocale */
.pied-bulle { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3em .8em; margin-top: .5em; }
.pied-bulle .signature { margin-top: 0; }
.bouton-lien { min-height: 48px; min-width: 48px; padding: .2em .7em; border: 1px solid var(--ligne); border-radius: 999px; background: transparent; color: var(--primaire); font-size: .8em; cursor: pointer; }
.bouton-lien[aria-pressed="true"] { background: var(--bulle-moi); }
.bouton.micro { font-size: .9em; }
.bouton.micro[aria-pressed="true"] { background: var(--erreur); border-color: var(--erreur); color: #fff; }
.vocal-lancer { margin-top: 1em; }
.formulaire label.case.preference, label.case.preference { display: flex; align-items: center; gap: .6rem; min-height: 48px; }
.vocal { position: fixed; inset: 0; z-index: 50; background: var(--fond); display: flex; flex-direction: column; align-items: center; padding: 0 0 max(1rem, env(safe-area-inset-bottom)); overflow: hidden; }
.vocal .bandeau-haut { align-self: stretch; }
.vocal-titre { margin: 1rem 1rem .5rem; color: var(--primaire); font-size: 1.3em; }
.vocal-cercle { width: 150px; height: 150px; margin: 1.2rem auto; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, var(--accent), var(--primaire)); box-shadow: 0 0 0 10px rgba(217, 115, 78, .15); transition: transform .08s linear; }
.vocal-statut { margin: .2rem 1rem; color: var(--texte-doux); text-align: center; min-height: 1.7em; }
.vocal-zone { flex: 1 1 auto; overflow-y: auto; align-self: stretch; padding: .5rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.vocal-boutons { display: flex; gap: .8rem; padding: .6rem 1rem 0; align-self: stretch; justify-content: center; }
.vocal-boutons .bouton { flex: 1 1 0; max-width: 16rem; min-height: 60px; }
.vocal-boutons .bouton[aria-pressed="true"] { background: var(--texte-doux); border-color: var(--texte-doux); color: #fff; }
@media (prefers-reduced-motion: reduce) { .vocal-cercle { transition: none; } }

/* Version 1.0.1 : écran de conversation à la hauteur visible réelle (clavier iOS), fil qui défile au-dessus de la saisie */
.chat { position: fixed; inset-inline: 0; top: var(--vv-haut, 0px); height: var(--vv-hauteur, 100dvh); display: flex; flex-direction: column; overflow: hidden; background: var(--fond); }
.chat .entete { position: relative; flex: none; }
.chat .bandeau-haut { flex: none; }
/* Série E (I2) : sauvegarde absente ou de plus de 48 h, chez l'administrateur ; ouvre l'onglet « Alertes ». */
.bandeau-sauvegarde { flex: none; display: block; width: 100%; min-height: 48px; margin: 0; padding: .55em 1rem; border: 0; border-bottom: 1px solid #8f1d1d; background: #b42318; color: #fff; font: inherit; font-size: .85em; font-weight: 700; line-height: 1.45; text-align: start; cursor: pointer; }
.bandeau-sauvegarde:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.chat-defile { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.chat-defile > .fil { flex: none; overflow: visible; min-height: 100%; padding-bottom: 10rem; }
.chat .saisie { position: absolute; bottom: 0; inset-inline: 0; z-index: 4; }
.etat-saisie { margin: 0; font-size: .82em; color: var(--erreur); text-align: center; line-height: 1.4; }
@media (min-width: 900px) { .chat-defile > .fil { padding-inline: calc((100% - 52rem) / 2); } }

/* Conversation vocale : le cercle se touche pour interrompre Hamdam */
.vocal-cercle { border: 0; padding: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.vocal-cercle.parle { box-shadow: 0 0 0 14px rgba(217, 115, 78, .28); }
.vocal-aide { margin: 0 1rem .2rem; color: var(--texte-doux); font-size: .82em; text-align: center; line-height: 1.45; }

/* Journal technique (administration) */
.journal-technique { direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--ligne); border-radius: 10px; padding: .7em; max-height: 60vh; overflow: auto; }
.groupe-boutons.ligne-boutons { flex-direction: row; flex-wrap: wrap; }

/* Version 1.0.2 : numéro d'urgence, réponse non vérifiée, résultats consultés, réponse Google masquée (vue admin) */
.note-urgence { margin: .6em 0 0 !important; font-size: .9em; font-weight: 700; }
.note-urgence a { display: inline-flex; align-items: center; min-height: 48px; color: var(--erreur); text-decoration: none; }
.note-medicale .note-urgence { display: inline; margin: 0 !important; }
.non-verifiee { margin: .6em 0 0 !important; padding: .4em .7em; border-radius: 10px; background: #fff3cd; color: #6b4a00; font-size: .8em; line-height: 1.45; }
.sources.consultes h2 { color: var(--texte-doux); }
.bulle.masquee { font-style: italic; color: var(--texte-doux); }
.bloc-suggestions { margin-top: .6em; }
