/**
 * Search Suggestions Dropdown Styles
 * 
 * @package ChildTheme_Clean
 */

.search-suggestions-dropdown {
    position: fixed !important;
    background: #ffffff !important;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1) !important;
    margin-top: 0 !important;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 2147483645 !important;
    /* Just below cart drawer (2147483647) but above everything else */
    border: 1px solid #E5E7EB !important;
    isolation: isolate !important;
    transform: translateZ(0) !important;
    will-change: transform !important;
    pointer-events: auto !important;
    /* Desktop: Make dropdown wider */
    min-width: 600px;
    max-width: 800px;
}

/* Ensure dropdown doesn't overflow viewport on desktop */
@media (min-width: 769px) {
    .search-suggestions-dropdown {
        max-width: min(800px, calc(100vw - 40px));
    }
}

.search-suggestions-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions-dropdown::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 8px;
}

.search-suggestions-dropdown::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 8px;
}

.search-suggestions-dropdown::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #111827;
    border-bottom: 1px solid #F3F4F6;
    transition: background-color 0.15s ease;
    cursor: pointer;
    gap: 12px;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover,
.search-suggestion-item.selected {
    background-color: #F9FAFB;
}

.search-suggestion-item:focus {
    outline: 2px solid #3B82F6;
    outline-offset: -2px;
}

.search-suggestion-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    background: #F3F4F6;
}

.search-suggestion-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.search-suggestion-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-suggestion-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-suggestion-title mark {
    background-color: #FEF3C7;
    color: #92400E;
    font-weight: 600;
    padding: 0;
}

.search-suggestion-price {
    font-size: 0.875rem;
    color: #6B7280;
    font-weight: 500;
}

.search-suggestion-price .woocommerce-Price-amount {
    color: #059669;
    font-weight: 600;
}

.search-suggestion-empty {
    padding: 24px 16px;
    text-align: center;
    color: #6B7280;
    font-size: 0.9375rem;
    border-bottom: none;
}

.search-suggestion-empty:hover {
    background-color: transparent;
}

/* Mobile optimizations - Full Screen */
@media (max-width: 768px) {
    .search-suggestions-dropdown {
        /* Full screen on mobile */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        z-index: 2147483646 !important;
        /* Even higher on mobile to ensure full screen overlay */
        box-shadow: none !important;
        border: none !important;
        display: flex !important;
        flex-direction: column !important;
        /* Force isolation to create new stacking context */
        isolation: isolate !important;
        transform: translateZ(0) !important;
        will-change: transform !important;
        /* Ensure it's above everything including hero sections and product images */
        pointer-events: auto !important;
    }

    /* Ensure all other elements are below the dropdown on mobile */
    @media (max-width: 768px) {
        body>*:not(.search-suggestions-dropdown) {
            position: relative !important;
            z-index: 1 !important;
        }

        /* Specifically target common overlay elements */
        .hero-section,
        .product-image,
        .woocommerce-product-gallery,
        .site-content,
        .entry-content,
        #page,
        .site {
            z-index: 1 !important;
        }
    }

    .search-suggestions-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid #E5E7EB;
        background: #ffffff;
        flex-shrink: 0;
    }

    .search-suggestions-mobile-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: #111827;
    }

    .search-suggestions-mobile-close {
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        color: #111827;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        transition: background-color 0.15s ease;
    }

    .search-suggestions-mobile-close:hover,
    .search-suggestions-mobile-close:focus {
        background-color: #F3F4F6;
    }

    .search-suggestions-mobile-close svg {
        width: 24px;
        height: 24px;
    }

    .search-suggestions-list {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .search-suggestion-item {
        padding: 16px 20px;
        gap: 16px;
    }

    .search-suggestion-image {
        width: 70px;
        height: 70px;
    }

    .search-suggestion-title {
        font-size: 1rem;
    }

    .search-suggestion-price {
        font-size: 0.9375rem;
    }
}

/* Force ALL page containers to have lower z-index than dropdown */
#page,
.site,
.entry-content,
.site-main,
.site-content,
.woocommerce,
.product-page,
.product-page-container,
.product-summary,
.single-product,
.type-product,
.woocommerce-product-gallery,
.checkout-form-container,
.product-fast-checkout-form,
.checkout-form-header,
.checkout-form-body,
.product-description-under-form {
    position: relative !important;
    z-index: 1 !important;
    isolation: auto !important;
}

/* Mobile: Force all elements below dropdown */
@media (max-width: 768px) {

    #page,
    .site,
    .entry-content,
    .site-main,
    .site-content,
    .woocommerce,
    .product-page,
    .product-page-container,
    .product-summary,
    .single-product,
    .type-product,
    .woocommerce-product-gallery,
    .hero-section,
    .product-image,
    img,
    .wp-block-image,
    .header-container,
    body>*:not(.search-suggestions-dropdown):not(.site-header) {
        z-index: 1 !important;
        position: relative !important;
    }
}

/* Ensure dropdown appears above ALL elements - highest priority (below cart drawer) */
body .search-suggestions-dropdown,
body>.search-suggestions-dropdown,
body>div.search-suggestions-dropdown,
.site-header .search-suggestions-dropdown,
.site-header.search-active .search-suggestions-dropdown,
.announcement-bar~* .search-suggestions-dropdown,
.hero-section~* .search-suggestions-dropdown,
.site-content .search-suggestions-dropdown,
.woocommerce .search-suggestions-dropdown,
.search-results .search-suggestions-dropdown,
.checkout-form-container~* .search-suggestions-dropdown,
.checkout-form-container .search-suggestions-dropdown,
.product-fast-checkout-form~* .search-suggestions-dropdown,
#page .search-suggestions-dropdown,
.site .search-suggestions-dropdown,
.entry-content .search-suggestions-dropdown,
.product-page .search-suggestions-dropdown,
.search-suggestions-dropdown {
    z-index: 2147483645 !important;
    /* Maximum z-index - just below cart drawer (2147483647) */
    position: fixed !important;
    isolation: isolate !important;
    transform: translateZ(0) !important;
    will-change: transform !important;
    /* Force it to be above everything */
    pointer-events: auto !important;
}

/* Nuclear option: Force dropdown to be last child of body when visible */
body>.search-suggestions-dropdown[style*="display: block"],
body>.search-suggestions-dropdown:not([style*="display: none"]) {
    z-index: 2147483645 !important;
    position: fixed !important;
}