/**
 * Vivaia Color Swatch Widget Styles
 *
 * @package Vivaia_Color_Swatch_Widget
 */

/* Container */
.vivaia-color-swatch-filter {
	padding: 0;
}

/* Grid Layout - Left Aligned */
.color-swatch-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
	gap: 8px;
	padding: 10px 0;
	justify-items: start;
}

/* Individual Swatch Item */
.color-swatch-item {
	position: relative;
	aspect-ratio: 1;
}

.color-swatch-item .swatch-link {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	text-decoration: none;
	position: relative;
	transition: all 0.3s ease;
}

/* Swatch Image Circle */
.color-swatch-item .swatch-image {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	border: 1px solid #000;
	transition: all 0.3s ease;
	display: block;
	position: relative;
}

/* Lazy Loading Support */
.color-swatch-item .swatch-image.d-lazy-back {
	background-color: transparent;
}

/* Hover State */
.color-swatch-item .swatch-link:hover .swatch-image {
	border-color: #333;
	transform: scale(1.1);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Selected State */
.color-swatch-item.selected .swatch-image {
	border-color: #333;
	border-width: 2px;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

.color-swatch-item.selected .swatch-link:hover .swatch-image {
	transform: scale(1.05);
}

/* Checkmark for selected state */
.color-swatch-item.selected .swatch-image::after {
	content: '\2713';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: #fff;
	font-size: 16px;
	font-weight: bold;
	text-shadow: 0 0 3px rgba(0, 0, 0, 0.8),
	             0 0 5px rgba(0, 0, 0, 0.6);
	z-index: 1;
}

/* Hide label by default (tooltip style) */
.color-swatch-item .swatch-label {
	position: absolute;
	bottom: -30px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.8);
	color: #fff;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 11px;
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
	z-index: 10;
	pointer-events: none;
}

.color-swatch-item .swatch-label::before {
	content: '';
	position: absolute;
	top: -4px;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-bottom: 4px solid rgba(0, 0, 0, 0.8);
}

/* Show label on hover */
.color-swatch-item .swatch-link:hover .swatch-label {
	opacity: 1;
	visibility: visible;
	bottom: -35px;
}

/* Widget Collapsible Support (Riode Theme) */
.widget.widget-collapsible .vivaia-color-swatch-filter {
	padding: 0 20px 20px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
	.color-swatch-grid {
		grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
		gap: 6px;
	}

	.color-swatch-item .swatch-image {
		width: 32px;
		height: 32px;
	}

	.color-swatch-item .swatch-label {
		font-size: 10px;
		padding: 3px 6px;
	}
}

/* Loading State */
.color-swatch-grid.loading {
	opacity: 0.6;
	pointer-events: none;
}

/* Empty State */
.color-swatch-grid:empty::after {
	content: attr(data-empty-message);
	display: block;
	text-align: center;
	padding: 20px;
	color: #999;
	font-size: 14px;
}

/* Focus State for Accessibility */
.color-swatch-item .swatch-link:focus {
	outline: 2px solid #4A90E2;
	outline-offset: 2px;
	border-radius: 50%;
}

.color-swatch-item .swatch-link:focus .swatch-image {
	border-color: #4A90E2;
}

/* Animation for selected state */
@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(51, 51, 51, 0.4);
	}
	70% {
		box-shadow: 0 0 0 6px rgba(51, 51, 51, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(51, 51, 51, 0);
	}
}

.color-swatch-item.selected .swatch-image {
	animation: pulse 0.6s ease-out;
}

/* Dark Mode Support (if Riode supports it) */
@media (prefers-color-scheme: dark) {
	.color-swatch-item .swatch-image {
		border-color: #555;
	}

	.color-swatch-item .swatch-link:hover .swatch-image {
		border-color: #ddd;
	}

	.color-swatch-item.selected .swatch-image {
		border-color: #fff;
		box-shadow: 0 0 0 2px #222, 0 0 0 4px #fff;
	}
}

/* Show More/Less Feature */
/* Hide items beyond initial visible count */
.color-swatch-item.swatch-item-hidden {
	display: none;
}

/* Toggle Button Container */
.color-swatch-toggle-container {
	text-align: left;
	padding: 15px 0 10px;
}

/* Toggle Button Styling */
.color-swatch-toggle-btn {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 8px 20px;
	font-size: 13px;
	color: #333;
	cursor: pointer;
	transition: all 0.3s ease;
	outline: none;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.color-swatch-toggle-btn:hover {
	background: #f5f5f5;
	border-color: #999;
	color: #000;
}

.color-swatch-toggle-btn:active {
	background: #e5e5e5;
	transform: translateY(1px);
}

.color-swatch-toggle-btn:focus {
	outline: 2px solid #4A90E2;
	outline-offset: 2px;
}

/* Smooth transition for showing/hiding items */
.color-swatch-item {
	transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Riode Theme Button Style Override (optional) */
.widget .color-swatch-toggle-btn {
	font-family: inherit;
	letter-spacing: normal;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
	.color-swatch-toggle-container {
		padding: 10px 0 5px;
	}

	.color-swatch-toggle-btn {
		padding: 6px 16px;
		font-size: 12px;
	}
}
