/* ══════════════════════════════════════════════════════════════════════════
   SEARCH – public page
   Every rule is scoped under .search-page so nothing leaks into other pages.
   Palette / radii / shadows match the News, Stores Locator & Categories pages.
   ══════════════════════════════════════════════════════════════════════════ */

.search-page {
    --sp-primary: #214086;
    --sp-primary-hover: #172f66;
    --sp-primary-soft: #eef2fb;
    --sp-dark: #0f172a;
    --sp-muted: #5b6b82;
    --sp-border: #e2e8f0;
    --sp-bg-light: #f8fafc;
    /* Shared width: title + search box line up with the state card below them */
    --sp-content-max: 720px;

    background-color: var(--sp-bg-light);
    padding-bottom: 80px;
}

/* ── Header + search box ─────────────────────────────────────────────────── */
.search-page .sp-header {
    background: #ffffff;
    border-bottom: 1px solid var(--sp-border);
    padding: 36px 0 26px 0;
    margin-bottom: 30px;
}

.search-page .sp-header-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--sp-primary);
    margin-bottom: 18px;
    line-height: 1.3;
    text-align: center;
}

.search-page .sp-form {
    display: flex;
    gap: 10px;
    max-width: var(--sp-content-max);
    margin-inline: auto;
}

.search-page .sp-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.search-page .sp-input {
    width: 100%;
    height: 54px;
    border: 1px solid var(--sp-border);
    border-radius: 14px;
    background: var(--sp-bg-light);
    color: var(--sp-dark);
    font-size: 1.02rem;
    padding-inline-start: 48px;
    padding-inline-end: 48px;
    text-overflow: ellipsis;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.search-page .sp-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

.search-page .sp-input::placeholder {
    color: #8a98ad;
    text-overflow: ellipsis;
}

.search-page .sp-input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 3px rgba(33, 64, 134, 0.15);
}

.search-page .sp-field-icon {
    position: absolute;
    top: 0;
    inset-inline-start: 18px;
    height: 54px;
    display: flex;
    align-items: center;
    color: var(--sp-muted);
    pointer-events: none;
}

.search-page .sp-clear {
    position: absolute;
    top: 7px;
    inset-inline-end: 7px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sp-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.search-page .sp-clear:hover {
    background: var(--sp-primary-soft);
    color: var(--sp-primary);
}

.search-page .sp-clear[hidden] {
    display: none;
}

.search-page .sp-clear:focus-visible,
.search-page .sp-submit:focus-visible,
.search-page .sp-chip:focus-visible,
.search-page .sp-cat-card:focus-visible,
.search-page .sp-jump-link:focus-visible,
.search-page .sp-view-all:focus-visible {
    outline: 3px solid rgba(33, 64, 134, 0.45);
    outline-offset: 2px;
}

.search-page .sp-submit {
    flex: 0 0 auto;
    min-height: 54px;
    padding: 0 26px;
    border: 0;
    border-radius: 14px;
    background: var(--sp-primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.search-page .sp-submit:hover {
    background: var(--sp-primary-hover);
    box-shadow: 0 4px 14px rgba(33, 64, 134, 0.3);
}

.search-page .sp-submit[disabled] {
    opacity: 0.75;
    cursor: progress;
}

.search-page .sp-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    animation: sp-spin 0.8s linear infinite;
}

.search-page .sp-submit.is-loading .sp-spinner {
    display: inline-block;
}

.search-page .sp-submit.is-loading .sp-submit-icon {
    display: none;
}

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

/* ── Suggestions (combobox listbox) ──────────────────────────────────────── */
.search-page .sp-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    inset-inline-end: 0;
    z-index: 30;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: #ffffff;
    border: 1px solid var(--sp-border);
    border-radius: 14px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
}

.search-page .sp-suggestions[hidden] {
    display: none;
}

.search-page .sp-suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    min-height: 48px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--sp-dark);
}

.search-page .sp-suggestion.is-active,
.search-page .sp-suggestion:hover {
    background: var(--sp-primary-soft);
}

.search-page .sp-suggestion img,
.search-page .sp-suggestion .sp-suggestion-ph {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--sp-bg-light);
}

.search-page .sp-suggestion .sp-suggestion-ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--sp-primary);
}

.search-page .sp-suggestion-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-page .sp-suggestion-tag {
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--sp-muted);
    background: var(--sp-bg-light);
    border-radius: 20px;
    padding: 2px 10px;
}

/* ── Summary + jump links ────────────────────────────────────────────────── */
.search-page .sp-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 16px;
}

.search-page .sp-summary {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--sp-muted);
    overflow-wrap: anywhere;
}

.search-page .sp-jump {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.search-page .sp-jump-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 16px;
    border-radius: 40px;
    background: #eef2f6;
    color: var(--sp-dark);
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none !important;
    transition: background 0.2s ease, color 0.2s ease;
}

.search-page .sp-jump-link:hover {
    background: var(--sp-primary);
    color: #ffffff;
}

.search-page .sp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 22px;
    padding: 0 7px;
    border-radius: 12px;
    background: var(--sp-primary-soft);
    color: var(--sp-primary);
    font-size: 0.78rem;
    font-weight: 800;
}

.search-page .sp-jump-link:hover .sp-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* ── Groups ──────────────────────────────────────────────────────────────── */
.search-page .sp-group {
    margin-bottom: 40px;
    scroll-margin-top: 110px;
}

