/* ==========================================================================
   SMART AUTOCOMPLETE DROPDOWN
   Row-based typeahead (replaces old grid-style SmartSearch).
   ========================================================================== */

.smart-ac-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    min-width: 400px;
    max-height: 560px;
    overflow-y: auto;
    background: var(--white-primary, #fff);
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
    z-index: 50;
    display: none;
    overscroll-behavior: contain;
}

.smart-ac-dropdown.is-open {
    display: block;
}

.smart-ac__list {
    display: flex;
    flex-direction: column;
}

.smart-ac__live {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* --- Row ------------------------------------------------------------------ */

.smart-ac__row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    min-height: 72px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--color-border-light, #f1f1f3);
    cursor: pointer;
    transition: background 0.12s ease;
}

.smart-ac__row:last-child {
    border-bottom: none;
}

.smart-ac__row:hover,
.smart-ac__row.is-highlighted {
    background: #f5f5f5;
    text-decoration: none;
    color: inherit;
}

/* --- Thumbnail ------------------------------------------------------------ */

.smart-ac__thumb {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: #fafafa;
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smart-ac__thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.smart-ac__compat-badge {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2563eb;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    padding: 2px 0;
    line-height: 1;
}

/* --- Body (name + category) ---------------------------------------------- */

.smart-ac__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.smart-ac__name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-text, #0f172a);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.smart-ac__cat-badge {
    align-self: flex-start;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--cyan-light, #e0f2fe);
    color: var(--cyan-dark, #0369a1);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* --- Stock ---------------------------------------------------------------- */

.smart-ac__stock {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--color-success, #16a34a);
    white-space: nowrap;
}

.smart-ac__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}

.smart-ac__oos {
    color: var(--color-error, #ef4444);
    font-size: 11px;
}

/* --- Price ---------------------------------------------------------------- */

.smart-ac__price {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text, #0f172a);
    white-space: nowrap;
}

/* --- Action --------------------------------------------------------------- */

.smart-ac__action {
    display: flex;
    align-items: center;
}

.smart-ac__add-btn {
    background: var(--cyan-primary, #2563eb);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s ease, transform 0.08s ease;
}

.smart-ac__add-btn:hover {
    background: var(--cyan-dark, #1d4ed8);
}

.smart-ac__add-btn:active {
    transform: scale(0.97);
}

.smart-ac__add-btn.is-added {
    background: var(--color-success, #16a34a);
}

.smart-ac__contact {
    font-size: 11px;
    color: var(--cyan-primary, #2563eb);
    text-decoration: underline;
    white-space: nowrap;
}

/* --- Empty state (recent + trending) ------------------------------------- */

.smart-ac__empty {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.smart-ac__empty-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.smart-ac__empty-header .smart-ac__empty-title {
    margin: 0;
}

.smart-ac__clear-recent {
    background: transparent;
    border: none;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted, #64748b);
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.12s ease, background 0.12s ease;
}

.smart-ac__clear-recent:hover {
    color: #dc2626;
    background: #fef2f2;
}

.smart-ac__empty-title {
    margin: 0 0 8px 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted, #64748b);
}

.smart-ac__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.smart-ac__chip {
    background: #f1f5f9;
    border: 1px solid transparent;
    color: var(--color-text, #0f172a);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.smart-ac__chip:hover {
    background: #e2e8f0;
    border-color: var(--cyan-primary, #2563eb);
}

/* --- No results / error --------------------------------------------------- */

.smart-ac__no-results,
.smart-ac__error {
    padding: 20px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-muted, #64748b);
}

.smart-ac__error {
    color: var(--color-error, #ef4444);
}

.smart-ac__no-results a {
    color: var(--cyan-primary, #2563eb);
}

.smart-ac__dym {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: var(--cyan-primary, #2563eb);
    cursor: pointer;
    text-decoration: underline;
}
.smart-ac__dym:hover {
    text-decoration: none;
}

.smart-ac__matched-printer {
    padding: 10px 14px;
    margin: 0 0 10px;
    background: var(--color-surface-subtle, #f1f5f9);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-text, #0f172a);
}
.smart-ac__matched-printer a {
    color: var(--cyan-primary, #2563eb);
    font-weight: 600;
    text-decoration: none;
}
.smart-ac__matched-printer a:hover {
    text-decoration: underline;
}

/* Spec §1.1 — clickable top rows above the suggest grid. */
.smart-ac__top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    margin: 0 0 6px;
    background: var(--color-surface-subtle, #f1f5f9);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-text, #0f172a);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    font: inherit;
    font-size: 13px;
}
.smart-ac__top-row:hover,
.smart-ac__top-row:focus-visible {
    background: #e0f2fe;
    border-color: var(--cyan-primary, #2563eb);
    outline: none;
}
.smart-ac__top-row__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #fff;
    color: var(--cyan-primary, #2563eb);
    font-weight: 700;
    flex-shrink: 0;
}
.smart-ac__top-row--dym .smart-ac__top-row__icon {
    background: #fef3c7;
    color: #92400e;
}
.smart-ac__top-row__text { flex: 1; min-width: 0; }
.smart-ac__top-row__text strong { color: var(--cyan-primary, #2563eb); }
.smart-ac__top-row__arrow {
    color: var(--cyan-primary, #2563eb);
    font-weight: 700;
    flex-shrink: 0;
}

/* Spec §1.2 — highlighted query terms inside suggest titles. */
.smart-ac__mark,
mark.smart-ac__mark {
    background: #fef08a;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* --- Skeleton ------------------------------------------------------------- */

.smart-ac__row--skeleton {
    pointer-events: none;
}

.smart-ac__skel {
    background: linear-gradient(90deg, #eef2f7 25%, #f7fafc 50%, #eef2f7 75%);
    background-size: 200% 100%;
    animation: smart-ac-shimmer 1.3s infinite linear;
    border-radius: 4px;
}

.smart-ac__skel--thumb { width: 100%; height: 100%; border-radius: 6px; }
.smart-ac__skel--line { height: 10px; width: 100%; margin: 4px 0; }
.smart-ac__skel--short { width: 40%; }
.smart-ac__skel--btn { width: 72px; height: 26px; border-radius: 6px; }

@keyframes smart-ac-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Shop page search banners (spec §2.2 / §3.1) ------------------------- */

.search-banners {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.search-correction-banner {
    padding: 12px 16px;
    background: var(--cyan-light, #e0f2fe);
    border: 1px solid var(--cyan-primary, #2563eb);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-text-secondary, #475569);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.search-correction-banner strong { color: var(--color-text, #0f172a); }
.search-correction-banner__link { color: var(--cyan-primary, #2563eb); text-decoration: none; font-size: 12px; }
.search-correction-banner__link:hover { text-decoration: underline; }

.search-did-you-mean {
    padding: 8px 14px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    font-size: 13px;
    color: #92400e;
}
.search-did-you-mean a { color: #92400e; text-decoration: underline; }
.search-did-you-mean a:hover { text-decoration: none; }

/* Spec §3.1 — printer hero banner above the grid. */
.printer-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 1px solid var(--cyan-primary, #2563eb);
    border-radius: 12px;
}
.printer-hero__icon {
    flex-shrink: 0;
    color: var(--cyan-primary, #2563eb);
    background: #fff;
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.printer-hero__body { flex: 1; min-width: 0; }
.printer-hero__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text, #0f172a);
    margin: 0 0 2px;
    line-height: 1.25;
}
.printer-hero__subtitle {
    font-size: 13px;
    color: var(--color-text-secondary, #475569);
    margin: 0;
}
.printer-hero__cta {
    flex-shrink: 0;
    color: var(--cyan-primary, #2563eb);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border: 1px solid var(--cyan-primary, #2563eb);
    border-radius: 999px;
    background: #fff;
    transition: background 0.15s ease, color 0.15s ease;
}
.printer-hero__cta:hover {
    background: var(--cyan-primary, #2563eb);
    color: #fff;
}
@media (max-width: 640px) {
    .printer-hero { flex-wrap: wrap; }
    .printer-hero__cta { width: 100%; text-align: center; }
}

/* Spec §3.3 — Fits Your Printer badge on product cards. */
.product-card__badge--fits-printer {
    background: #2563eb;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Spec §4 — value-pack / multipack ribbon. */
.product-card__ribbon {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fff;
    background: #f59e0b;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
.product-card__ribbon--multipack { background: #8b5cf6; }
.product-card__image-wrapper { position: relative; }

/* Spec §2.3 — zero-results recovery rails. */
.search-recovery {
    padding: 8px 0 24px;
}
.search-recovery__head { margin-bottom: 18px; text-align: center; }
.search-recovery__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text, #0f172a);
    margin: 0 0 4px;
}
.search-recovery__subtitle {
    font-size: 14px;
    color: var(--color-text-secondary, #475569);
    margin: 0;
}
.search-recovery__rails {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.search-recovery__rail-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text, #0f172a);
    margin: 0 0 10px;
}
.search-recovery__rail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.search-recovery__rail-grid.product-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.recovery-printer-card {
    display: block;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 10px;
    text-decoration: none;
    color: var(--color-text, #0f172a);
    font-weight: 600;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.recovery-printer-card:hover {
    border-color: var(--cyan-primary, #2563eb);
    box-shadow: 0 4px 12px rgba(37,99,235,0.12);
}

.recovery-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 10px;
    text-decoration: none;
    color: var(--color-text, #0f172a);
    font-weight: 600;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.recovery-tile:hover {
    border-color: var(--cyan-primary, #2563eb);
    background: var(--cyan-light, #e0f2fe);
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
    .smart-ac-dropdown {
        min-width: 0;
        max-height: 70vh;
    }

    .smart-ac__row {
        grid-template-columns: 56px minmax(0, 1fr) auto auto;
        gap: 10px;
        padding: 8px 10px;
    }

    .smart-ac__thumb {
        width: 56px;
        height: 56px;
    }

    /* Hide price column on narrow screens; keep stock + action */
    .smart-ac__price { display: none; }
}

/* --- Grid layout for product cards in search dropdown -------------------- */

.smart-ac-dropdown:has(.smart-ac__grid) {
    position: fixed;
    top: var(--smart-ac-top, 120px);
    left: var(--smart-ac-left, 0);
    right: auto;
    transform: none;
    width: var(--smart-ac-width, 100%);
    min-width: 0;
    max-width: 96vw;
    /* Height is set by search.js positionDropdown() to fill the viewport
       below the search input (window.innerHeight - top - 16px), so two
       full rows of product cards + the sticky View-all footer always fit.
       The fallback below covers the millisecond before JS runs and any
       no-JS preview rendering. */
    max-height: var(--smart-ac-max-height, calc(100vh - var(--smart-ac-top, 120px) - 16px));
}

.smart-ac__grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px;
}

.smart-ac__grid .product-card {
    cursor: pointer;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

/* Compact product cards inside the search dropdown */
.smart-ac__grid .product-card__image-wrapper {
    aspect-ratio: 10 / 7.5;
    padding: 3%;
    box-sizing: border-box;
}
.smart-ac__grid .product-card__image,
.smart-ac__grid .product-card__color-block {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.smart-ac__grid .product-card__content {
    padding: 4px 6px 6px;
}
.smart-ac__grid .product-card__brand {
    font-size: 10px;
    margin: 0 0 2px;
}
.smart-ac__grid .product-card__title {
    font-size: 12px;
    line-height: 1.3;
    margin: 0 0 4px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.smart-ac__grid .product-card__rating,
.smart-ac__grid .product-card__savings,
.smart-ac__grid .product-card__free-shipping,
.smart-ac__grid .product-card__color {
    display: none;
}
.smart-ac__grid .product-card__footer {
    gap: 4px;
}
.smart-ac__grid .product-card__footer-row {
    gap: 4px;
}
.smart-ac__grid .product-card__price {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
}
.smart-ac__grid .product-card__stock {
    font-size: 10px;
}
.smart-ac__grid .product-card__add-btn {
    font-size: 12px;
    padding: 8px 12px;
    min-height: 0;
    font-weight: 600;
}
/* Smart-AC dropdown cards run in a tight grid — the top-left chips
   (Save / Fits Your Printer / Lowest Price) crowd the thumbnail in
   that footprint, so we hide them dropdown-side only. */
.smart-ac__grid .product-card__badge {
    display: none;
}

.smart-ac__grid .product-card.is-highlighted,
.smart-ac__grid .product-card:hover {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.18);
    border-color: var(--cyan-primary, #2563eb);
}

.smart-ac__grid .product-card--skeleton {
    pointer-events: none;
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 8px;
    padding: 8px;
}

.smart-ac__grid .product-card--skeleton .product-card__image-wrapper {
    aspect-ratio: 1 / 1;
    background: var(--product-image-bg);
    border-radius: 6px;
    margin-bottom: 8px;
}

.smart-ac__view-all-wrap {
    display: flex;
    justify-content: center;
    padding: 10px 8px 14px;
    border-top: 1px solid var(--color-border-light, #e5e7eb);
    margin-top: 4px;
    background: #fafbfc;
    position: sticky;
    bottom: 0;
}

.smart-ac__view-all {
    display: inline-block;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--cyan-primary, #2563eb);
    background: #fff;
    border: 1px solid var(--cyan-primary, #2563eb);
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.smart-ac__view-all:hover {
    background: var(--cyan-primary, #2563eb);
    color: #fff;
}

@media (max-width: 640px) {
    .smart-ac__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 8px;
    }
}


/* ==========================================================================
   SEARCH RESULTS PAGINATION
   Renders beneath compatible+genuine grids on /search?q=... when the result
   set exceeds one page (backend caps `limit` at 100). Markup built in
   shop-page.js renderSearchPagination.
   ========================================================================== */

.search-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 32px 0 8px;
    padding: 24px 16px 8px;
    border-top: 1px solid var(--color-border-light, #e5e7eb);
}

.search-pagination .pagination__info {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary, #475569);
    text-align: center;
}

.search-pagination .pagination__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.search-pagination .pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--color-text, #0f172a);
    background: #fff;
    border: 1px solid var(--color-border, #d1d5db);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
    -webkit-appearance: none;
    appearance: none;
}

.search-pagination .pagination__btn:hover:not(:disabled) {
    background: var(--color-background-alt, #f3f4f6);
    border-color: var(--color-border-dark, #9ca3af);
}

.search-pagination .pagination__btn:active:not(:disabled) {
    transform: translateY(1px);
}

.search-pagination .pagination__btn:focus-visible {
    outline: 2px solid var(--cyan-primary, #2563eb);
    outline-offset: 2px;
}

.search-pagination .pagination__btn.active,
.search-pagination .pagination__btn[aria-current="page"] {
    background: var(--cyan-primary, #2563eb);
    border-color: var(--cyan-primary, #2563eb);
    color: #fff;
    cursor: default;
}

.search-pagination .pagination__btn.active:hover,
.search-pagination .pagination__btn[aria-current="page"]:hover {
    background: var(--cyan-primary, #2563eb);
    border-color: var(--cyan-primary, #2563eb);
}

.search-pagination .pagination__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.search-pagination .pagination__btn--prev svg,
.search-pagination .pagination__btn--next svg {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

.search-pagination .pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 40px;
    color: var(--text-secondary, #6b7280);
    user-select: none;
}

@media (max-width: 640px) {
    .search-pagination {
        gap: 10px;
        padding-top: 20px;
    }

    .search-pagination .pagination__btn {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }

    /* Hide the verbose Prev/Next labels on narrow viewports — the chevron
       icons carry the meaning, freeing space for page numbers. */
    .search-pagination .pagination__btn--prev span,
    .search-pagination .pagination__btn--next span {
        display: none;
    }
}
