/* =========================================
   CUSTOM WOOCOMMERCE CATEGORY UI - GRID LAYOUT
   ========================================= */

/* 1. STRUCTURAL GRID LAYOUT (Decoupling DOM with display: contents) */
body.tax-product_cat.archive.woocommerce.woocommerce-page #main .fusion-row {
    display: grid !important;
    grid-template-columns: 280px 1fr !important;
    column-gap: 40px !important;
    row-gap: 30px !important;
    align-items: start !important;
    margin-top: 50px !important;
}



/* Dissolve the wrapper divs to let children participate directly in the Grid */
body.tax-product_cat.archive.woocommerce #main .fusion-row>.woocommerce-container,
body.tax-product_cat.archive.woocommerce #main .fusion-row>.woocommerce-container>section#content {
    display: contents !important;
}

/* Assign grid areas manually by row and column to allow overlapping and spanning */
body.tax-product_cat .woocommerce-products-header {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: start;
    align-self: end;
    margin: 0 !important;
    padding: 0 !important;
}

body.tax-product_cat .catalog-ordering {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: end;
    align-self: end;
    margin: 0 !important;
    padding: 0 !important;
}

body.tax-product_cat .woocommerce-notices-wrapper {
    grid-column: 1 / -1;
    grid-row: 2;
}

/* Fix for Sidebar Squishing */
body.tax-product_cat aside#sidebar {
    grid-column: 1 / 2;
    grid-row: 3;
    width: 100% !important;
    /* Force override Avada's 22% sidebar width */
    max-width: 100% !important;
    float: none !important;
    padding: 0 !important;
}

body.tax-product_cat ul.products {
    grid-column: 2 / 3;
    grid-row: 3;
    width: 100% !important;
    /* Force override */
}

body.tax-product_cat nav.woocommerce-pagination {
    grid-column: 2 / 3;
    grid-row: 4;
}

/* Fix missing first product issue caused by clearfix pseudo-elements in Grid */
body.tax-product_cat ul.products::before,
body.tax-product_cat ul.products::after {
    display: none !important;
    content: none !important;
}


/* 2. COMPONENT STYLING (matching the supplied image design) */

/* Header Title Alignment */
body.tax-product_cat .woocommerce-products-header .term-description p {
    font-size: 32px;
    font-weight: 300;
    color: #102a43;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
}

body.tax-product_cat .woocommerce-products-header .term-description p strong {
    font-weight: 700;
}

/* Sorting Area Alignment */
body.tax-product_cat .catalog-ordering.fusion-clearfix {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    border: none !important;
    background: transparent !important;
    gap: 7px;
}

body.tax-product_cat .catalog-ordering.fusion-clearfix::before,
body.tax-product_cat .catalog-ordering.fusion-clearfix::after {
    content: none !important;
}

body.tax-product_cat .catalog-ordering .orderby-order-container,
body.tax-product_cat .catalog-ordering .order-dropdown,
body.tax-product_cat .catalog-ordering .order,
body.tax-product_cat .catalog-ordering .fusion-grid-list-view {
    display: flex !important;
    align-items: center !important;
    float: none !important;
    gap: 7px;
}

body.tax-product_cat .catalog-ordering ul.orderby,
body.tax-product_cat .catalog-ordering ul.sort-count,
body.tax-product_cat .catalog-ordering ul.order,
body.tax-product_cat .catalog-ordering .fusion-grid-list-view li {
    background: #ffffff !important;
    /* Must keep border to override default woo */
    border-radius: 6px !important;
    height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    box-shadow: none !important;
    gap: 7px;
}

body.tax-product_cat .catalog-ordering ul.order {
    width: 42px;
}

body.tax-product_cat .order-dropdown>li {
    width: 100%;
}

body.tax-product_cat .catalog-ordering .fusion-grid-list-view li {
    border: 1px solid #e1e8ed !important;
}

body.tax-product_cat .order-dropdown .current-li,
body.tax-product_cat .catalog-ordering ul.orderby span.current-li {
    border-radius: 6px;
}

body.tax-product_cat .catalog-ordering ul.order a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 42px;
    height: 42px;
    border-radius: 6px;
    font-size: 16px;
    color: #031E33;
}

