/**
 * GBP Product Listing Grid Widget Styles
 *
 * Styles for the product swatch grid layout similar to carpet/flooring product selectors.
 * All classes are prefixed with gbp- for namespacing.
 */

/* ==========================================================================
   Grid Container
   ========================================================================== */

.gbp-product-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	row-gap: 16px;
	column-gap: 16px;
	width: 100%;
}

.gbp-product-grid__empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 40px 20px;
	color: #666;
	font-style: italic;
}

/* ==========================================================================
   Product Card
   ========================================================================== */

.gbp-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background-color: #ffffff;
	border-radius: 8px;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* .gbp-product-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
} */

/* Card Link - Full clickable area */
.gbp-product-card__link {
	display: contents;
	text-decoration: none;
	color: inherit;
}

.gbp-product-card__link:hover,
.gbp-product-card__link:focus {
	text-decoration: none;
}

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

/* ==========================================================================
   Product Image
   ========================================================================== */

.gbp-product-card__image-wrapper {
	position: relative;
	width: 100%;
	overflow: hidden;
}

.gbp-product-card__image {
	width: 100%;
	aspect-ratio: 1 / 1;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	transition: transform 0.4s ease;
}

/* -- Hover Zoom Effect -- */
.gbp-product-card--hover-zoom:hover .gbp-product-card__image,
.gbp-product-card--hover-zoom:focus-within .gbp-product-card__image {
	transform: scale(1.05);
}

/* ==========================================================================
   Card Footer
   ========================================================================== */

.gbp-product-card__footer {
	display: flex;
	align-items: self-start;
	justify-content: space-between;
	padding: 12px;
	background-color: #232327;
	min-height: 48px;
}

.gbp-product-card__title {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.3;
	color: #ffffff;
	flex: 1;
	word-wrap: break-word;
	overflow-wrap: break-word;
	padding-right: 12px;
}

/* ==========================================================================
   Color Swatch
   ========================================================================== */

.gbp-product-card__swatch-wrapper {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.gbp-product-card__swatch {
	width: 41px;
	height: 41px;
	border-radius: 50%;
	border: 1px solid #D3D3D4;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	flex-shrink: 0;
	transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.gbp-product-card:hover .gbp-product-card__swatch,
.gbp-product-card:focus-within .gbp-product-card__swatch {
	border-color: rgba(255, 255, 255, 0.6);
	transform: scale(1.05);
}

.gbp-product-card__arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	opacity: 0.7;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.gbp-product-card__arrow svg {
	width: 14px;
	height: 8px;
	stroke: currentColor;
}

.gbp-product-card:hover .gbp-product-card__arrow,
.gbp-product-card:focus-within .gbp-product-card__arrow {
	opacity: 1;
}

/* ==========================================================================
   Colour Variant Dropdown
   ========================================================================== */

.gbp-product-card__dropdown-wrapper {
	position: relative;
	display: flex;
	align-items: center;
}

.gbp-product-card__dropdown-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	margin: 0;
	background: transparent;
	border: none;
	color: #ffffff;
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.gbp-product-card__dropdown-toggle:hover,
.gbp-product-card__dropdown-toggle:focus {
	opacity: 1;
}

.gbp-product-card__dropdown-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.gbp-product-card__dropdown-toggle[aria-expanded="true"] {
	opacity: 1;
}

.gbp-product-card__dropdown-toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

.gbp-product-card__dropdown-toggle svg {
	width: 14px;
	height: 8px;
	stroke: currentColor;
	transition: transform 0.2s ease;
}

/* Dropdown Panel - Overlays on card image */
.gbp-product-card__dropdown {
	position: absolute;
	bottom: 100%;
	right: -12px;
	width: 280px;
	background-color: #ffffff;
	border: 1px solid #D3D3D4;
	border-radius: 0;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
	z-index: 100;
	display: flex;
	flex-direction: column;
}

.gbp-product-card__dropdown-wrapper.gbp-dropdown-open .gbp-product-card__dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* Close Button - Teal square floating outside top left */
.gbp-product-card__dropdown-header {
	position: absolute;
	top: 0;
	left: -40px;
	z-index: 10;
}

.gbp-product-card__dropdown-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	background-color: #008c99;
	border: none;
	color: #ffffff;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.gbp-product-card__dropdown-close:hover,
.gbp-product-card__dropdown-close:focus-visible {
	background-color: #007a85;
}

.gbp-product-card__dropdown-close svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
}

/* Dropdown Content Area */
.gbp-product-card__dropdown-content {
	display: flex;
	flex-direction: column;
	width: 100%;
}

/* Dropdown Items List */
.gbp-product-card__dropdown-list {
	max-height: 300px;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 0;
}

.gbp-product-card__dropdown-item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 16px 10px 16px;
	cursor: pointer;
	transition: background-color 0.15s ease;
	background-color: #ffffff;
	text-decoration: none;
	color: inherit;
}

