/* ============================================================
   MIPB — Magnesium Table & Comparison Tool
   Stylesheet for [magnesium_table] and [compare_magnesium]
   Theme: Forest Green — relaxation, sleep, muscle recovery
   ============================================================ */

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

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

/* ── Insight box ─────────────────────────────────────────────── */
.mmag-insight-box {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-left: 4px solid #1b5e20;
    border-radius: 6px;
    padding: .85rem 1rem;
    margin-bottom: .9rem;
}
.mmag-insight-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #1b5e20;
    margin: 0 0 .55rem;
}
.mmag-insight-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: .88rem;
    color: #333;
}
.mmag-insight-list li { margin-bottom: .28rem; line-height: 1.5; }

/* ── Context card ─────────────────────────────────────────────── */
.mmag-context-card {
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-left: 4px solid #2e7d32;
    border-radius: 6px;
    padding: .75rem 1rem;
    font-size: .87rem;
    color: #333;
    line-height: 1.55;
}
.mmag-context-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #2e7d32;
    margin: 0 0 .35rem;
}
.mmag-context-card p { margin: 0; }
.mmag-context-card a { color: #1b5e20; font-weight: 600; text-decoration: underline; }
.mmag-context-card a:hover { color: #2e7d32; }

/* ── Main wrap ────────────────────────────────────────────────── */
.mmag-wrap {
    --primary:  #1b5e20;
    --bg-light: #e8f5e9;
    --border:   #a5d6a7;
    --bar-bg:   #2e7d32;
    max-width: 1040px;
    margin: 0 auto;
    font-family: inherit;
}

/* ── Controls row ────────────────────────────────────────────── */
.mmag-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: .75rem;
}
.mmag-search,
.mmag-select {
    padding: .45rem .7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .9rem;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color .15s;
}
.mmag-search { flex: 1 1 200px; min-width: 150px; }
.mmag-select { flex: 0 1 220px; }
.mmag-search:focus,
.mmag-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px #c8e6c9; }

.mmag-btn {
    padding: .45rem .9rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .88rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.mmag-btn:hover { background: #2e7d32; }

/* ── Table ────────────────────────────────────────────────────── */
.mmag-table-wrap { overflow-x: auto; margin-top: .6rem; }
.mmag-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.mmag-table th {
    background: var(--primary);
    color: #fff;
    padding: .55rem .75rem;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
}
.mmag-table td {
    padding: .45rem .75rem;
    border-bottom: 1px solid #c8e6c9;
    vertical-align: middle;
    color: #222;
}
.mmag-table tr:hover td { background: var(--bg-light); }
.mmag-table tr:last-child td { border-bottom: none; }

.col-rank  { width: 3rem; text-align: center; color: #777; font-size: .82rem; }
.col-food  { min-width: 160px; }
.col-group { min-width: 120px; color: #555; font-size: .85rem; }
.col-val   { width: 8rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-bar   { width: 120px; padding-right: .5rem; }

/* ── Bar ─────────────────────────────────────────────────────── */
.mmag-bar {
    height: 10px;
    background: linear-gradient(90deg, #1b5e20, #43a047);
    border-radius: 3px;
    min-width: 2px;
}

/* ── Pagination ──────────────────────────────────────────────── */
.mmag-pagination {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
}
.mmag-page-info { font-size: .85rem; color: #555; flex: 1 1 auto; }
.mmag-page-btn {
    padding: .4rem .85rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s;
}
.mmag-page-btn:hover { background: #2e7d32; }

/* ── Loading / empty states ──────────────────────────────────── */
.mmag-loading,
.mmag-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #888;
    font-style: italic;
}

/* ── Attribution ─────────────────────────────────────────────── */
.mmag-attribution {
    margin-top: 1rem;
    font-size: .78rem;
    color: #777;
    line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────
   COMPARISON TOOL — [compare_magnesium]
   ──────────────────────────────────────────────────────────── */

.mmagc-wrap {
    --primary:  #1b5e20;
    --bg-light: #e8f5e9;
    --border:   #a5d6a7;
    max-width: 960px;
    margin: 0 auto;
}

/* ── Picker area ─────────────────────────────────────────────── */
.mmagc-picker-area { margin-bottom: 1rem; }
.mmagc-search-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.mmagc-search {
    flex: 1;
    padding: .5rem .8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .9rem;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}
.mmagc-search:focus { border-color: var(--primary); box-shadow: 0 0 0 2px #c8e6c9; }

/* ── Suggestion dropdown ────────────────────────────────────── */
.mmagc-suggestions {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(27,94,32,.12);
    position: relative;
    z-index: 100;
}
.mmagc-sug-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid #e8f5e9;
    font-size: .88rem;
}
.mmagc-sug-item:last-child { border-bottom: none; }
.mmagc-sug-item:hover { background: var(--bg-light); }
.mmagc-sug-item .sug-name { flex: 1; font-weight: 500; }
.mmagc-sug-item .sug-cat  { font-size: .78rem; color: #777; white-space: nowrap; }
.mmagc-sug-item .sug-val  { font-size: .82rem; color: var(--primary); font-weight: 600;
                               white-space: nowrap; margin-left: .3rem; }

/* ── Chips ───────────────────────────────────────────────────── */
.mmagc-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.mmagc-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .65rem;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .83rem;
    color: #333;
}
.mmagc-chip-x {
    background: none;
    border: none;
    cursor: pointer;
    color: #777;
    font-size: 1rem;
    line-height: 1;
    padding: 0 .1rem;
    transition: color .1s;
}
.mmagc-chip-x:hover { color: var(--primary); }

/* ── Table ───────────────────────────────────────────────────── */
.mmagc-table-wrap { overflow-x: auto; margin-top: .75rem; }
.mmagc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.mmagc-table th {
    background: var(--primary);
    color: #fff;
    padding: .55rem .75rem;
    text-align: left;
    white-space: nowrap;
    font-weight: 600;
}
.mmagc-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid #c8e6c9;
    vertical-align: middle;
    color: #222;
}
.mmagc-table tr:hover td { background: var(--bg-light); }
.mmagc-table tr:last-child td { border-bottom: none; }
.mmagc-table .col-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--primary);
    width: 9rem;
}
.mmagc-table .col-bar { width: 160px; }

/* ── Bar ─────────────────────────────────────────────────────── */
.mmagc-bar {
    height: 12px;
    background: linear-gradient(90deg, #1b5e20, #43a047);
    border-radius: 3px;
    min-width: 2px;
}

/* ── Legend & attribution ─────────────────────────────────────── */
.mmagc-legend {
    margin-top: .75rem;
    font-size: .85rem;
    color: #555;
    line-height: 1.6;
}
.mmagc-attribution {
    margin-top: .5rem;
    font-size: .78rem;
    color: #777;
    line-height: 1.5;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .mmag-controls { flex-direction: column; align-items: stretch; }
    .mmag-search, .mmag-select, .mmag-btn { width: 100%; }
    .mmagc-search { width: 100%; }
    .col-group { display: none; }
    .mmag-table .col-group { display: none; }
}

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