/* Mediklass — pensé d'abord pour le téléphone, puis tablette et poste. */
:root {
  --fond: #f3f6f5;
  --carte: #ffffff;
  --encre: #13261f;
  --doux: #5b6e67;
  --trait: #dde5e2;
  --marque: #0e7c66;
  --marque-fonce: #0a5b4b;
  --marque-pale: #e2f2ed;
  --alerte: #b42318;
  --alerte-pale: #fdecea;
  --attente: #b26b00;
  --attente-pale: #fff4e0;
  --info: #1d5fa8;
  --info-pale: #e7f0fb;
  --ombre: 0 1px 2px rgba(19, 38, 31, .06), 0 2px 8px rgba(19, 38, 31, .05);
  --rayon: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1714; --carte: #17221e; --encre: #e6efeb; --doux: #98aba4; --trait: #2a3a34;
    --marque: #35b597; --marque-fonce: #5fd1b5; --marque-pale: #163a31;
    --alerte: #ff8a80; --alerte-pale: #3a1b19; --attente: #ffb547; --attente-pale: #3a2c12;
    --info: #8cbcf2; --info-pale: #172c44; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--encre);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--marque); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
p { margin: .4rem 0; }
.doux { color: var(--doux); }
.petit { font-size: .85rem; }

/* --- Ossature --- */
.barre {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; background: var(--marque); color: #fff;
}
.barre .logo { font-weight: 700; letter-spacing: .2px; text-decoration: none; color: #fff; display: flex; gap: .45rem; align-items: center; }
.barre .logo img { width: 26px; height: 26px; }
.barre .cabinet { font-size: .8rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.barre button { background: transparent; border: 0; color: #fff; position: relative; padding: .35rem; cursor: pointer; font-size: 1.15rem; }
.pastille { position: absolute; top: -2px; right: -4px; background: #ffb547; color: #2a1a00; border-radius: 9px; font-size: .68rem; min-width: 17px; padding: 0 4px; font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 6rem; }

nav.onglets {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--carte); border-top: 1px solid var(--trait); padding: .3rem 0 calc(.3rem + env(safe-area-inset-bottom));
}
nav.onglets a { flex: 1; text-align: center; text-decoration: none; color: var(--doux); font-size: .72rem; padding: .2rem 0; }
nav.onglets a span { display: block; font-size: 1.25rem; line-height: 1.3; }
nav.onglets a.actif { color: var(--marque); font-weight: 600; }

@media (min-width: 900px) {
  nav.onglets { position: static; justify-content: flex-start; gap: .25rem; max-width: 1100px; margin: 0 auto; padding: .4rem 1rem; border: 0; background: transparent; }
  nav.onglets a { flex: 0 0 auto; padding: .45rem .85rem; border-radius: 999px; font-size: .9rem; }
  nav.onglets a span { display: inline; font-size: 1rem; margin-right: .3rem; }
  nav.onglets a.actif { background: var(--marque-pale); }
  main { padding-bottom: 3rem; }
}

footer.credit { text-align: center; font-size: .75rem; color: var(--doux); padding: 1rem 0 0; }

/* --- Cartes, grilles --- */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 1rem; margin-bottom: 1rem; }
.grille { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grille-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grille-2 { grid-template-columns: 1fr 1fr; } }
.chiffre { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .8rem 1rem; }
.chiffre b { display: block; font-size: 1.6rem; line-height: 1.2; }
.chiffre small { color: var(--doux); }
.entete { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.entete h1 { margin: 0; flex: 1; min-width: 12rem; }

/* --- Listes --- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { border-bottom: 1px solid var(--trait); }
.liste > li:last-child { border-bottom: 0; }
.ligne { display: flex; align-items: center; gap: .75rem; padding: .7rem .25rem; text-decoration: none; color: inherit; }
a.ligne:hover { background: var(--marque-pale); }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .corps b, .ligne .corps span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .corps span { color: var(--doux); font-size: .85rem; }
/* Ligne avec des boutons (équipe, invitations) : sur un écran étroit, les
   boutons passent sous le nom plutôt que de le couper en « D… ». */
.ligne-pliable { flex-wrap: wrap; }
.ligne-pliable .corps { flex: 1 1 12rem; }
.ligne-pliable > .actions { margin-left: auto; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--marque-pale); color: var(--marque-fonce); display: grid; place-items: center; font-weight: 700; flex: 0 0 38px; font-size: .85rem; }
.heure { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2rem; }
.vide { text-align: center; color: var(--doux); padding: 1.5rem .5rem; }

/* --- Étiquettes de statut --- */
.etiq { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; font-weight: 600; white-space: nowrap; background: var(--trait); color: var(--encre); }
.etiq.en_attente, .etiq.brouillon, .etiq.demandee { background: var(--attente-pale); color: var(--attente); }
.etiq.confirme, .etiq.arrive { background: var(--info-pale); color: var(--info); }
.etiq.honore, .etiq.finalisee, .etiq.realisee { background: var(--marque-pale); color: var(--marque-fonce); }
.etiq.absent, .etiq.annule, .etiq.remplacee, .etiq.annulee { background: var(--alerte-pale); color: var(--alerte); }

/* --- Formulaires --- */
label { display: block; font-size: .82rem; color: var(--doux); margin: .6rem 0 .2rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--encre); background: var(--carte);
  border: 1px solid var(--trait); border-radius: 9px; padding: .6rem .7rem; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marque); outline-offset: 0; border-color: transparent; }
input[readonly], textarea[readonly] { background: var(--fond); }
.champs { display: grid; gap: 0 .75rem; grid-template-columns: 1fr; }
@media (min-width: 600px) { .champs { grid-template-columns: 1fr 1fr; } .champs .large { grid-column: 1 / -1; } }
.champs-3 { display: grid; gap: 0 .6rem; grid-template-columns: repeat(3, 1fr); }
.case { display: flex; gap: .5rem; align-items: center; color: var(--encre); font-size: .9rem; margin: .7rem 0; }
.case input { width: auto; min-height: 0; }
.reglages-notifs { width: 100%; border-collapse: collapse; font-size: .92rem; }
.reglages-notifs th { font-size: .78rem; font-weight: 600; color: var(--doux); text-align: center; padding: 0 .3rem .4rem; white-space: nowrap; }
.reglages-notifs td { padding: .55rem .3rem; border-top: 1px solid var(--trait); }
.reglages-notifs td + td { text-align: center; width: 4.5rem; }
.reglages-notifs input { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--marque); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 42px;
  padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--marque); background: var(--marque); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--marque-fonce); }
