/* WooCommerce Color Swatches - Frontend */

/* ===== 容器：强制独占一行，在加入购物车按钮上方 ===== */
.wcs-swatches-wrap {
	display: block !important;
	clear: both !important;
	width: 100% !important;
	float: none !important;
	margin: 0 0 20px 0;
	padding: 15px 0;
	border-top: 1px solid #eee;
	border-bottom: 1px solid #eee;
	box-sizing: border-box;
}

/* WooCommerce cart 表单内的元素强制不浮动 */
.woocommerce div.product form.cart .wcs-swatches-wrap,
.woocommerce div.product form.cart .wcs-swatches-wrap * {
	float: none !important;
}

.wcs-swatches-label {
	font-weight: 600;
	font-size: 14px;
	margin-bottom: 12px;
	color: #333;
}

.wcs-swatches-list {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	clear: both;
}

/* ===== 颜色选项：整个方框放图片，标题叠加在底部 ===== */
.wcs-swatch-item {
	cursor: pointer;
	position: relative;
	width: 80px;
	height: 80px;
	border: 2px solid #ddd;
	border-radius: 8px;
	overflow: hidden;
	transition: all 0.2s ease;
	background: #f0f0f0;
	flex-shrink: 0;
}

.wcs-swatch-item:hover {
	border-color: #999;
	transform: translateY(-2px);
}

.wcs-swatch-item.selected {
	border-color: #2271b1;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
}

/* 图片填满整个方框 */
.wcs-swatch-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wcs-swatch-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	font-weight: 600;
	color: #888;
}

/* 标题：叠加在图片底部 */
.wcs-swatch-title {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 11px;
	line-height: 1.3;
	padding: 3px 4px;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.wcs-swatch-item.selected .wcs-swatch-title {
	background: rgba(34, 113, 177, 0.85);
}

/* 抖动动画（未选颜色时提示） */
@keyframes wcs-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-6px); }
	75% { transform: translateX(6px); }
}

/* 响应式 */
@media (max-width: 480px) {
	.wcs-swatch-item {
		width: 64px;
		height: 64px;
	}
	.wcs-swatch-placeholder {
		font-size: 20px;
	}
	.wcs-swatch-title {
		font-size: 10px;
	}
}
