/**
 * Agápico Brands Grid - Estilos
 * Plugin author: TelFo NeTWorks (https://www.telfo.com/)
 * v1.1.2
 */

/*
 * Fix Elementor Flexbox Containers:
 * El widget shortcode dentro de un .e-con-inner con flex-direction:column
 * no se estira al 100% por defecto. Forzamos SOLO el widget directo del
 * shortcode (no sus ancestros), respetando así el max-width del container
 * padre que el usuario haya configurado en Elementor.
 *
 * El selector :has() funciona en navegadores modernos (Chrome 105+,
 * Firefox 121+, Safari 15.4+).
 */
.elementor-widget:has(> .elementor-widget-container > .abg-grid),
.elementor-widget:has(> .elementor-widget-container > .abg-block),
.elementor-widget-container:has(> .abg-grid),
.elementor-widget-container:has(> .abg-block) {
	width: 100%;
	max-width: 100%;
	align-self: stretch;
}

.abg-grid {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	align-self: stretch;
}

.abg-grid *,
.abg-grid *::before,
.abg-grid *::after {
	box-sizing: border-box;
}

/* Grid responsive */
.abg-grid .abg-items {
	display: grid;
	grid-template-columns: repeat(var(--abg-cols, 4), minmax(0, 1fr));
	gap: var(--abg-gap, 24px);
	align-items: stretch;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

@media (max-width: 1024px) {
	.abg-grid .abg-items {
		grid-template-columns: repeat(var(--abg-cols-tablet, 3), minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.abg-grid .abg-items {
		grid-template-columns: repeat(var(--abg-cols-mobile, 2), minmax(0, 1fr));
	}
}

/* Tarjeta */
.abg-grid .abg-item {
	display: flex;
	text-decoration: none;
	color: inherit;
	background: var(--abg-card-bg, #fff);
	border: 1px solid var(--abg-card-border, #e5e5e5);
	border-radius: var(--abg-card-radius, 8px);
	padding: var(--abg-card-pad, 20px);
	box-shadow: var(--abg-card-shadow, 0 1px 3px rgba(0, 0, 0, 0.06));
	transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
	overflow: hidden;
	min-width: 0;
	min-height: var(--abg-min-h, auto);
	height: 100%;
}

/* Estructura interna: por defecto el nombre se ancla abajo (name_position=bottom).
   La imagen ocupa el espacio sobrante, el texto queda clavado al pie de la tarjeta. */
.abg-grid .abg-item-inner {
	display: flex;
	flex-direction: column;
	align-items: var(--abg-align-h, center);
	width: 100%;
	gap: 12px;
	min-width: 0;
	flex: 1 1 auto;
}

/* Imagen
 * El truco: la imagen llena el área disponible (ancho 100% / alto 100% del wrapper)
 * pero con object-fit:contain mantiene proporción y se centra. Así TODAS las
 * imágenes ocupan el mismo área visual (definida por --abg-img-max-w y
 * --abg-img-max-h en el wrapper), sin que las que son naturalmente pequeñas
 * o de formato distinto queden desalineadas o desproporcionadas.
 */
.abg-grid .abg-image-wrap {
	display: flex;
	align-items: var(--abg-align-v, center);
	justify-content: var(--abg-align-h, center);
	width: 100%;
	flex: 1 1 auto;
	min-height: 0;
	/* Caja fija para que TODAS las imágenes tengan el mismo área disponible */
	height: var(--abg-img-max-h, 120px);
	max-height: var(--abg-img-max-h, 120px);
}

.abg-grid .abg-image {
	display: block;
	/* La imagen llena la caja, pero contain preserva proporción y centra */
	width: 100%;
	height: 100%;
	max-width: var(--abg-img-max-w, 100%);
	max-height: var(--abg-img-max-h, 100%);
	object-fit: var(--abg-img-fit, contain);
	object-position: center center;
}

.abg-grid .abg-text {
	width: 100%;
	text-align: var(--abg-text-align, center);
	display: flex;
	flex-wrap: wrap;
	justify-content: var(--abg-align-h, center);
	gap: 4px 6px;
	flex: 0 0 auto;
}

/* Posición del nombre: bottom (defecto) — texto pegado al fondo */
.abg-grid[data-name-pos="bottom"] .abg-text {
	margin-top: auto;
}

/* Posición top — texto arriba, imagen abajo */
.abg-grid[data-name-pos="top"] .abg-item-inner {
	flex-direction: column-reverse;
}
.abg-grid[data-name-pos="top"] .abg-text {
	margin-bottom: auto;
}

/* Posición inline — texto justo debajo de la imagen, sin separación al fondo */
.abg-grid[data-name-pos="inline"] .abg-item-inner {
	justify-content: center;
}

/* Placeholder con iniciales si la marca no tiene logo */
.abg-grid .abg-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 80px;
	background: #f3f3f3;
	border-radius: 6px;
	color: #888;
	font-weight: 700;
	font-size: 22px;
	letter-spacing: 0.05em;
}

/* Texto del nombre */
.abg-grid .abg-name {
	color: var(--abg-name-color, #222);
	font-size: var(--abg-name-size, 14px);
	font-weight: var(--abg-name-weight, 500);
	line-height: 1.3;
}

.abg-grid .abg-count {
	color: #888;
	font-size: calc(var(--abg-name-size, 14px) - 1px);
}

.abg-grid .abg-desc {
	display: block;
	width: 100%;
	color: #555;
	font-size: calc(var(--abg-name-size, 14px) - 1px);
	line-height: 1.4;
	margin-top: 4px;
}

a.abg-item:hover,
a.abg-item:focus {
	text-decoration: none;
	color: inherit;
}

/* Hover effects */
.abg-grid[data-hover="lift"] a.abg-item:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.abg-grid[data-hover="zoom"] a.abg-item .abg-image {
	transition: transform 0.3s ease;
}
.abg-grid[data-hover="zoom"] a.abg-item:hover .abg-image {
	transform: scale(1.06);
}

.abg-grid[data-hover="fade"] a.abg-item:hover {
	opacity: 0.75;
}

/* Foco para accesibilidad */
a.abg-item:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Botón cargar más */
.abg-grid .abg-loadmore-wrap {
	display: flex;
	justify-content: center;
	margin-top: 24px;
}

.abg-grid .abg-loadmore {
	display: inline-block;
	padding: 12px 28px;
	font-size: 14px;
	font-weight: 600;
	background: #222;
	color: #fff;
	border: none;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.2s ease, opacity 0.2s ease;
	font-family: inherit;
	line-height: 1.2;
}

.abg-grid .abg-loadmore:hover {
	background: #444;
}

.abg-grid .abg-loadmore:disabled {
	opacity: 0.5;
	cursor: default;
}

.abg-grid .abg-loadmore.is-loading {
	opacity: 0.7;
	pointer-events: none;
}

/* Paginación */
.abg-grid .abg-pagination {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 28px;
	flex-wrap: wrap;
}

.abg-grid .abg-page,
.abg-grid .abg-page-dots {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 10px;
	border-radius: 6px;
	font-size: 14px;
	text-decoration: none;
	color: #222;
	background: #f5f5f5;
	border: 1px solid transparent;
	transition: background 0.2s ease, color 0.2s ease;
	line-height: 1;
}

.abg-grid a.abg-page:hover {
	background: #e5e5e5;
	color: #222;
}

.abg-grid .abg-page-current {
	background: #222;
	color: #fff;
	font-weight: 600;
}

.abg-grid .abg-page-dots {
	background: transparent;
	color: #888;
}

/* Mensajes */
.abg-empty,
.abg-error {
	padding: 16px 20px;
	border-radius: 6px;
	background: #f8f8f8;
	color: #666;
	font-size: 14px;
	text-align: center;
}

.abg-error {
	background: #fff4f4;
	color: #a33;
	border: 1px solid #f1c2c2;
}
