/**
 * Byamber Live Search Overlay
 * @package Byamber
 * @since   6.0.29
 */

/* ── Overlay backdrop ── */
.ba-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(60px, 10vh, 120px);
}

.ba-search-overlay[hidden] { display: none !important; }

.ba-search-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .52);
    backdrop-filter: blur(4px);
    cursor: pointer;
    animation: ba-search-fade-in .18s ease;
}

@keyframes ba-search-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Panel ── */
.ba-search-overlay-panel {
    position: relative;
    width: min(660px, calc(100vw - 32px));
    max-height: calc(100dvh - clamp(60px, 10vh, 120px) - 24px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, .22);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: ba-search-panel-in .2s cubic-bezier(.2, .7, .2, 1);
}

@keyframes ba-search-panel-in {
    from { opacity: 0; transform: translateY(-12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header row ── */
.ba-search-overlay-head {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid #f0ebe4;
}

/* ── Input wrap ── */
.ba-search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.ba-search-input-icon {
    position: absolute;
    left: .85rem;
    display: flex;
    align-items: center;
    pointer-events: none;
    color: #796b64;
}

.ba-search-input-icon svg {
    width: 18px;
    height: 18px;
}

.ba-search-input {
    width: 100%;
    height: 48px;
    padding: 0 2.8rem 0 2.8rem;
    border: 1.5px solid #eadfd4;
    border-radius: 14px;
    background: #faf6f2;
    color: #000;
    font: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.ba-search-input:focus {
    border-color: var(--ba-primary, #a563e5);
    box-shadow: 0 0 0 3px rgba(165, 99, 229, .16);
    background: #fff;
}

.ba-search-input::placeholder {
    color: #b0a499;
}

/* ── Clear button ── */
.ba-search-clear {
    position: absolute;
    right: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: #eadfd4;
    color: #796b64;
    cursor: pointer;
    transition: background .18s ease;
}

.ba-search-clear[hidden] { display: none !important; }

.ba-search-clear:hover { background: #d6ccc4; }

.ba-search-clear svg { width: 14px; height: 14px; }

/* ── Cancel button ── */
.ba-search-close-btn {
    flex-shrink: 0;
    padding: .5rem .75rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--ba-primary, #a563e5);
    font: inherit;
    font-size: .88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease;
}

.ba-search-close-btn:hover {
    background: rgba(165, 99, 229, .08);
}

/* ── Scrollable body ── */
.ba-search-body {
    flex: 1;
    overflow-y: auto;
    padding: .75rem;
}

/* ── Section label ── */
.ba-search-section-label {
    margin: .5rem .25rem .6rem;
    font-size: .72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #b0a499;
}

/* ── Result items ── */
.ba-search-result-item {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .65rem .75rem;
    border-radius: 14px;
    text-decoration: none;
    color: #000;
    transition: background .15s ease;
    outline: none;
}

.ba-search-result-item:hover,
.ba-search-result-item.is-active {
    background: rgba(165, 99, 229, .07);
    color: #000;
}

.ba-search-result-item:focus-visible {
    box-shadow: 0 0 0 2px var(--ba-primary, #a563e5);
}

/* ── Thumbnail ── */
.ba-search-result-img {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: #f7eee8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ba-search-result-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ba-search-result-img-fallback {
    font-size: 22px;
    line-height: 1;
}

/* ── Copy ── */
.ba-search-result-copy {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: .18rem;
}

.ba-search-result-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(165, 99, 229, .1);
    color: var(--ba-primary, #a563e5);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    width: fit-content;
}

.ba-search-badge-cat {
    background: rgba(29, 33, 107, .1);
    color: var(--ba-primary-dark, #1d216b);
}

.ba-search-result-title {
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ba-search-result-price {
    font-size: .88rem;
    color: var(--ba-primary-dark, #1d216b);
    font-weight: 800;
}

/* ── View all ── */
.ba-search-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin-top: .5rem;
    padding: .85rem;
    border-radius: 14px;
    border: 1.5px solid var(--ba-primary, #a563e5);
    color: var(--ba-primary, #a563e5);
    font-weight: 800;
    font-size: .92rem;
    text-decoration: none;
    transition: background .18s ease;
}

.ba-search-view-all:hover {
    background: rgba(165, 99, 229, .06);
}

.ba-search-view-all svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── No results ── */
.ba-search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: #796b64;
    font-size: .92rem;
}

/* ── Loading spinner ── */
.ba-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    padding: 1.5rem;
    color: #796b64;
    font-size: .88rem;
}

.ba-search-loading[hidden] { display: none !important; }

.ba-search-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid #eadfd4;
    border-top-color: var(--ba-primary, #a563e5);
    border-radius: 50%;
    animation: ba-search-spin .6s linear infinite;
    flex-shrink: 0;
}

@keyframes ba-search-spin {
    to { transform: rotate(360deg); }
}

/* ── Recent searches ── */
.ba-search-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-bottom: .5rem;
}

.ba-search-recent-item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem .8rem;
    border: 1px solid #eadfd4;
    border-radius: 999px;
    background: #faf6f2;
    color: #000;
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.ba-search-recent-item:hover {
    background: #fff;
    border-color: var(--ba-primary, #a563e5);
    color: var(--ba-primary, #a563e5);
}

.ba-search-recent-item svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: .6;
}

/* ── Popular links ── */
.ba-search-popular-links {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .5rem;
}

.ba-search-popular-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .9rem;
    border-radius: 999px;
    background: #f7eee8;
    color: #000;
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s ease;
}

.ba-search-popular-link img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

.ba-search-popular-link:hover {
    background: rgba(165, 99, 229, .12);
    color: var(--ba-primary, #a563e5);
}

/* ── Body scroll lock ── */
body.ba-search-open {
    overflow: hidden;
}

/* ── Mobile ── */
@media (max-width: 767px) {
    .ba-search-overlay {
        padding-top: 0;
        align-items: flex-end;
    }

    .ba-search-overlay-panel {
        width: 100%;
        max-height: 90dvh;
        border-radius: 24px 24px 0 0;
        animation: ba-search-panel-mobile-in .22s cubic-bezier(.2, .7, .2, 1);
    }

    @keyframes ba-search-panel-mobile-in {
        from { opacity: 0; transform: translateY(20px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .ba-search-input { font-size: 16px; /* prevent iOS zoom */ }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .ba-search-overlay-backdrop,
    .ba-search-overlay-panel { animation: none !important; }
    .ba-search-spinner { animation: none; border-top-color: var(--ba-primary, #a563e5); }
}
