/* 
 * WEBIMPULSER INTELLIGENT SEARCH v4.9.3 
 * Premium Search UI for WooCommerce
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

#wi-search-root {
    --wi-primary: #6366f1;
    --wi-text-main: #1e293b;
    --wi-text-dim: #64748b;
    --wi-bg: #ffffff;
    --wi-radius: 22px;
    --wi-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);

    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    /* Controlled by JS */
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#wi-search-root.active {
    display: flex;
    opacity: 1;
}

.wi-search-modal {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 25px 70px -10px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#wi-search-root.active .wi-search-modal {
    transform: scale(1) translateY(0);
}

/* HEADER */
.wi-search-header {
    padding: 24px;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
}

.wi-search-input-wrap {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 18px;
    padding: 0 20px;
    height: 60px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.wi-search-input-wrap:focus-within {
    background: #fff;
    border-color: var(--wi-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.wi-search-icon {
    color: #94a3b8;
    margin-right: 14px;
}

#wi-search-input {
    flex: 1;
    background: transparent;
    border: none !important;
    outline: none !important;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    padding: 0;
    height: 100%;
    box-shadow: none !important;
}

.wi-search-close {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 34px;
    height: 34px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    color: #475569;
    z-index: 10;
    transition: all 0.2s;
    user-select: none;
}

.wi-search-close:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: scale(1.1);
}

/* CONTENT */
.wi-search-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: none;
}

.wi-search-body::-webkit-scrollbar {
    display: none;
}

/* INITIAL VIEW / HISTORY */
.wi-section-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.wi-history-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
}

.wi-history-pill {
    background: #f1f5f9;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.wi-history-pill:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
}

/* RESULTS GRID */
.wi-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.wi-product-card {
    background: #fff;
    border-radius: 20px;
    border: 1px solid #f1f5f9;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none !important;
    display: block;
}

.wi-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    border-color: var(--wi-primary);
}

.wi-product-img {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 14px;
    background-size: cover;
    background-position: center;
    margin-bottom: 8px;
    transition: opacity 0.2s, filter 0.2s;
}

.wi-product-info {
    padding: 4px;
}

.wi-product-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.wi-sku-badge {
    display: inline-block;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wi-product-price {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--wi-primary);
}

/* OUT OF STOCK */
.wi-out-of-stock {
    opacity: 0.85;
}

.wi-out-of-stock:hover {
    transform: none !important;
    box-shadow: none !important;
    border-color: #f1f5f9 !important;
    cursor: default;
}

.wi-out-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #ef4444;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 4px 4px 6px;
    width: calc(100% - 8px);
}

.wi-out-badge span {
    font-size: 0.75rem;
    font-weight: 900;
}

/* SALE BADGE */
.wi-sale-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #f97316;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* FUZZY WAND */
.wi-fuzzy-banner {
    background: rgba(99, 102, 241, 0.08);
    padding: 16px 20px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    cursor: pointer;
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--wi-primary);
    animation: wiSlideIn 0.5s ease-out;
}

@keyframes wiSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wi-fuzzy-banner b {
    text-decoration: underline;
}

/* LOADERS */
.wi-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--wi-primary);
    border-radius: 50%;
    animation: wiSpin 0.8s linear infinite;
}

@keyframes wiSpin {
    to {
        transform: rotate(360deg);
    }
}

.wi-skeleton {
    background: #f1f5f9;
    animation: wiShimmer 2s infinite linear;
    background: linear-gradient(90deg, #f1f5f9 25%, #f8fafc 50%, #f1f5f9 75%);
    background-size: 200% 100%;
}

@keyframes wiShimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* ── NO RESULTS STATE ───────────────────────────────────────────────────── */
.wi-no-results-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 36px 24px 20px;
    animation: wiSlideIn 0.4s ease-out;
}

.wi-no-results-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.28);
}

.wi-no-results-icon svg {
    width: 36px;
    height: 36px;
    color: #ffffff;
    stroke: #ffffff;
}

.wi-no-results-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.3;
}

.wi-no-results-sub {
    margin: 0;
    font-size: 0.9rem;
    color: #94a3b8;
    font-weight: 500;
}

/* ── RECOMMENDED PRODUCTS (no-results) ────────────────────────────────── */
.wi-no-results-rec-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 28px 0 14px;
    text-align: left;
}

.wi-no-results-rec-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.wi-rec-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    padding: 8px;
    text-decoration: none !important;
    display: block;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.wi-rec-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.1);
    border-color: var(--wi-primary);
}

.wi-rec-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-color: #f8fafc;
    margin-bottom: 7px;
    position: relative;
    overflow: hidden;
}

.wi-rec-info {
    padding: 2px 2px 0;
}

.wi-rec-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.wi-rec-price {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--wi-primary);
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
    .wi-no-results-rec-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 360px) {
    .wi-no-results-rec-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .wi-search-modal {
        max-height: 100vh;
        border-radius: 0;
    }

    #wi-search-root {
        padding: 0;
    }

    .wi-results-grid {
        gap: 10px;
    }

    .wi-no-results-icon {
        width: 60px;
        height: 60px;
    }

    .wi-no-results-icon svg {
        width: 28px;
        height: 28px;
    }

    .wi-no-results-title {
        font-size: 1rem;
    }
}

/* BANNER */
.wi-search-banner {
    display: block;
    position: relative;
    width: 100%;
    margin-bottom: 24px;
    border-radius: 20px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: #f8fafc;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    /* subtle shadow */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.wi-search-banner:hover {
    transform: translateY(-4px);
    /* lift effect */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.wi-banner-img {
    width: 100%;
    height: 140px;
    /* height of banner */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* gradient overlay so text is highly legible */
.wi-banner-img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.1) 100%);
    pointer-events: none;
}

.wi-banner-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    z-index: 2;
    /* above gradient overlay */
}

.wi-banner-title {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 4px;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.wi-banner-subtitle {
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* BRANDING */
.wi-search-branding {
    text-align: center;
    padding: 12px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}

.wi-search-branding a {
    text-decoration: none;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wi-search-branding a:hover {
    color: var(--wi-primary);
}