/* ─────────────────────────────────────────────────
   Typesense search
   ───────────────────────────────────────────────── */

.typesense-search {
    position: relative;
    margin: 0;
    z-index: 5;
}

/* ── Toggle — same structure as .ico-cart / .ico-account ── */

.typesense-search__toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 35px;
    height: 40px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.typesense-search__toggle .ico-search {
    width: 100%;
    height: 100%;
}

.typesense-search__toggle .ico-search svg {
    fill: #fff;
}

@media (hover: hover) {
    .typesense-search__toggle:hover .ico-search svg {
        fill: #93b4e8;
    }
}

/* ── Search form — slides in from right ── */

.typesense-search__form {
    position: absolute;
    top: 50%;
    right: 100%;
    width: clamp(240px, 22vw, 280px);
    margin-right: 8px;
    transform: translateY(-50%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 25;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.typesense-search .form-search {
    position: relative;
    display: block;
    width: 100%;
}

.typesense-search .form-search label {
    display: none;
}

.typesense-search .form-search .input-text {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 36px 0 34px;
    border: 0;
    border-radius: 999px;
    background: #2354d4;
    color: #fff;
    font-size: 14px;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    transition: background 0.2s ease;
}

.typesense-search .form-search .input-text::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.typesense-search .form-search .input-text:focus {
    background: #1d48b8;
}

/* ── Open state ── */

.typesense-search.is-open .typesense-search__toggle {
    opacity: 0;
    pointer-events: none;
}

.typesense-search.is-open .typesense-search__form {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}


/* ── Submit ── */

.typesense-search__submit {
    position: absolute;
    top: 50%;
    left: 4px;
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.typesense-search__submit svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.typesense-search__submit:not([disabled]):hover {
    color: #fff;
}

.typesense-search__submit[disabled] {
    opacity: 0.3;
    pointer-events: none;
}

/* ─────────────────────────────────────────────────
   Suggestions dropdown
   ───────────────────────────────────────────────── */

.typesense-search__suggestions {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-width: calc(100vw - 16px);
    z-index: 30;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(13, 27, 62, 0.14),
                0 1px 4px rgba(13, 27, 62, 0.06);
    overflow: hidden;
    overflow-y: auto;
    max-height: 400px;
    -webkit-overflow-scrolling: touch;
}

.typesense-search__item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    color: #1a2744;
    text-decoration: none;
    transition: background 0.1s ease;
}

.typesense-search__item:hover,
.typesense-search__item.is-active {
    background: #f5f7fb;
}

.typesense-search__item:focus {
    outline: none;
}

.typesense-search__item + .typesense-search__item {
    border-top: 1px solid #f0f2f6;
}

.typesense-search__thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f8;
}

.typesense-search__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.typesense-search__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.typesense-search__label {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    color: #1a2744;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.typesense-search__tagline {
    color: #5f6c89;
    font-size: 11px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typesense-search__prices {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    margin-left: 8px;
}

.typesense-search__prices .price-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    margin: 0;
}

.typesense-search__prices .old-price,
.typesense-search__prices .special-price,
.typesense-search__prices .regular-price {
    margin: 0;
}

.typesense-search__prices .price {
    display: block;
    white-space: nowrap;
    color: #1a2744;
    font-weight: 700;
    font-size: 13px;
}

.typesense-search__prices .old-price .price {
    color: #9aa4ba;
    font-size: 11px;
    font-weight: 500;
    text-decoration: line-through;
}

.typesense-search__status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 14px;
    color: #5f6c89;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.typesense-search__status--loading {
    min-height: 74px;
}

.typesense-search__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(29, 72, 184, 0.18);
    border-top-color: #1d48b8;
    border-radius: 50%;
    animation: typesense-search-spin 0.7s linear infinite;
}

.typesense-search__footer {
    position: sticky;
    bottom: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid #f0f2f6;
    background: #fff;
    box-shadow: 0 -10px 20px rgba(255, 255, 255, 0.96);
    z-index: 1;
}

.typesense-search__view-all {
    display: block;
    padding: 11px 14px;
    border: 1px solid #d6def0;
    border-radius: 10px;
    color: #1d48b8;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
    .typesense-search__view-all:hover {
        background: #f2f6ff;
        border-color: #c3d0ee;
        color: #163a97;
    }
}

.typesense-search__count {
    margin: 0;
    opacity: 0.75;
}

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

/* ── Results page ── */
/* Product card structure intentionally comes from the shared listing styles. */

.typesensesearch-page .shop-products {
    margin-top: 32px;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .typesense-search.is-open .typesense-search__toggle {
        opacity: 1;
        pointer-events: auto;
    }

    .typesense-search__form {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 56px;
        margin-right: 0;
        transform: none;
        background: #2F67F4;
        display: flex;
        align-items: center;
        z-index: 9999;
    }

    .typesense-search .form-search {
        padding: 0 12px;
        flex: 1;
    }

    .typesense-search__suggestions {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
        border-radius: 0 0 12px 12px;
        max-height: calc(100vh - 56px);
    }
}

@media (max-width: 520px) {
    .typesense-search__thumb {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }
}
