/* Critical WooCommerce Layout Fixes */

/* Prevent horizontal scroll */
body.woocommerce-page {
    overflow-x: hidden !important;
}

body.woocommerce-page .site-content {
    overflow-x: hidden !important;
}

body.woocommerce-page .container {
    max-width: 1200px !important;
    width: 100% !important;
    padding: 0 15px !important;
    box-sizing: border-box !important;
}

/* Fix main shop container */
body.woocommerce-page .woocommerce-shop-container {
    display: flex !important;
    gap: 30px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Fix sidebar width and prevent overflow */
body.woocommerce-page .shop-sidebar,
body.woocommerce-page aside.shop-sidebar {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Fix products container */
body.woocommerce-page .shop-products {
    flex: 1 !important;
    min-width: 0 !important; /* This prevents flex items from overflowing */
    overflow: hidden !important;
}

/* Fix all widgets in sidebar */
body.woocommerce-page .shop-sidebar .widget,
body.woocommerce-page .shop-sidebar .widget_layered_nav,
body.woocommerce-page .shop-sidebar .widget_price_filter,
body.woocommerce-page .shop-sidebar .widget_product_categories {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    margin-bottom: 30px !important;
    padding-bottom: 30px !important;
    border-bottom: 1px solid #e0e0e0 !important;
}

/* Fix price filter specific */
body.woocommerce-page .widget_price_filter .price_slider_wrapper {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 15px !important;
    box-sizing: border-box !important;
}

body.woocommerce-page .widget_price_filter .ui-slider {
    width: calc(100% - 30px) !important;
    margin: 0 auto !important;
    position: relative !important;
}

body.woocommerce-page .widget_price_filter .price_slider {
    margin-bottom: 20px !important;
}

body.woocommerce-page .widget_price_filter .price_slider_amount {
    text-align: center !important;
    margin-top: 20px !important;
}

body.woocommerce-page .widget_price_filter .price_slider_amount .button {
    width: 100% !important;
    max-width: 200px !important;
    margin: 15px auto 0 !important;
    display: block !important;
}

body.woocommerce-page .widget_price_filter .price_label {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 14px !important;
}

/* Fix custom price filter inputs */
body.woocommerce-page .price-filter-inputs {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    gap: 10px !important;
    box-sizing: border-box !important;
}

body.woocommerce-page .price-filter-inputs input {
    width: calc(50% - 15px) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Fix product grid to prevent overflow */
body.woocommerce-page ul.products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Responsive grid */
@media (max-width: 1400px) {
    body.woocommerce-page ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 991px) {
    body.woocommerce-page ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    body.woocommerce-page .woocommerce-shop-container {
        flex-direction: column !important;
    }
    
    body.woocommerce-page .shop-sidebar,
    body.woocommerce-page aside.shop-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        margin-bottom: 30px !important;
    }
    
    body.woocommerce-page ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
}

@media (max-width: 480px) {
    body.woocommerce-page ul.products {
        grid-template-columns: 1fr !important;
    }
}

/* Fix widget headings */
body.woocommerce-page .widget-title,
body.woocommerce-page .widget h2,
body.woocommerce-page .widget h3 {
    font-size: 18px !important;
    color: #1a4a5c !important;
    margin-bottom: 20px !important;
    font-weight: 600 !important;
}

/* Fix layered nav (category/filter widgets) */
body.woocommerce-page .widget_layered_nav ul,
body.woocommerce-page .widget_product_categories ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

body.woocommerce-page .widget_layered_nav li,
body.woocommerce-page .widget_product_categories li {
    margin-bottom: 10px !important;
    width: 100% !important;
}

body.woocommerce-page .widget_layered_nav a,
body.woocommerce-page .widget_product_categories a {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    color: #666 !important;
    text-decoration: none !important;
    padding: 5px 0 !important;
    width: 100% !important;
}

body.woocommerce-page .widget_layered_nav a:hover,
body.woocommerce-page .widget_product_categories a:hover {
    color: #4a90e2 !important;
}

/* Fix count styling */
body.woocommerce-page .widget_layered_nav .count,
body.woocommerce-page .widget_product_categories .count {
    color: #999 !important;
    font-size: 13px !important;
}

/* Fix WooCommerce notices */
body.woocommerce-page .woocommerce-notices-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure main content doesn't overflow */
body.woocommerce-page #primary,
body.woocommerce-page .content-area {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

/* Fix ordering select */
body.woocommerce-page .woocommerce-ordering {
    float: right !important;
    margin-bottom: 30px !important;
}

body.woocommerce-page .woocommerce-ordering select {
    padding: 10px 40px 10px 15px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    background: white !important;
    font-size: 14px !important;
}