/**
 * BS Loop Swatches - theme-friendly styles.
 * All selectors prefixed with .bs- to avoid collisions.
 */

/* Keep swapped variation image sharp when theme applies blur/filter on non-hover */
.product img.bs-swapped-image,
.product .product-media img.bs-swapped-image,
.product-content img.bs-swapped-image {
	filter: none !important;
	opacity: 1 !important;
	-webkit-backface-visibility: visible;
	backface-visibility: visible;
}

.bs-loop-swatches {
	margin-top: 0.5em;
	margin-bottom: 0.5em;
}

.bs-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
	margin-bottom: 8px;
}

.bs-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 28px;
	height: 28px;
	padding: 0 8px;
	font-size: 12px;
	line-height: 1.2;
	border: 1px solid #ddd;
	border-radius: 999px;
	background: #fff;
	color: #333;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bs-swatch:hover {
	border-color: #999;
}

.bs-swatch:focus {
	outline: 1px solid #333;
	outline-offset: 1px;
}

.bs-swatch.is-selected,
.bs-swatch[aria-pressed="true"] {
	border-color: #333;
	box-shadow: 0 0 0 1px #333;
}

/* Color swatch: circle */
.bs-swatch .bs-swatch-color {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	flex-shrink: 0;
}

/* Swatch with both color and label: side-by-side layout */
.bs-swatch.bs-swatch-has-color {
	gap: 8px;
	padding-left: 10px;
	padding-right: 12px;
}

.bs-swatch.bs-swatch-has-color .bs-swatch-color {
	width: 20px;
	height: 20px;
}

.bs-swatch .bs-swatch-label {
	white-space: nowrap;
}

.bs-add-to-cart-variation {
	margin-top: 4px;
	font-size: 13px;
}

.bs-msg {
	font-size: 12px;
	margin-top: 6px;
	min-height: 1.2em;
}

.bs-msg.bs-msg-error {
	color: #b32d2e;
}

/* Show on hover: hide by default, show on card hover */
body.bs-swatches-show-on-hover .bs-loop-swatches .bs-swatches,
body.bs-swatches-show-on-hover .bs-loop-swatches .bs-add-to-cart-variation,
body.bs-swatches-show-on-hover .bs-loop-swatches .bs-msg {
	opacity: 1;
	/* transition: opacity 0.2s ease; */
}

/* When overlay panel is open, keep it visible even when not hovering */
body.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel,
body.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-swatches,
body.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-add-to-cart-variation,
body.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-msg {
	opacity: 1;
}

body.bs-swatches-show-on-hover .product:hover .bs-loop-swatches .bs-swatches,
body.bs-swatches-show-on-hover .product:hover .bs-loop-swatches .bs-add-to-cart-variation,
body.bs-swatches-show-on-hover .product:hover .bs-loop-swatches .bs-msg {
	opacity: 1;
}

.product.bs-swatches-show-on-hover .bs-loop-swatches .bs-swatches,
.product.bs-swatches-show-on-hover .bs-loop-swatches .bs-add-to-cart-variation {
	opacity: 1;
	/* transition: opacity 0.2s ease; */
}

/* Overlay bar and open panel stay visible (bar always, panel when is-open) */
.product.bs-swatches-show-on-hover .bs-loop-swatches-overlay .bs-loop-swatches-bar {
	opacity: 1;
}
.product.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel,
.product.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-swatches,
.product.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-add-to-cart-variation,
.product.bs-swatches-show-on-hover .bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel .bs-msg {
	opacity: 1;
}

.product.bs-swatches-show-on-hover:hover .bs-loop-swatches .bs-swatches,
.product.bs-swatches-show-on-hover:hover .bs-loop-swatches .bs-add-to-cart-variation,
.product.bs-swatches-show-on-hover:hover .bs-loop-swatches .bs-msg {
	opacity: 1;
}

/* Responsive: allow wrapping on small cards */
@media (max-width: 480px) {
	.bs-swatches {
		gap: 5px;
	}
	.bs-swatch {
		min-width: 26px;
		height: 26px;
		padding: 0 6px;
		font-size: 11px;
	}
}

/* ========== On-image overlay (black bar with SELECT SHADE + cart icon) ========== */
.product-content .product-media,
.product-media {
	position: relative;
}

