/* ============================================================
   COMPONENTS - buttons, nav, cards, tabs, tables, modal, toast,
   badges, dropdown, stepper, bar graph. All read the tokens.
   ============================================================ */

/* ---- Buttons ---- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: var(--s-2) var(--s-4); border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--c-green); color: #fff;
  display: inline-flex; align-items: center; gap: var(--s-2);
}
.btn:hover { background: var(--c-green-dark); }
.btn.secondary { background: var(--c-card); color: var(--c-green); border-color: var(--c-line); }
.btn.secondary:hover { background: var(--c-green-soft); }
.btn.ghost { background: transparent; color: var(--c-slate); }
.btn.ghost:hover { background: #ece6dc; }
.btn.danger { background: var(--c-danger); }
.btn.danger:hover { filter: brightness(0.93); }
.btn.accent { background: linear-gradient(135deg, var(--c-coral), var(--c-amber)); }
.btn.accent:hover { filter: brightness(0.96); }
.btn.sm { padding: var(--s-1) var(--s-2); font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.week-selected { background: var(--c-green); color: #fff; border-color: var(--c-green); }
.btn.week-selected:hover { background: var(--c-green-dark); }

/* ---- Top navigation bar ---- */
.topbar {
  background: var(--c-card); border-bottom: 1px solid var(--c-line);
  box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: var(--s-3) var(--s-4);
  display: flex; align-items: center; gap: var(--s-4);
}
.brand { font-weight: 800; color: var(--c-green); font-size: var(--fs-md); display: flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--c-green), var(--c-teal)); display: inline-block; }
.nav-links { display: flex; gap: var(--s-1); margin-left: var(--s-5); flex: 1; }
.nav-link {
  background: none; border: none; font: inherit; cursor: pointer; color: var(--c-slate);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-weight: 600;
}
.nav-link:hover { background: #ece6dc; color: var(--c-ink); }
.nav-link.active { background: var(--c-green-soft); color: var(--c-green); }
@media (max-width: 720px) { .nav-links { overflow-x: auto; } }

/* Account dropdown on the far right */
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: var(--s-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--c-teal); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); }
.menu {
  position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--c-line);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); min-width: 200px; padding: var(--s-2); z-index: 60;
}
.menu button { display: block; width: 100%; text-align: left; background: none; border: none; font: inherit; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); cursor: pointer; color: var(--c-ink); }
.menu button:hover { background: #ece6dc; }
.menu .sep { height: 1px; background: var(--c-line); margin: var(--s-2) 0; }

/* ---- Cards + surfaces ---- */
.card { background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--r-md); padding: var(--s-4); box-shadow: var(--shadow-sm); }
.panel { background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--r-md); padding: var(--s-4); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: var(--s-2); border-bottom: 1px solid var(--c-line); margin-bottom: var(--s-4); }
.tab { background: none; border: none; font: inherit; cursor: pointer; padding: var(--s-3) var(--s-3); color: var(--c-slate); font-weight: 600; border-bottom: 3px solid transparent; }
.tab.active { color: var(--c-green); border-bottom-color: var(--c-green); }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: var(--s-3); border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.table th { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-muted); }
.table tr.selectable { cursor: pointer; }
.table tr.selectable:hover { background: var(--c-green-soft); }

