/* Product Layout Tweaker: variation selector */

/* Variation Selector Styles */
.plt-vs-hidden-select {
	display: none !important;
}

.plt-variation-selector-wrapper {
	margin: 10px 0;
}

.plt-attribute-label {
	display: block;
	margin-bottom: 10px;
	font-weight: 600;
	font-size: 14px;
}

/* Hide WooCommerce's default label since we're using our own custom label */
.variations .label,
.variations td.label,
.variations th.label,
.variations label:not(.plt-attribute-label),
.variations tr:has(> td.label) td.label,
.woocommerce-product-attributes .label,
table.variations .label,
table.variations td.label {
	display: none !important;
}

/* Also hide any labels that come before our wrapper */
.variations .plt-variation-selector-wrapper ~ .label,
.variations .plt-variation-selector-wrapper ~ td.label {
	display: none !important;
}

/* Color Swatches */
.plt-color-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.plt-color-swatch {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid #ddd;
	cursor: pointer;
	display: inline-block;
	position: relative;
	transition: all 0.2s ease;
}

.plt-color-swatch:hover {
	border-color: #333;
	transform: scale(1.1);
}

.plt-color-swatch.plt-selected {
	border-color: #10b981;
	border-width: 3px;
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.plt-color-swatch.plt-disabled {
	opacity: 0.5;
	cursor: not-allowed;
	position: relative;
}

.plt-color-swatch.plt-disabled::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 2px;
	height: 100%;
	background: #000;
	transform: translate(-50%, -50%) rotate(45deg);
}

/* Image Swatches */
.plt-image-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.plt-image-swatch {
	width: 80px;
	height: 80px;
	border: 2px solid #ddd;
	border-radius: 3px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	transition: all 0.2s ease;
	background: #fff;
}

.plt-image-swatch img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.plt-image-swatch:hover {
	border-color: #333;
	transform: scale(1.05);
}

