/* ==========================================================================
   B.Blue — Kit UI des écrans de rôles (économat · cuisine · creatif)
   Charte SUPERWASTE Connect / La Fabuleuse Cantine.
   Tokens repris à l'identique de public/index.html (applyTheme) : un seul
   langage visuel entre l'app historique et les écrans métier.
   Thème : data-theme="light" | "dark" sur <html>.
   ========================================================================== */

:root {
  --bb-bg: #FBF8EF;
  --bb-card: #F6F1E4;
  --bb-card2: #EFE8D6;
  --bb-line: rgba(214, 200, 164, .55);
  --bb-border: #D6C8A4;
  --bb-mute: #57513F;
  --bb-ink: #2A281F;
  --bb-acc: #6F93A6;
  --bb-acc2: #3F5A6B;
  --bb-soft: rgba(111, 147, 166, .12);
  --bb-cta: #3F5A6B;
  --bb-ctafg: #F6F1E4;
  --bb-sh: 0 1px 2px rgba(42, 40, 31, .04), 0 10px 30px rgba(42, 40, 31, .05);
  --bb-paper: #FCF9F0;

  /* Accents SUPERWASTE — jamais décoratifs seuls, toujours porteurs de sens */
  --bb-vert: #7A9B54;
  --bb-orange: #CF7D4C;
  --bb-violet: #9A86AB;
  --bb-bleu: #6F93A6;

  /* Typo */
  --bb-serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --bb-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bb-mono: 'Space Grotesk', 'SF Mono', ui-monospace, monospace;
  --bb-hand: 'Caveat', 'Bradley Hand', cursive;

  /* Rythme */
  --bb-r-card: 18px;
  --bb-r-btn: 11px;
  --bb-r-soft: 14px;
  --bb-tap: 44px;   /* cible tactile minimale */
  --bb-tap-xl: 64px; /* cible « mains mouillées » du rôle cuisine */
}

:root[data-theme="dark"] {
  --bb-bg: #1E2017;
  --bb-card: #262A20;
  --bb-card2: #303526;
  --bb-line: rgba(214, 200, 164, .16);
  --bb-border: rgba(214, 200, 164, .35);
  --bb-mute: #A8A18B;
  --bb-ink: #F2EEE0;
  --bb-acc: #7FA3B6;
  --bb-acc2: #A9C4D2;
  --bb-soft: rgba(127, 163, 182, .15);
  --bb-cta: #6F93A6;
  --bb-ctafg: #1E2017;
  --bb-sh: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 34px rgba(0, 0, 0, .28);
  --bb-paper: #F2EDE0;
}

/* ============================ Base ============================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bb-bg);
}

body {
  font-family: var(--bb-sans);
  color: var(--bb-ink);
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

a { color: var(--bb-acc2); text-decoration: none; }
a:hover { color: var(--bb-acc); }
::selection { background: rgba(111, 147, 166, .25); }

button, input, select, textarea { font-family: inherit; color: inherit; }

/* Respecte les réglages système — utile en cuisine où l'écran reste allumé */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ============================ Animations ============================ */

@keyframes bbUp    { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bbIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes bbToast { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bbPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(111, 147, 166, .38); } 55% { box-shadow: 0 0 0 8px rgba(111, 147, 166, 0); } }
@keyframes bbBlink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes bbScan  { 0% { top: 6%; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { top: 94%; opacity: 0; } }
@keyframes bbSpin  { to { transform: rotate(360deg); } }

.bb-anim-up { animation: bbUp .45s cubic-bezier(.2, .7, .2, 1) both; }
.bb-anim-in { animation: bbIn .3s ease both; }

/* ============================ Coquille d'app ============================ */

.bb-app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bb-bg);
  color: var(--bb-ink);
}

/* Rail latéral (tablette / desktop) */
.bb-rail {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 26px 16px 20px;
  border-right: 1px solid var(--bb-line);
  background: var(--bb-card);
  transition: background .3s ease;
}

.bb-wordmark {
  font-family: var(--bb-serif);
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1;
}
.bb-wordmark i { color: var(--bb-acc); font-style: normal; }

.bb-rail-nav { display: flex; flex-direction: column; gap: 4px; }

