:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --card-shadow: rgba(0,0,0,.125);

    /* Themeable color palette — overridable via admin color panel */
    --color-action: #5554f2;
    --color-action-hover: #3837d0;
    --color-nav-bg-light: #f1f1fd;
    --color-nav-bg-dark: #17172d;
    --color-nav-bg: var(--color-nav-bg-light);
    --color-nav-hover: #e1e1f0;
    --color-badge: #ca119a;
    --color-badge-text: #ffffff;

    /* Bootstrap primary override to match action color */
    --bs-primary: #5554f2;
    --bs-primary-rgb: 85, 84, 242;
    --bs-link-color: #5554f2;
    --bs-link-hover-color: #3837d0;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --card-bg: #2d2d2d;
    --card-shadow: rgba(0,0,0,.5);

    --color-nav-bg: var(--color-nav-bg-dark);
    --color-nav-hover: #22223f;

    /* Override Bootstrap CSS variables so var(--bs-*) resolves correctly without data-bs-theme */
    --bs-body-bg: #1a1a1a;
    --bs-body-bg-rgb: 26, 26, 26;
    --bs-body-color: #e9ecef;
    --bs-body-color-rgb: 233, 236, 239;
    --bs-secondary-bg: #2d2d2d;
    --bs-secondary-bg-rgb: 45, 45, 45;
    --bs-tertiary-bg: #2b2b2b;
    --bs-tertiary-bg-rgb: 43, 43, 43;
    --bs-secondary-color: #adb5bd;
    --bs-border-color: #495057;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.15);
    --bs-card-bg: #2d2d2d;
    --bs-card-cap-bg: rgba(255, 255, 255, 0.04);
    --bs-emphasis-color: #ffffff;
    --bs-emphasis-color-rgb: 255, 255, 255;
    --bs-offcanvas-bg: #1e1e1e;
    --bs-offcanvas-color: #e9ecef;
    --bs-modal-bg: #1e1e1e;
    --bs-modal-color: #e9ecef;
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

a, .btn-link {
    color: #006bb7;
}

[data-theme="dark"] a,
[data-theme="dark"] .btn-link {
    color: #4dabf7;
}

/* ======================================================
   Material Symbols icon utility
   ====================================================== */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
    font-size: 20px;
}

/* Alfa Slab One — available for titles via .font-display */
.font-display {
    font-family: 'Alfa Slab One', serif;
}

/* ======================================================
   Action / primary color overrides
   ====================================================== */
.btn-primary {
    color: #fff;
    background-color: var(--color-action);
    border-color: var(--color-action);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--color-action-hover);
    border-color: var(--color-action-hover);
}

.btn-outline-primary {
    --bs-btn-color: var(--color-action);
    --bs-btn-border-color: var(--color-action);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--color-action);
    --bs-btn-hover-border-color: var(--color-action);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--color-action);
    --bs-btn-active-border-color: var(--color-action);
    --bs-btn-focus-shadow-rgb: 85, 84, 242;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

/* Cart page retailer collapsible headers */
.retailer-header-full {
    cursor: pointer;
    transition: background-color 0.2s ease;
    padding: 0.5rem;
    margin: -0.5rem;
    border-radius: 0.375rem;
}

.retailer-header-full:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .retailer-header-full:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.retailer-toggle {
    display: inline-block;
    width: 20px;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--color-badge);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
    line-height: 1;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Card styling for dark mode */
