/* Hide Woostify default search overlay */
.site-dialog-search.woostify-search-wrap,
.dialog-search-content,
.woostify-search-overlay {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -999 !important;
}

/* ESW Discovery Hub Container */
#esw-discovery-hub {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-family: 'Inter', 'Roboto', sans-serif;
}
#esw-discovery-hub.esw-dh-open {
    opacity: 1;
    visibility: visible;
}

.esw-dh-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1;
}

.esw-dh-modal {
    position: relative;
    z-index: 2;
    width: 95vw;
    max-width: 1200px;
    height: 90vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-20px) scale(0.98);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
#esw-discovery-hub.esw-dh-open .esw-dh-modal {
    transform: translateY(0) scale(1);
}

/* Header & Input */
.esw-dh-header {
    display: flex;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
}
.esw-dh-input-wrapper {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.esw-dh-input-wrapper:focus-within {
    border-color: #cbd5e1;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(203,213,225, 0.2);
}
.esw-dh-search-icon {
    width: 28px; height: 28px;
    color: #64748b;
    margin-left: 20px;
}
#esw-dh-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 20px 15px;
    font-size: 20px;
    font-weight: 500;
    color: #0f172a;
    outline: none;
    box-shadow: none !important;
}
#esw-dh-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}
.esw-dh-clear-btn {
    background: none; border: none; cursor: pointer;
    color: #94a3b8; padding: 15px;
}
.esw-dh-clear-btn:hover { color: #ef4444; }
.esw-dh-clear-btn svg { width: 24px; height: 24px; }
.esw-dh-close {
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    margin-left: 20px;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
}
.esw-dh-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.esw-dh-close-mobile {
    display: none;
}

/* Body & Grid */
.esw-dh-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 30px;
}
.esw-dh-grid-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
}
.esw-dh-heading-wrap {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}
.esw-dh-heading {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 15px;
    font-weight: 700;
}
.esw-dh-heading-wrap .esw-dh-heading {
    margin-bottom: 0;
    margin-right: 12px;
}
.esw-dh-clear-history-btn {
    background: none; border: none; color: #94A3B8; font-size: 11px; cursor: pointer; font-weight: 600; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.5px;
}
.esw-dh-clear-history-btn:hover {
    color: #DC2626; background-color: #FEE2E2;
}

.esw-dh-section {
    margin-bottom: 30px;
}

/* Lists */
.esw-dh-list {
    list-style: none; padding: 0; margin: 0;
}
.esw-dh-list li {
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: #334155;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.esw-dh-list li:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.esw-dh-recent-list {
    max-height: 150px; overflow-y: auto; padding-right: 5px;
}
.esw-dh-trending-list {
    max-height: 200px; overflow-y: auto; padding-right: 5px;
}

/* Chips */
.esw-dh-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.esw-dh-chip {
    padding: 8px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.esw-dh-chip:hover {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

/* Product Cards */
.esw-dh-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.esw-dh-product-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}
.esw-dh-product-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
    transform: translateY(-4px);
    border-color: #cbd5e1;
}
.esw-dh-pc-img {
    height: 160px;
    background: #f8fafc;
    display: flex; justify-content: center; align-items: center;
    padding: 15px;
}
.esw-dh-pc-img img {
    max-height: 100%; max-width: 100%; object-fit: contain; mix-blend-mode: multiply;
}
.esw-dh-pc-info {
    padding: 15px;
}
.esw-dh-pc-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.esw-dh-pc-price {
    font-size: 16px;
    font-weight: 700;
    color: #059669; /* Price green */
}
.esw-dh-pc-price del {
    font-size: 12px; color: #94a3b8; font-weight: 400; margin-left: 5px;
}

/* Skeleton */
.esw-dh-skeleton {
    height: 200px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: eswLoading 1.5s infinite;
    border-radius: 12px;
    margin-bottom: 20px;
}
@keyframes eswLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* State Management */
.esw-dh-state-hidden { display: none !important; }
.esw-dh-state-active { display: block; }