.bb-nav {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: var(--bb-tap);
  background: none;
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--bb-mute);
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}
.bb-nav:hover { background: var(--bb-soft); }
.bb-nav[aria-current="page"], .bb-nav.is-on {
  background: var(--bb-soft);
  color: var(--bb-acc2);
}
.bb-nav svg { flex: none; }
.bb-nav .bb-count { margin-left: auto; }

/* Barre du haut */
.bb-topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--bb-line);
}

.bb-main { flex: 1; overflow-y: auto; overflow-x: hidden; }

.bb-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 26px 120px;
}
.bb-page--wide { max-width: 1320px; }

/* Barre d'onglets (téléphone) */
.bb-tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--bb-line);
  background: var(--bb-card);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}

.bb-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: var(--bb-tap);
  background: none;
  border: none;
  border-radius: 12px;
  padding: 8px 4px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--bb-mute);
  cursor: pointer;
}
.bb-tab.is-on { color: var(--bb-acc2); }

/* Bascule rail ↔ onglets */
@media (max-width: 860px) { .bb-desktop { display: none !important; } }
@media (min-width: 861px) { .bb-mobile  { display: none !important; } }

/* ============================ Typographie ============================ */

.bb-eyebrow {
  font-family: var(--bb-mono);
  font-size: 10.5px;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--bb-acc2);
}
.bb-eyebrow--mute { color: var(--bb-mute); }

.bb-h1 {
  font-family: var(--bb-serif);
  font-weight: 560;
  font-size: clamp(30px, 4.5vw, 42px);
  line-height: 1.05;
  letter-spacing: -.015em;
  margin: 0;
}
.bb-h2 {
  font-family: var(--bb-serif);
  font-weight: 560;
  font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin: 0;
}
.bb-h3 {
  font-family: var(--bb-serif);
  font-weight: 560;
  font-size: 19px;
  line-height: 1.2;
  margin: 0;
}

.bb-lede {
  margin: 12px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--bb-mute);
  max-width: 52ch;
}

.bb-num {
  font-family: var(--bb-mono);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Note de dressage — la voix du chef, toujours en italique serif */
.bb-dressage {
  font-family: var(--bb-serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--bb-mute);
}

.bb-hand { font-family: var(--bb-hand); }

/* ============================ Cartes ============================ */

.bb-card {
  background: var(--bb-card);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r-card);
  transition: background .3s ease, border-color .2s ease, transform .15s ease;
}
.bb-card--pad { padding: 18px 20px; }
.bb-card--accent { border-top: 4px solid var(--bb-acc); }
.bb-card--dashed { background: none; border: 1px dashed var(--bb-border); }
.bb-card--hover:hover { border-color: var(--bb-acc); }
.bb-card--lift:hover { transform: translateY(-3px); border-color: var(--bb-acc); }
.bb-card--shadow { box-shadow: var(--bb-sh); }

.bb-stat { padding: 18px 20px 16px; }
.bb-stat .bb-num { font-size: 40px; }
.bb-stat-label {
  margin-top: 8px;
  font-family: var(--bb-mono);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--bb-mute);
}

/* ============================ Boutons ============================ */

.bb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--bb-tap);
  background: none;
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r-btn);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--bb-mute);
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease, background .15s ease,
              border-color .15s ease, color .15s ease, opacity .2s ease;
}
.bb-btn:hover { background: var(--bb-soft); border-color: var(--bb-acc); color: var(--bb-acc2); }
.bb-btn:active { transform: scale(.98); }
.bb-btn svg { flex: none; }

.bb-btn--cta {
  background: var(--bb-cta);
  border-color: var(--bb-cta);
  color: var(--bb-ctafg);
  font-weight: 600;
}
.bb-btn--cta:hover { background: var(--bb-cta); color: var(--bb-ctafg); transform: translateY(-1px); filter: brightness(1.09); }

.bb-btn--outline { border-color: var(--bb-acc); color: var(--bb-acc2); }

.bb-btn--lg { min-height: 54px; padding: 15px 26px; font-size: 15.5px; border-radius: 13px; }