.card {
    background-color: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.card-body, .card-footer {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .card-header {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

/* Bootstrap utility overrides for dark mode */
[data-theme="dark"] .bg-light {
    background-color: #2d2d2d !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-dark {
    color: #e9ecef !important;
}

/* Close button (X) in offcanvas / modals — invert the icon for dark bg */
[data-theme="dark"] .offcanvas .btn-close,
[data-theme="dark"] .offcanvas-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Offcanvas dark mode */
[data-theme="dark"] .offcanvas {
    background-color: #1e1e1e;
    color: var(--text-primary);
}

[data-theme="dark"] .offcanvas-header {
    border-color: var(--border-color);
}

/* List group items */
[data-theme="dark"] .list-group-item {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* details/summary dark mode */
[data-theme="dark"] details summary {
    color: var(--text-secondary);
}

[data-theme="dark"] details .border {
    border-color: var(--border-color) !important;
}

/* input-group-text (addon spans) */
[data-theme="dark"] .input-group-text {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Badge secondary */
[data-theme="dark"] .badge.bg-secondary {
    background-color: #495057 !important;
    color: #e9ecef !important;
}

.text-muted {
    color: var(--text-secondary) !important;
}

/* Form controls for dark mode */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: #4dabf7;
}

/* Alert styling for dark mode */
[data-theme="dark"] .alert-info {
    background-color: #1e4e6e;
    border-color: #2c6d93;
    color: #d0e9ff;
}

[data-theme="dark"] .alert-warning {
    background-color: #6e4e1e;
    border-color: #936d2c;
    color: #ffe9d0;
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Table view styling */
.table-view {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem var(--card-shadow);
}

.table-view table {
    margin-bottom: 0;
}

[data-theme="dark"] .table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: var(--card-bg);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bg-secondary);
}

[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: #3a3a3a;
}

/* Dark mode: table-light thead becomes dark so header is readable */
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > *,
[data-theme="dark"] .table > thead.table-light > tr > th {
    background-color: #343a40 !important;
    color: #dee2e6 !important;
    border-color: #495057 !important;
}

/* Dark mode: table-info unit separator rows */
[data-theme="dark"] .table-info,
[data-theme="dark"] .table-info > *,
[data-theme="dark"] .table-striped > tbody > tr.table-info > * {
    background-color: #1e3a4a !important;
    color: #adb5bd !important;
}

/* Dark mode: Make all table text white */
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    color: #ffffff !important;
}

[data-theme="dark"] .table .text-success,
[data-theme="dark"] .table .text-primary {
    color: #ffffff !important;
}

[data-theme="dark"] .table .badge {
    color: #ffffff;
}

.table th {
    cursor: pointer;
    user-select: none;
}

.table th:hover {
    background-color: var(--bg-secondary);
}

.table th.sortable::after {
    content: " ⇅";
    opacity: 0.3;
}

.table th.sorted-asc::after {
    content: " ↑";
    opacity: 1;
}

.table th.sorted-desc::after {
    content: " ↓";
    opacity: 1;
}

/* ─── Affiliate Link Badge & Tooltip ──────────────────────────────────────── */

/* Container wraps the Ⓐ badge and positions the tooltip relative to it */
.affiliate-badge-container {
    position: absolute;
    top: -14px;
    right: -14px;
    z-index: 10;
}

/* The Ⓐ circle button */
.affiliate-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    color: #ff8c00;
    border-radius: 50%;
    font-size: 1.16rem;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #ff8c00;
    padding: 0;
    line-height: 1;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: background 0.15s, color 0.15s;
}

.affiliate-badge:hover,
.affiliate-badge:focus,
.affiliate-badge:active {
    background: #ff8c00;
    color: white;
    outline: none;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

/* Tooltip box — hidden by default, shown on hover/focus-within/click */
/* Light mode: light grey background with dark text */
.affiliate-badge-container .affiliate-tooltip-box {
    display: none;
    position: absolute;
    bottom: 38px;
    right: -4px;
    background: #f2f2f2;
    color: #1a1a1a;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-size: 0.72rem;
    width: 210px;
    z-index: 1050;
    text-align: left;
    line-height: 1.45;
    box-shadow: 0 3px 14px rgba(0,0,0,.2);
    border: 1px solid #d4d4d4;
    pointer-events: auto;
    white-space: normal;
}

/* Downward arrow pointing to the badge — light mode */
.affiliate-badge-container .affiliate-tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 8px;
    border: 6px solid transparent;
        border-top-color: #f2f2f2;
}

/* Dark mode tooltip overrides */
[data-theme="dark"] .affiliate-badge-container .affiliate-tooltip-box {
    background: #1e1e1e;
    color: #f0f0f0;
    border-color: #444;
    box-shadow: 0 3px 14px rgba(0,0,0,.55);
}

[data-theme="dark"] .affiliate-badge-container .affiliate-tooltip-box::after {
    border-top-color: #1e1e1e;
}

/* Show tooltip on desktop hover or keyboard focus */
.affiliate-badge-container:hover .affiliate-tooltip-box,
.affiliate-badge-container:focus-within .affiliate-tooltip-box,
.affiliate-badge-container.tooltip-open .affiliate-tooltip-box {
    display: block;
}

/* Link inside the tooltip — light mode */
.affiliate-tooltip-link {
    color: #0055bb !important;
    text-decoration: underline;
}

/* Link inside tooltip — dark mode */
[data-theme="dark"] .affiliate-tooltip-link {
    color: #82cfff !important;
}

/* Flip tooltip above-left when near left edge */
@media (max-width: 480px) {
    .affiliate-badge-container .affiliate-tooltip-box {
        right: auto;
        left: -4px;
    }
    .affiliate-badge-container .affiliate-tooltip-box::after {
        right: auto;
        left: 8px;
    }
}

/* ─── Serving Data Highlight ────────────────────────────────────────────────── */

/* Yellow tint + visible border for products with price-per-serving data */
.has-serving-highlight {
    background-color: rgba(255, 220, 50, 0.08) !important;
    border-color: rgba(190, 150, 0, 0.55) !important;
    border-width: 4px !important;
}

[data-theme="dark"] .has-serving-highlight {
    background-color: rgba(255, 220, 50, 0.08) !important;
    border-color: rgba(215, 175, 0, 0.55) !important;
    border-width: 4px !important;
}

/* Card body inside a highlighted card also gets the tint
   (Bootstrap doesn't set background on .card-body so it inherits, but
   some themes/overrides can reset it — this rule makes it explicit) */
.card.has-serving-highlight .card-body,
.card.has-serving-highlight .card-footer {
    background-color: rgba(255, 220, 50, 0.08) !important;
}

[data-theme="dark"] .card.has-serving-highlight .card-body,
[data-theme="dark"] .card.has-serving-highlight .card-footer {
    background-color: rgba(255, 220, 50, 0.08) !important;
}

/* ─── Price per Serving (PpS) Display ─────────────────────────────────────── */

/* Dark golden yellow for PpS price text — visible on both light and dark backgrounds */
.pps-price {
    color: #9a7200;
    font-weight: bold;
}

[data-theme="dark"] .pps-price {
    color: #d4a017;
}

/* Small star badge indicating this PPCU line was manually set by an admin (not auto-detected) */
.cu-manual-badge {
    display: inline-block;
    font-size: 0.65rem;
    background: #c8900a;
    color: #fff;
    border-radius: 3px;
    padding: 0 3px;
    vertical-align: middle;
    margin-left: 3px;
    line-height: 1.4;
    title: "Admin-verified";
}

/* Inline info icon that triggers the serving tooltip on click */
.serving-info-btn {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin-left: 3px;
    color: #9a7200;
    font-size: 0.82em;
    user-select: none;
    vertical-align: middle;
    z-index: 5;
}

[data-theme="dark"] .serving-info-btn {
    color: #d4a017;
}

/* Tooltip box — hidden by default */
.serving-info-btn .serving-tooltip-box {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #f2f2f2;
    color: #1a1a1a;
    font-size: 0.72rem;
    font-weight: normal;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    width: 245px;
    z-index: 3000;
    box-shadow: 0 3px 14px rgba(0,0,0,.2);
    white-space: normal;
    pointer-events: auto;
    line-height: 1.45;
    text-align: left;
    border: 1px solid #d4d4d4;
}

/* Downward arrow */
.serving-info-btn .serving-tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 8px;
    border: 6px solid transparent;
    border-top-color: #f2f2f2;
}