body.tax-product_cat ul.fusion-grid-list-view {
    padding: 0 !important;
    margin: 0 !important;
    column-gap: 7px;
    border: none !important;
    height: auto !important;
}

body.tax-product_cat ul.fusion-grid-list-view li a {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    border-radius: 6px;
}

body.tax-product_cat .catalog-ordering .fusion-grid-list-view li a i {
    position: relative;
    top: 0;
    left: 0;
    padding: 0;
    margin: 0;
    font-size: 16px;
    display: inline-block;
    width: auto;
}

body.tax-product_cat .catalog-ordering .fusion-grid-list-view li a .awb-icon-grid.icomoon-grid {
    background-image: url('../../Avada-Child-Theme/images/icon-grid.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    display: inline-block;
    width: 16px;
    height: 16px;
}

body.tax-product_cat .catalog-ordering .fusion-grid-list-view li a .awb-icon-grid.icomoon-grid::before {
    content: none;
}

body.tax-product_cat .catalog-ordering ul.orderby>li>span.current-li>span>a,
body.tax-product_cat .catalog-ordering ul.sort-count>li>span.current-li>a,
body.tax-product_cat .catalog-ordering ul.order li a,
body.tax-product_cat .catalog-ordering .fusion-grid-list-view li a {
    color: #334155 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    line-height: normal !important;
}

/* Sidebar Widgets (WooBeWoo Filters) */
body.tax-product_cat .wpfFilterWrapper {
    border: 1px solid rgb(217 217 217 / 50%) !important;
    border-radius: 6px !important;
    background: rgba(217, 217, 217, 0.05) !important;
    padding: 25px !important;
    margin-bottom: 25px !important;
    margin-top: 0 !important;
}

body.tax-product_cat .wpfFilterTitle {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 !important;
    border-bottom: none !important;
    color: #102a43 !important;

}

body.tax-product_cat .wpfFilterTitle i.wpfTitleToggle {
    font-size: 12px;
    color: #102a43;
}

body.tax-product_cat .wpfFilterContent {
    padding: 0 !important;
}

body.tax-product_cat .wpfFilterContent .wpfSearchWrapper {
    margin-top: 20px;
}

body.tax-product_cat .wpfSearchWrapper input.wpfSearchFieldsFilter {
    width: 100% !important;
    background: rgba(3, 30, 51, 0.05) !important;
    border: 1px solid rgba(3, 30, 51, 0.10) !important;
    border-radius: 6px !important;
    padding: 10px 15px !important;
    font-size: 14px !important;
    outline: none !important;
    box-shadow: none !important;
    display: flex;
    padding: 8px 0 8px 10px !important;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    align-self: stretch;
}

body.tax-product_cat .wpfSearchWrapper input.wpfSearchFieldsFilter::placeholder {
    color: #9baac1;
}

/* Custom Scrollbar */
body.tax-product_cat .wpfFilterVerScroll {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 15px;
}

body.tax-product_cat .wpfFilterVerScroll::-webkit-scrollbar {
    width: 5px;
}

body.tax-product_cat .wpfFilterVerScroll::-webkit-scrollbar-track {
    background: #e1e8ed;
    border-radius: 10px;
    border: none;
}

body.tax-product_cat .wpfFilterVerScroll::-webkit-scrollbar-thumb {
    background: #0f2b48;
    border-radius: 10px;
}

/* Fix List Items Squishing */
body.tax-product_cat .wpfCheckboxHier {
    margin-top: 20px;
}

body.tax-product_cat .wpfCheckboxHier ul li {
    list-style: none !important;
    margin-bottom: 12px !important;
}

body.tax-product_cat .wpfFilterVerScroll li label {
    display: flex;
    align-items: center;
    gap: 9px;
    align-self: stretch;
    cursor: pointer;
}

/* Checkboxes AND Radio buttons */
body.tax-product_cat .wpfCheckbox {
    display: flex !important;
    flex-shrink: 0 !important;
    justify-content: center;
    align-items: center;
}

/* Hide WooBeWoo inner label layout element */
body.tax-product_cat .wpfCheckbox>label {
    display: none !important;
}

body.tax-product_cat .wpfCheckbox input[type="checkbox"],
body.tax-product_cat .wpfCheckbox input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 3px !important;
    margin: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background: #fff !important;
    cursor: pointer !important;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1;
}

