/* ==========================================================================
   Gallery Folder Lightbox 2.0 — IPETH
   Todo está namespaced en .gfl-* y parametrizado con variables CSS, que es
   lo que los controles de Elementor escriben vía selectors.
   ========================================================================== */

.gfl-wrapper {
	--gfl-min-col: 180px;
	--gfl-gap: 14px;
	--gfl-ratio: 22 / 17;
	--gfl-fit: contain;
	--gfl-radius: 6px;
	--gfl-hover-scale: 1.03;
	--gfl-placeholder: #f5f5f5;
	--gfl-caption-color: var(--text-color-base, #333);
	--gfl-accent: var(--ipeth-primary, #00b0e1);
	--gfl-accent-hover: #2c2c2c;
	--gfl-overlay: rgba(0, 0, 0, 0.9);
}

/* --- Rejilla --------------------------------------------------------------- */

.gfl-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--gfl-min-col)), 1fr));
	gap: var(--gfl-gap);
	margin-bottom: 1rem;
}

.gfl-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0;
}

.gfl-thumb {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	font: inherit;
	text-align: inherit;
	background: transparent;
	cursor: pointer;
	border-radius: var(--gfl-radius);
}

.gfl-thumb:hover {
	background-color: transparent !important;
}

.gfl-thumb:focus-visible {
	outline: 3px solid var(--gfl-accent);
	outline-offset: 3px;
}

.gfl-thumb img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--gfl-ratio);
	object-fit: var(--gfl-fit);
	background: var(--gfl-placeholder);
	border-radius: var(--gfl-radius);
	transition: transform 0.2s ease, opacity 0.3s ease;
}

.gfl-thumb img.gfl-lazy {
	opacity: 0;
}

.gfl-thumb img.gfl-lazy.loaded {
	opacity: 1;
}

.gfl-thumb img.gfl-lazy.load-error {
	opacity: 0.6;
}

.gfl-thumb:hover img {
	transform: scale(var(--gfl-hover-scale));
}

.gfl-caption {
	margin-top: 6px;
	font-size: 0.75rem;
	text-align: center;
	color: var(--gfl-caption-color);
	line-height: 1.3;
}

/* --- Paginación ------------------------------------------------------------ */

.gfl-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 0.875rem;
	font-size: 0.875rem;
}

.gfl-page-prev,
.gfl-page-next {
	padding: 0.375rem 0.75rem;
	border-radius: 2rem;
	background: var(--gfl-accent);
	color: #fff;
	border: 1px solid transparent;
	text-decoration: none !important;
	transition: background-color 0.2s ease;
}

.gfl-page-prev:hover,
.gfl-page-next:hover,
.gfl-page-prev:focus-visible,
.gfl-page-next:focus-visible {
	background: var(--gfl-accent-hover);
	color: #fff;
}

.gfl-page-info {
	color: #555;
}

/* --- Visor ----------------------------------------------------------------- */

.gfl-lightbox[hidden] {
	display: none !important;
}

.gfl-lightbox:not([hidden]) {
	display: flex;
}

body.gfl-lightbox-open {
	overflow: hidden;
}

.gfl-lightbox {
	position: fixed;
	inset: 0;
	background: var(--gfl-overlay);
	align-items: center;
	justify-content: center;
	/* Por debajo del panel de Elementor (z-index 9999) para no taparlo
	   al editar, y por encima de cabeceras fijas y banners. */
	z-index: 9998;
}

.gfl-lightbox-content {
	position: relative;
	max-width: 95vw;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.gfl-lightbox-img {
	max-width: 100%;
	max-height: 80vh;
	object-fit: contain;
	border-radius: 4px;
	transition: opacity 0.2s ease;
}

.gfl-lightbox-img.loading {
	opacity: 0.4;
}

.gfl-lightbox-img:not(.loading) {
	opacity: 1;
}

.gfl-lightbox-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	font-size: 2rem;
	line-height: 1;
	color: #fff;
	background: rgba(255, 255, 255, 0.1);
	border: none;
	padding: 0.5rem 0.75rem;
	border-radius: var(--gfl-radius);
	cursor: pointer;
	user-select: none;
}

.gfl-lightbox-nav:hover,
.gfl-lightbox-nav:focus-visible {
	background: rgba(255, 255, 255, 0.25);
	outline: 2px solid var(--gfl-accent);
}

.gfl-lightbox-prev {
	left: -60px;
}

.gfl-lightbox-next {
	right: -60px;
}

.gfl-lightbox-close {
	position: absolute;
	top: -44px;
	right: 0;
	font-size: 1.5rem;
	line-height: 1;
	color: #fff;
	cursor: pointer;
	background-color: var(--gfl-accent);
	border: 1px solid var(--gfl-accent);
	padding: 0.5rem 0.8rem;
	border-radius: 4px;
}

.gfl-lightbox-close:hover,
.gfl-lightbox-close:focus-visible {
	background-color: var(--gfl-accent-hover);
	border-color: var(--gfl-accent-hover);
	outline: 2px solid #fff;
}

.gfl-lightbox-caption {
	margin: 0.625rem 0 0;
	color: #fff;
	font-size: 0.875rem;
	text-align: center;
}

@media (max-width: 768px) {
	.gfl-lightbox-prev {
		left: 10px;
	}

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

	.gfl-lightbox-close {
		position: fixed;
		top: 10px;
		right: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gfl-thumb img,
	.gfl-lightbox-img,
	.gfl-page-prev,
	.gfl-page-next {
		transition: none;
	}

	.gfl-thumb:hover img {
		transform: none;
	}
}

/* Ocultar títulos (control "Ocultar título" del widget, vía prefix_class) */
.gfl-captions-hidden .gfl-caption {
	display: none;
}
