/**
 * Swatchify Variant Swatches for WooCommerce — Frontend Styles
 *
 * @package SwatchifyVariantSwatches
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
	--swatchify-swatch-size: 32px;
	--swatchify-swatch-gap: 8px;
	--swatchify-swatch-border-radius: 4px;
	--swatchify-swatch-border-color: #ddd;
	--swatchify-swatch-border-color-active: #333;
	--swatchify-swatch-border-width: 2px;
	--swatchify-swatch-transition: all 0.2s ease;
	--swatchify-tooltip-bg: #333;
	--swatchify-tooltip-color: #fff;
	--swatchify-tooltip-font-size: 12px;
	--swatchify-oos-opacity: 0.4;
}

/* ==========================================================================
   WooCommerce Variations Table — Inline Layout
   ========================================================================== */

.variations td {
	display: flex;
	align-items: center;
	gap: 12px;
}

.variations td .swatchify-swatches-wrapper {
	margin-bottom: 0;
}

.variations td.label {
	display: flex;
	align-items: center;
}

.variations tr {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-bottom: 10px;
}

.variations td.label label {
	font-weight: 600;
	margin: 0;
	white-space: nowrap;
}

/* ==========================================================================
   Swatch Wrapper
   ========================================================================== */

.swatchify-swatches-wrapper {
	display: flex;
	flex-wrap: wrap;
	gap: var(--swatchify-swatch-gap);
	align-items: center;
	margin-bottom: 12px;
}

/* ==========================================================================
   Base Swatch
   ========================================================================== */

.swatchify-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--swatchify-swatch-size);
	height: var(--swatchify-swatch-size);
	border: var(--swatchify-swatch-border-width) solid var(--swatchify-swatch-border-color);
	border-radius: var(--swatchify-swatch-border-radius);
	cursor: pointer;
	position: relative;
	transition: var(--swatchify-swatch-transition);
	box-sizing: border-box;
	outline: none;
	user-select: none;
	-webkit-user-select: none;
	pointer-events: auto !important;
	z-index: 1;
}

.swatchify-swatch:hover {
	border-color: var(--swatchify-swatch-border-color-active);
	transform: scale(1.1);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	z-index: 3;
}

.swatchify-swatch:focus-visible {
	box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.4);
	border-color: var(--swatchify-swatch-border-color-active);
}

.swatchify-swatch.swatchify-swatch-active {
	border-color: #000 !important;
	border-width: 1px !important;
	box-shadow: 0 0 0 1px #000 !important;
	transform: scale(1.1);
	z-index: 2;
}

.swatchify-swatch.swatchify-swatch-active::after {
	z-index: 3;
}

/* Circle shape variant */
.swatchify-swatches-wrapper.swatchify-shape-circle .swatchify-swatch {
	border-radius: 50%;
}

/* ==========================================================================
   Color Swatches
   ========================================================================== */

.swatchify-swatch-color {
	overflow: hidden;
}

.swatchify-swatch-color.swatchify-swatch-active::after {
	content: '';
	display: block;
	width: 12px;
	height: 6px;
	border-left: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(-45deg);
	position: absolute;
	top: 50%;
	left: 50%;
	margin-top: -5px;
	margin-left: -6px;
	/* Add shadow for visibility on light colors */
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}

/* ==========================================================================
   Image Swatches
   ========================================================================== */

.swatchify-swatch-image {
	overflow: hidden;
	padding: 2px;
}

.swatchify-swatch-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: calc(var(--swatchify-swatch-border-radius) - 2px);
	display: block;
}

.swatchify-swatch-image-placeholder {
	font-size: 14px;
	font-weight: 600;
	color: #666;
	text-transform: uppercase;
}

/* ==========================================================================
   Label / Button Swatches
   ========================================================================== */

.swatchify-swatch-label {
	width: auto;
	min-width: var(--swatchify-swatch-size);
	height: auto;
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.4;
	color: #333;
	background-color: #f8f8f8;
}

.swatchify-swatch-label:hover {
	background-color: #eee;
}

.swatchify-swatch-label.swatchify-swatch-active {
	background-color: #333;
	color: #fff;
	border-color: #333;
}

/* ==========================================================================
   Checkbox Swatches
   ========================================================================== */

.swatchify-swatches-checkbox {
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
}

.swatchify-swatch-checkbox {
	display: flex;
	align-items: center;
	gap: 10px;
	width: auto;
	height: auto;
	border: none;
	padding: 6px 10px;
	border-radius: 6px;
	cursor: pointer;
	transition: var(--swatchify-swatch-transition);
}

.swatchify-swatch-checkbox:hover {
	background-color: #f5f5f5;
	transform: none;
	box-shadow: none;
	border-color: transparent;
}

