/**
 * Clubbercise Size Badges
 * Replaces WooCommerce variation dropdown with clickable size badges
 */

.clubbercise-size-badges-wrapper {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 10px 0;
}

.clubbercise-size-badge {
	min-width: 48px;
	height: 48px;
	padding: 0 16px;
	border: 2px solid #374151;
	border-radius: 50%;
	background: #ffffff;
	color: #111827;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.5px;
	cursor: pointer;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-transform: uppercase;
	line-height: 1;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.clubbercise-size-badge:hover:not(:disabled) {
	border-color: #ec4899;
	background: #fdf2f8;
	color: #ec4899;
	transform: scale(1.05);
	box-shadow: 0 4px 6px rgba(236, 72, 153, 0.15);
}

.clubbercise-size-badge:focus {
	outline: 2px solid #ec4899;
	outline-offset: 2px;
}

.clubbercise-size-badge.is-selected {
	background: #ec4899;
	border-color: #ec4899;
	color: #ffffff;
	transform: scale(1.08);
	box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.clubbercise-size-badge:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	border-style: dashed;
	background: #f9fafb;
}

.clubbercise-size-badge:disabled:hover {
	transform: none;
	background: #f9fafb;
	border-color: #d1d5db;
	color: #9ca3af;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
	.clubbercise-size-badges-wrapper {
		gap: 12px;
	}

	.clubbercise-size-badge {
		border-color: #4b5563;
		color: #e5e7eb;
		background: rgba(17, 24, 39, 0.8);
	}

	.clubbercise-size-badge:hover:not(:disabled) {
		border-color: #f472b6;
		background: rgba(244, 114, 182, 0.15);
		color: #f472b6;
	}

	.clubbercise-size-badge.is-selected {
		background: #ec4899;
		border-color: #ec4899;
		color: #ffffff;
	}

	.clubbercise-size-badge:disabled {
		border-color: #374151;
		color: #6b7280;
		background: rgba(17, 24, 39, 0.5);
	}
}

/* Mobile responsive */
@media (max-width: 767px) {
	.clubbercise-size-badges-wrapper {
		gap: 8px;
		justify-content: center;
	}

	.clubbercise-size-badge {
		min-width: 44px;
		height: 44px;
		font-size: 12px;
		padding: 0 12px;
	}
}

/* Animation for selection */
@keyframes sizeBadgePulse {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(236, 72, 153, 0);
	}
}

.clubbercise-size-badge.is-selected {
	animation: sizeBadgePulse 0.4s ease;
}

/* WooCommerce form integration */
.variations_form .clubbercise-size-badges-wrapper {
	margin: 15px 0;
}

.variations_form .clubbercise-size-badges-wrapper:first-child {
	margin-top: 0;
}

.variations_form .clubbercise-size-badges-wrapper:last-child {
	margin-bottom: 0;
}

/* Hide the original select elements that are replaced */
.clubbercise-select-hidden,
.variations .value > select:has(+ .clubbercise-size-badges-wrapper),
.variations .value:has(.clubbercise-size-badges-wrapper) > select,
.variations td.value.clubbercise-has-size-badges > select,
.variations .value.clubbercise-has-size-badges > select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border-width: 0 !important;
	pointer-events: none !important;
	opacity: 0 !important;
}

/* Hide any duplicate labels */
.clubbercise-label-hidden {
	display: none !important;
}

/* Single product page specific styling */
.single-product .clubbercise-size-badges-wrapper {
	gap: 12px;
}

.single-product .clubbercise-size-badge {
	min-width: 52px;
	height: 52px;
	font-size: 14px;
}

/* Align with WooCommerce variations table */
.variations td.value {
	position: relative;
}

.variations td.value.clubbercise-has-size-badges .woocommerce-select::after,
.variations td.value.clubbercise-has-size-badges .woocommerce-select:after {
	display: none !important;
	content: none !important;
}

.variations td.value.clubbercise-has-size-badges .reset_variations,
.variations td.value.clubbercise-has-size-badges + .reset_variations,
.variations .clubbercise-has-size-badges .reset_variations {
	display: none !important;
	visibility: hidden !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

/* Add subtle hint to select size */
.clubbercise-size-badges-wrapper:not(.has-selection)::before {
	content: attr(data-hint);
	display: block;
	width: 100%;
	color: #6b7280;
	font-size: 13px;
	margin-bottom: 8px;
	text-align: center;
}

.clubbercise-size-badges-wrapper.has-selection::before {
	display: none;
}

/* Loading state */
.clubbercise-size-badges-wrapper.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.clubbercise-size-badges-wrapper.is-loading .clubbercise-size-badge {
	animation: sizeBadgeLoading 1s ease-in-out infinite;
}

@keyframes sizeBadgeLoading {
	0%, 100% {
		opacity: 0.6;
	}
	50% {
		opacity: 1;
	}
}

/* Out of stock badge style */
.clubbercise-size-badge.out-of-stock {
	border-style: dashed;
	opacity: 0.72;
	background: #f3f4f6;
	color: #9ca3af;
	cursor: pointer;
}

.clubbercise-size-badge.out-of-stock:hover {
	background: #fff7ed;
	border-color: #fb923c;
	color: #9a3412;
}

.clubbercise-size-badge.out-of-stock.is-selected {
	background: #fff7ed;
	border-color: #f97316;
	color: #9a3412;
}

.clubbercise-size-stock-reminder {
	margin-top: 10px;
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #fdba74;
	border-radius: 8px;
	background: #fff7ed;
	color: #9a3412;
	font-size: 13px;
	line-height: 1.35;
}

.clubbercise-size-badges-wrapper.has-stock-reminder {
	row-gap: 8px;
}

/* Compact layout for many sizes */
.clubbercise-size-badges-wrapper.compact {
	gap: 6px;
}

.clubbercise-size-badges-wrapper.compact .clubbercise-size-badge {
	min-width: 42px;
	height: 42px;
	font-size: 12px;
	padding: 0 10px;
}