/* Cible « mains mouillées / gants » — rôle cuisine */
.bb-btn--xl {
  min-height: var(--bb-tap-xl);
  min-width: 150px;
  padding: 16px 28px;
  font-size: 19px;
  font-weight: 600;
  border-radius: 16px;
}

.bb-btn[disabled], .bb-btn.is-off { opacity: .42; pointer-events: none; }

.bb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: none;
  border: 1px solid var(--bb-line);
  border-radius: 50%;
  color: var(--bb-mute);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.bb-icon-btn:hover { border-color: var(--bb-acc); color: var(--bb-acc2); }
.bb-icon-btn--xl { width: 52px; height: 52px; }

/* ============================ Pastilles & étiquettes ============================ */

.bb-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--bb-mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 6px 13px;
  background: var(--bb-soft);
  color: var(--bb-acc2);
}
.bb-pill--quiet { background: var(--bb-card2); color: var(--bb-mute); }
.bb-pill--outline { background: none; border: 1px solid var(--bb-line); color: var(--bb-mute); }
.bb-pill--solid { background: var(--bb-cta); color: var(--bb-ctafg); }
.bb-pill--alert { background: var(--bb-orange); color: #fff; }

/* Chip d'ingrédient consommé — « tomates · 9 kg » */
.bb-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--bb-sans);
  font-size: 13px;
  background: var(--bb-card2);
  color: var(--bb-ink);
  border-radius: 999px;
  padding: 7px 15px;
  white-space: nowrap;
}

.bb-count {
  font-family: var(--bb-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--bb-cta);
  color: var(--bb-ctafg);
  border-radius: 999px;
  padding: 2px 8px;
}
.bb-count--alert { background: var(--bb-orange); color: #fff; }
.bb-count--quiet { background: var(--bb-card2); color: var(--bb-acc2); }

/* Pastille d'urgence — calculée, jamais saisie */
.bb-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; }
.bb-dot--today { background: var(--bb-acc2); animation: bbPulse 2s ease infinite; }
.bb-dot--week  { background: var(--bb-acc); opacity: .75; }
.bb-dot--ok    { background: none; border: 1.5px solid var(--bb-acc); }
.bb-dot--done  { background: var(--bb-mute); opacity: .5; }
.bb-dot--lg    { width: 14px; height: 14px; }

/* ============================ Formulaires ============================ */

.bb-field {
  width: 100%;
  min-height: var(--bb-tap);
  background: var(--bb-bg);
  border: 1px solid var(--bb-line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14.5px;
  color: var(--bb-ink);
  outline: none;
  transition: border-color .15s ease;
}
.bb-field:focus { border-color: var(--bb-acc); }
textarea.bb-field { min-height: 96px; line-height: 1.5; resize: vertical; }

.bb-label {
  display: block;
  font-family: var(--bb-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--bb-mute);
  margin-bottom: 7px;
}

/* Interrupteur */
.bb-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  min-height: var(--bb-tap);
}
.bb-switch-track {
  flex: none;
  width: 48px;
  height: 27px;
  border-radius: 999px;
  position: relative;
  background: var(--bb-card2);
  border: 1px solid var(--bb-border);
  transition: background .2s ease, border-color .2s ease;
}
.bb-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--bb-bg);
  box-shadow: 0 1px 3px rgba(42, 40, 31, .25);
  transition: left .2s cubic-bezier(.2, .7, .2, 1);
}
.bb-switch.is-on .bb-switch-track { background: var(--bb-cta); border-color: var(--bb-cta); }
.bb-switch.is-on .bb-switch-knob { left: 23px; }

/* Case à cocher ronde — les gestes du service */
.bb-check {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--bb-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}
.bb-check.is-on { background: var(--bb-acc); border-color: var(--bb-acc); }
.bb-check svg { opacity: 0; }
.bb-check.is-on svg { opacity: 1; }

