/*
 * Visually hide the original WooCommerce dropdowns.
 * They remain active so WooCommerce variation logic still works.
 */
form.variations_form .variations select.wdmv-variation-pill-select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

form.variations_form table.variations {
	width: 100%;
	margin-bottom: 20px;
}

form.variations_form table.variations tbody {
	display: block;
	width: 100%;
}

/*
 * Attribute rows are stacked: label on its own line, pills starting on the
 * next line, at every breakpoint.
 *
 * The previous layout used a fixed two-column grid (70px label + pills). Any
 * attribute name longer than 70px — "Nicotine Strength", "Bottle Size",
 * "Puff Count" — overflowed its column and ran into the first pill, so the
 * label text visually collided with the pill next to it.
 *
 * Sizing the label column to content (auto / max-content) would only move the
 * problem: a long name would then squeeze the pill track instead. A single
 * column removes the failure mode entirely rather than tuning around it, and
 * gives pills the full row width to wrap into.
 */
form.variations_form table.variations tr {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-items: start;
	gap: 8px;
	width: 100%;
	margin-bottom: 18px;
}

form.variations_form table.variations th.label,
form.variations_form table.variations td.value {
	display: block;
	width: auto;
	min-width: 0;
	padding: 0;
	text-align: left;
}

form.variations_form table.variations th.label label {
	display: block;
	margin: 0;
	color: #222222;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	/* Very long single-word attribute names must wrap, not overflow the row. */
	overflow-wrap: break-word;
	word-wrap: break-word;
}

.wdmv-variation-pills {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 9px;
	width: 100%;
	margin: 0;
}

.wdmv-variation-pill {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 58px;
	min-height: 42px;
	/*
	 * Never wider than the row. Long option labels such as "20MG (PROV-TAX)"
	 * wrap inside the pill instead of being clipped by overflow: hidden, which
	 * is required here so the unavailable-state diagonal cross stays inside the
	 * pill's rounded bounds.
	 */
	max-width: 100%;
	padding: 9px 17px;
	margin: 0;
	overflow: hidden;
	border: 1px solid #d6d6d6;
	border-radius: 7px;
	background: #ffffff;
	color: #222222;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	white-space: normal;
	overflow-wrap: break-word;
	cursor: pointer;
	user-select: none;
	transition:
		border-color 0.18s ease,
		background-color 0.18s ease,
		color 0.18s ease,
		box-shadow 0.18s ease,
		transform 0.18s ease;
}

.wdmv-variation-pill:hover {
	border-color: #222222;
	box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08);
	transform: translateY(-1px);
}

.wdmv-variation-pill:focus-visible {
	outline: 2px solid #222222;
	outline-offset: 2px;
}

.wdmv-variation-pill.is-selected {
	border-color: #111111;
	background: #111111;
	color: #ffffff;
	box-shadow: 0 0 0 1px #111111;
}

/*
 * Unavailable and out-of-stock options.
 */
.wdmv-variation-pill.is-unavailable,
.wdmv-variation-pill:disabled {
	border-color: #dddddd;
	background: #f1f1f1;
	color: #999999;
	cursor: not-allowed;
	box-shadow: none;
	opacity: 0.75;
	transform: none;
}

/*
 * Diagonal cross — first line.
 * overflow: hidden on the pill clips these to its bounds.
 * left: 0 / width: 100% fills the pill exactly.
 */
.wdmv-variation-pill.is-unavailable::before,
.wdmv-variation-pill:disabled::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	z-index: 2;
	width: 100%;
	height: 1px;
	background: rgba(100, 100, 100, 0.75);
	transform: rotate(-38deg);
	transform-origin: center;
	pointer-events: none;
}

/* Diagonal cross — second line. */
.wdmv-variation-pill.is-unavailable::after,
.wdmv-variation-pill:disabled::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	z-index: 2;
	width: 100%;
	height: 1px;
	background: rgba(135, 135, 135, 0.55);
	transform: rotate(38deg);
	transform-origin: center;
	pointer-events: none;
}

.wdmv-variation-pill.is-unavailable.is-selected {
	border-color: #cccccc;
	background: #eeeeee;
	color: #999999;
	box-shadow: none;
}

form.variations_form .reset_variations {
	display: inline-block;
	margin-top: 10px;
	font-size: 13px;
}

/*
 * WoodMart's mobile/tablet "reset below" layout absolutely positions this
 * wrapper beneath the table. With stacked MV pills, that puts Clear in the
 * following price/stock row. Reserve its actual height in the attribute cell
 * instead, including when the reset label wraps. Match WoodMart's breakpoint;
 * desktop, quick view, and forms without MV pills keep their existing layout.
 * WooCommerce/WoodMart still control the link's visibility and reset behavior.
 */
@media (max-width: 1024px) {
	body.single-product div.product.single-product-page .summary form.variations_form.wdmv-variation-pills-initialized.wd-reset-bottom-md .wd-reset-var {
		position: static;
		inset: auto;
		display: block;
		width: auto;
		max-width: 100%;
	}

	body.single-product div.product.single-product-page .summary form.variations_form.wdmv-variation-pills-initialized.wd-reset-bottom-md .wd-reset-var .reset_variations {
		margin-inline: 0;
		max-width: 100%;
		white-space: normal;
	}
}

/*
 * Disable Add to Cart until WooCommerce has found
 * a valid, purchasable variation.
 */
form.variations_form .single_add_to_cart_button:disabled,
form.variations_form .single_add_to_cart_button.disabled,
form.variations_form .single_add_to_cart_button.wdmv-variation-disabled {
	opacity: 0.45 !important;
	cursor: not-allowed !important;
	pointer-events: none !important;
}

@media (max-width: 767px) {

	/*
	 * The single-column layout and zero label padding are now the base rules,
	 * so this breakpoint only tightens spacing — it no longer needs to
	 * re-declare grid-template-columns or th.label padding.
	 */
	form.variations_form table.variations tr {
		gap: 6px;
		margin-bottom: 16px;
	}

	.wdmv-variation-pills {
		gap: 7px;
	}

	.wdmv-variation-pill {
		min-width: 52px;
		min-height: 40px;
		padding: 8px 13px;
		font-size: 13px;
	}
}
