/* Make It Plant Based — Ingredient Comparison Styles
 * Loaded ONLY on pages using the shortcode
 */

.ndc-app {
    --green-dark:  #2d5a27;
    --green-mid:   #4a8c3f;
    --green-light: #7aba6d;
    --green-pale:  #e8f5e3;
    --green-xpale: #f4faf2;
    --ink:         #1c2b1a;
    --ink-light:   #6b8264;
    --border:      #cde0c5;
    --white:       #ffffff;
    --radius:      12px;
    --radius-sm:   8px;
    --shadow:      0 2px 16px rgba(45,90,39,0.10);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

/* ── Ingredient picker ── */
.ndc-picker {
    background: var(--white); border: 1.5px solid var(--border);
    border-radius: var(--radius); padding: 24px 28px;
    margin-bottom: 20px; box-shadow: var(--shadow);
}
.ndc-picker-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--ink-light); margin-bottom: 14px;
}
.ndc-ingredient-slots { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; min-height: 34px; }
.ndc-slot {
    display: flex; align-items: center; gap: 8px;
    background: var(--green-pale); border: 1.5px solid var(--border);
    border-radius: 99px; padding: 6px 14px 6px 16px;
    font-size: 13px; font-weight: 500; color: var(--green-dark);
    animation: ndc-pop 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes ndc-pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ndc-slot-remove {
    background: none; border: none; cursor: pointer;
    color: var(--ink-light); font-size: 16px; line-height: 1;
    padding: 0 2px; transition: color 0.15s;
}
.ndc-slot-remove:hover { color: #c0392b; }

/* ── Autocomplete ── */
.ndc-search-wrap { position: relative; max-width: 420px; }
.ndc-search-wrap input {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--green-xpale); font-family: inherit;
    font-size: 14px; color: var(--ink); outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ndc-search-wrap input:focus {
    border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(74,140,63,0.15);
}
.ndc-autocomplete {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--white); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
    max-height: 220px; overflow-y: auto; z-index: 999; display: none;
}
.ndc-autocomplete.open { display: block; }
.ndc-ac-item {
    padding: 10px 14px; cursor: pointer; font-size: 13px;
    border-bottom: 1px solid var(--green-pale); transition: background 0.1s;
    display: flex; justify-content: space-between; align-items: center;
}
.ndc-ac-item:last-child { border-bottom: none; }
.ndc-ac-item:hover, .ndc-ac-item.focused { background: var(--green-pale); }
.ndc-ac-item.disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.ndc-ac-cat { font-size: 11px; color: var(--ink-light); }
.ndc-hint { font-size: 12px; color: var(--ink-light); margin-top: 8px; }

/* ── Nutrient filter ── */
.ndc-filter {
    background: var(--white); border: 1.5px solid var(--border);
    border-radius: var(--radius); padding: 20px 28px;
    margin-bottom: 20px; box-shadow: var(--shadow);
}
.ndc-filter-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.ndc-filter-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--ink-light);
}
.ndc-filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ndc-filter-search {
    padding: 7px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--green-xpale); font-family: inherit;
    font-size: 13px; color: var(--ink); outline: none; width: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ndc-filter-search:focus {
    border-color: var(--green-mid); box-shadow: 0 0 0 3px rgba(74,140,63,0.15);
}
.ndc-btn-sm {
    padding: 7px 14px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; border: 1.5px solid var(--border);
    background: var(--green-xpale); color: var(--ink-light);
    transition: all 0.15s; white-space: nowrap;
}
.ndc-btn-sm:hover { background: var(--green-pale); color: var(--ink); border-color: var(--green-mid); }
.ndc-btn-sm.primary { background: var(--green-dark); color: var(--white); border-color: var(--green-dark); }
.ndc-btn-sm.primary:hover { background: var(--green-mid); border-color: var(--green-mid); }
.ndc-checkbox-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 6px 16px; max-height: 220px; overflow-y: auto; padding-right: 4px;
}
.ndc-checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer; padding: 4px 6px;
    border-radius: var(--radius-sm); transition: background 0.1s;
}
.ndc-checkbox-label:hover { background: var(--green-xpale); }
.ndc-checkbox-label input[type=checkbox] {
    accent-color: var(--green-mid); width: 15px; height: 15px;
    flex-shrink: 0; cursor: pointer;
}

/* ── Compare bar (share left, button right) ── */
.ndc-compare-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}

/* ── Share bar — hidden until results load ── */
.ndc-share-bar {
    display: none; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ndc-share-bar.visible { display: flex; }
.ndc-share-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--ink-light); white-space: nowrap;
}
.ndc-share-icons { display: flex; gap: 8px; align-items: center; }

