/* Fix Search, Category, and Tag Pages Layout */

/* Force 50px padding on the main container for these pages */
body.search-results #primary.content-area,
body.tax-product_cat #primary.content-area,
body.tax-product_tag #primary.content-area,
body.post-type-archive-product #primary.content-area,
.mlm-advanced-search.site-main {
    padding-left: 50px !important;
    padding-right: 50px !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

/* Remove inner padding from product grids to prevent double padding */
.modern-product-archive,
.modern-search-results {
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Ensure the row inside doesn't have negative margins that push it out */
body.search-results .mlm-advanced-search .row,
body.tax-product_cat .mlm-advanced-search .row,
body.tax-product_tag .mlm-advanced-search .row,
body.post-type-archive-product .mlm-advanced-search .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}

/* Override any other margin/padding on main wrapper */
#main.site-main.mlm-advanced-search {
    padding: 0 50px !important;
    max-width: none !important;
}

/* Fix product title height and line clamp */
.modern-search-results .modern-product-card .item-title h4,
.modern-product-archive .modern-product-card .item-title h4,
.modern-product-card .item-title h4 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5 !important;
    height: 3em !important; /* 1.5 * 2 = 3em */
    margin: 0 !important;
}

.modern-search-results .modern-product-card .item-title a,
.modern-product-archive .modern-product-card .item-title a,
.modern-product-card .item-title a {
    display: inline !important; /* Ensure it flows with the text for clamp to work on parent or itself */
}

/* Fix responsive padding */
@media (max-width: 768px) {
    body.search-results #primary.content-area,
    body.tax-product_cat #primary.content-area,
    body.tax-product_tag #primary.content-area,
    body.post-type-archive-product #primary.content-area,
    .mlm-advanced-search.site-main,
    #main.site-main.mlm-advanced-search {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}
