/* =====================================================================
   ADEO — interface de suivi
   Mobile d'abord : la famille d'accueil saisit debout, souvent d'une main,
   parfois dans la salle d'attente du vétérinaire.
   ===================================================================== */

:root {
  --encre: #12241F;
  --encre-douce: #5C6B64;
  --papier: #EEF1EC;
  --carte: #FFFFFF;
  --vert: #1F6F5C;
  --vert-fonce: #0F2B25;
  --ambre: #B87309;
  --brique: #A32E22;
  --trait: #DCE2DA;
  --ombre: 0 1px 2px rgba(18, 36, 31, .06), 0 8px 24px -16px rgba(18, 36, 31, .35);

  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --texte: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --rayon: 14px;
  --rayon-s: 9px;
  --marge: 16px;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }

/* L'attribut `hidden` pose display:none, mais toute règle CSS définissant
   `display` l'écrase. Les blocs masqués par le JS (#app, #connexion, #modale)
   en ont tous une : sans ce garde-fou, ils restent affichés. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--texte);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.015em; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .6em; }
a { color: var(--vert); }

:focus-visible { outline: 2px solid var(--vert); outline-offset: 2px; border-radius: 4px; }

/* --- Marque ---------------------------------------------------------- */
.mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #4FA98C 0 42%, var(--vert) 43% 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .85);
  display: inline-block; flex: none;
}
.mark--grand { width: 42px; height: 42px; margin-bottom: 14px; }

/* =====================================================================
   Connexion
   ===================================================================== */
.connexion {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, #DDE6DF 0%, transparent 60%),
    var(--papier);
}
.connexion__carte {
  width: min(400px, 100%); background: var(--carte); padding: 30px 26px 26px;
  border-radius: 20px; box-shadow: var(--ombre); display: flex; flex-direction: column;
}
.connexion__carte h1 { font-size: 1.35rem; margin-bottom: 6px; }
.connexion__sous { color: var(--encre-douce); font-size: .88rem; margin-bottom: 20px; }
.connexion__carte label { font-size: .78rem; font-weight: 600; color: var(--encre-douce); margin-bottom: 5px; }
.connexion__carte input { margin-bottom: 14px; }
.connexion__carte .btn { margin-top: 6px; }

/* =====================================================================
   Ossature
   ===================================================================== */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--marge); background: var(--vert-fonce); color: #EAF1EC;
}
.topbar__brand { display: flex; align-items: center; gap: 9px; }
.topbar__nom { font-family: var(--display); font-weight: 700; letter-spacing: .14em; font-size: .95rem; }
.topbar__compte {
  display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .1);
  border: 0; color: inherit; font: inherit; font-size: .82rem; padding: 6px 10px;
  border-radius: 999px; cursor: pointer; max-width: 60%;
}
.topbar__compte span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vue { padding: var(--marge); max-width: 1080px; margin: 0 auto; }
.vue:focus { outline: none; }

.rail { display: none; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; background: var(--carte); border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  flex: 1; border: 0; background: none; cursor: pointer; padding: 8px 2px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--encre-douce); font: inherit; font-size: .66rem; font-weight: 600;
  position: relative;
}
.tabbar__item svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tabbar__item[aria-current="page"] { color: var(--vert); }
.tabbar__pastille {
  position: absolute; top: 4px; left: 50%; margin-left: 5px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--brique); color: #fff; font-size: .6rem; line-height: 16px; font-weight: 700;
}

/* =====================================================================
   En-tête de section
   ===================================================================== */
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.entete__titre { display: flex; flex-direction: column; gap: 2px; }
.eyebrow {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--encre-douce);
}

/* =====================================================================
   Boutons
   ===================================================================== */