/* Make radio buttons circular */
body.tax-product_cat .wpfCheckbox input[type="radio"] {
    border-radius: 50% !important;
}

body.tax-product_cat .wpfCheckbox input[type="checkbox"]:checked,
body.tax-product_cat .wpfCheckbox input[type="radio"]:checked {
    background: #0f2b48 !important;
    border-color: #0f2b48 !important;
}

body.tax-product_cat .wpfCheckbox input[type="checkbox"]:checked::after {
    content: "\2713";
    color: #fff !important;
    font-size: 12px !important;
    position: absolute !important;
}

/* Radio dot */
body.tax-product_cat .wpfCheckbox input[type="radio"]:checked::after {
    content: "";
    width: 8px !important;
    height: 8px !important;
    background-color: #fff !important;
    border-radius: 50% !important;
    position: absolute !important;
}

body.tax-product_cat .wpfFilterTaxNameWrapper {
    font-size: 14px !important;
    color: #102a43 !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    /* helps with wrapped text */
}

/* Product Grid (3 Columns) */
body.tax-product_cat ul.products {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    margin-top: 0 !important;
    justify-content: flex-start;
    align-items: flex-start;
}

body.tax-product_cat ul.products li.product.type-product.product-grid-view {
    width: calc(100% / 3 - 13.5px);
}

body.tax-product_cat ul.products li.product.type-product.product-list-view {
    width: 100%;
}

@media (max-width: 992px) {
    body.tax-product_cat ul.products li.product.type-product.product-grid-view {
        width: calc(100% / 2 - 10px);
    }
}

@media (max-width: 640px) {
    body.tax-product_cat ul.products li.product.type-product.product-grid-view {
        width: 100%;
    }

    /* Remove borders bounding the image on thin mobile screens, replace with list separation */
    body.tax-product_cat .product-images {
        border: none !important;
        background-color: transparent !important;
        padding: 10px 0 !important;
        height: auto !important;
        min-height: 200px;
        /* retain some visual height */
    }

    body.tax-product_cat .fusion-product-content {
        padding: 5px 0 25px 0 !important;
        border-bottom: 1px solid #e1e8ed !important;
    }
}

body.tax-product_cat ul.products li.product {
    width: 100%;
    margin: 0;
    clear: none;
    padding: 0;
}

/* Override Avada Product Border */
body.tax-product_cat .fusion-product-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

body.tax-product_cat .product-details-container {
    border: none !important;
    min-height: auto;
}

body.tax-product_cat .product-images {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #e1e8ed !important;
    border-radius: 6px !important;
    padding: 30px !important;
    height: 300px !important;
    background-color: #fff !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
}

body.tax-product_cat .product-images:hover {
    border-color: #2271b1 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
}

body.tax-product_cat .product-images .featured-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.tax-product_cat .product-images img {
    max-height: 100% !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

body.tax-product_cat .fusion-product-content {
    background: transparent !important;
    padding: 15px 0 0 0 !important;
    border: none !important;
}

body.tax-product_cat .product-details {
    padding: 0 !important;
    text-align: left !important;
}

body.tax-product_cat .product-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #102a43 !important;
    margin: 0 !important;
}

body.tax-product_cat .product-title a {
    color: inherit !important;
    text-decoration: none !important;
}

/* Hide Unwanted Elements Details Button & Price */
body.tax-product_cat .fusion-price-rating,
body.tax-product_cat .product-buttons,
body.tax-product_cat .fusion-content-sep {
    display: none !important;
}

/* Pagination Styling */
body.tax-product_cat nav.woocommerce-pagination {
    margin-top: 50px !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
}

body.tax-product_cat nav.woocommerce-pagination a.page-numbers,
body.tax-product_cat nav.woocommerce-pagination span.page-numbers {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #102a43 !important;
    background: #f0f4f8 !important;
    text-decoration: none !important;
    padding: 0 !important;
    border: none !important;
    transition: background-color 0.2s ease !important;
}

body.tax-product_cat nav.woocommerce-pagination span.current {
    background: #0f2b48 !important;
    color: #ffffff !important;
}

