/* ============================================================
   MIPB — Flavonoid Table + Comparison Tools
   Shared CSS for [flavonoid_table] and [compare_flavonoids]
   Theme: Rose/Magenta — flavonoid pigments, berries, flowers
   ============================================================ */

/* ── Tool-specific color variables ──────────────────────────── */
.mft-app, .mfc-app {
  --primary:  #880e4f;
  --bg-light: #fce4ec;
  --border:   #f48fb1;
  --g-dark:   #560027;
  --g-mid:    #ad1457;
}

/* ── Top-10 SEO block ────────────────────────────────────────── */
.mft-top10 { margin-bottom: 2rem; }
.mft-top10 h2 { font-size: 1.25rem; margin-bottom: .5rem; color: #880e4f; }
.mft-top10-list { margin: 0; padding-left: 1.4rem; }
.mft-top10-list li { margin-bottom: .3rem; line-height: 1.5; }

/* ── Shared ────────────────────────────────────────────────── */
.mft-app, .mfc-app {
    font-family: inherit;
    color: var(--g-dark, #560027);
    max-width: 960px;
    margin: 0 auto;
}
.mft-source-note {
    font-size: 0.78rem;
    color: var(--g-mid, #666);
    margin-top: 1.5rem;
}
.mft-source-note a { color: var(--primary, #880e4f); }
.mft-loading { color: var(--g-mid, #ad1457); font-style: italic; }
.mft-error   { color: #c0392b; }
.mft-empty   { color: var(--g-mid, #ad1457); }

/* ── Controls row ───────────────────────────────────────────── */
.mft-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.mft-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 170px;
    flex: 1;
}
.mft-control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--g-mid, #666);
}

/* ── Combobox ───────────────────────────────────────────────── */
.mft-combobox { position: relative; }
.mft-combobox-input,
.mft-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    box-sizing: border-box;
}
.mft-combobox-input:focus,
.mft-search-input:focus {
    outline: none;
    border-color: var(--primary, #880e4f);
    box-shadow: 0 0 0 3px rgba(136,14,79,.12);
}
.mft-combobox-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.mft-combo-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
}
.mft-combo-item:hover { background: var(--bg-light, #fce4ec); }

/* ── Sort toggle ─────────────────────────────────────────────── */
.mft-sort-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    overflow: hidden;
}
.mft-sort-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--g-dark, #333);
    transition: background .15s;
}
.mft-sort-btn + .mft-sort-btn { border-left: 1px solid var(--border, #f48fb1); }
.mft-sort-btn.active {
    background: var(--primary, #880e4f);
    color: #fff;
    font-weight: 600;
}

/* ── Meta row ────────────────────────────────────────────────── */
.mft-meta {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--g-dark, #333);
}
.mft-class-badge {
    display: inline-block;
    background: var(--bg-light, #fce4ec);
    color: var(--primary, #880e4f);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15em 0.55em;
    border-radius: 20px;
    margin-left: 0.25rem;
}

/* ── Ranking table ───────────────────────────────────────────── */
.mft-table-wrap { overflow-x: auto; }
.mft-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.mft-table th {
    background: var(--bg-light, #fce4ec);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--border, #f48fb1);
    white-space: nowrap;
}
.mft-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border, #e8e8e8);
    vertical-align: middle;
}
.mft-table tr:last-child td { border-bottom: none; }
.mft-table tr:hover td { background: var(--bg-light, #fef6f9); }
.mft-rank      { color: var(--g-mid, #ad1457); width: 3rem; text-align: right; }
.mft-food-name { font-weight: 500; }
.mft-cat       { color: var(--g-mid, #ad1457); font-size: 0.8rem; }
.mft-val-col, .mft-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mft-bar-col   { width: 180px; }
.mft-bar-cell  { padding-right: 0.5rem; }
.mft-bar {
    height: 8px;
    background: var(--primary, #880e4f);
    border-radius: 4px;
    min-width: 2px;
    opacity: .75;
    transition: width .3s;
}

/* ── Pagination ──────────────────────────────────────────────── */
.mft-pagination { margin-top: 1rem; }
.mft-page-btns  { display: flex; align-items: center; gap: 0.75rem; }
.mft-page-btn {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
}
.mft-page-btn:hover { background: var(--bg-light, #fce4ec); }
.mft-page-info { font-size: 0.85rem; color: var(--g-mid, #666); }

/* ── Comparison tool ─────────────────────────────────────────── */
.mfc-food-selector { margin-bottom: 1rem; }
.mfc-search-row    { position: relative; max-width: 440px; }
.mfc-food-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}
.mfc-food-input:focus {
    outline: none;
    border-color: var(--primary, #880e4f);
    box-shadow: 0 0 0 3px rgba(136,14,79,.12);
}
.mfc-ac-box {
    position: absolute;
    top: calc(100% + 3px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
.mfc-ac-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.mfc-ac-item:hover  { background: var(--bg-light, #fce4ec); }
.mfc-ac-cat { font-size: 0.75rem; color: var(--g-mid, #ad1457); flex-shrink: 0; }

.mfc-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; min-height: 1.5rem; }
.mfc-chip  {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    background: var(--bg-light, #fce4ec);
    border: 1px solid var(--primary, #a5d6a7);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--g-dark, #560027);
}
.mfc-chip-rm {
    background: none; border: none; cursor: pointer;
    font-size: 1rem; line-height: 1; color: var(--g-mid, #666);
    padding: 0; margin: 0;
}
.mfc-chip-rm:hover { color: #c0392b; }
.mfc-hint { font-size: 0.78rem; color: var(--g-mid, #ad1457); margin: 0.4rem 0 0; }

.mfc-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    padding: 0.85rem;
    background: var(--bg-light, #fce4ec);
    border-radius: 8px;
}
.mfc-filter-group { display: flex; flex-direction: column; gap: 0.3rem; }
.mfc-filter-group label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing:.04em; color: var(--g-mid,#666); }
.mfc-filter-group select,
.mfc-filter-group input {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
    min-width: 160px;
}
.mfc-compare-btn {
    padding: 0.5rem 1.25rem;
    background: var(--primary, #880e4f);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    align-self: flex-end;
}
.mfc-compare-btn:hover { background: #6a0036; }

/* ── Comparison table ────────────────────────────────────────── */
.mfc-table-wrap { overflow-x: auto; }
.mfc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
}
.mfc-table th {
    background: var(--bg-light, #fce4ec);
    padding: 0.55rem 0.65rem;
    text-align: left;
    border-bottom: 2px solid var(--border, #f48fb1);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.mfc-table th + th {
    border-left: 1px solid #f0c0d0;
}
.mfc-th-food { flex: 1; font-size: 0.8rem; word-wrap: break-word; overflow-wrap: break-word; overflow: hidden; }
.mfc-table td {
    padding: 0.4rem 0.65rem;
    border-bottom: 1px solid #f3d4df;
    vertical-align: middle;
}
.mfc-table td + td {
    border-left: 1px solid #f3d4df;
}
.mfc-class-row td {
    background: var(--bg-light, #fce4ec);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary, #880e4f);
    padding: 0.3rem 0.65rem;
    border-bottom: 1px solid #f0b0c8;
}
.mfc-compound { font-weight: 500; min-width: 140px; }
.mfc-cell {
    min-width: 90px;
    position: relative;
    padding-bottom: 0.55rem !important;
}
.mfc-no-data { color: var(--g-mid, #bbb); text-align: center; }
.mfc-cell-bar {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background: var(--primary, #880e4f);
    border-radius: 0 2px 2px 0;
    opacity: .6;
}
.mfc-cell-val { font-weight: 600; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* ── Winner highlighting ─────────────────────────────────────── */
.mfc-winner-cell {
    background: #fef3f7 !important;
}

/* ── Retention factor badges ─────────────────────────────────── */
.mfc-rf-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    background: #fce4ec;
    color: #880e4f;
    margin-left: 0.3rem;
    vertical-align: middle;
}
.mfc-rf-na {
    background: #f5f5f5;
    color: #999;
}
.mfc-rf-note {
    display: block;
    font-size: 0.78rem;
    color: var(--g-mid, #ad1457);
    font-style: italic;
    margin-top: 0.25rem;
}

/* ── Class subtotal row ──────────────────────────────────────── */
.mfc-class-total {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary, #880e4f);
}

/* ── Toggle switch ───────────────────────────────────────────── */
.mfc-serving-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    user-select: none;
}
.mfc-serving-toggle input { display: none; }
.mfc-toggle-track {
    display: inline-block;
    width: 36px;
    height: 20px;
    background: #ccc;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}
.mfc-serving-toggle input:checked + .mfc-toggle-track {
    background: var(--primary, #880e4f);
}
.mfc-toggle-thumb {
    display: block;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.mfc-serving-toggle input:checked + .mfc-toggle-track .mfc-toggle-thumb {
    transform: translateX(16px);
}
.mfc-toggle-label {
    font-weight: 600;
    color: var(--g-dark, #560027);
}

/* ── Per-serving inputs row ──────────────────────────────────── */
.mfc-serving-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background: #fef8fa;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 8px;
    margin-bottom: 1rem;
}
.mfc-serving-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--g-mid, #666);
    margin-right: 0.25rem;
}
.mfc-serving-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    border-left: 3px solid var(--food-color, #880e4f);
    padding-left: 0.5rem;
}
.mfc-serving-name {
    font-weight: 500;
    color: var(--g-dark, #560027);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mfc-serving-g {
    width: 56px;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border, #f48fb1);
    border-radius: 4px;
    font-size: 0.82rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.mfc-serving-unit {
    font-size: 0.75rem;
    color: var(--g-mid, #999);
}

/* ── Insights panel ──────────────────────────────────────────── */
.mfc-insights {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, #fef3f7 0%, #f8f0ff 100%);
    border: 1px solid #f0d4e2;
    border-radius: 10px;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}
.mfc-insight-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 0.1rem;
}
.mfc-insight-body {
    font-size: 0.88rem;
    color: #333;
}
.mfc-insight-body p { margin: 0 0 0.35rem; }
.mfc-insight-body p:last-of-type { margin-bottom: 0; }

/* ── Visualization row (radar + winners) ─────────────────────── */
.mfc-viz-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1.25rem;
}
.mfc-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--g-mid, #ad1457);
    margin: 0 0 0.5rem;
}
.mfc-radar-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.mfc-radar-wrap canvas {
    display: block;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    background: #fff;
    max-width: 100%;
    height: auto;
}
.mfc-radar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.6rem;
}
.mfc-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #555;
}
.mfc-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Winner cards ────────────────────────────────────────────── */
.mfc-winners-wrap {
    min-width: 0;
    max-height: 420px;
    overflow-y: auto;
}
.mfc-winners {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.mfc-winner-card {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.6rem 0.8rem;
    background: #fff;
    border: 1px solid #f0d4e2;
    border-radius: 8px;
    border-left: 3px solid var(--primary, #880e4f);
}
.mfc-winner-total {
    background: linear-gradient(135deg, #fef3f7, #fff);
    border-left-width: 4px;
}
.mfc-winner-trophy {
    font-size: 1rem;
    line-height: 1;
}
.mfc-winner-class {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--g-mid, #ad1457);
}
.mfc-winner-food {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--g-dark, #560027);
}
.mfc-winner-val {
    font-size: 0.78rem;
    color: #666;
    font-variant-numeric: tabular-nums;
}

/* ── Export button ────────────────────────────────────────────── */
.mfc-export-bar {
    display: flex;
    justify-content: flex-end;
    margin: 1.5rem 0 0.5rem;
}
.mfc-export-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    background: #fff;
    color: var(--primary, #880e4f);
    border: 1.5px solid var(--primary, #880e4f);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.mfc-export-btn:hover {
    background: var(--primary, #880e4f);
    color: #fff;
}
.mfc-export-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}
.mfc-export-btn svg { flex-shrink: 0; }

/* ── Comparison responsive ───────────────────────────────────── */
@media (max-width: 820px) {
    .mfc-viz-row {
        grid-template-columns: 1fr;
    }
    .mfc-radar-wrap {
        width: 100%;
    }
    .mfc-winners-wrap {
        max-height: none;
        overflow: visible;
    }
    .mfc-winners {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .mfc-winner-card {
        flex: 1 1 140px;
    }
}

@media (max-width: 600px) {
    .mft-controls { flex-direction: column; }
    .mft-bar-col, .mft-bar-cell, .mft-bar { display: none; }
    .mft-cat-col, .mft-cat { display: none; }
}

/* ── FAQ section ─────────────────────────────────────────────── */
.mft-faq { max-width: 960px; margin: 2rem auto 0; font-family: inherit; }
.mft-faq h2 { font-size: 1.2rem; margin-bottom: .75rem; color: var(--primary, #880e4f); }
.mft-faq details { border: 1px solid var(--border, #f3c5da); border-radius: 6px; margin-bottom: .5rem; padding: .6rem .9rem; }
.mft-faq details[open] { border-color: var(--primary, #880e4f); }
.mft-faq summary { cursor: pointer; font-weight: 600; font-size: .95rem; list-style: none; padding-right: 1.4rem; position: relative; }
.mft-faq summary::-webkit-details-marker { display: none; }
.mft-faq summary::after { content: '+'; position: absolute; right: 0; color: var(--primary, #880e4f); font-size: 1.1rem; line-height: 1; }
.mft-faq details[open] summary::after { content: '−'; }
.mft-faq details p { margin: .6rem 0 .2rem; font-size: .92rem; line-height: 1.65; color: #444; }

/* ── Header grid (two-column layout) ────────────────────────── */
.mft-header-grid {
    max-width: 1040px;
    margin: 0 auto 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 720px) {
    .mft-header-grid { grid-template-columns: 1fr; }
}

/* ── Insight box (dataset snapshot) ─────────────────────────── */
.mft-insight-box {
    background: #f0f7ff;
    border: 1px solid var(--border, #e8d5ea);
    border-radius: 8px;
    padding: 1rem 1.2rem;
}
.mft-insight-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary, #880e4f);
    margin: 0 0 .6rem;
}
.mft-insight-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: .9rem;
    line-height: 1.7;
    color: #333;
}
.mft-insight-list li { border-bottom: 1px solid #eeddf0; padding: .2rem 0; }
.mft-insight-list li:last-child { border-bottom: none; }

/* ── Context card ────────────────────────────────────────────── */
.mft-context-card {
    margin-top: .8rem;
    background: #fff8e1;
    border-left: 4px solid #f9a825;
    border-radius: 0 6px 6px 0;
    padding: .7rem 1rem;
    font-size: .88rem;
    color: #444;
    line-height: 1.6;
}
.mft-context-label {
    font-weight: 700;
    font-size: .85rem;
    color: #c43e00;
    margin: 0 0 .3rem;
}
.mft-context-card p:last-child { margin: 0; }
.mft-context-card a { color: var(--primary, #880e4f); }

/* ── Related tools section ───────────────────────────────────── */
.mft-related {
    max-width: 1120px;
    width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
    margin-top: 2.5rem;
    padding: 0 1rem;
    box-sizing: border-box;
}
.mft-related-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary, #880e4f);
    margin-bottom: 1rem;
}
.mft-related-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.mft-related-card {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .9rem 1rem;
    border: 1px solid #dde;
    border-top: 3px solid var(--card-accent, var(--primary, #880e4f));
    border-radius: 8px;
    text-decoration: none;
    background: #fff;
    min-height: 140px;
    transition: box-shadow .18s, transform .18s;
}
.mft-related-card:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,.1);
    transform: translateY(-2px);
}
.mft-related-icon { font-size: 2.25rem; flex-shrink: 0; line-height: 1; color: var(--card-accent, #880e4f); }
.mft-related-icon svg { width: 38px; height: 38px; flex-shrink: 0; }
.mft-related-body { display: flex; flex-direction: column; gap: .25rem; }
.mft-related-name { font-size: .9rem; font-weight: 700; color: #1a1a2e; }
.mft-related-desc { font-size: .8rem; color: #555; margin: 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