.search-page .sp-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 16px;
}

.search-page .sp-group-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--sp-dark);
    margin: 0;
}

.search-page .sp-view-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    font-weight: 700;
    color: var(--sp-primary);
    text-decoration: none !important;
}

.search-page .sp-view-all:hover {
    color: var(--sp-primary-hover);
    text-decoration: underline !important;
}

.search-page mark {
    background: #fff3c4;
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

/* Arrows / chevrons follow the reading direction */
.search-page[dir="rtl"] .sp-dir-icon {
    transform: scaleX(-1);
}

/* ── Category cards (compact) ────────────────────────────────────────────── */
.search-page .sp-cat-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.search-page .sp-cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
    min-height: 76px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid var(--sp-border);
    border-radius: 14px;
    color: var(--sp-dark);
    text-decoration: none !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.search-page .sp-cat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(33, 64, 134, 0.3);
    box-shadow: 0 12px 28px rgba(33, 64, 134, 0.12);
}

.search-page .sp-cat-media {
    position: relative;
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--sp-bg-light);
}

.search-page .sp-cat-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.search-page .sp-cat-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sp-primary);
    font-size: 22px;
    background: linear-gradient(135deg, #eef2fb 0%, #dfe7f7 100%);
}

.search-page .sp-cat-placeholder[hidden] {
    display: none;
}

.search-page .sp-cat-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 700;
    font-size: 0.96rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.search-page .sp-cat-arrow {
    flex: 0 0 auto;
    color: var(--sp-primary);
    font-size: 0.85rem;
}

/* ── Sort ────────────────────────────────────────────────────────────────── */
.search-page .sp-sort {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.search-page .sp-sort-label {
    margin: 0;
    font-weight: 600;
    color: var(--sp-muted);
    white-space: nowrap;
}

.search-page .sp-sort-select {
    height: 44px;
    min-width: 200px;
    border-radius: 10px;
}

/* ── Products: reuse the Products page card, 4 / 3 / 2 columns ───────────── */
.search-page .sp-products-grid > .product-card {
    flex: 0 0 25%;
    max-width: 25%;
    margin-bottom: 24px;
}

/* ── Pagination (same look as the News page) ─────────────────────────────── */
.search-page .sp-pagination {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.search-page .sp-pagination .pagination {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.search-page .sp-pagination .page-link {
    border-radius: 8px;
    border: 1px solid var(--sp-border);
    color: #334155;
    padding: 9px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.search-page .sp-pagination .page-link:hover {
    background: #e2e8f0;
    color: var(--sp-primary);
}

.search-page .sp-pagination .page-item.active .page-link {
    background: var(--sp-primary);
    border-color: var(--sp-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(33, 64, 134, 0.25);
}

/* ── States: empty / too short / no results / error ──────────────────────── */
.search-page .sp-state {
    background: #ffffff;
    border: 2px dashed #cbd5e1;
    border-radius: 20px;
    padding: 56px 30px;
    text-align: center;
    max-width: var(--sp-content-max);
    margin: 20px auto 40px auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.02);
}

.search-page .sp-state-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--sp-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 18px;
}

.search-page .sp-state-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--sp-dark);
    margin-bottom: 10px;
    overflow-wrap: anywhere;
}

.search-page .sp-state-desc {
    color: var(--sp-muted);
    font-size: 0.98rem;
    line-height: 1.7;
    margin-bottom: 20px;
}

.search-page .sp-tips {
    list-style: none;
    padding: 0;
    margin: 0 auto 22px auto;
    color: var(--sp-muted);
    line-height: 2;
}

.search-page .sp-tips li::before {
    content: "•";
    color: var(--sp-primary);
    font-weight: 800;
    margin-inline-end: 8px;
}

.search-page .sp-state-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-page .sp-btn {
    min-height: 44px;
    border-radius: 10px;
    font-weight: 700;
    padding: 9px 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.search-page .sp-chips-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sp-dark);
    margin: 10px 0 14px 0;
}

.search-page .sp-chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.search-page .sp-chip {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 18px;
    border-radius: 40px;
    border: 1px solid var(--sp-border);
    background: #ffffff;
    color: var(--sp-dark);
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.search-page .sp-chip:hover {
    background: var(--sp-primary);
    border-color: var(--sp-primary);
    color: #ffffff;
}

.search-page .sp-alternative {
    margin-top: 10px;
}

/* ── Tablet ──────────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .search-page .sp-cat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-page .sp-products-grid > .product-card {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
    }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .search-page {
        padding-bottom: 48px;
    }

    .search-page .sp-header {
        padding: 22px 0 18px 0;
        margin-bottom: 22px;
    }

    .search-page .sp-header-title {
        font-size: 1.6rem;
        margin-bottom: 12px;
    }

    .search-page .sp-form {
        flex-direction: column;
    }

    .search-page .sp-submit {
        justify-content: center;
        min-height: 48px;
        width: 100%;
    }

    .search-page .sp-cat-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }

    .search-page .sp-products-grid > .product-card {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 16px;
    }

    .search-page .sp-sort {
        width: 100%;
    }

    .search-page .sp-sort-select {
        flex: 1 1 auto;
        min-width: 0;
    }

    .search-page .sp-state {
        padding: 40px 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-page .sp-cat-card,
    .search-page .sp-spinner {
        transition: none !important;
        animation: none !important;
    }

    .search-page .sp-cat-card:hover {
        transform: none;
    }
}
