/* ==========================================================================
   MIPB Ingredient Pricing Tool — pricing-table.css
   Covers [ingredient_pricing_table] (.mpt-*)
   ========================================================================== */

:root {
  --pt-primary:   #2e7d32;
  --pt-accent:    #66bb6a;
  --pt-bar-bg:    #e8f5e9;
  --pt-bar-fill:  #2e7d32;
  --pt-border:    #e0e0e0;
  --pt-row-hover: #f1f8f1;
  --pt-muted:     #757575;
  --pt-radius:    6px;
}

/* ============================================================
   Layout
   ============================================================ */
.mpt-wrap { max-width: 1100px; margin: 0 auto; font-family: inherit; }

/* ── Hero: outer wrapper ──────────────────────────────────────── */
.mpt-hero { max-width: 1100px; margin-bottom: 1.5rem; }

/* Row 1 — "Top 10 Lists" label + pill buttons in one line */
.mpt-hero-nav-row {
  display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center;
  margin-bottom: .75rem;
}
.mpt-hero-label {
  font-weight: 700; font-size: .95rem; color: var(--pt-primary);
  white-space: nowrap; flex-shrink: 0;
}
.mpt-hero-tab-nav {
  display: flex; flex-wrap: wrap; gap: .3rem; flex: 1 1 auto;
}
.mpt-hero-tab-btn {
  padding: .3rem .65rem; background: #f1f3f4; border: 1px solid var(--pt-border);
  border-radius: 20px; font-size: .78rem; cursor: pointer; color: #333;
  transition: background .15s, color .15s; white-space: nowrap;
}
.mpt-hero-tab-btn:hover { background: var(--pt-bar-bg); }
.mpt-hero-tab-btn--active {
  background: var(--pt-primary); color: #fff; border-color: var(--pt-primary);
}
.mpt-hero-tab-btn--active:hover { background: #1b5e20; border-color: #1b5e20; }

/* Row 2 — panels (left) + snapshot (right) side by side */
.mpt-hero-content {
  display: grid; grid-template-columns: 1fr auto; gap: 1.5rem;
  align-items: start;
}
.mpt-hero-tabs { min-width: 0; position: relative; }

/* ── Hero panels — all in DOM flow for full SEO indexing ──────────
   Inactive panels use sr-only clip technique (not display:none)
   so Googlebot treats all content as primary crawlable text. */
.mpt-hero-panel {
  clip: rect(0 0 0 0); clip-path: inset(50%);
  height: 1px; width: 1px; overflow: hidden;
  position: absolute; white-space: nowrap;
  padding: 0; margin: -1px; border: 0;
}
.mpt-hero-panel--active {
  clip: auto; clip-path: none;
  height: auto; width: auto; overflow: visible;
  position: static; white-space: normal;
  padding: 0; margin: 0;
}
.mpt-hero-panel h2 { font-size: 1.05rem; margin: 0 0 .4rem; }

/* ── Numbered ranked lists (CSS counter for visible 1–10) ─────── */
.mpt-top10-list {
  list-style: none; margin: 0; padding: 0;
  counter-reset: mpt-rank;
}
.mpt-top10-list li {
  counter-increment: mpt-rank;
  margin-bottom: .1rem; line-height: 1.4; font-size: .87rem;
  display: flex; flex-wrap: wrap; gap: 0 .35rem; align-items: baseline;
}
.mpt-top10-list li::before {
  content: counter(mpt-rank) ".";
  font-weight: 700; color: var(--pt-primary); min-width: 1.5em;
  flex-shrink: 0; font-size: .85rem;
}
.mpt-li-name { font-weight: 600; color: #222; }
.mpt-li-val  { font-size: .8rem; color: var(--pt-muted); white-space: nowrap; }

/* ── Dataset Snapshot card (right side, flavonoid insight style) ── */
.mpt-snapshot {
  background: #f0f7f0; border: 1px solid var(--pt-border); border-radius: 8px;
  padding: 1rem 1.2rem; min-width: 210px;
}
.mpt-snapshot-title {
  font-size: 1rem; font-weight: 700; color: var(--pt-primary);
  margin: 0 0 .6rem;
}
.mpt-snapshot-list {
  list-style: none; margin: 0; padding: 0;
  font-size: .88rem; line-height: 1.7; color: #333;
}
.mpt-snapshot-list li { border-bottom: 1px solid #d6e8d6; padding: .2rem 0; }
.mpt-snapshot-list li:last-child { border-bottom: none; }

/* Controls */
.mpt-controls {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: 1rem;
}
.mpt-search {
  padding: .45rem .7rem; border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius); font-size: .93rem;
  background: #fff; flex: 1 1 220px; max-width: 400px;
}
.mpt-search:focus { outline: 2px solid var(--pt-primary); outline-offset: 1px; }
.mpt-order-btn {
  padding: .45rem .9rem; background: var(--pt-primary); color: #fff;
  border: none; border-radius: var(--pt-radius); font-size: .88rem;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.mpt-order-btn:hover { background: #1b5e20; }

/* Sort tabs */
.mpt-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.mpt-tab {
  padding: .38rem .85rem; background: #f1f3f4; border: 1px solid var(--pt-border);
  border-radius: 20px; font-size: .85rem; cursor: pointer; color: #333;
  transition: background .15s, color .15s;
}
.mpt-tab:hover { background: var(--pt-bar-bg); }
.mpt-tab.active {
  background: var(--pt-primary); color: #fff; border-color: var(--pt-primary);
}

/* Summary bar */
.mpt-summary {
  background: var(--pt-bar-bg); padding: .6rem 1rem; border-radius: var(--pt-radius);
  margin-bottom: 1rem; font-size: .88rem; color: #333; display: flex;
  flex-wrap: wrap; gap: .6rem 1.5rem; align-items: center;
}
.mpt-summary-stat { font-weight: 600; color: var(--pt-primary); }

/* Table */
.mpt-table-wrap { overflow-x: auto; border: 1px solid var(--pt-border); border-radius: var(--pt-radius); }
.mpt-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 580px; }
.mpt-table thead { background: #f9f9f9; }
.mpt-table th {
  text-align: left; padding: .55rem .7rem; font-weight: 600; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .02em; color: #555;
  border-bottom: 2px solid var(--pt-border); white-space: nowrap;
}
.mpt-table td { padding: .5rem .7rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.mpt-table tbody tr:hover { background: var(--pt-row-hover); }

.mpt-food-name { font-weight: 500; color: #222; max-width: 320px; }
.mpt-price { font-weight: 600; color: var(--pt-primary); white-space: nowrap; }
.mpt-ref { color: var(--pt-muted); font-size: .85rem; white-space: nowrap; }
.mpt-source { font-size: .82rem; color: var(--pt-muted); }
.mpt-null { color: #ccc; }

/* Price bar */
.mpt-bar-cell { width: 120px; min-width: 80px; }
.mpt-bar { height: 12px; border-radius: 3px; background: var(--pt-bar-fill); min-width: 2px; transition: width .3s; }

/* Pagination */
.mpt-pagination {
  display: flex; justify-content: center; gap: .4rem; margin-top: 1rem; flex-wrap: wrap;
}
.mpt-page-btn {
  padding: .35rem .7rem; border: 1px solid var(--pt-border); border-radius: var(--pt-radius);
  background: #fff; font-size: .85rem; cursor: pointer; color: #333;
}
.mpt-page-btn:hover { background: var(--pt-bar-bg); }
.mpt-page-btn.active { background: var(--pt-primary); color: #fff; border-color: var(--pt-primary); }
.mpt-page-btn:disabled { opacity: .4; cursor: default; }

/* Loading */
.mpt-loading { text-align: center; padding: 2rem; color: var(--pt-muted); }

/* Legend */
.mpt-legend { font-size: .82rem; color: var(--pt-muted); margin-top: 1rem; line-height: 1.6; }

/* FAQ — left-aligned, width-matched to .mpt-wrap to prevent overflow */
.mpt-faq {
  margin-top: 2rem; text-align: left;
  max-width: 1100px !important; width: 100% !important;
  overflow: hidden !important; box-sizing: border-box;
}
.mpt-faq h2 { font-size: 1.15rem; margin-bottom: .6rem; text-align: left; }
.mpt-faq details {
  border-bottom: 1px solid #eee;
  max-width: 100% !important; overflow: hidden !important;
  box-sizing: border-box;
}
.mpt-faq summary {
  padding: .7rem 0; font-weight: 500; cursor: pointer; font-size: .95rem; color: #333;
  max-width: 100%; box-sizing: border-box;
}
.mpt-faq summary:hover { color: var(--pt-primary); }
.mpt-faq details[open] summary { color: var(--pt-primary); }
.mpt-faq p, .mpt-faq a {
  margin: 0 0 .8rem; padding-left: .5rem; font-size: .92rem; line-height: 1.65; color: #444;
  overflow-wrap: break-word !important; word-wrap: break-word !important;
  word-break: break-word !important; max-width: 100% !important;
  box-sizing: border-box;
}
.mpt-faq a { display: inline; }

/* Nutrient secondary column */
.mpt-price-secondary { font-size: .85rem; color: #555; white-space: nowrap; }

/* Clickable column headers */
.mpt-th-sort { cursor: pointer; user-select: none; }
.mpt-th-sort:hover { color: var(--pt-primary); }
.mpt-sort-arrow { font-size: .7rem; vertical-align: middle; color: var(--pt-primary); }

/* Nutrient selector row */
.mpt-nutrient-row {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  margin-bottom: 1rem;
}
.mpt-nutrient-label { font-size: .88rem; color: #555; white-space: nowrap; }
.mpt-nutrient-select {
  padding: .38rem .6rem; border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius); font-size: .88rem; background: #fff;
  min-width: 180px; max-width: 340px; flex: 1 1 auto;
}
.mpt-nutrient-select:focus { outline: 2px solid var(--pt-primary); outline-offset: 1px; }

/* Whole-food toggle */
.mpt-wf-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  cursor: pointer; user-select: none; white-space: nowrap;
  margin-left: auto;
}
.mpt-wf-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.mpt-wf-slider {
  position: relative; display: inline-block;
  width: 36px; height: 20px; border-radius: 10px;
  background: #ccc; transition: background .25s;
  flex-shrink: 0;
}
.mpt-wf-slider::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .25s;
}
.mpt-wf-checkbox:checked + .mpt-wf-slider { background: var(--pt-primary, #2e7d32); }
.mpt-wf-checkbox:checked + .mpt-wf-slider::after { transform: translateX(16px); }
.mpt-wf-checkbox:focus-visible + .mpt-wf-slider { outline: 2px solid var(--pt-primary); outline-offset: 2px; }
.mpt-wf-label-text { font-size: .85rem; color: #555; }

/* Category filter dropdown */
.mpt-category-select {
  padding: .45rem .6rem; border: 1px solid var(--pt-border);
  border-radius: var(--pt-radius); font-size: .88rem; background: #fff;
  min-width: 160px; max-width: 260px; flex-shrink: 0;
}
.mpt-category-select:focus { outline: 2px solid var(--pt-primary); outline-offset: 1px; }

/* Share bar (reuses global share styles) */

/* ---- Tablet ---- */
@media (max-width: 860px) {
  .mpt-hero-content { grid-template-columns: 1fr; }
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
  .mpt-table { min-width: 500px; font-size: .82rem; }
  .mpt-table th, .mpt-table td { padding: .4rem .5rem; }
  .mpt-bar-cell { width: 60px; min-width: 40px; }
  .mpt-summary { flex-direction: column; gap: .3rem; }
  .mpt-nutrient-row { flex-direction: column; align-items: stretch; }
  .mpt-nutrient-select { max-width: 100%; }
  .mpt-wf-toggle { margin-left: 0; }
  .mpt-category-select { max-width: 100%; min-width: 0; }
  .mpt-hero-tab-nav { gap: .2rem; }
  .mpt-hero-tab-btn { font-size: .72rem; padding: .25rem .45rem; }
  .mpt-hero-label { font-size: .85rem; }
}
