/* =========================================================
   1. NAVBAR ICON NEXT TO CART
   ========================================================= */
.lwh-search-cart-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
}

.lwh-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: inherit;
    padding: 6px;
    margin-right: -14px; /* Pulls the search icon closer to the mini-cart icon */
    cursor: pointer;
    line-height: 1;
    border-radius: 50%;
    transition: transform 0.18s ease, background-color 0.18s ease;
}

.lwh-search-trigger:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.06);
}

.lwh-search-trigger__icon {
    width: 22px;
    height: 22px;
    display: block;
}

/* Lock page scroll when modal is open */
body.lwh-search-open {
    overflow: hidden !important;
}

/* =========================================================
   2. MODAL OVERLAY & RESPONSIVE DIMENSIONS (40% DESKTOP / 100% MOBILE)
   ========================================================= */
.lwh-search-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.lwh-search-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.lwh-search-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 28, 0.52);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Desktop: Centered, 40% of screen width */
.lwh-search-modal__dialog {
    position: relative;
    z-index: 2;
    width: 40vw;
    min-width: 480px;
    max-width: 760px;
    height: 82vh;
    max-height: 840px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(14px) scale(0.98);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

.lwh-search-modal.is-open .lwh-search-modal__dialog {
    transform: translateY(0) scale(1);
}

/* Mobile: Fullscreen 100% width and height */
@media (max-width: 960px) {
    .lwh-search-modal__dialog {
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        border-radius: 0 !important;
        transform: translateY(10px);
    }
}

/* =========================================================
   3. SEARCH BAR HEADER
   ========================================================= */
.lwh-search-modal__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    flex-shrink: 0;
}

.lwh-search-modal__input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    background: #f4f5f7;
    border-radius: 999px;
    padding: 0 14px;
    border: 1.5px solid transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.lwh-search-modal__input-wrap:focus-within {
    background: #ffffff;
    border-color: #111111;
}

.lwh-search-modal__search-icon {
    color: #666;
    flex-shrink: 0;
    margin-right: 8px;
}

.lwh-search-modal__input {
    width: 100%;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 11px 4px;
    font-size: 15px;
    color: #111;
    font-family: inherit;
}

.lwh-search-modal__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.lwh-search-modal__clear {
    background: rgba(0, 0, 0, 0.08);
    border: none;
    color: #333;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 6px;
}

.lwh-search-modal__close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f4f5f7;
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.lwh-search-modal__close:hover {
    background: #111;
    color: #fff;
}

/* =========================================================
   4. MODAL BODY & 2-COLUMN PRODUCT GRID
   ========================================================= */
.lwh-search-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 28px;
    -webkit-overflow-scrolling: touch;
}

.lwh-search-modal__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.lwh-search-modal__section-title {
    font-family: var(--wp--preset--font-family--oswald, inherit);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #555;
}

.lwh-search-modal__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #ff6900;
    border-radius: 50%;
    animation: lwhSrchSpin 0.65s linear infinite;
}

@keyframes lwhSrchSpin {
    to { transform: rotate(360deg); }
}

.lwh-search-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (min-width: 961px) {
    .lwh-search-grid--desktop-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Always enforce 2 columns on mobile */
@media (max-width: 960px) {
    .lwh-search-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px;
    }
}

/* Subtle divider when similarity engine adds products */
.lwh-search-grid__divider {
    grid-column: 1 / -1;
    margin: 10px 0 2px;
    padding-top: 14px;
    border-top: 1px dashed rgba(0, 0, 0, 0.12);
    font-family: var(--wp--preset--font-family--oswald, inherit);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lwh-search-grid__divider::before {
    content: "✦";
    color: #ff6900;
}

/* =========================================================
   5. PRODUCT CARDS & SUBTLE STAGGERED ANIMATION
   ========================================================= */
@keyframes lwhCardFadeUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.lwh-search-card {
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    color: inherit !important;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    opacity: 0;
    animation: lwhCardFadeUp 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.lwh-search-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.18);
}

.lwh-search-card__media {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f6f6f6;
    overflow: hidden;
}

.lwh-search-card__img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
    transition: transform 0.35s ease;
}

.lwh-search-card:hover .lwh-search-card__img {
    transform: scale(1.04);
}

.lwh-search-card__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #111;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 99px;
    letter-spacing: 0.03em;
}

.lwh-search-card__cat {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #222;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

.lwh-search-card__info {
    padding: 10px 10px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.lwh-search-card__title {
    font-family: var(--wp--preset--font-family--oswald, inherit);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.25;
    color: #111;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lwh-search-card__price {
    font-size: 12.5px;
    color: #444;
    font-weight: 600;
    margin-top: auto;
}

.lwh-search-card__price del {
    opacity: 0.5;
    margin-right: 4px;
}

.lwh-search-card__price ins {
    text-decoration: none;
    color: #d63638;
}