[data-theme="dark"] .serving-info-btn .serving-tooltip-box {
    background: #1e1e1e;
    color: #f0f0f0;
    border-color: #444;
    box-shadow: 0 3px 14px rgba(0,0,0,.55);
}

[data-theme="dark"] .serving-info-btn .serving-tooltip-box::after {
    border-top-color: #1e1e1e;
}

/* Show on hover, focus, or click */
.serving-info-btn:hover .serving-tooltip-box,
.serving-info-btn:focus-within .serving-tooltip-box,
.serving-info-btn.tooltip-open .serving-tooltip-box {
    display: block;
}

/* Link inside the tooltip */
.serving-tooltip-link {
    color: #0055bb !important;
    text-decoration: underline;
}

[data-theme="dark"] .serving-tooltip-link {
    color: #82cfff !important;
}

.serving-tooltip-detail {
    margin: 0.25rem 0 0.35rem;
    font-weight: 600;
}

.product-card,
.product-card-horizontal {
    position: relative;
}

.product-card:hover,
.product-card:focus-within,
.product-card.ppcu-tooltip-active,
.product-card-horizontal:hover,
.product-card-horizontal:focus-within,
.product-card-horizontal.ppcu-tooltip-active {
    z-index: 40;
}

.serving-info-btn:hover,
.serving-info-btn:focus-within,
.serving-info-btn.tooltip-open {
    z-index: 3001;
}

