/* ============================================
   EA Related Products & Recently Viewed Tabs
   ============================================ */

/* Main wrapper */
.ea-related-recently-viewed-tabs {
    width: 100%;
    clear: both;
    margin-top: 80px;
    margin-bottom: 80px;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Tab Navigation Wrapper - Rounded container with light grey background */
.ea-tabs-nav-wrapper {
    display: inline-flex;
    gap: 0;
    margin-bottom: 0;
    background: #f5f5f5;
    border-radius: 12px 12px 0 0;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 2;
}

/* Tab Buttons */
.ea-tab-button {
    padding: 10px 24px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: #666;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 500;
    font-style: normal;
    line-height: 110%;
    letter-spacing: -0.16px;
    vertical-align: middle;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    position: relative;
    outline: none;
    white-space: nowrap;
}

.ea-tab-button:hover {
    color: #1a1a1a;
    background: rgba(255, 255, 255, 0.5);
}

.ea-tab-button.active {
    background: #ffffff;
    color: #1a1a1a;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 110%;
    letter-spacing: -0.16px;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border-radius: 8px 8px 0 0;
    position: relative;
    z-index: 3;
    margin-bottom: -1px; /* Connect with content */
}

/* Tab Content Wrapper */
.ea-tabs-content-wrapper {
    position: relative;
    min-height: 200px;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-top: -1px; /* Connect with active tab */
    z-index: 1;
    overflow: hidden;
}

/* Ensure tab content has padding */
.ea-tabs-content-wrapper .ea-tab-content {
    padding: 40px 0 !important;
}

/* Tab Content */
.ea-tab-content {
    display: none;
    padding: 40px 0 !important;
}

.ea-tab-content.active {
    display: block;
}

/* Empty state */
.ea-tab-content-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Products grid - Let Salient theme handle the grid */
.ea-recently-viewed-tab-products {
    /* Use Salient's products class to inherit all styling */
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    width: 100%;
    clear: both;
}

/* Ensure Salient's column system works for recently viewed products */
.ea-tab-content .ea-recently-viewed-tab-products.columns-4 {
    display: block;
    width: 100%;
    clear: both;
    padding: 0 !important;
    margin: 0 !important;
}

/* Make sure products inherit Salient's related products styling */
/* Note: Recently viewed products have their own styling below, this is just for fallback */

/* Related products section styling */
.ea-tab-content .related.products,
.ea-tab-content section.related.products {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

/* Hide only "Related products" heading, not product titles */
.ea-tab-content .related.products > h2,
.ea-tab-content section.related.products > h2,
.ea-tab-content .products.related > h2 {
    display: none !important; /* Hide default "Related products" heading since we have tabs */
}

/* Hide "Related products" section heading outside tabs too */
.ea-related-recently-viewed-tabs + section.related.products > h2,
.ea-related-recently-viewed-tabs ~ section.related.products > h2,
.ea-related-recently-viewed-tabs + .related.products > h2,
.ea-related-recently-viewed-tabs ~ .related.products > h2 {
    display: none !important;
}

/* Hide entire "Related products" section that appears after our tabs */
.ea-related-recently-viewed-tabs + section.related.products,
.ea-related-recently-viewed-tabs ~ section.related.products,
.ea-related-recently-viewed-tabs + .related.products,
.ea-related-recently-viewed-tabs ~ .related.products {
    display: none !important;
}

/* Also hide if it appears anywhere after our tabs wrapper */
.single-product .ea-related-recently-viewed-tabs ~ * section.related.products,
.single-product .ea-related-recently-viewed-tabs ~ * .related.products {
    display: none !important;
}

/* Hide any standalone "Related products" section on single product pages (outside our tabs) */
/* Only show related products inside our tab content */
.single-product section.related.products {
    display: none !important;
}

.single-product .related.products {
    display: none !important;
}

/* But show related products inside our tab content */
.ea-tab-content section.related.products,
.ea-tab-content .related.products {
    display: block !important;
}

/* Ensure product titles are visible */
.ea-tab-content .product h2,
.ea-tab-content .product .woocommerce-loop-product__title,
.ea-tab-content .products .product h2,
.ea-tab-content .products .product .woocommerce-loop-product__title {
    display: block !important;
}

/* Ensure products list has proper spacing */
.ea-tab-content .products,
.ea-tab-content ul.products {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    width: 100% !important;
}

/* Recently viewed products list - match related products styling */
.ea-tab-content .ea-recently-viewed-tab-products,
.ea-tab-content ul.ea-recently-viewed-tab-products {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
    width: 100% !important;
}

/* Tab content padding is handled by .ea-tab-content itself */

/* Product grid - 4 columns with 120px total spacing (for related products only) */
.ea-tab-content .related.products.columns-4 li.product:not(:empty),
.ea-tab-content section.related.products .products.columns-4 li.product:not(:empty) {
    width: calc((100% - 120px) / 4) !important;
    margin-right: 40px !important;
    margin-bottom: 30px !important;
    float: left !important;
    box-sizing: border-box !important;
}

.ea-tab-content .related.products.columns-4 li.product:not(:empty):nth-child(4n),
.ea-tab-content section.related.products .products.columns-4 li.product:not(:empty):nth-child(4n) {
    margin-right: 0 !important;
}

/* Exclude recently viewed from general products rule */
.ea-tab-content ul.products.columns-4:not(.ea-recently-viewed-tab-products) li.product:not(:empty) {
    width: calc((100% - 120px) / 4) !important;
    margin-right: 40px !important;
    margin-bottom: 30px !important;
    float: left !important;
    box-sizing: border-box !important;
}

.ea-tab-content ul.products.columns-4:not(.ea-recently-viewed-tab-products) li.product:not(:empty):nth-child(4n) {
    margin-right: 0 !important;
}

/* Recently Viewed Products - 4 columns with 120px total spacing (40px between items) */
.ea-tab-content .ea-recently-viewed-tab-products.columns-4 li.product {
    width: calc((100% - 120px) / 4) !important;
    margin-right: 40px !important;
    margin-bottom: 30px !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
    float: left !important;
    box-sizing: border-box !important;
    clear: none !important;
}

.ea-tab-content .ea-recently-viewed-tab-products.columns-4 li.product:nth-child(4n) {
    margin-right: 0 !important;
}

/* Hide empty product items */
.ea-tab-content ul.products li.product:empty,
.ea-tab-content ul.ea-recently-viewed-tab-products li.product:empty,
.ea-tab-content .ea-recently-viewed-tab-products li.product:empty {
    display: none !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Product image border radius */
.single-product .product[data-n-lazy="1"] .minimal img.nectar-lazy,
ul.products li.product.minimal img {
    border-radius: 10px !important;
}

/* ============================================
   Mobile Responsive Styles
   ============================================ */

/* Tablet and below */
@media only screen and (max-width: 999px) {
    .ea-related-recently-viewed-tabs {
        margin-top: 40px;
        margin-bottom: 40px;
    }
    
    .ea-tab-button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .ea-tabs-content-wrapper .ea-tab-content {
        padding: 30px 0 !important;
    }
    
    .ea-tab-content {
        padding: 30px 0 !important;
    }
}

/* Mobile devices */
@media only screen and (max-width: 768px) {
    /* Tab navigation adjustments */
    .ea-tabs-nav-wrapper {
        width: 100%;
        justify-content: center;
    }
    
    .ea-tab-button {
        padding: 8px 16px;
        font-size: 14px;
        flex: 1;
        text-align: center;
    }
    
    /* Tab content padding */
    .ea-tabs-content-wrapper .ea-tab-content {
        padding: 20px 0 !important;
    }
    
    .ea-tab-content {
        padding: 20px 0 !important;
    }
    
    /* Mobile: Single column with horizontal scroll (gallery view) */
    .ea-tab-content .related.products.columns-4,
    .ea-tab-content section.related.products .products.columns-4,
    .ea-tab-content ul.products.columns-4,
    .ea-tab-content .ea-recently-viewed-tab-products.columns-4 {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-snap-type: x mandatory !important;
        gap: 16px !important;
        padding: 0 20px !important;
        margin: 0 -20px !important;
    }
    
    /* Product items in mobile gallery */
    .ea-tab-content .related.products.columns-4 li.product:not(:empty),
    .ea-tab-content section.related.products .products.columns-4 li.product:not(:empty),
    .ea-tab-content ul.products.columns-4:not(.ea-recently-viewed-tab-products) li.product:not(:empty),
    .ea-tab-content .ea-recently-viewed-tab-products.columns-4 li.product {
        width: 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
        flex-shrink: 0 !important;
        float: none !important;
        margin: 0 !important;
        scroll-snap-align: start !important;
        box-sizing: border-box !important;
    }
    
    /* Fix product card layout on mobile */
    .ea-tab-content .products li.product .product-wrap,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .product-wrap {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    
    /* Product image should be full width on mobile */
    .ea-tab-content .products li.product .product-wrap .product-image,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .product-wrap .product-image {
        width: 100% !important;
        float: none !important;
        margin-bottom: 12px !important;
    }
    
    /* Product details should be below image, not beside */
    .ea-tab-content .products li.product .product-wrap .product-details,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .product-wrap .product-details {
        width: 100% !important;
        float: none !important;
        clear: both !important;
        padding-left: 0 !important;
    }
    
    /* Product title and price alignment */
    .ea-tab-content .products li.product h2,
    .ea-tab-content .products li.product .woocommerce-loop-product__title,
    .ea-tab-content .ea-recently-viewed-tab-products li.product h2,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .woocommerce-loop-product__title {
        margin-bottom: 8px !important;
    }
    
    .ea-tab-content .products li.product .price,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .price {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    
    /* Remove large spacing below price */
    .ea-tab-content .products li.product .product-wrap::after,
    .ea-tab-content .ea-recently-viewed-tab-products li.product .product-wrap::after {
        display: none !important;
    }
    
    /* Hide scrollbar but keep functionality */
    .ea-tab-content .related.products.columns-4::-webkit-scrollbar,
    .ea-tab-content section.related.products .products.columns-4::-webkit-scrollbar,
    .ea-tab-content ul.products.columns-4::-webkit-scrollbar,
    .ea-tab-content .ea-recently-viewed-tab-products.columns-4::-webkit-scrollbar {
        display: none;
    }
    
    .ea-tab-content .related.products.columns-4,
    .ea-tab-content section.related.products .products.columns-4,
    .ea-tab-content ul.products.columns-4,
    .ea-tab-content .ea-recently-viewed-tab-products.columns-4 {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Extra small mobile devices */
@media only screen and (max-width: 480px) {
    .ea-related-recently-viewed-tabs {
        margin-top: 30px;
        margin-bottom: 30px;
    }
    
    .ea-tabs-nav-wrapper {
        padding: 3px;
        border-radius: 10px 10px 0 0;
    }
    
    .ea-tab-button {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    /* Reduce product width on very small screens */
    .ea-tab-content .related.products.columns-4 li.product:not(:empty),
    .ea-tab-content section.related.products .products.columns-4 li.product:not(:empty),
    .ea-tab-content ul.products.columns-4:not(.ea-recently-viewed-tab-products) li.product:not(:empty),
    .ea-tab-content .ea-recently-viewed-tab-products.columns-4 li.product {
        width: 240px !important;
        min-width: 240px !important;
        max-width: 240px !important;
    }
}

.woocommerce-page button[type=submit].single_add_to_cart_button, body[data-form-submit=regular].woocommerce-page .container-wrap button[type=submit].single_add_to_cart_button {
    margin-top: 0px !important;
}