/**
 * Product Gallery Shortcode Styles
 * Desktop: Grid layout (1 large + 4 small)
 * Mobile: Slider layout (1 image at a time with navigation)
 */

/* ============================================
   Base Styles
   ============================================ */
.pgs-product-gallery {
	width: 100%;
	margin: 0 auto;
}

/* Remove default browser outlines and borders */
.pgs-product-gallery *:focus,
.pgs-product-gallery *:active {
	outline: none !important;
}

.pgs-product-gallery button,
.pgs-product-gallery a,
.pgs-product-gallery img {
	-webkit-tap-highlight-color: transparent;
	-webkit-focus-ring-color: transparent;
	outline: none !important;
}

/* Reset any default spacing that might cause gaps */
.pgs-product-gallery *,
.pgs-product-gallery *::before,
.pgs-product-gallery *::after {
	box-sizing: border-box;
}

.pgs-gallery-item *,
.pgs-gallery-item *::before,
.pgs-gallery-item *::after {
	margin: 0;
	padding: 0;
	vertical-align: top;
}

.pgs-gallery-container {
	position: relative;
	width: 100%;
}

/* ============================================
   Desktop Grid Layout
   ============================================ */
.pgs-gallery-grid {
	display: grid;
	grid-template-columns: 2fr 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	gap: 12px;
	height: 400px;
	position: relative;
	align-items: stretch;
	align-content: stretch;
}

.pgs-gallery-grid > *:not(.pgs-view-all-wrapper) {
	min-height: 0;
	height: 100%;
}

/* Large featured image (top-left, spans 2 rows) */
.pgs-gallery-item-large {
	grid-row: 1 / 3;
	grid-column: 1 / 2;
	height: 100%;
}

/* Small gallery images */
.pgs-gallery-item-small {
	grid-column: auto;
	grid-row: auto;
	height: 100%;
}

.pgs-gallery-item {
	position: relative;
	overflow: hidden;
	border-radius: 8px;
	background: #000;
	width: 100%;
	height: 100%;
	min-height: 0;
	padding: 0;
	margin: 0;
	display: block;
	line-height: 0;
	font-size: 0;
}

.pgs-image-link {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
	cursor: pointer;
	outline: none;
	border: none;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
	padding: 0 !important;
	margin: 0 !important;
	line-height: 0;
}

.pgs-gallery-item img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	max-height: 100% !important;
	object-fit: cover !important;
	object-position: center;
	transition: transform 0.3s ease, opacity 0.3s ease;
	display: block;
	outline: none;
	border: none;
	-webkit-tap-highlight-color: transparent;
	z-index: 0;
	padding: 0 !important;
	margin: 0 !important;
}

.pgs-gallery-item img:focus,
.pgs-gallery-item img:active {
	outline: none;
	border: none;
	box-shadow: none;
}

.pgs-gallery-item:hover img {
	transform: scale(1.05);
}

.pgs-image-link:focus,
.pgs-image-link:active {
	outline: none;
	border: none;
	box-shadow: none;
}

/* View All Button (Desktop) */
.pgs-gallery-grid .pgs-view-all-wrapper {
	position: absolute;
	bottom: 16px !important;
	right: 16px !important;
	top: auto !important;
	left: auto !important;
	z-index: 10;
	grid-column: unset;
	grid-row: unset;
}

.pgs-view-all-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 20px;
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(10px);
	color: #333;
	text-decoration: none;
	border: 1px solid rgba(255, 255, 255, 0.8);
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	transition: all 0.3s ease;
	cursor: pointer;
	font-family: inherit;
}

.pgs-view-all-button:hover {
	background: rgba(255, 255, 255, 1);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	transform: translateY(-2px);
	color: #000;
}

.pgs-view-all-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
}

.pgs-view-all-text {
	white-space: nowrap;
}

/* Hide mobile slider on desktop */
.pgs-mobile-slider {
	display: none;
}

/* ============================================
   Mobile Slider Layout
   ============================================ */
