/**
 * Custom WooCommerce — Frontend styles.
 *
 * Everything is scoped under the .cwoo- prefix so nothing here leaks into the
 * theme, Elementor, or other WooCommerce components. No global element
 * selectors (body, img, a, button, …) are used.
 *
 * Layout uses CSS Grid:
 *   Desktop (>= 992px): 4 columns
 *   Tablet  (600–991px): 2 columns
 *   Mobile  (< 600px):   1 column
 */

/* -------------------------------------------------------------------------- */
/* Box-sizing reset — scoped to our components only.                          */
/* -------------------------------------------------------------------------- */

.cwoo-products,
.cwoo-products *,
.cwoo-pagination,
.cwoo-pagination * {
	box-sizing: border-box;
}

/* Widget Builder wrapper — a unique .cwoo-widget-{id} scope is added per widget
   so custom CSS/JS can target just that instance without leaking out. */
.cwoo-widget {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

/* Custom-design container: left intentionally unstyled (block flow) so the
   user's own template CSS controls the layout. Only overflow safety here. */
.cwoo-widget-custom .cwoo-widget-items {
	width: 100%;
	max-width: 100%;
}

/* -------------------------------------------------------------------------- */
/* Layout                                                                     */
/* -------------------------------------------------------------------------- */

.cwoo-products {
	width: 100%;
	max-width: 100%;
	margin: 0 0 2rem;
}

.cwoo-products-grid {
	display: grid;
	/* Mobile first: single column, always fitting the container. */
	grid-template-columns: minmax(0, 1fr);
	gap: 1.25rem;
	width: 100%;
	max-width: 100%;
}

/* Tablet: 2 columns. minmax(0, 1fr) prevents grid blowout from long content. */
@media (min-width: 600px) {
	.cwoo-products-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Desktop: 4 columns. */
@media (min-width: 992px) {
	.cwoo-products-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* -------------------------------------------------------------------------- */
/* Product card                                                               */
/* -------------------------------------------------------------------------- */

.cwoo-product-card {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 100%;
	min-width: 0; /* Allow the card to shrink inside the grid track. */
	background: #fff;
	border: 1px solid #e6e6e6;
	border-radius: 10px;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cwoo-product-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

/* Consistent image area across cards without distorting the image. */
.cwoo-product-image {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1; /* Uniform square image area for a tidy grid. */
	overflow: hidden;
	line-height: 0;
	background: #f7f7f7;
}

.cwoo-product-image img {
	width: 100%;
	height: 100%;
	max-width: 100%;
	display: block;
	object-fit: cover; /* Fill the area, crop overflow — never stretch. */
	object-position: center;
}

/* Fallback for browsers without aspect-ratio support: cap the image height. */
@supports not (aspect-ratio: 1 / 1) {
	.cwoo-product-image {
		height: 0;
		padding-top: 100%;
	}
	.cwoo-product-image img {
		position: absolute;
		inset: 0;
	}
}

.cwoo-badge-sale {
	position: absolute;
	top: 10px;
	left: 10px;
	background: #e2401c;
	color: #fff;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1;
	padding: 5px 9px;
	border-radius: 4px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.cwoo-product-body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto; /* Fill remaining height so cards in a row match up. */
	min-width: 0;   /* Enable text truncation/wrapping inside flex. */
	padding: 0.9rem 1rem 1.1rem;
	gap: 0.4rem;
}

.cwoo-product-category {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #888;
	overflow-wrap: break-word;
	word-wrap: break-word;
}

.cwoo-product-category a {
	color: inherit;
	text-decoration: none;
}

.cwoo-product-category a:hover {
	text-decoration: underline;
}

.cwoo-product-title {
	font-size: 1rem;
	line-height: 1.35;
	margin: 0;
	font-weight: 600;
	overflow-wrap: break-word; /* Long words/SKUs wrap instead of overflowing. */
	word-wrap: break-word;
}

.cwoo-product-title a {
	color: #1a1a1a;
	text-decoration: none;
}

.cwoo-product-title a:hover {
	color: #000;
	text-decoration: underline;
}

.cwoo-product-rating {
	font-size: 0.85rem;
	overflow-wrap: break-word;
}

.cwoo-product-price {
	font-size: 1.05rem;
	color: #1a1a1a;
	margin-top: auto; /* Pin price + actions to the bottom for even cards. */
	padding-top: 0.2rem;
	overflow-wrap: break-word;
	word-wrap: break-word;
}

.cwoo-product-price del {
	color: #999;
	margin-right: 0.4em;
	font-weight: 400;
}

.cwoo-product-price ins {
	text-decoration: none;
	font-weight: 700;
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.cwoo-product-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.6rem;
}

.cwoo-btn {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 100%;
	display: inline-block;
	text-align: center;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.2;
	padding: 0.6rem 0.75rem;
	border-radius: 6px;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	overflow-wrap: break-word;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cwoo-btn-view {
	background: #fff;
	color: #1a1a1a;
	border-color: #d0d0d0;
}

.cwoo-btn-view:hover {
	border-color: #1a1a1a;
}

.cwoo-btn-cart {
	background: #1a1a1a;
	color: #fff;
}

.cwoo-btn-cart:hover {
	background: #000;
	color: #fff;
}

/* WooCommerce toggles this class on while an AJAX add-to-cart is running. */
.cwoo-btn-cart.loading {
	opacity: 0.7;
	pointer-events: none;
}

/* On the narrowest screens, stack the buttons full width for easy tapping. */
@media (max-width: 400px) {
	.cwoo-product-actions {
		flex-direction: column;
	}
	.cwoo-btn {
		width: 100%;
	}
}

/* -------------------------------------------------------------------------- */
/* Pagination                                                                 */
/* -------------------------------------------------------------------------- */

.cwoo-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.4rem;
	margin: 1.75rem 0 0;
	width: 100%;
	max-width: 100%;
}

.cwoo-pagination-item {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;   /* Touch-friendly target size. */
	min-height: 44px;
	padding: 0 0.75rem;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	background: #fff;
	color: #1a1a1a;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

a.cwoo-pagination-item:hover {
	border-color: #1a1a1a;
	background: #f5f5f5;
}

.cwoo-pagination-current {
	background: #1a1a1a;
	border-color: #1a1a1a;
	color: #fff;
	cursor: default;
}

.cwoo-pagination-prev,
.cwoo-pagination-next {
	font-weight: 600;
}

.cwoo-pagination-dots {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 32px;
	min-height: 44px;
	color: #888;
}

/* Slightly tighter controls on small screens. */
@media (max-width: 400px) {
	.cwoo-pagination-item {
		min-width: 40px;
		padding: 0 0.55rem;
		font-size: 0.85rem;
	}
}

/* -------------------------------------------------------------------------- */
/* Notices                                                                    */
/* -------------------------------------------------------------------------- */

.cwoo-notice {
	padding: 1rem;
	background: #f7f7f7;
	border: 1px solid #e6e6e6;
	border-radius: 8px;
	color: #555;
}