/* Flip to right-align when near right edge */
@media (max-width: 480px) {
    .serving-info-btn .serving-tooltip-box {
        left: auto;
        right: 0;
    }
    .serving-info-btn .serving-tooltip-box::after {
        left: auto;
        right: 8px;
    }
}

/* ─── Out-of-Stock Product Treatment ──────────────────────────────────────── */

.out-of-stock-card {
    position: relative;
    opacity: 0.7;
}

[data-theme="dark"] .out-of-stock-card {
    opacity: 0.55;
}

/* Red add-to-cart button for unavailable products */
.btn-out-of-stock {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.btn-out-of-stock:hover {
    background-color: #bb2d3b !important;
    border-color: #b02a37 !important;
}

/* Out-of-stock tooltip — reuses affiliate badge tooltip pattern */
.oos-tooltip-container {
    position: relative;
    display: inline-block;
}

.oos-tooltip-container .oos-tooltip-box {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: rgba(25, 25, 25, 0.96);
    color: #f0f0f0;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    font-size: 0.72rem;
    width: 230px;
    z-index: 1050;
    text-align: left;
    line-height: 1.45;
    box-shadow: 0 3px 14px rgba(0,0,0,.4);
    pointer-events: auto;
    white-space: normal;
}

.oos-tooltip-container .oos-tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 16px;
    border: 6px solid transparent;
    border-top-color: rgba(25, 25, 25, 0.96);
}

.oos-tooltip-container:hover .oos-tooltip-box,
.oos-tooltip-container:focus-within .oos-tooltip-box,
.oos-tooltip-container.tooltip-open .oos-tooltip-box {
    display: block;
}

/* ─── Affiliate Badge Modifier Classes ───────────────────────────────────── */

/* Left-positioned variant — Rows and Grid views */
.affiliate-badge-container--left {
    left: -14px;
    right: auto;
}

.affiliate-badge-container--left .affiliate-tooltip-box {
    right: auto;
    left: -4px;
}

.affiliate-badge-container--left .affiliate-tooltip-box::after {
    right: auto;
    left: 8px;
}

/* Small (50%) variant — Rows view */
.affiliate-badge-container--sm .affiliate-badge {
    width: 16px;
    height: 16px;
    font-size: 0.58rem;
}

.affiliate-badge-container--sm {
    top: -8px;
    left: -8px;
}

/* Inline (non-absolute) variant — Table affiliate column */
.affiliate-badge-container--cell {
    position: relative;
    top: auto;
    right: auto;
    display: inline-block;
}