/* ---- Badges + tags ---- */
.badge { display: inline-block; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-sm); padding: 2px 8px; }
.badge.deal { background: var(--c-green-soft); color: var(--c-green); border: 1px solid #bfe3cd; }
.badge.cheapest { background: #fbf0d6; color: #8a6a1a; border: 1px solid #ecdcbf; }
.badge.value { background: var(--c-teal); color: #fff; border: 1px solid #1a6f7a; }
.badge.danger { background: var(--c-danger-soft); color: var(--c-danger); }
.tag { display: inline-block; font-size: var(--fs-xs); color: #fff; border-radius: var(--r-pill); padding: 2px 10px; font-weight: 600; }
.cost-pill { display: inline-block; background: linear-gradient(135deg, var(--c-coral), var(--c-amber)); color: #fff; font-weight: 700; border-radius: var(--r-sm); padding: 2px 8px; font-size: var(--fs-sm); }
.rating { color: var(--c-amber); font-weight: 700; }

/* ---- Recipe cards (in the Find/results grid) ---- */
.recipe-card { background: #fff; border: 1px solid var(--c-line); border-left: 6px solid var(--c-green); border-radius: var(--r-md); padding: var(--s-3); display: flex; gap: var(--s-3); align-items: flex-start; }
.recipe-card.complementary { background: var(--c-highlight); }
.recipe-card .title { font-weight: 700; color: var(--c-green-dark); cursor: pointer; }
.recipe-card .title:hover { text-decoration: underline; }
.recipe-thumb { width: 92px; height: 66px; object-fit: cover; border-radius: var(--r-sm); flex-shrink: 0; }
.recipe-hero { width: 100%; height: 200px; object-fit: cover; border-radius: var(--r-md); margin-bottom: var(--s-3); display: block; }
.tags { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: var(--s-2) 0; }
.pantry-badge { display: inline-block; background: var(--c-green-soft); color: var(--c-green); border: 1px solid #bfe3cd; border-radius: var(--r-sm); padding: 1px 8px; font-size: var(--fs-xs); font-weight: 600; }

/* ---- Filter sidebar ---- */
.filters .group { border-top: 1px solid var(--c-line); padding: var(--s-3) 0; }
.filters .group:first-of-type { border-top: none; }
.group-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-muted); font-weight: 700; margin-bottom: var(--s-2); }
.filter-toggle { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; margin-bottom: 0; padding: var(--s-1) 0; }
.filter-toggle:hover { color: var(--c-ink); }
.filter-arrow { font-size: 10px; transition: transform 0.2s; display: inline-block; }
.filter-toggle.open .filter-arrow { transform: rotate(180deg); }
.filter-body { padding-top: var(--s-2); }
.check { display: flex; align-items: center; gap: var(--s-2); padding: 3px 0; font-size: var(--fs-sm); cursor: pointer; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.field { width: 100%; padding: var(--s-2); border: 1px solid var(--c-line); border-radius: var(--r-sm); font: inherit; }

/* ---- Stepper (times per week) ---- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--c-line); border-radius: var(--r-sm); overflow: hidden; }
.stepper button { background: #ece6dc; border: none; cursor: pointer; padding: 2px 10px; font: inherit; font-weight: 700; }
.stepper button:hover { background: #ddd5c6; }
.stepper .val { padding: 2px 10px; min-width: 28px; text-align: center; }

/* ---- Nudge banner (bulk deal) ---- */
.nudge { background: #fbf2dd; border: 1px solid #ecdcbf; border-radius: var(--r-md); padding: var(--s-3); color: #7a5b00; display: flex; gap: var(--s-2); align-items: flex-start; }

/* ---- Collapsible store row (shopping) ---- */
.store-row { border: 1px solid var(--c-line); border-radius: var(--r-md); margin-bottom: var(--s-3); overflow: hidden; }
.store-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-4); cursor: pointer; background: #fff; }
.store-head:hover { background: #f3eee6; }
.store-total { font-weight: 800; color: var(--c-green); }
.chev { transition: transform 0.15s ease; }
.store-row.open .chev { transform: rotate(180deg); }
.store-body { border-top: 1px solid var(--c-line); padding: var(--s-3) var(--s-4); }
.aisle-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; color: var(--c-muted); font-weight: 700; margin: var(--s-3) 0 var(--s-1); }
.line-item { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #ece4d6; }
.price { font-weight: 700; color: var(--c-green); }

/* ---- Modal + overlay ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 35, 28, 0.5); display: flex; align-items: flex-start; justify-content: center; padding: var(--s-5) var(--s-4); overflow-y: auto; z-index: 100; }
.modal { background: #fff; border-radius: var(--r-lg); max-width: 720px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4); border-bottom: 1px solid var(--c-line); }
.modal-body { padding: var(--s-4); }
.close-x { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--c-muted); }
.close-x:hover { color: var(--c-ink); }

/* ---- Toast ---- */
.toast-stack { position: fixed; right: var(--s-4); bottom: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); z-index: 200; }
.toast { background: var(--c-ink); color: #fff; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-md); font-size: var(--fs-sm); max-width: 320px; }
.toast.success { background: var(--c-success); }
.toast.warn { background: var(--c-warn); }

/* ---- Bar graph (nutrition, used in M2) ---- */
.bargraph { display: flex; align-items: flex-end; gap: var(--s-2); height: 140px; padding-top: var(--s-3); }
.bargraph .bar { flex: 1; background: linear-gradient(180deg, var(--c-teal), var(--c-green)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bargraph .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: var(--fs-xs); color: var(--c-muted); }

/* ---- Nutrient bars (shared) ---- */
.nutrient { margin: var(--s-2) 0; }
.nutrient-top { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.bar-track { background: #ece4d6; border-radius: var(--r-sm); height: 10px; margin-top: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--c-teal), var(--c-green)); }
.bar-fill.over { background: linear-gradient(90deg, #e57373, var(--c-danger)); }
.over-max { background: var(--c-danger-soft); color: var(--c-danger); border: 1px solid #f5c6c0; font-size: var(--fs-xs); font-weight: 700; border-radius: 4px; padding: 0 6px; margin-left: 6px; }

/* ---- Shopping line items: name + quantity, unit price, line total ---- */
.line-item.cols3 { display: grid; grid-template-columns: 1fr auto auto; gap: 2px var(--s-4); align-items: center; }
.line-item .qty { color: var(--c-muted); font-size: var(--fs-xs); }
.line-item .unit-price { color: var(--c-slate); font-size: var(--fs-sm); white-space: nowrap; }

/* ---- Ingredient -> recipes backlink ---- */
.ing-link { color: var(--c-green-dark); text-decoration: underline; text-decoration-style: dotted; cursor: pointer; }
.ing-link:hover { color: var(--c-green); }
.ing-recipe { display: block; width: 100%; text-align: left; background: var(--c-green-soft); color: var(--c-green); border: 1px solid #bfe3cd; border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); cursor: pointer; font: inherit; font-weight: 600; }
.ing-recipe:hover { background: #d8eede; }

/* ---- Creator attribution + community ---- */
.creator-bar { background: linear-gradient(135deg, var(--c-teal), var(--c-green)); color: #fff; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-sm); padding: 3px 10px; margin-bottom: var(--s-2); display: inline-block; }
.creator-bar .creator-link { color: #fff; text-decoration: underline; cursor: pointer; }
.creator-badge { background: #fbf0d6; color: #8a6a1a; border: 1px solid #ecdcbf; border-radius: var(--r-sm); padding: 0 6px; font-size: var(--fs-xs); font-weight: 700; }

/* ---- Future-feature (greyed-out) filter groups ---- */
.future-feature { opacity: 0.6; }
.future-feature .check { cursor: not-allowed; }
.future-tag { background: var(--c-highlight); color: #8a6a1a; border: 1px solid #ecdcbf; border-radius: var(--r-pill); padding: 0 8px; font-size: var(--fs-xs); font-weight: 700; margin-left: 6px; vertical-align: middle; }

/* ---- Complete-meal vs needs-a-side label ---- */
.pc-meal-label { margin: 6px 0 2px; }
.meal-label { display: inline-block; font-size: var(--fs-sm); font-weight: 700; border-radius: var(--r-pill); padding: 2px 10px; }
.meal-label.complete { background: var(--c-green-soft); color: var(--c-green-dark); border: 1px solid #bfe3cd; }
.meal-label.needs { background: var(--c-highlight); color: #8a6a1a; border: 1px solid #ecdcbf; }

/* ---- Step headings + bold ingredients in instructions ---- */
.step-list .step-head { list-style: none; margin-left: -1.2em; margin-top: var(--s-3); }
.step-heading { display: inline-block; font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--c-teal); }
.step-list li strong { color: var(--c-ink); font-weight: 700; }

/* ---- Card extra blocks (pairings, alternatives, rating) ---- */
.card-extra { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--c-line); }
.card-extra h3 { margin: 0 0 var(--s-2); }
.pairing-item { display: block; width: 100%; text-align: left; background: var(--c-card); border: 1px solid var(--c-line); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); cursor: pointer; font: inherit; margin-bottom: var(--s-2); }
.pairing-item:hover { background: var(--c-green-soft); border-color: #bfe3cd; }
.pairing-title { display: block; font-weight: 700; color: var(--c-green-dark); }
.pairing-why { display: block; font-size: var(--fs-sm); color: var(--c-muted); }
.alt-method { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--c-line); }
.alt-name { font-weight: 700; }
.alt-window { font-weight: 600; color: var(--c-teal); white-space: nowrap; }
.alt-note { grid-column: 1 / -1; }

/* ---- Star rating widget + reviews ---- */
.star-row { display: flex; align-items: center; gap: 2px; margin-bottom: var(--s-2); }
.star-btn { background: none; border: none; cursor: pointer; font-size: 1.5rem; line-height: 1; color: var(--c-amber); padding: 0 1px; }
.star-btn:hover { filter: brightness(1.1); }
.star-row .small { margin-left: var(--s-2); }
.stars-static { color: var(--c-amber); letter-spacing: 1px; }
.review-item { margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px dashed var(--c-line); }
.review-text { margin-top: 2px; }

/* ---- Combined-recipe merge tags (mix & match) ---- */
.merge-tag { display: inline-block; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-pill); padding: 0 7px; margin-right: 4px; vertical-align: baseline; }
.merge-main { background: var(--c-green-soft); color: var(--c-green-dark); border: 1px solid #bfe3cd; }
.merge-side { background: var(--c-highlight); color: #8a6a1a; border: 1px solid #ecdcbf; }
.merge-shared { background: #e7eef6; color: var(--c-sky); border: 1px solid #cdddee; }

/* ---- Nutrition-tier badge (previews the curator nutrition rubric) ---- */
.badge.tier-excellent { background: var(--c-green); color: #fff; border: 1px solid var(--c-green-dark); }
.badge.tier-very-good { background: var(--c-green-soft); color: var(--c-green-dark); border: 1px solid #bfe3cd; }
.badge.tier-good { background: #fbf0d6; color: #8a6a1a; border: 1px solid #ecdcbf; }
.badge.tier-moderate { background: #eee9e0; color: var(--c-slate); border: 1px solid var(--c-line); }

/* ---- Region chip (recipe card; previews the curated DB's region organization) ---- */
.region-chip { display: inline-block; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-pill); padding: 1px 10px; background: #e7eef6; color: var(--c-sky); border: 1px solid #cdddee; }

/* ---- Budget slider (Find filter; demos cost_flag "filter by budget, never reject") ---- */
.budget-slider { width: 100%; margin: var(--s-2) 0 0; accent-color: var(--c-green); }
.budget-readout { font-weight: 700; color: var(--c-green-dark); }

/* ---- This-week tray chip (header running count + total cost) ---- */
.week-tray { display: inline-flex; align-items: center; gap: 6px; background: var(--c-green-soft); color: var(--c-green-dark); border: 1px solid #bfe3cd; border-radius: var(--r-pill); padding: 2px 12px; font-weight: 700; font-size: var(--fs-sm); }
.week-tray .tray-cost { font-weight: 600; opacity: 0.85; }
