/* Sportsafe Commerce — instant search results.
   Enterprise-style, theme-aware dropdown driven by CSS custom properties so the
   whole palette flips for dark mode in one small block. Row layout is flex (not
   grid) so results without a thumbnail fill the width cleanly. */

.sdr-search-ui {
    position: relative;
}

/* Unified, rounded search bar (input + button/icon as one control). The corner
   radius and button colours come from the settings via CSS variables. */
.sdr-search-form__shell {
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid #c6d2de;
    border-radius: var( --sdr-search-radius, 8px );
    background: #fff;
}

.sdr-search-form__shell:focus-within {
    border-color: var( --sdr-search-btn-bg, #0f172a );
    box-shadow: 0 0 0 1px var( --sdr-search-btn-bg, #0f172a );
}

.sdr-search-form__shell .search-field {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.4;
}

.sdr-search-form__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 18px;
    border: 0;
    background: var( --sdr-search-btn-bg, #0f172a );
    color: var( --sdr-search-btn-fg, #fff );
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
}

.sdr-search-form--icon .sdr-search-form__button {
    padding: 0 14px;
}

.sdr-search-form__icon {
    width: 18px;
    height: 18px;
}

.sdr-search-form__button:hover {
    filter: brightness( 0.94 );
}

.sdr-search-form__button:focus-visible {
    outline: 2px solid var( --sdr-search-btn-bg, #0f172a );
    outline-offset: 2px;
}

.sdr-search-results {
    --sdr-s-bg: #ffffff;
    --sdr-s-fg: #0f172a;
    --sdr-s-muted: #64748b;
    --sdr-s-subtle: #f1f5f9;
    --sdr-s-hover: #f8fafc;
    --sdr-s-border: rgba( 15, 23, 42, 0.10 );
    --sdr-s-hairline: rgba( 15, 23, 42, 0.06 );
    --sdr-s-accent: #4f46e5;
    --sdr-s-accent-soft: rgba( 79, 70, 229, 0.10 );
    --sdr-s-price: #0f766e;
    --sdr-s-mark-bg: #fef3c7;
    --sdr-s-mark-fg: #92400e;

    position: absolute;
    top: calc( 100% + 8px );
    left: 0;
    right: 0;
    z-index: 9999;
    max-height: min( 70vh, 560px );
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var( --sdr-s-bg );
    color: var( --sdr-s-fg );
    border: 1px solid var( --sdr-s-border );
    border-radius: 12px;
    box-shadow: 0 24px 48px -12px rgba( 15, 23, 42, 0.25 ), 0 8px 16px -8px rgba( 15, 23, 42, 0.12 );
    font-size: 14px;
    line-height: 1.4;
    -webkit-overflow-scrolling: touch;
}

/* Dark palette — applied when the "Dark" theme is chosen, or when "Auto" is
   chosen and the visitor's device prefers dark. Light is the default. */
.sdr-search-results--theme-dark {
    --sdr-s-bg: #0f172a;
    --sdr-s-fg: #e2e8f0;
    --sdr-s-muted: #94a3b8;
    --sdr-s-subtle: #1e293b;
    --sdr-s-hover: #1e293b;
    --sdr-s-border: rgba( 255, 255, 255, 0.12 );
    --sdr-s-hairline: rgba( 255, 255, 255, 0.07 );
    --sdr-s-accent: #a5b4fc;
    --sdr-s-accent-soft: rgba( 129, 140, 248, 0.16 );
    --sdr-s-price: #34d399;
    --sdr-s-mark-bg: rgba( 250, 204, 21, 0.25 );
    --sdr-s-mark-fg: #fde68a;
    box-shadow: 0 24px 48px -12px rgba( 0, 0, 0, 0.55 );
}

@media ( prefers-color-scheme: dark ) {
    .sdr-search-results--theme-auto {
        --sdr-s-bg: #0f172a;
        --sdr-s-fg: #e2e8f0;
        --sdr-s-muted: #94a3b8;
        --sdr-s-subtle: #1e293b;
        --sdr-s-hover: #1e293b;
        --sdr-s-border: rgba( 255, 255, 255, 0.12 );
        --sdr-s-hairline: rgba( 255, 255, 255, 0.07 );
        --sdr-s-accent: #a5b4fc;
        --sdr-s-accent-soft: rgba( 129, 140, 248, 0.16 );
        --sdr-s-price: #34d399;
        --sdr-s-mark-bg: rgba( 250, 204, 21, 0.25 );
        --sdr-s-mark-fg: #fde68a;
        box-shadow: 0 24px 48px -12px rgba( 0, 0, 0, 0.55 );
    }
}

/* ── Sections ──────────────────────────────────────────────────────────────── */

.sdr-search-results__section-title {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var( --sdr-s-muted );
    background: var( --sdr-s-bg );
    border-bottom: 1px solid var( --sdr-s-hairline );
}

.sdr-search-results__count {
    padding: 1px 7px;
    border-radius: 999px;
    background: var( --sdr-s-subtle );
    color: var( --sdr-s-muted );
    font-size: 10px;
    letter-spacing: 0;
}

.sdr-search-results__list {
    display: flex;
    flex-direction: column;
}

/* ── Result row ────────────────────────────────────────────────────────────── */

.sdr-search-result {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 11px 16px;
    text-decoration: none !important;
    border-top: 1px solid var( --sdr-s-hairline );
    color: var( --sdr-s-fg ) !important;
    transition: background 0.12s ease;
}

.sdr-search-result:first-child {
    border-top: 0;
}

.sdr-search-result:hover,
.sdr-search-result.is-active {
    background: var( --sdr-s-hover );
}

.sdr-search-result.is-active {
    box-shadow: inset 3px 0 0 var( --sdr-s-accent );
}

.sdr-search-result__thumb {
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: var( --sdr-s-subtle );
    border: 1px solid var( --sdr-s-hairline );
}

.sdr-search-result__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sdr-search-result__thumb--empty svg {
    width: 20px;
    height: 20px;
    color: var( --sdr-s-muted );
    opacity: 0.55;
}

.sdr-search-result__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1 1 auto;
}

.sdr-search-result__title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.sdr-search-result__title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var( --sdr-s-fg );
}

.sdr-search-result__title mark,
.sdr-search-result__excerpt mark {
    background: var( --sdr-s-mark-bg );
    color: var( --sdr-s-mark-fg );
    padding: 0 2px;
    border-radius: 3px;
}

.sdr-search-result__price {
    flex: none;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
    color: var( --sdr-s-price );
}

.sdr-search-result__sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.sdr-search-result__type {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var( --sdr-s-muted );
}

.sdr-search-result__stock {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    background: var( --sdr-s-subtle );
    color: var( --sdr-s-muted );
}

.sdr-search-result__stock::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.sdr-search-result__stock--in {
    color: #0f766e;
    background: rgba( 15, 118, 110, 0.12 );
}

.sdr-search-result__stock--out {
    color: #b91c1c;
    background: rgba( 185, 28, 28, 0.12 );
}

.sdr-search-result__stock--backorder {
    color: #b45309;
    background: rgba( 180, 83, 9, 0.12 );
}

.sdr-search-result__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 11px;
    color: var( --sdr-s-muted );
}

.sdr-search-result__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sdr-search-result__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.5;
    color: var( --sdr-s-muted );
}

