/* =====================================================================
   HealthEat — Feuille de style
   ===================================================================== */
:root {
  --teal:        #0f766e;
  --teal-dark:   #0b5850;
  --teal-light:  #14b8a6;
  --green:       #16a34a;
  --green-soft:  #dcfce7;
  --orange:      #ea580c;
  --orange-soft: #ffedd5;
  --red:         #dc2626;
  --red-soft:    #fee2e2;
  --bg:          #f6faf9;
  --card:        #ffffff;
  --ink:         #1f2937;
  --muted:       #6b7280;
  --line:        #e5e7eb;
  --radius:      14px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--teal); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
button { font: inherit; cursor: pointer; }

/* ---- Layout --------------------------------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--teal); color: #fff;
  padding: calc(env(safe-area-inset-top) + .8rem) 1rem .8rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.app-header h1 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.app-header .brand-logo { width: 26px; height: 26px; }
.app-header .sub { font-size: .78rem; opacity: .85; font-weight: 400; }
/* Le nom (bouton) mène au profil : apparence texte, mais cliquable. */
button.sub {
  background: none; border: 0; color: inherit; font: inherit;
  padding: .1rem .2rem; margin: -.1rem -.2rem; cursor: pointer;
  border-radius: 6px; -webkit-tap-highlight-color: transparent;
}
button.sub:hover { opacity: 1; text-decoration: underline; }
button.sub:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

main { max-width: 780px; margin: 0 auto; padding: 1rem 1rem 5.5rem; }

/* ---- Bottom navigation ---------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 4px rgba(0,0,0,.05);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: .5rem 0 .55rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: .72rem;
}
.tabbar button .ic { width: 23px; height: 23px; display: block; }
.tabbar button.active { color: var(--teal); font-weight: 600; }
/* Un onglet masqué (ex. Admin pour un membre) doit rester caché : la règle
   display:flex ci-dessus l'emporterait sinon sur l'attribut [hidden]. */
.tabbar button[hidden] { display: none !important; }

