/*
 * WooCommerce's own default `table.variations` styling (a plain bordered/
 * boxed table row per attribute) looks plain and dated - reported live
 * ("nó bị xấu ấy bạn làm kiểu khác được không") even for an attribute still
 * left on the default "Text" type, once the swatch-typed attributes right
 * next to it had already been un-boxed. Deliberately applied to EVERY row
 * now (not just `tr:has(.xtool-vswatch-list)` like the first version of
 * this fix) for visual consistency across a product's own mixed attributes
 * - safe to do unconditionally since this whole stylesheet is already
 * gated behind the module's own Enable switch + is_product(), so it only
 * ever runs on a site that has actually turned this feature on.
 */
/*
 * The outer <table> element itself was never un-tabled here before - only
 * its <tr> children were set to display:block. A display:table PARENT
 * with display:block CHILDREN is a genuine structural mismatch (the
 * browser's own CSS table "fixup" rules have to reconcile it, which
 * behaves inconsistently) - the real, root cause of a whole series of
 * live reports of the quantity/button block unpredictably jumping to a
 * disconnected position elsewhere on the page, which multiple earlier
 * flex-selector fixes (see the Add to Cart widget's own entries above)
 * never fully resolved because they were never actually the real cause.
 * Un-tabling the table itself here removes the mismatch entirely.
 */
table.variations {
	display: block;
	width: 100%;
}
table.variations tr {
	display: block;
	border: none !important;
	background: none !important;
	margin: 0 0 20px !important;
}
table.variations tr th,
table.variations tr td {
	display: block;
	border: none !important;
	background: none !important;
	padding: 0 !important;
	width: 100%;
	text-align: left;
	vertical-align: top;
}
table.variations tr th {
	font-size: var(--xtool-vswatch-label-size, 13px);
	font-weight: 600;
	color: var(--xtool-vswatch-label-color, #1A1814);
	text-transform: none;
	margin: 0 0 8px;
}
.xtool-vswatch-current {
	font-weight: 400;
	color: var(--xtool-vswatch-current-color, #8A8680);
	font-size: var(--xtool-vswatch-current-size, 13px);
}
table.variations tr .reset_variations {
	display: inline-block;
	margin-top: 10px;
	font-size: 12px;
	color: #8A8680;
	text-decoration: underline;
}

/*
 * A plain native <select> (an attribute still left on "Text"/"Select")
 * gets the same clean, modern look as everything else here - deliberately
 * never touches `display`: a SWATCH-typed attribute's own real <select>
 * already has `display:none` set inline by render_dropdown(), and this
 * rule must never override that (it doesn't - only non-layout properties
 * are set below).
 */
table.variations td select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	width: 100%;
	max-width: 320px;
	padding: 10px 40px 10px 14px;
	border: 1px solid #D4CEC7;
	border-radius: 8px;
	font-size: 14px;
	color: #1A1814;
	background-color: #fff;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8680' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
	background-size: 16px 16px;
	cursor: pointer;
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
table.variations td select:focus {
	border-color: #1A1814;
	box-shadow: 0 0 0 3px rgba(26, 24, 20, .08);
}

.xtool-vswatch-list {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: var(--xtool-vswatch-gap, 10px);
	margin: 0;
	padding: 0;
}
.xtool-vswatch-item {
	cursor: pointer;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
}
.xtool-vswatch-item:not(.xtool-vswatch-item--button) {
	width: var(--xtool-vswatch-size, 32px);
	height: var(--xtool-vswatch-size, 32px);
}
.xtool-vswatch--square .xtool-vswatch-item:not(.xtool-vswatch-item--button) {
	border-radius: 8px;
}
.xtool-vswatch--round .xtool-vswatch-item:not(.xtool-vswatch-item--button) {
	border-radius: 50%;
}
/*
 * A separate, dedicated Border Radius for Image/Pattern swatches only,
 * requested directly - the shared Shape (Square/Round) switch above is a
 * blunt on/off, this is a precise px value that can differ from whatever
 * Shape is set to for Color. Same specificity as the 2 rules above
 * (2 classes each) - deliberately placed AFTER them in the file so it
 * always wins for Image/Pattern swatches specifically, regardless of the
 * Shape choice, matching this codebase's own "later-registered wins the
 * cascade" convention for exactly this kind of control composition.
 */
.xtool-vswatch-list--image .xtool-vswatch-item:not(.xtool-vswatch-item--button),
.xtool-vswatch-list--pattern .xtool-vswatch-item:not(.xtool-vswatch-item--button) {
	border-radius: var(--xtool-vswatch-image-radius, 8px);
}
.xtool-vswatch-color {
	width: 100%;
	height: 100%;
	border-radius: inherit;
	border: var(--xtool-vswatch-border-width, 1px) var(--xtool-vswatch-border-style, solid) var(--xtool-vswatch-border, rgba(0, 0, 0, .12));
	box-sizing: border-box;
	transition: box-shadow .15s;
}
.xtool-vswatch-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: inherit;
	border: var(--xtool-vswatch-border-width, 1px) var(--xtool-vswatch-border-style, solid) var(--xtool-vswatch-border, #E2E2E2);
	box-sizing: border-box;
	display: block;
	transition: box-shadow .15s;
}
.xtool-vswatch-item--button {
	width: auto;
	height: auto;
}
.xtool-vswatch-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: max(var(--xtool-vswatch-size, 32px), 44px);
	height: max(var(--xtool-vswatch-size, 32px), 40px);
	padding: 0 16px;
	border: var(--xtool-vswatch-border-width, 1px) var(--xtool-vswatch-border-style, solid) var(--xtool-vswatch-border, #E2E2E2);
	border-radius: 8px;
	font-size: var(--xtool-vswatch-btn-size, 13px);
	font-weight: 500;
	line-height: 1;
	color: var(--xtool-vswatch-btn-color, #1A1814);
	background: #fff;
	box-sizing: border-box;
	transition: border-color .15s, background-color .15s, color .15s;
}
.xtool-vswatch-item:not(.xtool-vswatch-item--button):hover .xtool-vswatch-color,
.xtool-vswatch-item:not(.xtool-vswatch-item--button):hover .xtool-vswatch-image {
	box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--xtool-vswatch-border, #D4CEC7);
}
.xtool-vswatch-item--button:hover .xtool-vswatch-button {
	border-color: var(--xtool-vswatch-active, #1A1814);
}
.xtool-vswatch-item.is-selected .xtool-vswatch-color,
.xtool-vswatch-item.is-selected .xtool-vswatch-image {
	box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--xtool-vswatch-active, #1A1814);
}
.xtool-vswatch-item.is-selected .xtool-vswatch-button {
	border-color: var(--xtool-vswatch-active, #1A1814);
	background: var(--xtool-vswatch-active, #1A1814);
	color: #fff;
}