/* ── States ────────────────────────────────────────────────────────────────── */

.sdr-search-results__empty {
    padding: 18px 16px;
    font-size: 13px;
    color: var( --sdr-s-muted );
    text-align: center;
}

.sdr-search-results__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 16px;
    font-size: 13px;
    color: var( --sdr-s-muted );
}

.sdr-search-results__spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var( --sdr-s-border );
    border-top-color: var( --sdr-s-accent );
    animation: sdr-search-spin 0.6s linear infinite;
}

@keyframes sdr-search-spin {
    to { transform: rotate( 360deg ); }
}

@media ( prefers-reduced-motion: reduce ) {
    .sdr-search-results__spinner { animation-duration: 1.4s; }
    .sdr-search-result { transition: none; }
}

.sdr-search-results__redirect {
    padding: 12px 16px;
    font-size: 12px;
    color: var( --sdr-s-muted );
    border-bottom: 1px solid var( --sdr-s-hairline );
    background: var( --sdr-s-accent-soft );
}

.sdr-search-results__redirect a {
    color: var( --sdr-s-accent ) !important;
    text-decoration: none !important;
    font-weight: 600;
}

/* ── Footer / recent ───────────────────────────────────────────────────────── */

.sdr-search-results__footer {
    position: sticky;
    bottom: 0;
    padding: 10px 16px;
    border-top: 1px solid var( --sdr-s-border );
    background: var( --sdr-s-bg );
}

.sdr-search-results__view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    background: var( --sdr-s-accent-soft );
    color: var( --sdr-s-accent ) !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
}

.sdr-search-results__view-all::after {
    content: "\2192";
}

.sdr-search-results__clear,
.sdr-search-results__recent-item {
    appearance: none;
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var( --sdr-s-accent ) !important;
    text-decoration: none !important;
}

.sdr-search-results__clear {
    width: 100%;
    text-align: center;
}

.sdr-search-results__recent {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
}

.sdr-search-results__recent-item {
    padding: 7px 12px;
    border: 1px solid var( --sdr-s-border );
    border-radius: 999px;
    background: var( --sdr-s-bg );
    color: var( --sdr-s-fg ) !important;
    font-weight: 500;
}

.sdr-search-results__recent-item:hover {
    background: var( --sdr-s-hover );
    border-color: var( --sdr-s-accent );
}

/* ── Mobile fullscreen ─────────────────────────────────────────────────────── */

@media ( max-width: 782px ) {
    .sdr-search-ui.is-mobile-open .sdr-search-results {
        position: fixed;
        inset: 0;
        max-height: none;
        border-radius: 0;
        border: 0;
        box-shadow: none;
        padding-top: 64px;
    }

    .sdr-search-mobile-open {
        overflow: hidden;
    }
}