@media screen and (max-width: 768px) {
	/* Hide desktop grid on mobile */
	.pgs-gallery-grid {
		display: none;
	}

	/* Show mobile slider */
	.pgs-mobile-slider {
		display: block;
		position: relative;
		width: 100%;
		overflow: hidden;
		border-radius: 8px;
		background: #f5f5f5;
	}

	.pgs-slider-container {
		position: relative;
		width: 100%;
		height: 400px;
		overflow: hidden;
		background: #000;
		line-height: 0;
		font-size: 0;
	}

	.pgs-slide {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		opacity: 0;
		transition: opacity 0.4s ease, transform 0.4s ease;
		transform: translateX(100%);
		min-height: 0;
		display: block;
		line-height: 0;
		font-size: 0;
	}

	.pgs-slide.pgs-slide-active {
		opacity: 1;
		transform: translateX(0);
		position: relative;
	}

	.pgs-slide.pgs-slide-prev {
		transform: translateX(-100%);
	}

	.pgs-slide-link {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		z-index: 1;
		padding: 0 !important;
		margin: 0 !important;
		display: block;
		text-decoration: none;
		outline: none;
		border: none;
	}

	.pgs-slide-link:focus,
	.pgs-slide-link:active {
		outline: none;
		border: none;
		box-shadow: none;
	}

	.pgs-slide img {
		position: absolute;
		top: 0;
		left: 0;
		width: 100% !important;
		height: 100% !important;
		max-width: 100% !important;
		max-height: 100% !important;
		object-fit: cover !important;
		object-position: center;
		display: block;
		outline: none;
		border: none;
		-webkit-tap-highlight-color: transparent;
		z-index: 0;
		padding: 0 !important;
		margin: 0 !important;
	}

	.pgs-slide img:focus,
	.pgs-slide img:active {
		outline: none;
		border: none;
		box-shadow: none;
	}

	/* Navigation Arrows */
	.pgs-slider-nav {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		background: rgba(255, 255, 255, 0.95);
		backdrop-filter: blur(10px);
		border: 1px solid rgba(0, 0, 0, 0.1);
		border-radius: 50%;
		width: 44px;
		height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
		z-index: 20;
		transition: all 0.3s ease;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
		padding: 0;
		margin: 0;
		outline: none;
		-webkit-tap-highlight-color: transparent;
	}

	.pgs-slider-nav:focus,
	.pgs-slider-nav:active {
		outline: none;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	}

	.pgs-slider-nav:focus:not(:focus-visible) {
		outline: none;
	}

	.pgs-slider-nav:hover {
		background: rgba(255, 255, 255, 1);
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
		transform: translateY(-50%) scale(1.1);
	}

	.pgs-slider-nav:active {
		transform: translateY(-50%) scale(0.95);
	}

	.pgs-slider-prev {
		left: 12px;
	}

	.pgs-slider-next {
		right: 12px;
	}

	.pgs-slider-nav svg {
		width: 24px;
		height: 24px;
		color: #333;
	}

	.pgs-slider-nav:disabled {
		opacity: 0.4;
		cursor: not-allowed;
	}

	.pgs-slider-nav:disabled:hover {
		transform: translateY(-50%);
		background: rgba(255, 255, 255, 0.95);
	}

	/* View All Button (Mobile) */
	.pgs-mobile-view-all {
		position: absolute;
		bottom: 16px;
		right: 16px;
		z-index: 25;
	}

	.pgs-mobile-view-all .pgs-view-all-button {
		background: rgba(255, 255, 255, 0.95);
		backdrop-filter: blur(10px);
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	}

	.pgs-mobile-view-all .pgs-view-all-button:hover {
		background: rgba(255, 255, 255, 1);
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	}
}

/* ============================================
   Tablet Adjustments
   ============================================ */
@media screen and (min-width: 769px) and (max-width: 1024px) {
	.pgs-gallery-grid {
		height: 350px;
		gap: 10px;
	}
}

/* ============================================
   Large Desktop Adjustments
   ============================================ */
@media screen and (min-width: 1400px) {
	.pgs-gallery-grid {
		height: 450px;
		gap: 16px;
	}
}

/* ============================================
   Accessibility
   ============================================ */
.pgs-product-gallery:focus-within {
	outline: none;
}

.pgs-slider-nav:focus {
	outline: none;
}

/* ============================================
   Loading States
   ============================================ */
.pgs-gallery-item img[loading="lazy"] {
	opacity: 0;
	transition: opacity 0.3s ease;
}

.pgs-gallery-item img[loading="lazy"].loaded {
	opacity: 1;
}

/* ============================================
   Lightbox Styles
   ============================================ */
/* Hide headers completely when lightbox is open - more aggressive approach for DIVI */
body.pgs-lightbox-open #main-header,
body.pgs-lightbox-open .et-fixed-header,
body.pgs-lightbox-open header#main-header,
body.pgs-lightbox-open .main-header,
body.pgs-lightbox-open .et_header_style_split,
body.pgs-lightbox-open [id*="header"]:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open header:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open .site-header:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open [class*="header"]:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open [class*="Header"]:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open [class*="et-header"]:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open [data-et-module-type*="header"]:not(.pgs-lightbox):not(.pgs-lightbox *) {
	z-index: -1 !important;
	opacity: 0 !important;
	pointer-events: none !important;
	visibility: hidden !important;
}