.gbp-product-card__dropdown-item:hover,
.gbp-product-card__dropdown-item:focus {
	text-decoration: none;
}

.gbp-product-card__dropdown-item:first-child {
	padding-top: 12px;
}

.gbp-product-card__dropdown-item:hover {
	background-color: #f0f0f0;
}

.gbp-product-card__dropdown-item--active {
	background-color: #e8e8e8;
}

.gbp-product-card__dropdown-swatch {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.1);
	flex-shrink: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

.gbp-product-card__dropdown-label {
	font-size: 15px;
	font-weight: 400;
	color: #333333;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Dropdown Footer with More Colours Button */
.gbp-product-card__dropdown-footer {
	padding: 16px 20px 20px;
	text-align: center;
	background-color: #ffffff;
}

.gbp-product-card__dropdown-more {
	display: inline-block;
	padding: 10px 28px;
	font-size: 14px;
	font-weight: 500;
	color: #008c99;
	background-color: transparent;
	border: 1px solid #008c99;
	border-radius: 0;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.gbp-product-card__dropdown-more:hover,
.gbp-product-card__dropdown-more:focus-visible {
	background-color: #008c99;
	color: #ffffff;
}

/* Scrollbar styling for dropdown */
.gbp-product-card__dropdown-list::-webkit-scrollbar {
	width: 6px;
}

.gbp-product-card__dropdown-list::-webkit-scrollbar-track {
	background: #f0f0f0;
	border-radius: 3px;
}

.gbp-product-card__dropdown-list::-webkit-scrollbar-thumb {
	background: #cccccc;
	border-radius: 3px;
}

.gbp-product-card__dropdown-list::-webkit-scrollbar-thumb:hover {
	background: #aaaaaa;
}

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

/* Tablet (1024px and below) */
@media screen and (max-width: 1024px) {
	.gbp-product-grid {
		grid-template-columns: repeat(3, 1fr);
		row-gap: 14px;
		column-gap: 14px;
	}

	.gbp-product-card__title {
		font-size: 13px;
	}

	.gbp-product-card__swatch {
		width: 24px;
		height: 24px;
	}
}

/* Mobile Landscape (768px and below) */
@media screen and (max-width: 768px) {
	.gbp-product-grid {
		grid-template-columns: repeat(2, 1fr);
		row-gap: 12px;
		column-gap: 12px;
	}

	.gbp-product-card__footer {
		padding: 10px;
	}

	.gbp-product-card__title {
		font-size: 12px;
	}

	.gbp-product-card__swatch {
		width: 22px;
		height: 22px;
	}

	.gbp-product-card__arrow svg {
		width: 12px;
		height: 7px;
	}

	/* Dropdown - Centered modal on mobile */
	.gbp-product-card__dropdown {
		position: fixed;
		top: 50%;
		left: 50%;
		bottom: auto;
		right: auto;
		transform: translate(-50%, -50%) scale(0.95);
		width: calc(100vw - 40px);
		max-width: 320px;
		max-height: calc(100vh - 80px);
		z-index: 1000;
	}

	.gbp-product-card__dropdown-wrapper.gbp-dropdown-open .gbp-product-card__dropdown {
		transform: translate(-50%, -50%) scale(1);
	}

	/* Backdrop overlay for mobile */
	.gbp-product-card__dropdown-wrapper.gbp-dropdown-open::before {
		content: '';
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 999;
	}

	/* Close button repositioned for centered modal */
	.gbp-product-card__dropdown-header {
		position: absolute;
		top: -40px;
		left: auto;
		right: 0;
	}

	/* Adjust dropdown list max height for mobile */
	.gbp-product-card__dropdown-list {
		max-height: calc(100vh - 200px);
	}
}

/* Mobile Portrait (480px and below) */
@media screen and (max-width: 480px) {
	.gbp-product-grid {
		grid-template-columns: repeat(2, 1fr);
		row-gap: 10px;
		column-gap: 10px;
	}

	.gbp-product-card__footer {
		padding: 8px 10px;
		min-height: 42px;
	}

	.gbp-product-card__title {
		font-size: 11px;
		padding-right: 8px;
	}

	.gbp-product-card__swatch {
		width: 20px;
		height: 20px;
	}

	.gbp-product-card__swatch-wrapper {
		gap: 4px;
	}
}

/* ==========================================================================
   Elementor Editor Specific Styles
   ========================================================================== */

/* Ensure proper display in editor preview panel */
.elementor-editor-preview .gbp-product-grid {
	width: 100%;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
	.gbp-product-card__footer {
		border: 1px solid #ffffff;
	}

	.gbp-product-card__swatch {
		border-width: 3px;
	}
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	.gbp-product-card,
	.gbp-product-card__image,
	.gbp-product-card__swatch,
	.gbp-product-card__arrow {
		transition: none;
	}

	.gbp-product-card:hover .gbp-product-card__image {
		transform: none;
	}

	.gbp-product-card:hover {
		transform: none;
	}
}