.plt-image-swatch.plt-selected {
	border-color: #10b981;
	border-width: 3px;
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.plt-image-swatch.plt-disabled {
	opacity: 0.5;
	cursor: not-allowed;
	position: relative;
}

.plt-image-swatch.plt-disabled::after {
	content: '×';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 24px;
	color: #000;
	font-weight: bold;
	z-index: 10;
}

/* Button Selectors */
.plt-button-selectors {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.plt-button-selector {
	min-width: 48px;
	min-height: 48px;
	padding: 8px 6px;
	cursor: pointer;
	font-size: 14px;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	background: #f5f5f5;
	border: 1px solid #ddd;
	color: #333;
}

/* Apply theme button classes if available */
.plt-button-selector.button,
.plt-button-selector.btn,
.plt-button-selector[class*="button"] {
	background: #f5f5f5;
	border: 1px solid #ddd;
	color: #333;
}

.plt-button-selector:hover {
	background: #e5e5e5;
	border-color: #bbb;
}

.plt-button-selector.plt-selected {
	background: #f0fdf4 !important;
	border: 2px solid #10b981 !important;
	color: #166534 !important;
	font-weight: 600;
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

.plt-button-selector.plt-disabled {
	opacity: 0.5;
	cursor: not-allowed;
	text-decoration: line-through;
	pointer-events: none;
}

/* Mobile Slider Styles */
@media (max-width: 768px) {
	.plt-variation-selector-wrapper {
		display: flex;
		flex-direction: column;
	}

	.plt-variation-selector-wrapper:first-of-type,
	.plt-variation-selector-wrapper:first-child {
		margin-top: 3px;
	}

	.woocommerce-product-gallery + .plt-variation-selector-wrapper,
	.woocommerce-product-gallery ~ .plt-variation-selector-wrapper:first-of-type {
		margin-top: 3px;
	}

	.plt-variation-selector-wrapper + .plt-variation-selector-wrapper {
		margin-top: 13px;
	}

	.plt-attribute-label {
		order: -1;
		margin-bottom: 10px;
		font-weight: 600;
		font-size: 14px;
	}

	.woocommerce-product-attributes .label,
	.variations .label,
	.variations label:not(.plt-attribute-label) {
		display: none;
	}

	.plt-image-swatches {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
		scroll-padding-left: 10px;
		scroll-padding-right: 10px;
		padding: 10px 0 10px 10px;
		margin: -10px;
		gap: 10px;
		width: 100%;
		box-sizing: border-box;
	}

	.plt-image-swatch {
		flex: 0 0 calc((100% - 10px - 30px) / 4);
		min-width: calc((100% - 10px - 30px) / 4);
		max-width: calc((100% - 10px - 30px) / 4);
		width: calc((100% - 10px - 30px) / 4);
		height: calc((100% - 10px - 30px) / 4);
		aspect-ratio: 1;
		scroll-snap-align: start;
		flex-shrink: 0;
	}

	.plt-image-swatches::after {
		content: '';
		flex: 0 0 calc(((100% - 10px - 30px) / 4) + 10px);
		min-width: calc(((100% - 10px - 30px) / 4) + 10px);
		max-width: calc(((100% - 10px - 30px) / 4) + 10px);
	}

	.plt-color-swatches {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
		scroll-padding-left: 10px;
		scroll-padding-right: 10px;
		padding: 10px 0 10px 10px;
		margin: -10px;
		gap: 10px;
		width: 100%;
		box-sizing: border-box;
		position: relative;
	}

	.plt-color-swatch {
		flex: 0 0 calc((100% - 10px - 40px) / 5);
		min-width: calc((100% - 10px - 40px) / 5);
		max-width: calc((100% - 10px - 40px) / 5);
		width: calc((100% - 10px - 40px) / 5);
		height: calc((100% - 10px - 40px) / 5);
		aspect-ratio: 1;
		scroll-snap-align: start;
		flex-shrink: 0;
	}

	.plt-color-swatches::after {
		content: '';
		flex: 0 0 calc(((100% - 10px - 40px) / 5) + 10px);
		min-width: calc(((100% - 10px - 40px) / 5) + 10px);
		max-width: calc(((100% - 10px - 40px) / 5) + 10px);
	}

	@media (max-width: 360px) {
		.plt-color-swatch {
			flex: 0 0 calc((100% - 10px - 30px) / 4);
			min-width: calc((100% - 10px - 30px) / 4);
			max-width: calc((100% - 10px - 30px) / 4);
			width: calc((100% - 10px - 30px) / 4);
			height: calc((100% - 10px - 30px) / 4);
		}

		.plt-color-swatches::after {
			flex: 0 0 calc(((100% - 10px - 30px) / 4) + 10px);
			min-width: calc(((100% - 10px - 30px) / 4) + 10px);
			max-width: calc(((100% - 10px - 30px) / 4) + 10px);
		}
	}

	.plt-button-selectors {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scroll-snap-type: x proximity;
		scroll-padding-left: 10px;
		scroll-padding-right: 10px;
		padding: 10px 0 10px 10px;
		margin: -10px;
		gap: 8px;
		width: 100%;
		box-sizing: border-box;
	}

	.plt-button-selector {
		flex: 0 0 auto;
		min-width: 50px;
		padding: 8px 6px;
		white-space: nowrap;
		scroll-snap-align: start;
		flex-shrink: 0;
		width: auto;
	}

	.plt-button-selectors::after {
		content: '';
		flex: 0 0 60px;
		min-width: 60px;
	}

	@media (max-width: 480px) {
		.plt-button-selector {
			min-width: 45px;
		}

		.plt-button-selectors::after {
			flex: 0 0 50px;
			min-width: 50px;
		}
	}

	.plt-image-swatches::-webkit-scrollbar,
	.plt-color-swatches::-webkit-scrollbar,
	.plt-button-selectors::-webkit-scrollbar {
		height: 4px;
	}

	.plt-image-swatches::-webkit-scrollbar-track,
	.plt-color-swatches::-webkit-scrollbar-track,
	.plt-button-selectors::-webkit-scrollbar-track {
		background: #f1f1f1;
		border-radius: 2px;
	}

	.plt-image-swatches::-webkit-scrollbar-thumb,
	.plt-color-swatches::-webkit-scrollbar-thumb,
	.plt-button-selectors::-webkit-scrollbar-thumb {
		background: #888;
		border-radius: 2px;
	}

	.plt-image-swatches::-webkit-scrollbar-thumb:hover,
	.plt-color-swatches::-webkit-scrollbar-thumb:hover,
	.plt-button-selectors::-webkit-scrollbar-thumb:hover {
		background: #555;
	}
}

/* Desktop Grid Layout - Show all items with wrap */
@media (min-width: 769px) {
	.plt-color-swatches,
	.plt-image-swatches {
		display: flex;
		flex-wrap: wrap;
		max-width: 100%;
		overflow: visible;
	}

	.plt-image-swatch {
		flex: 0 0 auto;
		width: 80px;
		height: 80px;
	}

	.plt-button-selectors {
		display: flex;
		flex-wrap: wrap;
		max-width: 100%;
		overflow: visible;
	}
}