/* Ensure DIVI fixed headers are behind lightbox */
body.pgs-lightbox-open header.et-fixed-header,
body.pgs-lightbox-open #main-header.et-fixed-header,
body.pgs-lightbox-open [class*="et-fixed-header"]:not(.pgs-lightbox):not(.pgs-lightbox *),
body.pgs-lightbox-open .et_pb_section_header:not(.pgs-lightbox):not(.pgs-lightbox *) {
	z-index: -1 !important;
	opacity: 0 !important;
	pointer-events: none !important;
	visibility: hidden !important;
}

.pgs-lightbox {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	width: 100% !important;
	height: 100% !important;
	z-index: 2147483647 !important; /* Maximum safe z-index value */
	display: none;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.pgs-lightbox.pgs-lightbox-active {
	display: block !important;
	opacity: 1;
}

.pgs-lightbox-backdrop {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	width: 100vw !important;
	height: 100vh !important;
	background: rgba(0, 0, 0, 0.95) !important;
	cursor: pointer;
	z-index: 2147483646 !important; /* Just below lightbox container */
}

.pgs-lightbox-content {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	width: 100% !important;
	height: 100% !important;
	display: flex !important;
	align-items: center;
	justify-content: center;
	padding: 20px;
	box-sizing: border-box;
	z-index: 2147483647 !important;
	pointer-events: none;
}

.pgs-lightbox-content > * {
	pointer-events: auto;
}

.pgs-lightbox-image-wrapper {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pgs-lightbox-image {
	max-width: 100%;
	max-height: 90vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
	animation: pgs-lightbox-fade-in 0.3s ease;
	outline: none;
	border: none;
	-webkit-tap-highlight-color: transparent;
}

.pgs-lightbox-image:focus,
.pgs-lightbox-image:active {
	outline: none;
	border: none;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

@keyframes pgs-lightbox-fade-in {
	from {
		opacity: 0;
		transform: scale(0.9);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* Close Button */
.pgs-lightbox-close {
	position: fixed !important;
	top: 20px !important;
	right: 20px !important;
	width: 48px;
	height: 48px;
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2147483647 !important;
	transition: all 0.3s ease;
	color: #fff;
	padding: 0;
	margin: 0;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

.pgs-lightbox-close:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: rotate(90deg);
}

.pgs-lightbox-close:focus,
.pgs-lightbox-close:active {
	outline: none;
	box-shadow: none;
}

.pgs-lightbox-close:focus:not(:focus-visible) {
	outline: none;
}

.pgs-lightbox-close svg {
	width: 24px;
	height: 24px;
	stroke: currentColor;
}

/* Navigation Arrows */
.pgs-lightbox-nav {
	position: fixed !important;
	top: 50%;
	transform: translateY(-50%);
	width: 56px;
	height: 56px;
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2147483647 !important;
	transition: all 0.3s ease;
	color: #fff;
	padding: 0;
	margin: 0;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

.pgs-lightbox-nav:focus,
.pgs-lightbox-nav:active {
	outline: none;
	box-shadow: none;
}

.pgs-lightbox-nav:focus:not(:focus-visible) {
	outline: none;
}

.pgs-lightbox-nav:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: translateY(-50%) scale(1.1);
}

.pgs-lightbox-nav:active {
	transform: translateY(-50%) scale(0.95);
}

.pgs-lightbox-nav:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.pgs-lightbox-nav:disabled:hover {
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.1);
}

.pgs-lightbox-prev {
	left: 20px;
}

.pgs-lightbox-next {
	right: 20px;
}

.pgs-lightbox-nav svg {
	width: 24px;
	height: 24px;
	stroke: currentColor;
}

/* Counter */
.pgs-lightbox-counter {
	position: fixed !important;
	bottom: 20px !important;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 20px;
	padding: 8px 16px;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	z-index: 2147483647 !important;
}

/* Mobile Lightbox Adjustments */
@media screen and (max-width: 768px) {
	.pgs-lightbox-content {
		padding: 10px;
	}

	.pgs-lightbox-image-wrapper {
		max-width: 95vw;
		max-height: 85vh;
	}

	.pgs-lightbox-close {
		position: fixed !important;
		top: 10px !important;
		right: 10px !important;
		width: 44px;
		height: 44px;
		z-index: 2147483647 !important;
	}

	.pgs-lightbox-close svg {
		width: 20px;
		height: 20px;
	}

	.pgs-lightbox-nav {
		position: fixed !important;
		width: 44px;
		height: 44px;
		z-index: 2147483647 !important;
	}

	.pgs-lightbox-nav svg {
		width: 20px;
		height: 20px;
	}

	.pgs-lightbox-prev {
		left: 10px;
	}

	.pgs-lightbox-next {
		right: 10px;
	}

	.pgs-lightbox-counter {
		position: fixed !important;
		bottom: 10px !important;
		font-size: 12px;
		padding: 6px 12px;
		z-index: 2147483647 !important;
	}
}
