/*
 * Cafe420 — DP Woo Products category layout fix
 *
 * Uses a controlled flex-wrap layout that remains compatible with Divi Plus,
 * while neutralising WooCommerce first/last clearing and residual Isotope
 * positioning. Desktop 4 columns, tablet 3, mobile 2.
 */

body.tax-product_cat .dipl_woo_products,
body.tax-product_cat .dipl_woo_products .et_pb_module_inner,
body.tax-product_cat .dipl_woo_products .woocommerce {
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	box-sizing: border-box !important;
}

/* Replace the conflicting CSS Grid layer with Divi Plus-compatible flex. */
body.tax-product_cat .dipl_woo_products .dipl_woo_products_layout,
body.tax-product_cat .dipl_woo_products ul.products {
	display: flex !important;
	flex-wrap: wrap !important;
	align-items: stretch !important;
	align-content: flex-start !important;
	justify-content: flex-start !important;
	column-gap: 15px !important;
	row-gap: 30px !important;
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	height: auto !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	box-sizing: border-box !important;
}

/* Desktop: four equal columns across the available module width. */
body.tax-product_cat .dipl_woo_products .dipl_woo_products_layout > li.product,
body.tax-product_cat .dipl_woo_products ul.products > li.product,
body.tax-product_cat .dipl_woo_products li.dipl_woo_products_isotope_item {
	float: none !important;
	clear: none !important;
	position: relative !important;
	left: auto !important;
	top: auto !important;
	transform: none !important;
	flex: 0 0 calc((100% - 45px) / 4) !important;
	width: calc((100% - 45px) / 4) !important;
	max-width: calc((100% - 45px) / 4) !important;
	min-width: 0 !important;
	margin: 0 !important;
	box-sizing: border-box !important;
	display: flex !important;
	flex-direction: column !important;
}

/* Neutralise WooCommerce row-clearing classes. */
body.tax-product_cat .dipl_woo_products li.product.first,
body.tax-product_cat .dipl_woo_products li.product.last {
	clear: none !important;
	margin: 0 !important;
}

/* Make the complete product card use the tile width. */
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product {
	display: flex !important;
	flex-direction: column !important;
	flex: 1 1 auto !important;
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	height: 100% !important;
	box-sizing: border-box !important;
}

body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_thumbnail_wrapper,
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_thumbnail,
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_content,
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_add_to_cart {
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	box-sizing: border-box !important;
	flex-basis: auto !important;
}

body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_content {
	display: flex !important;
	flex-direction: column !important;
	flex-grow: 1 !important;
}

body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_price {
	flex-grow: 1 !important;
}

body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_add_to_cart {
	margin-top: auto !important;
}

/* Thumbnail fills the product tile without intrinsic-width squashing. */
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_thumbnail > a,
body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_thumbnail .et_shop_image {
	display: block !important;
	width: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
}

body.tax-product_cat .dipl_woo_products .dipl_single_woo_product_thumbnail img {
	display: block !important;
	width: 100% !important;
	max-width: 100% !important;
	height: auto !important;
	object-fit: cover;
}

/* Tablet: three equal columns. */
@media (max-width: 980px) {
	body.tax-product_cat .dipl_woo_products .dipl_woo_products_layout > li.product,
	body.tax-product_cat .dipl_woo_products ul.products > li.product,
	body.tax-product_cat .dipl_woo_products li.dipl_woo_products_isotope_item {
		flex-basis: calc((100% - 30px) / 3) !important;
		width: calc((100% - 30px) / 3) !important;
		max-width: calc((100% - 30px) / 3) !important;
	}
}

/* Mobile: two equal columns. */
@media (max-width: 767px) {
	body.tax-product_cat .dipl_woo_products .dipl_woo_products_layout,
	body.tax-product_cat .dipl_woo_products ul.products {
		column-gap: 12px !important;
		row-gap: 24px !important;
	}

	body.tax-product_cat .dipl_woo_products .dipl_woo_products_layout > li.product,
	body.tax-product_cat .dipl_woo_products ul.products > li.product,
	body.tax-product_cat .dipl_woo_products li.dipl_woo_products_isotope_item {
		flex-basis: calc((100% - 12px) / 2) !important;
		width: calc((100% - 12px) / 2) !important;
		max-width: calc((100% - 12px) / 2) !important;
	}
}