.btn {
  font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer;
  border-radius: var(--rayon-s); border: 1px solid transparent; padding: 10px 15px;
  background: var(--carte); color: var(--encre); border-color: var(--trait);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; transition: transform .12s ease, background-color .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn--principal { background: var(--vert); color: #fff; border-color: var(--vert); }
.btn--danger { background: transparent; color: var(--brique); border-color: #E4CBC7; }
.btn--fantome { background: transparent; border-color: transparent; color: var(--vert); padding: 8px 10px; }
.btn--icone { min-height: 34px; padding: 4px 9px; background: transparent; border-color: transparent; font-size: 1rem; }
.btn--bloc { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-groupe { display: flex; flex-wrap: wrap; gap: 8px; }

/* =====================================================================
   Cartes et listes
   ===================================================================== */
.carte {
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 15px; margin-bottom: 12px;
}
.carte--plate { box-shadow: none; border: 1px solid var(--trait); }

/* Ligne de liste : le rail de gauche porte le statut, c'est le repère visuel
   commun à toutes les listes de l'application. */
.fiche {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 0 13px; align-items: center;
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre);
  margin-bottom: 9px; overflow: hidden; cursor: pointer; width: 100%;
  border: 0; padding: 0; text-align: left; font: inherit; color: inherit;
}
.fiche__rail { background: var(--trait); align-self: stretch; }
.fiche__corps { padding: 12px 0; min-width: 0; }
.fiche__titre { font-weight: 600; font-size: .97rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fiche__meta { color: var(--encre-douce); font-size: .8rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fiche__fin { padding-right: 14px; display: flex; align-items: center; gap: 9px; }
.fiche__vignette { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--papier); }

.fiche[data-ton="attente"] .fiche__rail { background: var(--ambre); }
.fiche[data-ton="urgent"] .fiche__rail { background: var(--brique); }
.fiche[data-ton="ok"] .fiche__rail { background: var(--vert); }
.fiche[data-ton="neutre"] .fiche__rail { background: #B9C4BC; }

/* Référence DV-0001 / BV-0001 : la colonne vertébrale du dossier, toujours en mono. */
.ref {
  font-family: var(--mono); font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: #E7EEE9; color: var(--vert-fonce); padding: 2px 7px; border-radius: 5px;
}

.badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: #E7EEE9; color: var(--vert-fonce);
  white-space: nowrap;
}
.badge--attente { background: #FBEFD9; color: #7A4B00; }
.badge--urgent { background: #F6DFDC; color: #7C2018; }
.badge--ok { background: #DDEEE5; color: #17513F; }
.badge--neutre { background: #E6EAE6; color: #4A554E; }
.badge--role { background: rgba(255, 255, 255, .18); color: #EAF1EC; }

/* =====================================================================
   Tableau de bord
   ===================================================================== */
.chiffres { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.chiffre {
  background: var(--carte); border-radius: var(--rayon); padding: 13px 14px; box-shadow: var(--ombre);
  border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.chiffre__valeur { font-family: var(--display); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.chiffre__label { font-size: .76rem; color: var(--encre-douce); }
.chiffre--alerte .chiffre__valeur { color: var(--brique); }

.bandeau {
  background: var(--vert-fonce); color: #E6EFE8; border-radius: var(--rayon);
  padding: 15px 16px; margin-bottom: 16px;
}
.bandeau h2 { color: #fff; font-size: 1.05rem; margin-bottom: 3px; }
.bandeau p { color: #B9CFC2; font-size: .84rem; margin: 0 0 11px; }

/* =====================================================================
   Formulaires
   ===================================================================== */
.champ { margin-bottom: 13px; }
.champ label { display: block; font-size: .78rem; font-weight: 600; color: var(--encre-douce); margin-bottom: 5px; }
.champ .aide { font-size: .74rem; color: var(--encre-douce); margin: 4px 0 0; }

input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px : évite le zoom iOS */
  padding: 11px 12px; border-radius: var(--rayon-s); border: 1px solid var(--trait);
  background: var(--carte); color: var(--encre); min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--vert); outline: none; box-shadow: 0 0 0 3px rgba(31, 111, 92, .14); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--encre-douce) 50%), linear-gradient(135deg, var(--encre-douce) 50%, transparent 50%); background-position: right 17px center, right 12px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.champ--case { display: flex; align-items: center; gap: 10px; }
.champ--case input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--vert); }
.champ--case label { margin: 0; font-size: .9rem; color: var(--encre); font-weight: 500; }

.grille-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }

.sep { border: 0; border-top: 1px solid var(--trait); margin: 18px 0 14px; }
.section-titre { font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--encre-douce); margin-bottom: 9px; }

/* Détail : liste clé / valeur */
.details { display: grid; grid-template-columns: 1fr; gap: 0; }
.detail { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--trait); }
.detail:last-child { border-bottom: 0; }
.detail dt { color: var(--encre-douce); font-size: .82rem; }
.detail dd { margin: 0; font-weight: 600; font-size: .88rem; text-align: right; word-break: break-word; }

.photos { display: flex; gap: 9px; flex-wrap: wrap; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--rayon-s); }
.portrait { width: 100%; max-height: 240px; object-fit: cover; border-radius: var(--rayon); margin-bottom: 12px; }

/* =====================================================================
   États
   ===================================================================== */
.alerte { padding: 11px 13px; border-radius: var(--rayon-s); font-size: .85rem; margin: 0 0 12px; }
.alerte--erreur { background: #F6DFDC; color: #7C2018; }
.alerte--info { background: #E7EEE9; color: var(--vert-fonce); }
.alerte--attention { background: #FBEFD9; color: #7A4B00; }

.vide { text-align: center; padding: 40px 20px; color: var(--encre-douce); }
.vide h3 { color: var(--encre); margin-bottom: 6px; }
.vide p { font-size: .87rem; }

.chargement { padding: 34px; text-align: center; color: var(--encre-douce); font-size: .86rem; }

.filtres { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.filtres::-webkit-scrollbar { display: none; }
.filtre {
  flex: none; border: 1px solid var(--trait); background: var(--carte); color: var(--encre-douce);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.filtre[aria-pressed="true"] { background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff; }

.recherche { margin-bottom: 12px; }

/* =====================================================================
   Modale et toasts
   ===================================================================== */
.modale { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; }
.modale__fond { position: absolute; inset: 0; background: rgba(12, 26, 22, .45); }
.modale__carte {
  position: relative; background: var(--carte); width: min(560px, 100%);
  max-height: 88dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  animation: monte .22s ease;
}
.modale__tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
@keyframes monte { from { transform: translateY(22px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modale__carte { animation: none; } .btn { transition: none; } }

.toasts { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px); transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 24px)); }
.toast { background: var(--vert-fonce); color: #EAF1EC; padding: 11px 14px; border-radius: var(--rayon-s); font-size: .86rem; box-shadow: var(--ombre); }
.toast--erreur { background: var(--brique); }

/* =====================================================================
   Tablette et bureau : le rail latéral remplace la barre d'onglets
   ===================================================================== */
@media (min-width: 760px) {
  .grille-2 { grid-template-columns: 1fr 1fr; }
  .chiffres { grid-template-columns: repeat(4, 1fr); }
  .modale { place-items: center; }
  .modale__carte { border-radius: 20px; }
}

@media (min-width: 1000px) {
  .app { display: grid; grid-template-columns: 226px 1fr; grid-template-rows: auto 1fr; padding-bottom: 0; }
  .topbar { grid-column: 1 / -1; }
  .tabbar { display: none; }
  .toasts { bottom: 20px; left: auto; right: 20px; transform: none; }

  .rail { display: block; padding: 18px 12px; border-right: 1px solid var(--trait); background: var(--carte); min-height: 100%; }
  .rail__item {
    display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none;
    font: inherit; font-size: .89rem; font-weight: 600; color: var(--encre-douce);
    padding: 10px 12px; border-radius: var(--rayon-s); cursor: pointer; margin-bottom: 3px;
  }
  .rail__item svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; }
  .rail__item[aria-current="page"] { background: #E7EEE9; color: var(--vert-fonce); }
  .rail__pastille { margin-left: auto; background: var(--brique); color: #fff; border-radius: 999px; font-size: .68rem; padding: 1px 7px; font-weight: 700; }
  .vue { padding: 22px 26px 40px; }
}