.btn.second { background: transparent; color: var(--marque); }
.btn.second:hover { background: var(--marque-pale); }
.btn.danger { background: transparent; color: var(--alerte); border-color: var(--alerte); }
.btn.petit { min-height: 32px; padding: .25rem .65rem; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.segment { display: inline-flex; border: 1px solid var(--trait); border-radius: 9px; overflow: hidden; }
.segment button { border: 0; background: var(--carte); color: var(--encre); padding: .45rem .8rem; font: inherit; cursor: pointer; }
.segment button.actif { background: var(--marque); color: #fff; }

.message { padding: .65rem .8rem; border-radius: 9px; margin: .6rem 0; font-size: .9rem; }
.message.erreur { background: var(--alerte-pale); color: var(--alerte); }
.message.ok { background: var(--marque-pale); color: var(--marque-fonce); }
.message.info { background: var(--info-pale); color: var(--info); }
.message.attente { background: var(--attente-pale); color: var(--attente); }

/* --- Agenda --- */
.semaine { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .semaine { grid-template-columns: repeat(7, 1fr); } }
.jour { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .5rem; min-height: 4rem; }
.jour.aujourdhui { border-color: var(--marque); }
.jour h3 { font-size: .8rem; color: var(--doux); text-transform: capitalize; }
.rdv { display: block; text-decoration: none; color: inherit; border-left: 3px solid var(--marque); background: var(--fond); border-radius: 6px; padding: .35rem .5rem; margin: .3rem 0; font-size: .83rem; cursor: pointer; width: 100%; text-align: left; font-family: inherit; border-top: 0; border-right: 0; border-bottom: 0; }
.rdv.en_attente { border-left-color: var(--attente); }
.rdv.annule, .rdv.absent { opacity: .55; text-decoration: line-through; }
.rdv.honore { border-left-color: var(--doux); }
.creneaux { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.creneaux button { border: 1px solid var(--marque); background: var(--carte); color: var(--marque); border-radius: 8px; padding: .35rem .6rem; cursor: pointer; font: inherit; font-size: .85rem; }
.creneaux button.choisi { background: var(--marque); color: #fff; }

/* --- Ordonnance --- */
.lignes-ordo .ligne-ordo { border: 1px solid var(--trait); border-radius: 10px; padding: .6rem; margin-bottom: .6rem; position: relative; }
.lignes-ordo .ligne-ordo .retirer { position: absolute; top: .3rem; right: .3rem; }
.lecture dt { color: var(--doux); font-size: .8rem; margin-top: .6rem; }
.lecture dd { margin: .1rem 0 0; white-space: pre-wrap; }
.alerte-allergie { background: var(--alerte-pale); color: var(--alerte); border-radius: 9px; padding: .5rem .7rem; font-weight: 600; font-size: .88rem; margin: .4rem 0; }
.fil { font-size: .85rem; margin-bottom: .5rem; }
.fil a { text-decoration: none; }

/* --- Panneau, modale --- */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .voile { align-items: center; } }
.modale { background: var(--carte); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 1rem 1rem 1.5rem; }
@media (min-width: 700px) { .modale { border-radius: 16px; } }
.modale .fermer { float: right; background: none; border: 0; font-size: 1.4rem; color: var(--doux); cursor: pointer; }

.notif { padding: .6rem .25rem; border-bottom: 1px solid var(--trait); font-size: .9rem; }
.notif.non-lue { font-weight: 600; }
.notif small { display: block; color: var(--doux); font-weight: 400; }

/* --- Barres de statistiques --- */
.histo { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: .5rem; }
.histo div { flex: 1; background: var(--marque); border-radius: 3px 3px 0 0; min-height: 2px; }
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th, .tableau td { text-align: left; padding: .45rem .35rem; border-bottom: 1px solid var(--trait); }
.tableau th { color: var(--doux); font-weight: 600; font-size: .8rem; }
.defile { overflow-x: auto; }

/* --- Pages d'accès --- */
.acces { max-width: 420px; margin: 2rem auto; }
.acces .marque { text-align: center; margin-bottom: 1rem; }
.acces .marque img { width: 64px; height: 64px; }
.acces .marque h1 { margin: .4rem 0 0; font-size: 1.6rem; color: var(--marque); }

/* --- Écran neutre hors connexion --- */
.hors-ligne { position: fixed; inset: 0; z-index: 100; background: var(--fond); display: grid; place-items: center; text-align: center; padding: 2rem; }
.hors-ligne div { max-width: 340px; }
.hors-ligne b { font-size: 1.15rem; display: block; margin: .6rem 0; }

[hidden] { display: none !important; }

/* Filtres à bascule (historique médical) */
.btn.second[aria-pressed="true"] { background: var(--marque); color: #fff; }
/* Une colonne de grille ne doit jamais s’élargir sous un texte long. */
.grille > *, .grille-2 > *, .semaine > * { min-width: 0; }

/* Textes longs (engagements) : listes lisibles, titres resserrés. */
.texte-long h2 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.texte-long ul { padding-left: 1.2rem; margin: .3rem 0; }
.texte-long li { margin: .3rem 0; }
.texte-long p { line-height: 1.5; }
