/* Ma petite ardoise — jetons issus des maquettes Figma (collection « Ardoise »). */
:root {
  --ardoise: #1f2a30;
  --ardoise-2: #2e3c44;
  --craie: #fff;
  --fond: #f4f1ec;
  --surface: #fff;
  --bordure: #ddd6cc;
  --texte: #1f2a30;
  --texte-2: #5f6b71;
  --accent: #c8553d;
  --accent-doux: #f7e3dd;
  --succes: #2f7d4f;
  --succes-doux: #ddf0e3;
  --cuisson: #b4540a;
  --cuisson-doux: #fce9d6;
  --danger: #b3261e;
  --danger-doux: #f9dedc;
  --enfant: #3b5ba9;
  --enfant-doux: #e1e8f7;
  --alerte: #7a5300;
  --alerte-doux: #fff1b8;
  --radius-m: 12px;
  --radius-l: 16px;
  --tap: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Un mot très long (nom de vin, note) passe à la ligne au lieu d'élargir la page. */
  overflow-wrap: break-word;
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

/* --- Barre haute --------------------------------------------------------- */
.appbar {
  background: var(--ardoise);
  color: var(--craie);
  padding: calc(env(safe-area-inset-top) + 16px) 16px 16px;
  display: grid;
  gap: 12px;
}
.switcher {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 8px 14px;
  border: 0; border-radius: 999px;
  background: var(--ardoise-2); color: var(--craie);
  font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1;
  cursor: pointer;
}
.appbar__top { display: flex; align-items: center; gap: 12px; }
.switcher { min-width: 0; }
.switcher__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
}
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: var(--craie); font-weight: 700; font-size: 17px;
  box-shadow: 0 0 0 2px var(--ardoise), 0 0 0 4px rgba(255, 255, 255, .35);
}
.avatar--lg { width: 52px; height: 52px; font-size: 22px; box-shadow: none; }
.btn--deconnexion { background: var(--danger-doux); color: var(--danger); }
.appbar__title { display: flex; align-items: center; gap: 8px; }
.appbar__title h1 { font-size: clamp(21px, 6.4vw, 26px); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.back { display: inline-flex; width: 40px; height: 40px; margin-left: -8px; align-items: center; justify-content: center; color: var(--craie); }

/* --- Mise en page ---------------------------------------------------------- */
.content { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.actions {
  position: sticky; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--bordure);
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px);
}
.actions__inner { max-width: 720px; margin: 0 auto; display: grid; gap: 8px; }
.hint { color: var(--texte-2); font-size: 15px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 10px; }

/* --- Boutons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 24px;
  border: 0; border-radius: var(--radius-m);
  font-family: inherit; font-weight: 600; font-size: 18px; line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer; width: 100%;
}
.btn--primaire { background: var(--accent); color: var(--craie); }
.btn--secondaire { background: var(--surface); color: var(--texte); box-shadow: inset 0 0 0 1.5px var(--bordure); }
.btn--danger { background: var(--danger); color: var(--craie); }
.btn--fantome { background: var(--fond); color: var(--texte); }
.btn--lien-danger { background: none; color: var(--danger); }
.btn--lien { background: none; color: var(--texte-2); text-decoration: underline; font-size: 15px; font-weight: 500; }
.btn:disabled { background: var(--bordure); color: var(--texte-2); cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 10px;
  background: transparent; color: var(--texte-2); cursor: pointer; font-family: inherit;
}
.icon-btn:hover { background: var(--fond); }
form.inline { display: inline; margin: 0; }

/* --- Cartes et lignes ------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--radius-l);
  padding: 16px; display: grid; gap: 12px;
}
.card__title { font-size: 19px; font-weight: 700; }
.card__meta { color: var(--texte-2); font-size: 14px; }
.dish-row {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--radius-m);
  padding: 8px 4px 8px 12px; min-height: 76px;
}
.dish-row--off { opacity: .55; }
.dish-row--shared { text-decoration: none; padding-right: 12px; border-style: dashed; color: var(--texte-2); }
/* Description sur 2 lignes au plus : lisible sur téléphone sans allonger la liste. */
.dish-row__desc {
  font-size: 14px; color: var(--texte-2); overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.card--shared { border-style: dashed; border-width: 1.5px; }
.dish-row__main { flex: 1; min-width: 0; text-decoration: none; display: grid; gap: 6px; padding: 4px 0; }
.dish-row__name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.dish-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--texte-2); font-size: 15px; font-weight: 500; }
.reorder { display: grid; }
.reorder .icon-btn { width: 40px; height: 34px; }