body.tax-product_cat nav.woocommerce-pagination a.next,
body.tax-product_cat nav.woocommerce-pagination a.prev {
    background: transparent !important;
    color: #102a43 !important;
}

body.tax-product_cat nav.woocommerce-pagination .page-text {
    display: none !important;
}

body.tax-product_cat.archive.woocommerce #main .fusion-row>.woocommerce-container>section#content .woocommerce-notices-wrapper {
    border-bottom: 1px solid rgb(3 30 51 / 10%) !important;
}

body.tax-product_cat .wpfFilterWrapper .wfpTitle {
    font-size: 26px;
    font-weight: 400;
    height: auto;
    line-height: 1.1;
}

body.tax-product_cat .wpfFilterWrapper .wpfCheckbox label::before {
    width: 25px;
    height: 25px;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    border: 1px solid #D9D9D9;
    background: rgba(217, 217, 217, 0.05);
}

body.tax-product_cat label.wpfLiLabel {
    display: flex;
    align-items: center;
    gap: 9px;
    align-self: stretch;
}

body.tax-product_cat .wpfFilterVerScroll li label span.wpfDisplay span.wpfValue {
    padding: 0 !important;
}

/* =========================================
   MOBILE RESPONSIVE OVERRIDES
   (Placed at the bottom to ensure cascade priority!)
   ========================================= */

@media (max-width: 992px) {
    body.tax-product_cat.archive.woocommerce.woocommerce-page #main .fusion-row {
        grid-template-columns: 1fr !important;
        row-gap: 25px !important;
    }

    /* Reposition Grid items securely in a 1fr column */
    body.tax-product_cat #wrapper .woocommerce-products-header {
        grid-column: 1 / -1 !important;
        grid-row: 1 !important;
        justify-self: center !important;
        width: 100%;
        text-align: center;
    }

    body.tax-product_cat #wrapper .woocommerce-products-header .term-description p {
        text-align: center;
        font-size: 28px;
    }

    body.tax-product_cat #wrapper .catalog-ordering {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        justify-self: stretch !important;
        width: 100%;
    }

    body.tax-product_cat #wrapper .woocommerce-notices-wrapper {
        grid-column: 1 / -1 !important;
        grid-row: 3 !important;
    }

    body.tax-product_cat #wrapper aside#sidebar {
        grid-column: 1 / -1;
        grid-row: 4;
        margin-bottom: 20px;
        margin-top: 0;
    }

    body.tax-product_cat #wrapper ul.products {
        grid-column: 1 / -1 !important;
        grid-row: 5 !important;
        margin: 0;
    }

    body.tax-product_cat #wrapper nav.woocommerce-pagination {
        grid-column: 1 / -1 !important;
        grid-row: 6 !important;
        margin-top: 20px !important;
    }
}

@media (max-width: 640px) {
    body.tax-product_cat #wrapper .catalog-ordering.fusion-clearfix {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 7px;
    }

    body.tax-product_cat #wrapper .catalog-ordering ul.orderby {
        flex: 1;
    }

    body.tax-product_cat #wrapper .catalog-ordering ul.orderby>li {
        width: 100%;
    }

    body.tax-product_cat #wrapper .catalog-ordering ul.orderby>li>span.current-li {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    body.tax-product_cat #wrapper .wpfFilterWrapper {
        padding: 15px !important;
    }

    body.tax-product_cat #wrapper .current-li-content {
        display: flex;
        align-items: center;
        height: 42px;
    }

    body.tax-product_cat #wrapper .orderby-order-container {
        margin-bottom: 0px;
    }

    body.tax-product_cat #wrapper .order-dropdown.sort-count {
        min-width: 181px;
    }

    body.tax-product_cat #wrapper .catalog-ordering .fusion-grid-list-view li {
        width: 42px;
    }

    body.tax-product_cat #wrapper .has-sidebar #sidebar {
        margin-top: 0;
    }

    body.tax-product_cat #wrapper .sidebar .widget {
        margin-bottom: 0px;
    }
}

@media only screen and (max-width: 800px) {
    body.tax-product_cat #wrapper .order-dropdown>li:hover>ul {
        display: block;
        position: absolute;
        top: 100%;
        z-index: 100;
        width: 100%;
    }
}