/**
 * GBP Product Image Gallery Widget Styles
 *
 * Styles for the product image gallery with color variant swatches.
 * All classes are prefixed with gbp-pig- for namespacing.
 */

/* ==========================================================================
   Main Container
   ========================================================================== */

.gbp-pig {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.gbp-pig__placeholder {
	padding: 40px;
	text-align: center;
	background-color: #f5f5f5;
	border: 2px dashed #ddd;
	border-radius: 8px;
}

.gbp-pig__placeholder p {
	margin: 0;
	color: #666;
	font-size: 14px;
}

/* ==========================================================================
   Main Image
   ========================================================================== */

.gbp-pig__main-wrapper {
	width: 100%;
}

.gbp-pig__main-image {
	position: relative;
	width: 100%;
	overflow: hidden;
	background-color: #f5f5f5;
}

.gbp-pig__main-image--ratio {
	aspect-ratio: 16/9;
}

.gbp-pig__main-image img.gbp-pig__image {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.3s ease;
}

/* Skeleton loading state */
@keyframes gbp-pig-skeleton {
	0%   { background-position: -200% 0; }
	100% { background-position: 200% 0; }
}

.gbp-pig__main-image--loading img.gbp-pig__image {
	opacity: 0;
}

.gbp-pig__main-image--loading::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: gbp-pig-skeleton 1.5s ease-in-out infinite;
	z-index: 1;
}

/* ==========================================================================
   Swatches Container
   ========================================================================== */

.gbp-pig__swatches-wrapper {
	/* width: 100%; */
	max-width: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
}

.gbp-pig__active-name {
	font-size: 16px;
	font-weight: 500;
	color: #333;
	text-align: center;
}

.gbp-pig__swatches {
	display: flex;
	flex-wrap: nowrap !important;
	justify-content: flex-start;
	align-items: flex-start; /* default; overridden by Elementor control */
	gap: 16px;
	width: 100%;
	max-width: 100%;
	overflow-x: auto;
	overflow-y: visible;
	padding: 8px 0;
	-webkit-overflow-scrolling: touch;
	/* Hide scrollbar - drag to scroll instead */
	scrollbar-width: none;
	-ms-overflow-style: none;
	/* Cursor for drag */
	cursor: grab;
	user-select: none;
}

.gbp-pig__swatches::-webkit-scrollbar {
	display: none;
}

.gbp-pig__swatches:active {
	cursor: grabbing;
}

/* ==========================================================================
   Individual Swatch
   ========================================================================== */

.gbp-pig__swatch {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 0;
	margin: 0;
	background: transparent;
	border: none;
	cursor: grab;
	flex-shrink: 0;
	text-decoration: none;
	color: inherit;
	user-select: none;
}

.gbp-pig__swatch:active {
	cursor: grabbing;
}

.gbp-pig__swatch:hover,
.gbp-pig__swatch:focus {
	text-decoration: none;
	color: inherit;
}

.gbp-pig__swatch:focus {
	outline: none;
}

.gbp-pig__swatch:focus-visible .gbp-pig__swatch-image {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* Swatch Image/Thumbnail */
.gbp-pig__swatch-image {
	width: 70px;
	height: 70px;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	background-color: #e0e0e0;
	border: 2px solid transparent;
	border-radius: 0;
}

.gbp-pig__swatch:hover .gbp-pig__swatch-image,
.gbp-pig__swatch:focus-visible .gbp-pig__swatch-image {
	border-color: #ccc;
}

/* Active Swatch State - border only, no size change */
.gbp-pig__swatch--active .gbp-pig__swatch-image {
	border-color: #333;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Swatch Label */
.gbp-pig__swatch-label {
	font-size: 12px;
	font-weight: 400;
	color: #666;
	text-align: center;
	max-width: 90px;
	transition: color 0.2s ease;
}

.gbp-pig__swatch--active .gbp-pig__swatch-label {
	font-weight: 600;
	color: #000;
}

.gbp-pig__swatch:hover .gbp-pig__swatch-label,
.gbp-pig__swatch:focus-visible .gbp-pig__swatch-label {
	color: #333;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet */
@media screen and (max-width: 1024px) {
	.gbp-pig {
		gap: 20px;
	}

	.gbp-pig__swatch-image {
		width: 60px;
		height: 60px;
	}

	.gbp-pig__swatch-label {
		font-size: 11px;
		max-width: 60px;
	}
}

/* Mobile */
@media screen and (max-width: 768px) {
	.gbp-pig {
		gap: 16px;
	}

	.gbp-pig__swatches {
		gap: 12px;
	}

	.gbp-pig__swatch-image {
		width: 50px;
		height: 50px;
	}

	.gbp-pig__swatch-label {
		font-size: 10px;
		max-width: 50px;
	}

	.gbp-pig__active-name {
		font-size: 14px;
	}
}

/* Small Mobile */
@media screen and (max-width: 480px) {
	.gbp-pig__swatch-image {
		width: 45px;
		height: 45px;
	}

	.gbp-pig__swatches {
		gap: 8px;
	}

	.gbp-pig__swatch-label {
		font-size: 9px;
		max-width: 45px;
	}
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* High contrast mode */
@media (prefers-contrast: high) {
	.gbp-pig__swatch-image {
		border: 2px solid #000;
	}

	.gbp-pig__swatch--active .gbp-pig__swatch-image {
		border-color: #000;
	}
}


/* ==========================================================================
   Elementor Editor
   ========================================================================== */

.elementor-editor-active .gbp-pig__placeholder {
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
}