/* --- Badges ---------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge--actif { background: var(--succes-doux); color: var(--succes); }
.badge--cuisson { background: var(--cuisson-doux); color: var(--cuisson); }
.badge--enfant { background: var(--enfant-doux); color: var(--enfant); }
.badge--off { background: var(--fond); color: var(--texte-2); }
.badge--commun { background: var(--ardoise); color: var(--craie); }

/* --- Onglets de catégorie -------------------------------------------------- */
.tabs {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border-bottom: 1px solid var(--bordure);
  padding: 12px 16px;
}
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--bordure); background: var(--surface);
  font-weight: 600; text-decoration: none;
}
.tab small { color: var(--texte-2); font-weight: 500; }
.tabs--muted .tab[aria-current="page"] { background: var(--surface); border-color: var(--bordure); color: inherit; }
.tab[aria-current="page"] { background: var(--ardoise); border-color: var(--ardoise); color: var(--craie); }
.tab[aria-current="page"] small { color: inherit; opacity: .8; }

/* --- Formulaires ----------------------------------------------------------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 15px; font-weight: 600; }
.input {
  width: 100%; min-height: var(--tap); padding: 12px 16px;
  border: 1.5px solid var(--bordure); border-radius: var(--radius-m);
  background: var(--surface); color: var(--texte); font-family: inherit; font-size: 18px; line-height: 1.3;
}
textarea.input { min-height: 0; resize: vertical; font-size: 17px; }
.input:focus { outline: none; border-color: var(--ardoise); box-shadow: 0 0 0 3px rgba(31, 42, 48, .15); }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 44px; }
.input-suffix span { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--texte-2); font-weight: 500; font-size: 18px; }
.errors { color: var(--danger); font-size: 14px; font-weight: 600; margin: 0; padding: 0; list-style: none; }

/* Choix tactiles (radio) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; min-width: 56px; padding: 0 18px;
  border: 1.5px solid var(--bordure); border-radius: var(--radius-m); background: var(--surface);
  font-weight: 600; font-size: 16px; cursor: pointer;
}
.choices--stack { flex-direction: column; }
.choices--stack label { justify-content: flex-start; min-height: var(--tap); }
.choices input:checked + label { background: var(--ardoise); border-color: var(--ardoise); color: var(--craie); }
.choices input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Interrupteurs */
.option {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--radius-m);
  padding: 14px 16px;
}
.option__text { flex: 1; display: grid; gap: 4px; }
.option__title { font-size: 17px; font-weight: 600; }
.option__desc { font-size: 14px; color: var(--texte-2); }
.option--cuisson:has(input:checked) { background: var(--cuisson-doux); }
.switch { position: relative; flex: none; width: 56px; height: 32px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--bordure); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--craie); transition: transform .15s; }
.switch input:checked + span { background: var(--succes); }
.switch input:checked + span::after { transform: translateX(24px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- Messages -------------------------------------------------------------- */
.flash { border-radius: var(--radius-m); padding: 12px 14px; font-weight: 600; font-size: 15px; }
.flash--success { background: var(--succes); color: var(--craie); }
.flash--error { background: var(--danger-doux); color: var(--danger); }
.flash--info { background: var(--alerte-doux); color: var(--alerte); }
.empty { text-align: center; color: var(--texte-2); padding: 32px 16px; border: 2px dashed var(--bordure); border-radius: var(--radius-l); }

/* --- Fenêtres (confirmation, feuille du bas) ------------------------------- */
dialog { border: 0; padding: 0; color: var(--texte); background: var(--surface); }
dialog::backdrop { background: rgba(18, 26, 31, .55); }
.dialog { width: min(342px, calc(100% - 32px)); border-radius: 20px; }
.dialog__body { padding: 24px 20px 20px; display: grid; gap: 12px; }
.dialog__body h2 { font-size: 21px; }
.dialog__body p { color: var(--texte-2); font-size: 15px; }
.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 24px 24px 0 0;
  max-height: 85dvh;
}
.sheet__body { padding: 12px 16px calc(env(safe-area-inset-bottom) + 24px); display: grid; gap: 10px; }
.sheet__handle { width: 40px; height: 5px; border-radius: 3px; background: var(--bordure); justify-self: center; }
.resto {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 72px; padding: 14px 16px; border: 0; border-radius: var(--radius-m);
  background: var(--fond); color: var(--texte); font-family: inherit; cursor: pointer;
}
.resto[aria-current="true"] { background: var(--accent-doux); }
.resto__name { font-size: 17px; font-weight: 600; }
.resto__sub { font-size: 14px; color: var(--texte-2); }
.resto__default { color: var(--cuisson); font-weight: 500; }
.sheet__links { display: grid; gap: 4px; border-top: 1px solid var(--bordure); padding-top: 10px; margin-top: 4px; }
.sheet__links a, .sheet__links button {
  display: flex; align-items: center; min-height: 48px; padding: 0 8px;
  border: 0; background: none; font-family: inherit; font-weight: 600; font-size: 16px; line-height: 1; color: var(--texte);
  text-decoration: none; cursor: pointer; width: 100%;
}
.link-accent { color: var(--accent) !important; justify-content: center; }

/* --- Pages d'accueil (connexion) ------------------------------------------- */
.auth { flex: 1; display: grid; align-content: center; gap: 24px; padding: 32px 16px; width: 100%; max-width: 420px; margin: 0 auto; }
.brand { text-align: center; display: grid; gap: 6px; }
.brand h1 { font-size: 30px; font-weight: 800; color: var(--ardoise); }
.brand p { color: var(--texte-2); }

/* --- Prise de commande ----------------------------------------------------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn--small { width: auto; min-height: 40px; padding: 8px 14px; font-size: 15px; }
.badge--brouillon { background: var(--accent-doux); color: var(--accent); }
.input--big { font-size: 24px; font-weight: 700; min-height: 64px; }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset legend { margin-bottom: 8px; padding: 0; }
.required { color: var(--danger); font-size: 14px; margin-left: 6px; }
.required--ok { color: var(--succes); }

.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--bordure); border-radius: var(--radius-l); background: var(--surface); overflow: hidden; }
.stepper__btn { width: 64px; min-height: 64px; border: 0; background: none; font-size: 30px; font-weight: 500; color: var(--texte); cursor: pointer; }
.stepper__btn:active { background: var(--fond); }
.stepper__value { width: 72px; border: 0; text-align: center; font: inherit; font-size: 28px; font-weight: 700; color: var(--texte); background: none; -moz-appearance: textfield; }
.stepper__value::-webkit-inner-spin-button, .stepper__value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field > .stepper { display: flex; }
.field > .stepper .stepper__value { flex: 1; }
.chip {
  flex: 1; min-height: 48px; min-width: 44px; border: 1.5px solid var(--bordure); border-radius: var(--radius-m);
  background: var(--surface); font-family: inherit; font-size: 17px; font-weight: 600; color: var(--texte); cursor: pointer;
}
.choices--grid { display: grid; grid-template-columns: 1fr 1fr; }
.choices--grid3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.choices--grid label, .choices--grid3 label { min-height: var(--tap); font-size: 17px; }
.choices--error label { border: 2px solid var(--danger); }

.tile {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--radius-m);
  padding: 12px 10px 12px 16px; min-height: 80px;
}
.tile:active { background: var(--fond); }
.tile__info { flex: 1; min-width: 0; display: grid; gap: 6px; }
.tile__count { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--ardoise); color: var(--craie); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.tile__add { flex: none; width: 56px; height: 56px; border-radius: var(--radius-m); background: var(--accent); color: var(--craie); display: inline-flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 500; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-m); background: var(--alerte-doux); color: var(--alerte); font-size: 14px; }
.alert strong { font-size: 15px; }
.course { display: grid; gap: 8px; margin-top: 4px; }
.course__pill { background: var(--ardoise); color: var(--craie); font-weight: 700; font-size: 13px; padding: 5px 10px; border-radius: 6px; }
.line { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--radius-m); padding: 10px 8px 12px 14px; display: grid; gap: 8px; }
.line--new { border: 2px solid var(--accent); }
.line__qty { color: var(--accent); font-weight: 700; font-size: 18px; }
.line__name { font-weight: 600; font-size: 17px; }
.line__cooking { justify-self: start; background: var(--cuisson); color: var(--craie); font-weight: 700; font-size: 15px; letter-spacing: .06em; padding: 5px 12px; border-radius: 6px; }
.line__note { background: #eef1f4; border-radius: 8px; padding: 8px 10px; font-style: italic; font-size: 15px; }
.course-select { min-height: 40px; padding: 4px 8px; border: 1px solid var(--bordure); border-radius: 999px; background: var(--fond); font: inherit; font-weight: 600; font-size: 16px; color: var(--texte); }
.course-select--static { display: inline-flex; align-items: center; }

.shift { display: grid; gap: 10px; }
.shift + .shift { margin-top: 12px; }
.shift__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--ardoise); padding-bottom: 6px; }
.shift__head h2 { font-size: 18px; }
.order-card a.flash { text-decoration: none; }

/* --- Suivi et archives ------------------------------------------------------ */
.shift-card { text-decoration: none; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--texte-2); font-size: 15px; }
.stats strong { color: var(--texte); }
.pdf-links { flex-wrap: wrap; }
.pdf-links .badge { text-decoration: none; padding: 6px 12px; font-size: 14px; }