/* ---- Cards & generic ------------------------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---- Buttons -------------------------------------------------------- */
.btn {
  border: 1px solid var(--teal); background: var(--teal); color: #fff;
  padding: .6rem 1rem; border-radius: 10px; font-weight: 600;
  transition: filter .15s;
  min-height: 44px;                         /* cible tactile confortable */
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: #fff; color: var(--teal); }
.btn.ghost { background: none; border-color: var(--line); color: var(--ink); }
.btn.small { padding: .4rem .7rem; font-size: .82rem; border-radius: 8px; min-height: 40px; }
.btn.block { width: 100%; }

/* Accessibilité clavier : anneau de focus visible et cohérent partout. */
a:focus-visible, button:focus-visible, summary:focus-visible,
[tabindex]:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal-light); outline-offset: 2px; border-radius: 6px;
}
/* Zone tactile minimale pour les boutons icône seule (× ✕). */
.close, .ingDel, .stepDel, .veg-del, .fav-btn { min-width: 40px; min-height: 40px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- Forms ---------------------------------------------------------- */
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .25rem; color: #374151; }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-light); border-color: var(--teal-light); }
.field { margin-bottom: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check-inline { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.check-inline input { width: auto; }

/* ---- Badges / chips ------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: #eef2f1; color: #374151;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.vert   { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.rouge  { background: var(--red); }
.badge-vert   { background: var(--green-soft);  color: #166534; }
.badge-orange { background: var(--orange-soft); color: #9a3412; }
.badge-rouge  { background: var(--red-soft);    color: #991b1b; }

/* ---- Auth ----------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 1rem; }
.auth-logo img { width: 64px; height: 64px; }
.auth-logo h1 { color: var(--teal); margin-top: .4rem; }
.tabs-switch { display: flex; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs-switch button { flex: 1; border: 0; background: #fff; padding: .6rem; color: var(--muted); font-weight: 600; }
.tabs-switch button.active { background: var(--teal); color: #fff; }

/* ---- Calendar ------------------------------------------------------- */
.cal-scroll { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; }
.day-col { flex: 0 0 78%; max-width: 300px; scroll-snap-align: start; }
@media (min-width: 700px) { .day-col { flex-basis: 46%; } }
.day-col h3 { font-size: .95rem; text-transform: capitalize; }
.meal { border-left: 4px solid var(--teal-light); padding: .5rem .6rem; background: #f8fafc; border-radius: 8px; margin-bottom: .5rem; }
.meal .type { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meal.empty { border-left-color: var(--line); color: var(--muted); font-style: italic; }

/* ---- Shopping ------------------------------------------------------- */
.course-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line); }
.course-item:last-child { border-bottom: 0; }
.course-item input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--teal); flex: 0 0 auto; }
.course-item.bought .cname { text-decoration: line-through; color: var(--muted); }
.course-item .cqty { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.course-item .repl { font-size: .72rem; color: var(--orange); }
.plat-tile { border: 2px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.plat-tile.complet { border-color: var(--green); background: var(--green-soft); }
.cat-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: .8rem 0 .2rem; }

/* ---- Recipe list ---------------------------------------------------- */
.recipe { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.recipe .meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .25rem; }
.fav-btn { border: 0; background: none; font-size: 1.35rem; line-height: 1; color: #d1d5db; }
.fav-btn.on { color: #f59e0b; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.filters select { width: auto; flex: 1 1 auto; min-width: 130px; }

/* ---- Accueil -------------------------------------------------------- */
.info-box { background: linear-gradient(135deg, var(--teal), var(--teal-light)); color: #fff; border: 0; }
.info-box h2 { color: #fff; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; padding: .45rem .1rem; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }

/* ---- Modal ---------------------------------------------------------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 1.2rem; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 16px; } }
.modal .close { float: right; border: 0; background: none; font-size: 1.5rem; color: var(--muted); }

/* ---- Toast / banners ------------------------------------------------ */
.toast { position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .85rem;
  z-index: 60; opacity: 0; transition: opacity .25s; max-width: 90%; text-align: center; }
.toast.show { opacity: .96; }
.offline-banner { background: #fef3c7; color: #92400e; text-align: center; font-size: .8rem; padding: .35rem; }
.install-banner { background: var(--teal-dark); color: #fff; display: flex; gap: .6rem; align-items: center;
  justify-content: space-between; padding: .6rem 1rem; }
.spinner { text-align: center; color: var(--muted); padding: 2rem 0; }

/* ---- Dropdown (details/summary) ------------------------------------- */
.dropdown > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; font-size: 1.05rem; font-weight: 700;
  color: var(--ink);
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary .chev { transition: transform .2s; color: var(--teal); }
.dropdown[open] > summary .chev { transform: rotate(180deg); }

/* ---- Recipe images -------------------------------------------------- */
.recipe-thumb {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
  flex: 0 0 auto; cursor: pointer; background: #eef2f1;
}
.recipe-hero {
  width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px;
  margin: 0 0 .8rem; display: block;
}

/* ---- Administration -------------------------------------------------- */
.stat { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.stat strong { font-size: 1.5rem; line-height: 1.1; }
.btn.danger { color: #c62828; }
.btn.danger:hover { background: #fdecea; }
.admin-user strong { font-size: .98rem; }

/* ---- Formulaires de recette : lignes dynamiques ---------------------- */
.ing-row {
  display: grid; grid-template-columns: 1fr 66px 92px 34px;
  gap: .35rem; margin-bottom: .35rem; align-items: center;
}
.ing-row input, .ing-row select { min-width: 0; }
.ing-name { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.step-row {
  display: grid; grid-template-columns: auto 1fr 34px;
  gap: .4rem; margin-bottom: .4rem; align-items: start;
}
.step-num { white-space: nowrap; align-self: start; margin-top: .35rem; }
.ingDel, .stepDel { padding: .3rem .5rem; }

/* ---- Stories : légumes de saison (bande défilante) ------------------ */
.stories-wrap { margin: 0 -.25rem .9rem; }
.stories {
  display: flex; gap: .7rem; overflow-x: auto;
  padding: .3rem .35rem .5rem;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.stories::-webkit-scrollbar { display: none; }
.story {
  flex: 0 0 auto; width: 72px; padding: 0; border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  cursor: pointer;
}
.story-ring {
  width: 64px; height: 64px; border-radius: 50%; padding: 3px;
  background: linear-gradient(135deg, #16a34a, #14b8a6 45%, #f59e0b);
  display: flex; box-shadow: var(--shadow);
}
.story-img {
  flex: 1; border-radius: 50%; background: var(--card); overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 1.9rem;
}
.story-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story:active .story-ring { transform: scale(.94); }
.story-ring { transition: transform .12s; }
.story-name {
  font-size: .72rem; text-align: center; color: var(--ink); line-height: 1.1;
  max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Admin : photos des légumes ------------------------------------- */
.veg-photos { display: grid; grid-template-columns: 1fr; gap: .2rem; }
.veg-photo {
  display: grid; grid-template-columns: 44px 1fr auto; gap: .6rem;
  align-items: center; padding: .45rem 0; border-top: 1px solid var(--line);
}
.veg-thumb {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #eef2f1; font-size: 1.4rem;
}
.veg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.veg-name { font-weight: 600; font-size: .9rem; }