/* Ligne cochable */
.bb-step {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  text-align: left;
  background: var(--bb-card2);
  border: 1px solid var(--bb-line);
  border-radius: var(--bb-r-soft);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.bb-step:hover { border-color: var(--bb-acc); }
.bb-step:active { transform: scale(.99); }
.bb-step.is-done { background: var(--bb-soft); border-color: var(--bb-acc); }
.bb-step-text { font-size: 15.5px; font-weight: 500; line-height: 1.35; }
.bb-step.is-done .bb-step-text { color: var(--bb-mute); text-decoration: line-through; }

/* ============================ Progression ============================ */

.bb-progress {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--bb-card2);
  overflow: hidden;
}
.bb-progress > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--bb-acc);
  transition: width .3s cubic-bezier(.2, .7, .2, 1);
}

/* ============================ Emplacement photo ============================ */
/* Reprend la maquette de référence : cadre pointillé, picto, légende du plat.  */

.bb-imgslot {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bb-card2);
  border: 1.5px dashed var(--bb-border);
  border-radius: 0;
  color: var(--bb-mute);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}
.bb-imgslot:hover { border-color: var(--bb-acc); }
.bb-imgslot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bb-imgslot-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  text-align: center;
  font-size: 13px;
}
.bb-imgslot-hint u { text-decoration: underline; text-underline-offset: 3px; }

/* ============================ Toast ============================ */

.bb-toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bb-ink);
  color: var(--bb-bg);
  border-radius: 999px;
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 34px rgba(30, 32, 23, .32);
  animation: bbToast .35s cubic-bezier(.2, .7, .2, 1) both;
  z-index: 90;
  max-width: 92vw;
}
.bb-toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================ Voile & panneau ============================ */

.bb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 28, 20, .48);
  display: flex;
  z-index: 80;
  animation: bbIn .2s ease both;
}
.bb-sheet {
  margin-left: auto;
  width: min(560px, 100%);
  height: 100%;
  background: var(--bb-bg);
  border-left: 1px solid var(--bb-border);
  display: flex;
  flex-direction: column;
  animation: bbUp .28s cubic-bezier(.2, .7, .2, 1) both;
  overflow-y: auto;
}
.bb-modal {
  margin: auto;
  width: min(460px, 100%);
  background: var(--bb-card);
  border: 1px solid var(--bb-border);
  border-radius: var(--bb-r-card);
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  animation: bbUp .22s cubic-bezier(.2, .7, .2, 1) both;
}

/* ============================ Grilles ============================ */

.bb-grid { display: grid; gap: 16px; }
.bb-grid--stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.bb-grid--cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.bb-grid--tiles { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.bb-row { display: flex; align-items: center; gap: 12px; }
.bb-row--wrap { flex-wrap: wrap; }
.bb-stack { display: flex; flex-direction: column; gap: 12px; }
.bb-spacer { margin-left: auto; }

/* ============================ Pied de page charte ============================ */

.bb-signature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--bb-mono);
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--bb-mute);
}
.bb-signature-dots { display: flex; gap: 4px; }
.bb-signature-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }

/* ============================ Échelle cuisine ============================ */
/* Le rôle cuisine tourne sur tablette, à bout de bras, avec des gants.
   Tout grossit d'un cran ; rien ne change de sens.                        */

.bb-scale-cuisine {
  --bb-tap: 56px;
  --bb-r-btn: 14px;
}
.bb-scale-cuisine .bb-lede { font-size: 17px; max-width: 46ch; }
.bb-scale-cuisine .bb-chip { font-size: 14.5px; padding: 8px 16px; }
.bb-scale-cuisine .bb-pill { font-size: 11.5px; padding: 7px 15px; }
.bb-scale-cuisine .bb-step { min-height: var(--bb-tap-xl); padding: 14px 18px; }
.bb-scale-cuisine .bb-step-text { font-size: 18px; }
.bb-scale-cuisine .bb-check { width: 32px; height: 32px; }
.bb-scale-cuisine .bb-btn { font-size: 16px; min-height: 56px; }
.bb-scale-cuisine .bb-progress { height: 8px; }

/* ============================ Utilitaires ============================ */

.bb-mute { color: var(--bb-mute); }
.bb-acc { color: var(--bb-acc2); }
.bb-strike { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.bb-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-hidden { display: none !important; }
.bb-dim { opacity: .6; }

.bb-sep { border: none; border-top: 1px solid var(--bb-line); margin: 0; }
.bb-sep--dash { border-top: 1px dashed var(--bb-line); }

.bb-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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