.bs-loop-swatches-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	flex-direction: column-reverse;
	z-index: 15;
	pointer-events: none;
}

.bs-loop-swatches-overlay > * {
	pointer-events: auto;
}

.bs-loop-swatches-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 10px 12px;
	background: rgba(0, 0, 0, 0.9);
	color: #fff;
	border: none;
	cursor: pointer;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	transition: background 0.2s ease;
}

.bs-loop-swatches-bar:hover {
	background: #000;
}

.bs-loop-swatches-bar:focus {
	outline: 1px solid #fff;
	outline-offset: 1px;
}

.bs-select-shade-text {
	line-height: 1;
}

.bs-cart-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.bs-cart-icon svg {
	display: block;
}

.bs-loop-swatches-panel {
	max-height: 0;
	overflow: hidden;
	background: rgba(0, 0, 0, 0.92);
	color: #fff;
	transition: max-height 0.25s ease;
}

.bs-loop-swatches-overlay.is-open .bs-loop-swatches-panel {
	max-height: 280px;
	overflow: visible;
	padding: 12px;
}

.bs-loop-swatches-overlay.is-open .bs-loop-swatches-bar {
	background: #000;
}

.bs-loop-swatches-overlay .bs-swatches {
	margin-bottom: 10px;
}

.bs-loop-swatches-overlay .bs-swatch {
	border-color: rgba(255, 255, 255, 0.4);
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.bs-loop-swatches-overlay .bs-swatch:hover {
	border-color: rgba(255, 255, 255, 0.7);
	background: rgba(255, 255, 255, 0.2);
}

.bs-loop-swatches-overlay .bs-swatch.is-selected,
.bs-loop-swatches-overlay .bs-swatch[aria-pressed="true"] {
	border-color: #fff;
	box-shadow: 0 0 0 1px #fff;
	background: rgba(255, 255, 255, 0.25);
}

.bs-loop-swatches-overlay .bs-add-to-cart-variation {
	width: 100%;
	margin-top: 8px;
	padding: 8px 12px;
	font-size: 12px;
	background: #fff;
	color: #000;
	border: none;
	cursor: pointer;
	font-weight: 600;
}

.bs-loop-swatches-overlay .bs-add-to-cart-variation:hover {
	background: #f0f0f0;
}

.bs-loop-swatches-overlay .bs-msg {
	color: rgba(255, 255, 255, 0.9);
	margin-top: 6px;
}

.bs-loop-swatches-overlay .bs-msg.bs-msg-error {
	color: #f5a0a0;
}

/* ========== Single product page: swatches replace dropdown ========== */
.bs-single-swatches {
	margin-bottom: 0.5em;
}

/* Attribute name on its own row above swatches */
.bs-single-swatches-label {
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 10px;
	color: #111;
	display: block;
}

/* Hide WooCommerce’s default attribute label on the same row (table layout) */
.variations tr:has(td .bs-single-swatches) th.label {
	display: none;
}

.bs-single-swatches .bs-swatches {
	margin-bottom: 0.5em;
	gap: 10px;
}

/* Single product: slightly larger, modern swatches with color + label */
.bs-single-swatches .bs-swatch {
	min-width: 36px;
	height: 40px;
	padding: 0 14px;
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0.02em;
	border-radius: 999px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.bs-single-swatches .bs-swatch:hover {
	border-color: #666;
	background-color: #fafafa;
}

.bs-single-swatches .bs-swatch.is-selected,
.bs-single-swatches .bs-swatch[aria-pressed="true"] {
	border-color: #111;
	box-shadow: 0 0 0 1px #111;
	background-color: #fff;
}

.bs-single-swatches .bs-swatch.bs-swatch-has-color .bs-swatch-color {
	width: 22px;
	height: 22px;
}

.bs-single-swatches .bs-swatch.bs-swatch-has-color {
	gap: 10px;
	padding-left: 12px;
	padding-right: 14px;
}

/* Keep select in DOM for WooCommerce variation form but hide from view (accessible to screen readers) */
.bs-single-swatches select.bs-swatch-select {
	position: absolute;
	width: 1px;
	height: 1px;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	overflow: hidden;
	margin: -1px;
	padding: 0;
	border: 0;
}