.affiliate-badge-container--cell .affiliate-tooltip-box {
    right: auto;
    left: -4px;
    bottom: 38px;
}

.affiliate-badge-container--cell .affiliate-tooltip-box::after {
    right: auto;
    left: 8px;
}

.oos-tooltip-link {
    color: #82cfff !important;
    text-decoration: underline;
    cursor: pointer;
}

/* ── Horizontal scroll rows (CommonRows view + RecentSearches) ──────────────── */
.scroll-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--bs-border-color);
    color: var(--bs-body-color);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.scroll-btn:hover {
    background: var(--bs-primary);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

[data-theme="dark"] .scroll-btn {
    background: rgba(42, 42, 42, 0.95);
    border-color: #555;
    color: #fff;
}

[data-theme="dark"] .scroll-btn:hover {
    background: var(--color-action);
    border-color: var(--color-action);
}

.scroll-btn-left { left: 0; }
.scroll-btn-right { right: 0; }

.horizontal-scroll-container {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 2.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 2;
}

.horizontal-scroll-container::-webkit-scrollbar { height: 8px; }
.horizontal-scroll-container::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg);
    border-radius: 4px;
}
.horizontal-scroll-container::-webkit-scrollbar-thumb {
    background: var(--bs-secondary);
    border-radius: 4px;
}

.product-card-horizontal {
    flex: 0 0 auto;
    width: 200px;
    background: var(--bs-card-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card-horizontal:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

[data-theme="dark"] .product-card-horizontal {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .product-card-horizontal:hover {
    box-shadow: 0 4px 12px rgba(255,255,255,0.1);
}

.product-image-horizontal {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background-color: var(--bs-secondary-bg);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.product-image-placeholder-horizontal {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-secondary-bg);
    border-radius: 4px;
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

[data-theme="dark"] .product-image-horizontal,
[data-theme="dark"] .product-image-placeholder-horizontal {
    background-color: #1a1a1a;
}

/* ─── Product Image Wrapper (overlay container for pin + affiliate badge) ─── */

/* Grid view image wrapper — clips oversized images */
.product-img-wrapper {
    position: relative;
    overflow: visible;
    height: 160px; /* fixed height to keep all cards consistent */
}

.product-img-wrapper img,
.product-img-wrapper .product-image-placeholder {
    height: 160px !important;
    width: 100%;
    object-fit: contain;
}

/* Horizontal (rows) view image wrapper */
.product-img-wrapper-horizontal {
    position: relative;
    overflow: visible;
    height: 120px;
}

/* ─── Affiliate badge: image overlay variant (top-left of image) ─── */
.affiliate-badge-container--img {
    position: absolute;
    top: 6px;
    left: 6px;
    right: auto;
    z-index: 20;
}

.affiliate-badge-container--img .affiliate-tooltip-box {
    right: auto;
    left: -4px;
    top: 38px;
    bottom: auto;
}

.affiliate-badge-container--img .affiliate-tooltip-box::after {
    right: auto;
    left: 8px;
}

.affiliate-badge-container--sm.affiliate-badge-container--img {
    top: 4px;
    left: 4px;
}

.affiliate-badge-container--sm.affiliate-badge-container--img .affiliate-tooltip-box {
    top: 24px;
    bottom: auto;
}

/* ─── Retailer Pill Badge ─── */
.retailer-pill {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 20px;
    z-index: 10;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.5;
}

/* ─── Retailer-colored View button ─── */
.btn-retailer-view:hover {
    filter: brightness(0.88);
}

/* ─── Pin Button ─── */
.pin-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    opacity: 0.45;
    transition: opacity 0.15s, background 0.15s;
    line-height: 1;
}

.pin-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.97);
}

.pin-btn--active {
    opacity: 1;
    background: #fff3cd;
    border-color: #ffc107;
}

/* Small variant for rows view */
.pin-btn--sm {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    top: 4px;
    right: 4px;
}

.shopping-list-toggle-btn {
    position: absolute;
    top: 40px;
    right: 6px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0;
    opacity: 0.45;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    line-height: 1;
}

.shopping-list-toggle-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.98);
}

