/* =========================================
   YouBuild Header Product Search
========================================= */

.yb-header-search {
    position: relative;
    display: flex;
    align-items: center;
}

.yb-header-search-toggle {
    background: none;
    border: none;
    color: #020617;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.yb-header-search-toggle:hover {
    background: #f8fafc;
    transform: translateY(-1px);
}

.yb-header-search-panel {
    position: absolute;
    top: calc(100% + 14px);
    right: -150px;
    width: 390px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.18);
    padding: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 10000;
}

.yb-header-search.is-open .yb-header-search-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.yb-header-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.yb-header-search-input {
    width: 100%;
    height: 46px;
    border: 1px solid #e2e8f0;
    border-radius: 13px;
    padding: 0 42px 0 42px;
    outline: none;
    font-size: 14px;
    color: #0f172a;
    background: #f8fafc;
}

.yb-header-search-input:focus {
    border-color: #0f172a;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.yb-header-search-input-icon {
    position: absolute;
    left: 14px;
    color: #64748b;
    pointer-events: none;
}

.yb-header-search-close {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);

    width: 30px;
    height: 30px;
    padding: 0;

    border: none;
    border-radius: 50%;
    background: #e2e8f0;
    color: #0f172a;

    font-size: 22px;
    font-weight: 400;
    line-height: 30px;
    text-align: center;

    display: flex;
    align-items: center;
    justify-content: center;

    font-family: Arial, sans-serif;
}

.yb-header-search-close:hover {
    background: #cbd5e1;
}

.yb-header-search-close:focus {
    outline: none;
}

.yb-header-search-close:hover {
    background: #cbd5e1;
}

.yb-header-search-results {
    margin-top: 10px;
    max-height: 390px;
    overflow-y: auto;
}

.yb-header-search-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: 13px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.yb-header-search-item:hover {
    background: #f8fafc;
    transform: translateX(2px);
}

.yb-header-search-thumb {
    width: 54px;
    height: 54px;
    border-radius: 11px;
    overflow: hidden;
    background: #f1f5f9;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
}

.yb-header-search-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.yb-header-search-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.yb-header-search-info strong {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.yb-header-search-info small {
    margin-top: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #64748b;
}

.yb-header-search-state {
    padding: 18px 14px;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

/* =========================================
   Search Cleanup
========================================= */

.yb-header-search-panel {
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.yb-header-search-results {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.yb-header-search-item {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.yb-header-search-info {
    min-width: 0 !important;
    max-width: 100% !important;
}

.yb-header-search-info strong,
.yb-header-search-info small {
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
}

.yb-header-search-info small {
    overflow: hidden !important;
}

/* Hide browser default search clear X */
.yb-header-search-input::-webkit-search-cancel-button,
.yb-header-search-input::-webkit-search-decoration,
.yb-header-search-input::-webkit-search-results-button,
.yb-header-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none !important;
    appearance: none !important;
    display: none !important;
}

.yb-header-search-input[type="search"] {
    -webkit-appearance: none !important;
    appearance: none !important;
}

/* =========================================
   Mobile Header + Search Final Layout
========================================= */

@media (max-width: 768px) {

    html,
    body {
        max-width: 100% !important;
/*         overflow-x: hidden !important; */
    }

    #yb-header .yb-topbar {
        position: relative !important;
        height: 68px !important;
        padding: 0 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    #yb-header .yb-menu-toggle {
        position: relative !important;
        z-index: 20 !important;
        width: 38px !important;
        height: 38px !important;
        flex: 0 0 38px !important;
        padding: 0 !important;
    }

    #yb-header .yb-logo {
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 180px !important;
        max-width: 180px !important;
        z-index: 2 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: unset !important;
    }

    #yb-header .yb-logo img {
        width: 180px !important;
        max-width: 180px !important;
        height: auto !important;
        display: block !important;
    }

    #yb-header .yb-actions {
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 25 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 4px !important;
    }

    #yb-header .yb-header-search-toggle,
    #yb-header .yb-actions .wishlist_products_counter,
    #yb-header .yb-account-btn,
    #yb-header .yb-account-trigger,
    #yb-header .yb-cart-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #yb-header .yb-header-search-toggle svg {
        width: 19px !important;
        height: 19px !important;
    }

    #yb-header .wishlist_products_counter:before {
        width: 18px !important;
        height: 18px !important;
    }

    #yb-header .yb-account-btn svg,
    #yb-header .yb-account-trigger svg {
        width: 18px !important;
        height: 18px !important;
    }

    #yb-header .yb-cart-btn svg {
        width: 21px !important;
        height: 21px !important;
    }

    #yb-header .yb-cart-btn .cart-count,
    #yb-header .yb-actions .wishlist_products_counter_number {
        top: -3px !important;
        right: -3px !important;
        min-width: 15px !important;
        height: 15px !important;
        padding: 0 4px !important;
        font-size: 9px !important;
        line-height: 15px !important;
    }

    /*
      IMPORTANT:
      This works with the updated JS where mobile panel is moved to body.
    */
    body > .yb-header-search-panel.yb-mobile-search-panel {
        position: fixed !important;
        top: 78px !important;
        left: 12px !important;
        right: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: calc(100% - 24px) !important;
        min-width: 0 !important;

        padding: 12px !important;
        box-sizing: border-box !important;

        border-radius: 18px !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22) !important;

        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(-8px) !important;

        z-index: 999999 !important;
        overflow: hidden !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel.is-open {
        opacity: 1 !important;
        pointer-events: auto !important;
        transform: translateY(0) !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-input-wrap {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-input {
        width: 100% !important;
        max-width: 100% !important;
        height: 48px !important;
        border-radius: 14px !important;
        font-size: 15px !important;
        padding: 0 44px 0 44px !important;
        box-sizing: border-box !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-results {
        width: 100% !important;
        max-height: 62vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        margin-top: 10px !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-state {
        width: 100% !important;
        white-space: normal !important;
        text-align: center !important;
        padding: 22px 14px !important;
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
}

/* Final mobile search safety */
@media (max-width: 768px) {
    html,
    body {
/*         overflow-x: hidden !important; */
    }

    body > .yb-header-search-panel.yb-mobile-search-panel {
        display: block !important;
        max-height: 70vh !important;
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22) !important;
        border: 1px solid #e2e8f0 !important;
        padding: 12px !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-input-wrap {
        width: 100% !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-input {
        width: 100% !important;
        height: 48px !important;
        box-sizing: border-box !important;
    }

    body > .yb-header-search-panel.yb-mobile-search-panel .yb-header-search-results {
        max-height: 58vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}