/* Food (Calories) page — Tracker / Food List / Meal Prep / Macro Targets.
   Scoped to .fx-* classes. Reuses exercise.css tokens:
   --bg, --border, --ink, --slate, --muted, --blue, --blue-dark, --blue-light,
   --error, --error-light, --ok, --white.
   FAB/sheet/field/button shapes follow body_comp.css's .bcx-fab-*/.bcx-sheet-*/
   .bcx-field/.bcx-btn-* patterns (same visual language, new prefix since food's
   sheets need an autocomplete dropdown + dynamic ingredient rows body_comp's
   sheets don't). */

#fx-main {
  overflow-y: auto;
  padding: 16px 0 96px;
}

/* ── Section tab bar ── plain segmented control, no JS-positioned pill (the
   two existing tab bars use a JS-measured sliding indicator; not worth the
   DOM-measurement code for a static 4-item bar). */
.fx-tabbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #EFF0F3;
  border-radius: 999px;
  padding: 5px;
  margin: 14px 16px 16px;
}
.fx-tabbtn {
  height: 40px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #8A919E;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color .2s, background .2s;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-tabbtn.on { background: var(--white); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.07); }

.fx-panel { padding: 0 16px; }

/* ── Period select ─────────────────────────────────────────────────────── */
.fx-period-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.fx-period-select {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
}
.fx-view-banner {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-dark);
  background: var(--blue-light);
  border-radius: 8px;
  padding: 6px 10px;
}

