/**
 * Variation Swatches Styles
 *
 * @package PerdeGelsin
 * @since 1.0.0
 */

.pg-variation-swatches {
	margin-bottom: 0;
}

/* WooCommerce variations table adjustments */
.variations {
	margin-bottom: 5px !important;
}

.variations tr.has-pg-swatches {
	display: flex;
	flex-direction: column; /* Label on top */
	margin-bottom: 0px !important;
}

.variations tr.has-pg-swatches td.value {
	padding-bottom: 0 !important;
}

.variations tr.has-pg-swatches .label {
	display: none; /* Hide default label */
}

.pg-swatch-header {
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 12px;
	color: #333;
}

/* Hide reset/clear button - multiple selectors for compatibility */
.reset_variations,
.woocommerce-variation-add-to-cart .reset_variations,
a.reset_variations {
	display: none !important;
	visibility: hidden !important;
}

.pg-swatches-wrapper {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	margin-bottom: 0; /* Extra space for labels */
	padding-bottom: 0;
}

.pg-swatch-item {
	position: relative;
	width: 68px;
	height: 68px;
	border: 2px solid #ddd;
	border-radius: 6px;
	overflow: visible; /* Changed from hidden to show labels */
	cursor: pointer;
	transition: all 0.3s ease;
	background: #fff;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	margin-bottom: 30px;
}

/* Keep image clipped inside swatch */
.pg-swatch-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 4px; /* Match parent border radius */
}

.pg-swatch-item:hover {
	border-color: #999;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pg-swatch-item.selected {
	border-color: #000;
	border-width: 3px;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.pg-swatch-item.disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.pg-swatch-item.disabled::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 2px;
	background: #f00;
	transform: translateY(-50%) rotate(-45deg);
}

.pg-swatch-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.pg-swatch-item .pg-swatch-text {
	font-size: 12px;
	font-weight: 600;
	text-align: center;
	padding: 5px;
	color: #333;
}

.pg-swatch-label {
	position: absolute;
	bottom: -30px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 13px;
	color: #666;
	white-space: nowrap;
	text-align: center;
	width: max-content;
	max-width: 82px;
	opacity: 1;
	transition: all 0.3s ease;
	font-weight: 400;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Tooltip on hover - shows full name */
.pg-swatch-item::after {
	content: attr(title);
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(-8px);
	background: rgba(0, 0, 0, 0.85);
	color: #fff;
	padding: 6px 10px;
	border-radius: 4px;
	font-size: 12px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
	z-index: 100;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Tooltip arrow */
.pg-swatch-item::before {
	content: '';
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(-2px);
	border: 5px solid transparent;
	border-top-color: rgba(0, 0, 0, 0.85);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
	z-index: 100;
}

.pg-swatch-item:hover::after,
.pg-swatch-item:hover::before {
	opacity: 1;
	transform: translateX(-50%) translateY(-5px);
}

.pg-swatch-item:hover::before {
	transform: translateX(-50%) translateY(0px);
}

.pg-swatch-item:hover .pg-swatch-label {
	color: #333;
}

.pg-swatch-item.selected .pg-swatch-label {
	color: #000;
	font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 768px) {
	.pg-swatch-item {
		width: 60px;
		height: 60px;
		margin-bottom: 27px;
	}

	.pg-swatches-wrapper {
		gap: 12px;
	}

	.pg-swatch-label {
		font-size: 12px;
		bottom: -27px;
		max-width: 75px;
	}
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
	.pg-swatch-item {
		width: 65px;
		height: 65px;
	}
}

/* Loading state */
.pg-variation-swatches.loading .pg-swatch-item {
	pointer-events: none;
	opacity: 0.6;
}

/* Hidden state for swatches when night-day mechanism is selected */
.pg-variation-swatches.pg-swatches-hidden {
	opacity: 0;
	pointer-events: none;
	max-height: 0;
	overflow: hidden;
	margin: 0;
	padding: 0;
	transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}

/* Visible state (default) */
.pg-variation-swatches {
	opacity: 1;
	pointer-events: auto;
	max-height: 1000px;
	transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}
