/**
 * Shaked Addons - Product Variation Swatches
 * Base styles for swatch structure.
 */

/* Hidden native WooCommerce selects - required for form logic */
.shaked-hidden-select {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.shaked-hidden-select select {
	display: none !important;
}

/* Swatches container */
.shaked-swatches-container {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/* Individual swatch button */
.shaked-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	margin: 0;
	border: 2px solid #dddddd;
	background-color: #f5f5f5;
	color: #333333;
	cursor: pointer;
	transition: all 0.2s ease;
	font-size: 14px;
	line-height: 1;
	text-decoration: none;
	box-sizing: border-box;
	min-width: 36px;
	min-height: 36px;
	position: relative;
}

.shaked-swatch:hover:not(.disabled) {
	opacity: 0.9;
}

/* Hover effects */
.shaked-hover-effect-lift .shaked-swatch:hover:not(.disabled) {
	transform: translateY(-2px);
}

.shaked-hover-effect-scale .shaked-swatch:hover:not(.disabled) {
	transform: scale(1.1);
}

.shaked-hover-effect-shadow .shaked-swatch:hover:not(.disabled) {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.shaked-swatch.active {
	background-color: #333333;
	color: #ffffff;
	border-color: #333333;
}

/* Focus state for accessibility */
.shaked-swatch:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(51, 51, 51, 0.3);
}

.shaked-swatch:focus-visible {
	outline: 2px solid #333333;
	outline-offset: 2px;
}

/* Disabled state */
.shaked-swatch.disabled {
	cursor: not-allowed;
	opacity: 0.4;
	position: relative;
}

.shaked-swatch.disabled::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 10%;
	right: 10%;
	height: 2px;
	background: currentColor;
	transform: translateY(-50%) rotate(-45deg);
	pointer-events: none;
	opacity: 0.8;
}

/* Out of stock badge */
.shaked-swatch.out-of-stock {
	position: relative;
}

.shaked-swatch.out-of-stock::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 10%;
	right: 10%;
	height: 1px;
	background: #e74c3c;
	transform: translateY(-50%) rotate(-45deg);
	pointer-events: none;
	z-index: 1;
}

/* Color swatches (no text by default) */
.shaked-swatch-color {
	font-size: 0;
}

/* Image swatches */
.shaked-swatch-image {
	font-size: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

/* Color/Image swatches with label */
.shaked-swatch.shaked-with-label {
	font-size: inherit;
	position: relative;
}

.shaked-swatch.shaked-with-label .swatch-label-text {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.2;
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

/* Label swatches (S, M, L, etc.) */
.shaked-swatch-label {
	font-weight: 500;
	padding: 0 8px;
}

/* Attribute row styling - ensure swatches align with label */
.variations .value .shaked-swatches-container {
	margin-top: 4px;
}

/* Add to cart area - quantity + button layout */
.shaked-swatches-form .woocommerce-variation-add-to-cart,
.shaked-swatches-form .variations_button {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.shaked-atc-layout-stacked .woocommerce-variation-add-to-cart .quantity {
	margin-right: 0;
}

.shaked-atc-layout-stacked .woocommerce-variation-add-to-cart .single_add_to_cart_button {
	margin-left: 0;
}

/* Editor preview notice */
.shaked-editor-notice {
	font-size: 12px;
	color: #666;
	margin-top: 10px;
	font-style: italic;
}

/* RTL Support */
[dir="rtl"] .shaked-swatches-container {
	direction: rtl;
}

[dir="rtl"] .shaked-variations .value {
	padding-left: 0;
	padding-right: 8px;
}

[dir="rtl"] .woocommerce-variation-add-to-cart .quantity {
	margin-right: 0;
	margin-left: 8px;
}

[dir="rtl"] .reset_variations {
	margin-left: 0;
	margin-right: 8px;
}

/* Loading state for image swap */
img.shaked-loading {
	opacity: 0.5;
	transition: opacity 0.3s ease;
}

/* Tooltip styling - browser native tooltip */
.shaked-swatch[title] {
	position: relative;
}

/* Hide elements based on widget settings */
.shaked-hide-price .woocommerce-variation-price {
	display: none !important;
}

.shaked-hide-add-to-cart .woocommerce-variation-add-to-cart,
.shaked-hide-add-to-cart .single_variation_wrap {
	display: none !important;
}

.shaked-hide-quantity .woocommerce-variation-add-to-cart .quantity {
	display: none !important;
}

/* Plus/Minus Quantity Style */
.shaked-qty-plusminus .quantity {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.shaked-qty-plusminus .quantity input {
	text-align: center;
	-moz-appearance: textfield;
	padding-left: 0;
	padding-right: 0;
}

.shaked-qty-plusminus .quantity input::-webkit-outer-spin-button,
.shaked-qty-plusminus .quantity input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.shaked-qty-plusminus .quantity .qty-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 100%;
	border: 1px solid #dddddd;
	background: #f5f5f5;
	cursor: pointer;
	user-select: none;
	transition: all 0.2s ease;
	font-size: 16px;
	line-height: 1;
	color: #333333;
}

.shaked-qty-plusminus .quantity .qty-button:hover {
	background: #e5e5e5;
	border-color: #cccccc;
}

.shaked-qty-plusminus .quantity .qty-button:active {
	background: #d5d5d5;
}

.shaked-qty-plusminus .quantity .qty-minus {
	order: -1;
	border-right: 0;
	border-radius: 4px 0 0 4px;
}

.shaked-qty-plusminus .quantity .qty-plus {
	order: 1;
	border-left: 0;
	border-radius: 0 4px 4px 0;
}

/* Responsive - Mobile improvements */
@media (max-width: 768px) {
	.shaked-swatches-container {
		gap: 6px;
	}
	
	.shaked-swatch {
		min-width: 32px;
		min-height: 32px;
		font-size: 12px;
	}
	
	.shaked-swatch-label {
		padding: 0 6px;
	}
	
	.shaked-variations .label {
		font-size: 14px;
		padding-bottom: 4px;
	}
	
	.shaked-variations tbody tr {
		display: block;
		margin-bottom: 12px;
	}
	
	.shaked-variations tbody tr th,
	.shaked-variations tbody tr td {
		display: block;
		width: 100%;
		text-align: left;
	}
	
	.woocommerce-variation-add-to-cart {
		flex-direction: column !important;
		align-items: stretch;
	}
	
	.woocommerce-variation-add-to-cart .quantity,
	.woocommerce-variation-add-to-cart .single_add_to_cart_button {
		width: 100%;
		margin: 4px 0 !important;
	}
}