/* ── Hero card ─────────────────────────────────────────────────────────── */
.fx-hero {
  background: var(--blue);
  border-radius: 18px;
  padding: 18px 18px 16px;
  color: #fff;
  margin-bottom: 14px;
}
.fx-hero-label { font-size: 12px; font-weight: 600; opacity: .9; }
.fx-hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}
.fx-hero-cell-name { font-size: 11px; opacity: .8; margin-bottom: 4px; }
.fx-hero-cell-val { font-size: 20px; font-weight: 700; }
.fx-hero-cell-val span { font-size: 12px; font-weight: 500; opacity: .8; }
.fx-hero-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.25);
  margin: 8px 0 4px;
  overflow: hidden;
}
.fx-hero-bar-fill { height: 100%; background: #fff; border-radius: 4px; transition: width .3s; }
.fx-hero-bar-fill.over { background: #ffd2c2; }
.fx-hero-cell-meta { font-size: 10px; opacity: .85; display: flex; justify-content: space-between; }
.fx-hero-macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.fx-hero-macro-cell {
  background: rgba(255,255,255,.14);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}
.fx-hero-macro-val { font-size: 15px; font-weight: 700; }
.fx-hero-macro-lab { font-size: 9px; opacity: .85; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.fx-hero-meta { font-size: 11px; opacity: .85; margin-top: 12px; }

/* ── Rows list ─────────────────────────────────────────────────────────── */
.fx-rows { display: flex; flex-direction: column; gap: 8px; }
.fx-row {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}
.fx-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.fx-row-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.fx-row-manual {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--slate);
  background: var(--bg);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.fx-row-freq {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--blue-dark);
  background: var(--blue-light);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.fx-row-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.fx-row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.fx-row-time { font-size: 11px; color: var(--muted); }
.fx-row-del {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: none;
  background: var(--error-light);
  color: var(--error);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.fx-row-del svg { width: 14px; height: 14px; }
.fx-row-pills { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.fx-pill-tag {
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  padding: 3px 7px;
  white-space: nowrap;
}
.fx-pill-cal { background: #fdecea; color: #c0392b; }
.fx-pill-p   { background: #e6f1fb; color: #1e6091; }
.fx-pill-c   { background: #fff4e0; color: #b7791f; }
.fx-pill-f   { background: #f1e9fb; color: #7b3fbf; }
.fx-pill-s   { background: #e8f7ef; color: #0f6e56; }

.fx-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 13px;
}

/* ── FAB (single action — reuse body_comp's fab shape via a scoped alias) ─ */
.fx-fab-wrap {
  position: fixed;
  right: max(18px, calc(50% - 320px + 18px));
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.fx-fab-main {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--blue);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(37,99,201,.4);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fx-fab-main svg { width: 26px; height: 26px; stroke: #fff; }

/* ── Scrim + floating sheet (same shape language as body_comp.css) ───────── */
.fx-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 50;
}
.fx-scrim.show { opacity: 1; pointer-events: auto; }

.fx-sheet {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 28px);
  max-width: 612px;
  transform: translateX(-50%) translateY(calc(100% + 28px));
  z-index: 60;
  background: var(--bg);
  border-radius: 18px;
  padding: 8px 16px 22px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .28);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  max-height: 84%;
  overflow-y: auto;
}
.fx-sheet.show { transform: translateX(-50%) translateY(0); }
.fx-grab { width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 6px auto 14px; }
.fx-sheet h3 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 12px; }

.fx-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 14px; }
.fx-sheet-grid--three { grid-template-columns: repeat(3, 1fr); }
.fx-field { display: flex; flex-direction: column; gap: 4px; position: relative; }
.fx-field--full { grid-column: 1 / -1; }
.fx-field label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fx-field input, .fx-field select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  outline: none;
}
.fx-field input:focus, .fx-field select:focus { border-color: var(--blue); }
.fx-field input:read-only { background: var(--bg); color: var(--slate); }
.fx-field-hint { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Autocomplete suggestion list */
.fx-suggest {
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.12);
  max-height: 200px;
  overflow-y: auto;
  z-index: 5;
}
.fx-suggest-opt {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg);
}
.fx-suggest-opt:last-child { border-bottom: none; }
.fx-suggest-opt:hover { background: var(--blue-light); }
.fx-suggest-name { font-weight: 600; color: var(--ink); }
.fx-suggest-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }
.fx-suggest-empty { padding: 10px 11px; font-size: 12px; color: var(--muted); }

/* Manual-mode toggle chip row */
.fx-mode-row { display: flex; gap: 8px; margin-bottom: 12px; }
.fx-mode-chip {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--slate);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.fx-mode-chip.on { border-color: var(--blue); background: var(--blue-light); color: var(--blue-dark); }

.fx-sheet-actions { display: flex; gap: 8px; align-items: center; }
.fx-btn-primary {
  flex: 2;
  background: var(--blue);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 12px;
  border-radius: 9px;
  cursor: pointer;
}
.fx-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.fx-btn-ghost {
  flex: 1;
  background: transparent;
  color: var(--slate);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 9px;
  cursor: pointer;
}
.fx-status { display: block; font-size: 12px; color: var(--muted); margin-top: 8px; }
.fx-status.success { color: #0f6e56; }
.fx-status.error { color: #c0392b; }

/* ── Ingredient rows (Meal Prep) ──────────────────────────────────────── */
.fx-ingredient {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  position: relative;
}
.fx-ingredient-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fx-ingredient-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fx-ingredient-remove {
  border: none; background: transparent; color: var(--error);
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 2px 6px;
}
.fx-add-ingredient {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--blue);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
}
.fx-meal-totals {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.fx-meal-total-cell { text-align: center; }
.fx-meal-total-val { font-size: 13px; font-weight: 700; color: var(--ink); }
.fx-meal-total-lab { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ── Target history list (Macro Targets tab) ──────────────────────────── */
.fx-target-form { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.fx-target-history { display: flex; flex-direction: column; gap: 8px; }
.fx-target-row {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.fx-target-date { font-size: 12px; font-weight: 600; color: var(--ink); }
.fx-goal-pill { font-size: 10px; font-weight: 700; border-radius: 6px; padding: 3px 8px; text-transform: capitalize; }
.fx-goal-cutting     { background: #fdecea; color: #c0392b; }
.fx-goal-maintenance { background: #e6f1fb; color: #1e6091; }
.fx-goal-bulking     { background: #e8f7ef; color: #0f6e56; }
.fx-target-vals { font-size: 11px; color: var(--slate); display: flex; gap: 8px; }

.fx-section-title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 4px 0 10px; }