.swatchify-checkbox-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.swatchify-checkbox-mark {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 2px solid #ccc;
	border-radius: 4px;
	position: relative;
	flex-shrink: 0;
	transition: var(--swatchify-swatch-transition);
	background-color: #fff;
}

.swatchify-swatch-checkbox.swatchify-swatch-active .swatchify-checkbox-mark,
.swatchify-checkbox-input:checked+.swatchify-checkbox-mark {
	background-color: #333;
	border-color: #333;
}

.swatchify-swatch-checkbox.swatchify-swatch-active .swatchify-checkbox-mark::after,
.swatchify-checkbox-input:checked+.swatchify-checkbox-mark::after {
	content: '';
	position: absolute;
	left: 6px;
	top: 2px;
	width: 5px;
	height: 10px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.swatchify-checkbox-label {
	font-size: 14px;
	color: #333;
	line-height: 1.4;
}

/* ==========================================================================
   Enhanced Dropdown
   ========================================================================== */

.swatchify-swatches-dropdown {
	display: block;
}

.swatchify-enhanced-dropdown {
	width: 100%;
	max-width: 300px;
	padding: 8px 12px;
	border: 2px solid var(--swatchify-swatch-border-color);
	border-radius: var(--swatchify-swatch-border-radius);
	font-size: 14px;
	background-color: #fff;
	cursor: pointer;
	transition: var(--swatchify-swatch-transition);
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='%23333' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	padding-right: 32px;
}

.swatchify-enhanced-dropdown:hover,
.swatchify-enhanced-dropdown:focus {
	border-color: var(--swatchify-swatch-border-color-active);
	outline: none;
}

/* ==========================================================================
   Out of Stock States
   ========================================================================== */

.swatchify-swatch-oos {
	opacity: var(--swatchify-oos-opacity);
	cursor: not-allowed;
}

.swatchify-swatch-oos-clickable {
	opacity: var(--swatchify-oos-opacity);
	pointer-events: auto;
}

/* Cross style */
.swatchify-swatch-oos-cross {
	position: relative;
}

.swatchify-swatch-oos-cross::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(to top right,
			transparent calc(50% - 1px),
			#cc0000 calc(50% - 1px),
			#cc0000 calc(50% + 1px),
			transparent calc(50% + 1px));
	z-index: 1;
	pointer-events: none;
}

/* Blur style */
.swatchify-swatch-oos-blur {
	filter: blur(1px) grayscale(50%);
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.swatchify-swatch-tooltip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background-color: var(--swatchify-tooltip-bg);
	color: var(--swatchify-tooltip-color);
	font-size: var(--swatchify-tooltip-font-size);
	padding: 4px 10px;
	border-radius: 4px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	z-index: 10;
	line-height: 1.4;
}

.swatchify-swatch-tooltip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border-width: 5px;
	border-style: solid;
	border-color: var(--swatchify-tooltip-bg) transparent transparent transparent;
}

.swatchify-swatch:hover .swatchify-swatch-tooltip {
	opacity: 1;
	visibility: visible;
}

/* ==========================================================================
   Hidden Select (for WooCommerce JS compatibility)
   ========================================================================== */

.swatchify-hidden-select {
	display: none !important;
	position: absolute !important;
	visibility: hidden !important;
	width: 0 !important;
	height: 0 !important;
	overflow: hidden !important;
	z-index: -1 !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
	:root {
		--swatchify-swatch-size: 28px;
		--swatchify-swatch-gap: 6px;
	}

	.swatchify-swatch-label {
		padding: 5px 10px;
		font-size: 12px;
	}
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .swatchify-swatches-wrapper {
	direction: rtl;
}

[dir="rtl"] .swatchify-enhanced-dropdown {
	background-position: left 12px center;
	padding-right: 12px;
	padding-left: 32px;
}

/* ==========================================================================
   Selected Name Label
   ========================================================================== */

.swatchify-selected-name {
	font-weight: normal;
	color: #666;
	margin-left: 4px;
}

/* ==========================================================================
   Tooltip at End of Variants
   ========================================================================== */

.swatchify-swatch-tooltip-end {
	display: inline-flex;
	align-items: center;
	font-size: 14px;
	color: #666;
	margin-left: 10px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	transform: translateX(-4px);
	white-space: nowrap;
	line-height: 1.4;
	pointer-events: none;
	position: relative;
	font-weight: 500;
}

.swatchify-swatch-tooltip-end.swatchify-tooltip-visible {
	opacity: 1;
	visibility: visible;
	transform: translateX(0);
}

/* RTL Support for Tooltip at End */
[dir="rtl"] .swatchify-swatch-tooltip-end {
	margin-left: 0;
	margin-right: 8px;
	transform: translateX(4px);
}

[dir="rtl"] .swatchify-swatch-tooltip-end.swatchify-tooltip-visible {
	transform: translateX(0);
}