.shopping-list-toggle-btn--active {
    opacity: 1;
    background: #e8f7ee;
    border-color: #198754;
    color: #198754;
}

.shopping-list-toggle-btn--sm {
    width: 22px;
    height: 22px;
    font-size: 0.75rem;
    top: 28px;
    right: 4px;
}

/* Table view variant (non-absolute, inline) */
.pin-btn--table {
    position: static;
    opacity: 0.45;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.15s, background 0.15s;
}

.pin-btn--table:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.07);
}

.pin-btn--table.pin-btn--active {
    opacity: 1;
    background: #fff3cd;
    border-color: #ffc107;
}

[data-theme="dark"] .pin-btn {
    background: rgba(40, 40, 40, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e9ecef;
}

[data-theme="dark"] .pin-btn:hover {
    background: rgba(60, 60, 60, 0.97);
}

[data-theme="dark"] .pin-btn--active {
    background: #3d2e00;
    border-color: #ffc107;
}

[data-theme="dark"] .pin-btn--table:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .pin-btn--table.pin-btn--active {
    background: #3d2e00;
    border-color: #ffc107;
}

[data-theme="dark"] .shopping-list-toggle-btn {
    background: rgba(40, 40, 40, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e9ecef;
}

[data-theme="dark"] .shopping-list-toggle-btn:hover {
    background: rgba(60, 60, 60, 0.97);
}

[data-theme="dark"] .shopping-list-toggle-btn--active {
    background: #123524;
    border-color: #198754;
    color: #9ae6b4;
}

/* ─── In-Cart Quantity Controls ─── */
.qty-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--color-action);
    border-radius: 6px;
    overflow: hidden;
    height: 31px; /* matches btn-sm height */
}

.qty-btn {
    background: var(--color-action);
    color: #fff;
    border: none;
    padding: 0 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    height: 100%;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    line-height: 1;
}

.qty-btn:hover {
    background: var(--color-action-hover);
}

.qty-count {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-action);
    background: #fff;
    padding: 0 4px;
    min-width: 24px;
}

[data-theme="dark"] .qty-count {
    background: #1e1e1e;
    color: #a0a0fa;
}

[data-theme="dark"] .qty-btn {
    background: var(--color-action-hover);
}

[data-theme="dark"] .qty-btn:hover {
    background: #2e2db8;
}

[data-theme="dark"] .qty-control {
    border-color: var(--color-action-hover);
}

/* ─── Cart Toast (mobile slide-up notification) ─── */
.cart-toast {
    display: none; /* hidden on desktop */
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    z-index: 9999;
    background: #198754;
    color: #fff;
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    gap: 10px;
    align-items: center;
    font-size: 0.9rem;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.cart-toast-name {
    opacity: 0.9;
    font-weight: normal;
    font-size: 0.82rem;
}

.cart-toast-link {
    color: #fff;
    font-weight: 700;
    text-decoration: underline;
    margin-left: 8px;
    white-space: nowrap;
}

.cart-toast-link:hover {
    color: #d1fae5;
}

@media (max-width: 767px) {
    .cart-toast {
        display: flex;
    }

    /* ── User-specified padding reductions ── */
    /* Reduce article/px-4 outer content padding */
    .px-4 {
        padding-right: 0.2rem !important;
        padding-left: 0.2rem !important;
    }
    /* Reduce column padding so cards pack tighter */
    [class*="col-"] {
        padding-left: 0.1rem !important;
        padding-right: 0.1rem !important;
    }

    /* Reduce outer page padding on mobile */
    .container-fluid {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    /* Compact "Found X products" alert */
    .alert.alert-info {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.8rem;
        margin-bottom: 0.5rem !important;
    }
    .alert.alert-info .pagination-sm .page-link {
        padding: 0.2rem 0.45rem;
        font-size: 0.75rem;
    }

    /* Hide category badges and HR divider in product cards to save vertical space */
    .product-card .category-badges { display: none !important; }
    .product-card hr { display: none !important; }
    /* Tighten price-info box */
    .price-info {
        padding: 5px !important;
    }

    /* Reduce gap between product card rows */
    .row {
        --bs-gutter-x: 0.25rem;
    }
    .col-6.mb-4, .col-md-4.mb-4, .col-lg-3.mb-4 {
        margin-bottom: 0.4rem !important;
    }

    /* Card footer buttons: stack vertically on mobile */
    .card-footer .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.3rem !important;
    }
    .card-footer .d-flex.gap-2 > a,
    .card-footer .d-flex.gap-2 > button {
        flex: none !important;
        width: 100% !important;
    }
    .card-footer .d-flex.gap-2 .qty-control {
        flex: none !important;
        width: 100% !important;
    }
}

/* ─── Comparison Floating Button ─── */
.compare-float-wrapper {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 997;
    display: flex;
    align-items: center;
    background: #e67e22;
    border-radius: 24px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.28);
    overflow: hidden;
    white-space: nowrap;
}