/* --- Saisie rapide ------------------------------------------------------------ */
[hidden] { display: none !important; }
.tile__info { text-decoration: none; color: inherit; align-self: stretch; text-align: left; align-content: center; }
.tile__add { border: 0; cursor: pointer; font-family: inherit; text-decoration: none; }
.tile__add:active { transform: scale(.94); }
.tile form { margin: 0; }
.tile--added { animation: tile-added .6s ease-out; }
@keyframes tile-added { from { box-shadow: 0 0 0 3px var(--succes); } to { box-shadow: 0 0 0 0 transparent; } }
.line-form__head h2 { font-size: 22px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 96px); z-index: 10;
  width: min(560px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-m);
  background: var(--ardoise); color: var(--craie); font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast__undo { border: 0; background: none; color: #ffd2c6; font: inherit; font-weight: 700; padding: 8px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .tile--added { animation: none; } }

/* --- Hors ligne ----------------------------------------------------------------- */
.offline-banner {
  position: sticky; top: 0; z-index: 5;
  padding: 10px 16px; background: var(--alerte-doux); color: var(--alerte);
  font-size: 14px; border-bottom: 1px solid #e8d48a;
}
.offline-banner--pending { background: var(--accent-doux); color: var(--accent); border-color: #efc7bb; }
.sync-alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--danger); color: var(--craie); font-weight: 600; font-size: 14px;
}
.tile--pending { border-style: dashed; border-color: var(--accent); }
.tile--pending .tile__count { background: var(--accent); }

/* --- Recherche rapide d'un plat ---------------------------------------------- */
.search { position: relative; background: var(--surface); padding: 12px 16px 0; margin: 0; }
.search__input { padding-left: 44px; padding-right: 52px; -webkit-appearance: none; appearance: none; }
.search__input::-webkit-search-cancel-button { display: none; }
.search::before {
  content: ""; position: absolute; left: 30px; top: calc(12px + 50% - 6px); transform: translateY(-50%);
  width: 18px; height: 18px; pointer-events: none; opacity: .55;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f2a30' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
}
.search__clear {
  position: absolute; right: 20px; top: calc(12px + 50% - 6px); transform: translateY(-50%);
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--texte-2); text-decoration: none;
}
.search__kind { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-2); margin: 8px 0 0; }