/* ── Social icon buttons ── */
.ndc-social-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    border: 1.5px solid var(--border); background: var(--white);
    cursor: pointer; transition: all 0.18s; text-decoration: none;
    flex-shrink: 0;
}
.ndc-social-btn svg { width: 18px; height: 18px; display: block; }
.ndc-social-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.14); }
.ndc-social-btn.pinterest { border-color: #E60023; }
.ndc-social-btn.pinterest:hover { background: #E60023; }
.ndc-social-btn.pinterest:hover svg path { fill: #fff; }
.ndc-social-btn.facebook  { border-color: #1877F2; }
.ndc-social-btn.facebook:hover  { background: #1877F2; }
.ndc-social-btn.facebook:hover svg path { fill: #fff; }
.ndc-social-btn.whatsapp  { border-color: #25D366; }
.ndc-social-btn.whatsapp:hover  { background: #25D366; }
.ndc-social-btn.whatsapp:hover svg path { fill: #fff; }
.ndc-social-btn.twitter   { border-color: #000; }
.ndc-social-btn.twitter:hover   { background: #000; }
.ndc-social-btn.twitter:hover svg path { fill: #fff; }

/* ── Copy link button ── */
.ndc-copy-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; border: 1.5px solid var(--border);
    background: var(--green-xpale); color: var(--ink-light);
    transition: all 0.15s; white-space: nowrap;
}
.ndc-copy-btn:hover { background: var(--green-pale); color: var(--ink); border-color: var(--green-mid); }
.ndc-copy-btn.copied { background: var(--green-dark); color: var(--white); border-color: var(--green-dark); }

/* ── Compare button ── */
.ndc-compare-btn {
    padding: 12px 28px; background: var(--green-dark); color: var(--white);
    border: none; border-radius: var(--radius-sm); font-family: inherit;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.2s, transform 0.1s; box-shadow: var(--shadow);
    white-space: nowrap;
}
.ndc-compare-btn:hover { background: var(--green-mid); transform: translateY(-1px); }
.ndc-compare-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Comparison table ── */
.ndc-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: var(--radius); border: 1.5px solid var(--border); box-shadow: var(--shadow);
}
.ndc-table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 14px; table-layout: fixed; }
.ndc-table thead tr { background: var(--green-dark); color: var(--white); }
.ndc-table thead th {
    padding: 14px 16px; text-align: left; font-weight: 600;
    font-size: 12px; letter-spacing: 0.04em;
    white-space: normal; word-break: break-word;
    word-wrap: break-word; overflow-wrap: break-word;
    flex: 1;
}
.ndc-table thead th:first-child {
    min-width: 200px; max-width: 200px;
    position: sticky; left: 0; background: var(--green-dark); z-index: 2;
    white-space: normal; word-break: break-word;
}
.ndc-table tbody tr { border-bottom: 1px solid var(--green-pale); transition: background 0.1s; }
.ndc-table tbody tr:last-child { border-bottom: none; }
.ndc-table tbody tr:hover { background: var(--green-xpale); }
.ndc-table td { padding: 11px 16px; vertical-align: middle; text-align: right; }
.ndc-table td:first-child {
    text-align: left; font-weight: 500; color: var(--ink);
    position: sticky; left: 0; background: var(--white); z-index: 1;
    border-right: 1px solid var(--border);
    white-space: normal; word-break: break-word;
    min-width: 200px; max-width: 200px;
}
.ndc-table tbody tr:hover td:first-child { background: var(--green-xpale); }
.ndc-table td.ndc-winner { color: var(--green-dark); font-weight: 700; background: var(--green-pale) !important; }
.ndc-table td.ndc-zero { color: var(--ink-light); font-weight: 300; }
.ndc-cell-inner { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ndc-mini-bar { width: 60px; height: 4px; background: var(--green-pale); border-radius: 99px; overflow: hidden; }
.ndc-mini-fill {
    height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--green-mid), var(--green-light));
    transition: width 0.5s ease;
}
td.ndc-winner .ndc-mini-fill { background: linear-gradient(90deg, #c5960a, #f0c030); }
.ndc-unit { font-size: 10px; font-weight: 400; color: var(--ink-light); margin-left: 2px; }

/* ── States ── */
.ndc-empty-state { text-align: center; padding: 64px 20px; color: var(--ink-light); }
.ndc-leaf { font-size: 42px; display: block; margin-bottom: 12px; }
.ndc-empty-state p { font-size: 15px; margin: 0; }
.ndc-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 60px 20px; color: var(--ink-light); font-size: 14px; }
.ndc-spinner {
    width: 22px; height: 22px; border: 3px solid var(--green-pale);
    border-top-color: var(--green-mid); border-radius: 50%;
    animation: ndc-spin 0.7s linear infinite;
}
@keyframes ndc-spin { to { transform: rotate(360deg); } }
.ndc-error { text-align: center; padding: 32px; color: #c0392b; font-size: 14px; }
.ndc-meta { font-size: 13px; color: var(--ink-light); margin-bottom: 12px; padding-left: 4px; }
.ndc-meta strong { color: var(--ink); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .ndc-picker, .ndc-filter { padding: 16px 18px; }
    .ndc-filter-header { flex-direction: column; align-items: flex-start; }
    .ndc-filter-search { width: 100%; }
    .ndc-checkbox-grid { grid-template-columns: 1fr 1fr; }
    .ndc-compare-bar { flex-direction: column; align-items: stretch; }
    .ndc-share-bar { justify-content: flex-start; }
    .ndc-compare-btn { width: 100%; text-align: center; }
    .ndc-table thead th, .ndc-table td { padding: 8px 10px; font-size: 12px; }
    .ndc-table thead th { min-width: 70px; max-width: 110px; }
    .ndc-table thead th:first-child { min-width: 140px; max-width: 140px; }
    .ndc-table td:first-child { min-width: 140px; max-width: 140px; font-size: 11px; }
}
@media (max-width: 480px) {
    .ndc-table thead th { min-width: 60px; max-width: 90px; font-size: 11px; padding: 6px 8px; }
    .ndc-table thead th:first-child { min-width: 110px; max-width: 110px; }
    .ndc-table td { padding: 6px 8px; font-size: 11px; }
    .ndc-table td:first-child { min-width: 110px; max-width: 110px; }
    .ndc-mini-bar { display: none; }
    .ndc-share-icons { gap: 6px; }
    .ndc-social-btn { width: 32px; height: 32px; }
    .ndc-social-btn svg { width: 15px; height: 15px; }
}

/* ── Data source attribution ── */
.mipb-data-source {
    margin-top: 1rem;
    font-size: 12px;
    color: #999;
    text-align: right;
}
.mipb-source-label { font-weight: 600; color: #888; }
.mipb-data-source a {
    color: #4a8c3f;
    text-decoration: none;
}
.mipb-data-source a:hover { text-decoration: underline; }