.compare-float-btn {
    background: transparent;
    border: none;
    color: #fff;
    padding: 0.55rem 1rem 0.55rem 1.1rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 0.02em;
}

.compare-float-btn:hover {
    background: rgba(0,0,0,0.1);
}

.compare-float-count {
    background: rgba(0,0,0,0.22);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.8rem;
    margin-left: 4px;
}

.compare-float-clear {
    background: rgba(0,0,0,0.18);
    border: none;
    border-left: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    padding: 0.55rem 0.85rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.compare-float-clear:hover {
    background: rgba(0,0,0,0.35);
}

/* Mobile: sit above the 45px cart bar at the bottom */
@media (max-width: 767px) {
    .compare-float-wrapper {
        bottom: 55px;
    }
}

/* ─── Affiliate-Only toggle button (SettingsPanel retailer filter) ─── */
.affiliate-only-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.28rem 0.75rem 0.28rem 0.5rem;
    border-radius: 20px;
    border: 2px solid #FF9900;
    background: transparent;
    color: #FF9900;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    cursor: pointer;
    box-shadow: none;
}

.affiliate-only-btn .aff-badge-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: 2px solid #FF9900;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    color: #FF9900;
    flex-shrink: 0;
}

.affiliate-only-btn:hover {
    background: rgba(255, 153, 0, 0.12);
    box-shadow: 0 0 0 2px rgba(255, 153, 0, 0.2);
}

.affiliate-only-btn.active {
    background: #FF9900;
    border-color: #FF9900;
    color: #fff;
}