/* Hide Scrollbars for Professional Presentation */
.esw-dh-list, .esw-dh-trending-wrapper {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}
.esw-dh-list::-webkit-scrollbar, .esw-dh-trending-wrapper::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}


/* =========================================================================
   MOBILE SEARCH OPTIMIZATION
   ========================================================================= */
@media (max-width: 900px) {
    /* Full Screen Modal */
    #esw-discovery-hub {
        padding-top: 0;
    }
    .esw-dh-modal {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }
    
    /* Header Optimization */
    .esw-dh-header {
        padding: 10px 15px;
    }
    .esw-dh-search-icon {
        width: 20px; height: 20px; margin-left: 12px;
    }
    #esw-dh-input {
        padding: 12px 10px;
        font-size: 16px; /* Prevents iOS auto-zoom */
    }
    .esw-dh-close-desktop { display: none; }
    .esw-dh-close-mobile { 
        display: block; 
        background: none; 
        padding: 10px; 
        margin-left: 5px; 
    }
    .esw-dh-close-mobile svg {
        width: 28px; height: 28px;
    }

    /* Body Optimization */
    .esw-dh-body {
        padding: 15px 0 0 0; /* Strict no empty space policy */
    }
    .esw-dh-grid-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .esw-dh-col-left {
        padding: 0 15px; /* Padding on the left column contents */
    }
    .esw-dh-col-right {
        padding: 0 15px 15px 15px; /* Padding on products */
    }
    
    .esw-dh-section {
        margin-bottom: 20px;
    }
    .esw-dh-heading {
        margin-bottom: 10px;
        font-size: 12px;
    }

    /* Hide Unnecessary Desktop Elements */
    .esw-dh-desktop-only {
        display: none !important;
    }

    /* Recent Searches: Horizontal Chips on Mobile */
    .esw-dh-recent-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 5px;
        max-height: none;
        gap: 8px;
    }
    .esw-dh-recent-list li {
        flex: 0 0 auto;
        background: #f1f5f9;
        border-radius: 20px;
        padding: 6px 12px;
        font-size: 13px;
        border: 1px solid #e2e8f0;
        white-space: nowrap;
    }
    /* Hide the delete 'x' on mobile chips for space, or style it compact */
    .esw-dh-recent-list li span[onclick*="deleteSingleHistory"] {
        margin-left: 6px;
        font-size: 14px;
    }

    /* Trending Searches: Horizontal Swipeable Chips */
    .esw-dh-trending-wrapper {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .esw-dh-trending-list {
        display: inline-flex;
        flex-direction: row;
        padding-bottom: 5px;
        max-height: none;
        gap: 8px;
    }
    .esw-dh-trending-list li {
        flex: 0 0 auto;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 20px;
        padding: 6px 14px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }
    .esw-dh-trending-list li:before {
        content: "🔥 ";
    }
    .esw-dh-section .esw-dh-heading:contains("Trending Searches") {
        display: none; /* The fire emoji acts as the indicator, or keep text minimal */
    }

    /* Product Cards: Compact List View for Mobile */
    .esw-dh-product-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .esw-dh-product-card {
        flex-direction: row;
        height: 100px;
    }
    .esw-dh-pc-img {
        width: 100px;
        height: 100px;
        padding: 10px;
        flex-shrink: 0;
    }
    .esw-dh-pc-info {
        padding: 10px 15px 10px 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex-grow: 1;
    }
    .esw-dh-pc-title {
        font-size: 13px;
        margin-bottom: 4px;
        -webkit-line-clamp: 2;
    }
    .esw-dh-pc-price {
        font-size: 15px;
    }
    
    /* Search Results Adjustments */
    #esw-dh-suggestions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    #esw-dh-suggestions li {
        padding: 6px 12px;
        background: #f1f5f9;
        border-radius: 20px;
        font-size: 13px;
        white-space: nowrap;
        flex: 0 0 auto;
    }
}