.affiliate-only-btn.active .aff-badge-mini {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

[data-theme="dark"] .affiliate-only-btn {
    border-color: #FF9900;
    color: #FF9900;
}

[data-theme="dark"] .affiliate-only-btn .aff-badge-mini {
    border-color: #FF9900;
    color: #FF9900;
}

[data-theme="dark"] .affiliate-only-btn.active {
    background: #FF9900;
    color: #fff;
}

[data-theme="dark"] .affiliate-only-btn.active .aff-badge-mini {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

/* ─── Page header desktop title (hidden on mobile) ─── */
.page-header-desktop {
    position: relative; /* anchor for absolutely-positioned WordsLogo */
    min-height: 2.5rem;
}

@media (max-width: 767px) {
    .page-header-desktop { display: none !important; }
}

/* ─── WordsLogo centered in page header (mask-image technique) ───────────────
   The SVG acts as a mask; background-color provides the tint.
   No new color files needed — just change background-color per page.
   ─────────────────────────────────────────────────────────────────────────── */
.page-header-words-logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    /* Height matches the 2rem page titles.
       Width must be generous enough that height is always the constraining axis —
       mask-size: auto 100% pins height to the element height and derives width
       proportionally, so the logo never shrinks due to a narrow container. */
    height: 2rem;
    width: 400px;
    pointer-events: none;
    /* Mask the SVG shape and fill it with background-color */
    -webkit-mask-image: url('/branding/WordsLogo.svg');
    mask-image: url('/branding/WordsLogo.svg');
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    /* auto 100% = SVG height fills the element; width derived from SVG aspect ratio */
    -webkit-mask-size: auto 100%;
    mask-size: auto 100%;
    -webkit-mask-position: center;
    mask-position: center;
    /* Default color: site action color (Search + Cart) */
    background-color: var(--color-action, #5554f2);
}

/* Dark mode overrides per page */
[data-theme="dark"] .page-header-words-logo {
    background-color: #8281ff; /* matches cart-page-title dark */
}

/* ── Per-page theme colors ── */
/* Compare — orange */
.compare-page .page-header-words-logo            { background-color: #ea580c; }
[data-theme="dark"] .compare-page .page-header-words-logo { background-color: #fb923c; }

/* Shopping List — green */
.shopping-list-page .page-header-words-logo            { background-color: #16a34a; }
[data-theme="dark"] .shopping-list-page .page-header-words-logo { background-color: #4ade80; }

/* PPCU — gold */
.ppcu-page-wrapper .page-header-words-logo            { background-color: #c8900a; }
[data-theme="dark"] .ppcu-page-wrapper .page-header-words-logo { background-color: #e0b020; }

/* Nutrition — green */
.nutr-page-wrapper .page-header-words-logo            { background-color: #2e7d32; }
[data-theme="dark"] .nutr-page-wrapper .page-header-words-logo { background-color: #66bb6a; }

/* Hide logo on screens narrow enough that it would overlap the page title */
@media (max-width: 1050px) {
    .page-header-words-logo { display: none !important; }
}

/* ─── Compare Page ─── */
.compare-page {
    padding: 1rem 0;
}


/* ─── Mobile Grid: ensure 2-column layout at small sizes ─── */
@media (max-width: 575px) {
    .col-6 {
        padding-left: 0.4rem;
        padding-right: 0.4rem;
    }

    .col-6 .card {
        font-size: 0.82rem;
    }

    .col-6 .product-img-wrapper img,
    .col-6 .product-image-placeholder {
        height: 110px;
    }

    .col-6 .card-body {
        padding: 0.5rem;
    }

    .col-6 .card-footer {
        padding: 0.4rem 0.5rem;
    }

    .col-6 .card-title {
        font-size: 0.8rem;
    }
}

.product-info-horizontal { font-size: 0.9rem; }

.product-name-horizontal {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-retailer-horizontal { font-size: 0.8rem; }
.product-quantity-horizontal { font-size: 0.8rem; color: #6c757d; }

/* ── Mobile Tooltip Modal ──────────────────────────────────────────────── */
.mobile-tooltip-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.mobile-tooltip-modal {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    width: min(90vw, 340px);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.mobile-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    gap: 8px;
}

.mobile-tooltip-title {
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
    color: var(--text-primary, #212529);
}

.mobile-tooltip-body {
    padding: 14px 16px;
    overflow-y: auto;
    color: var(--text-primary, #212529);
    font-size: 0.875rem;
    line-height: 1.55;
}

/* Portrait mobile ≤640px  OR  landscape mobile (tall≤500px, wide≤1023px) */
@media (max-width: 640px), (max-height: 500px) and (max-width: 1023px) {
    .mobile-tooltip-overlay {
        display: flex;
    }

    /* Hide all inline desktop tooltip boxes on mobile */
    .affiliate-tooltip-box,
    .serving-tooltip-box,
    .oos-tooltip-box,
    .search-timing-tooltip,
    .add-to-search-info-popup {
        display: none !important;
    }
}

[data-theme="dark"] .mobile-tooltip-modal {
    background: var(--card-bg, #1e1e1e);
}

[data-theme="dark"] .mobile-tooltip-header {
    border-bottom-color: var(--bs-border-color, #444);
}
.product-price-horizontal { font-size: 0.85rem; }
