/**
 * GM Diseño — Cantidad en el botón de carrito
 *
 * Nota importante sobre Shoptimizer:
 * en escritorio el botón del catálogo es `position:absolute; bottom:0` y se
 * ancla a `li.product`. Por eso ni el envoltorio ni el bloque del botón
 * pueden generar caja propia: usan `display:contents`. Si se les pone
 * `position:relative`, el botón del tema se ancla al envoltorio y aterriza
 * encima del precio.
 */

.gmcc {
	--gmcc-fondo: #2f80ed;
	--gmcc-texto: #fff;
	--gmcc-radio: 999px;
	--gmcc-alto: 44px;

	display: contents;
}

.gmcc__boton {
	display: contents;
}

.gmcc.is-activo .gmcc__boton {
	display: none;
}

.gmcc__control {
	display: none;
}

.gmcc.is-activo .gmcc__control {
	display: inline-flex;
}

/* WooCommerce añade su enlace «Ver carrito»: aquí sobra. */
.gmcc .added_to_cart {
	display: none !important;
}

/* --- El control --------------------------------------------------------- */

.gmcc__control {
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: var(--gmcc-alto);
	padding: 4px;
	border-radius: var(--gmcc-radio);
	background: var(--gmcc-fondo);
	color: var(--gmcc-texto);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	line-height: 1;
	vertical-align: middle;
}

.gmcc__paso {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: calc(var(--gmcc-alto) - 8px);
	height: calc(var(--gmcc-alto) - 8px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.15s ease;
}

.gmcc__paso:hover,
.gmcc__paso:focus-visible {
	background: rgba(255, 255, 255, 0.22);
}

.gmcc__paso:focus-visible {
	outline: 2px solid var(--gmcc-texto);
	outline-offset: 2px;
}

.gmcc__paso:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.gmcc__paso svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	pointer-events: none;
}

/* Los temas suelen estilar `input` con reglas muy específicas (ancho al
 * 100%, borde, fondo blanco). Por eso aquí se sube la especificidad y se
 * fuerzan las cuatro propiedades que romperían el control. */
.gmcc .gmcc__control input.gmcc__cantidad {
	box-sizing: border-box;
	flex: 0 0 auto;
	width: 40px !important;
	min-width: 0;
	max-width: none;
	height: calc(var(--gmcc-alto) - 8px);
	min-height: 0;
	margin: 0 !important;
	padding: 0 2px !important;
	border: 0 !important;
	border-radius: 8px;
	background: transparent !important;
	color: inherit;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	line-height: calc(var(--gmcc-alto) - 8px);
	-moz-appearance: textfield;
	appearance: none;
	box-shadow: none !important;
}

.gmcc .gmcc__control input.gmcc__cantidad:focus {
	outline: none;
	background: rgba(255, 255, 255, 0.16) !important;
}

.gmcc--fila:not(.is-activo) .gmcc__control input.gmcc__cantidad:focus {
	background: rgba(0, 0, 0, 0.05) !important;
}

.gmcc__cantidad::-webkit-outer-spin-button,
.gmcc__cantidad::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.gmcc.is-cargando .gmcc__cantidad {
	animation: gmcc-latido 0.9s ease-in-out infinite;
}

@keyframes gmcc-latido {
	50% {
		opacity: 0.45;
	}
}

/* --- Aviso (tope de existencias, errores) ------------------------------- */

.gmcc__aviso {
	position: absolute;
	z-index: 6;
	right: 15px;
	bottom: 48px;
	left: 15px;
	padding: 5px 8px;
	border-radius: 6px;
	background: #fff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
	color: #b3261e;
	font-size: 11px;
	line-height: 1.35;
	text-align: center;
}

/* --- Colocación en el catálogo -------------------------------------------
 * No se codifican aquí las medidas de ningún tema. El JavaScript mide el
 * botón real de cada tarjeta y copia su posición, su orden y su alto al
 * control. Lo de abajo es solo el punto de partida por si el script aún
 * no ha corrido.
 * --------------------------------------------------------------------- */

.gmcc__control {
	order: 9;
	opacity: 1;
}

.gmcc:not(.gmcc--overlay):not(.gmcc--fila) .gmcc__control {
	width: 100%;
}

/* --- Modo «flotando sobre la imagen» ------------------------------------ */

.gmcc--overlay .gmcc__control,
ul.products li.product .gmcc--overlay .gmcc__control {
	position: absolute;
	z-index: 5;
	top: 12px;
	right: 12px;
	bottom: auto;
	left: auto;
	width: auto;
	opacity: 1;
}

.gmcc--overlay .gmcc__aviso {
	top: 64px;
	bottom: auto;
}

/* --- Móvil ---------------------------------------------------------------
 * De 992px hacia abajo el tema ya devuelve el botón al flujo normal, así
 * que aquí solo se agrandan las zonas táctiles.
 * --------------------------------------------------------------------- */

@media (max-width: 992px) {
	.gmcc {
		--gmcc-alto: 46px;
	}

	.gmcc__cantidad {
		font-size: 16px; /* evita el zoom automático de iOS al enfocar */
	}

	.gmcc:not(.gmcc--overlay) .gmcc__control {
		width: 100%;
	}

	.gmcc--overlay .gmcc__control {
		top: 8px;
		right: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gmcc__paso,
	.gmcc.is-cargando .gmcc__cantidad {
		transition: none;
		animation: none;
	}
}

/* =========================================================================
 * Etiqueta «N en el carrito» en tarjetas de producto variable
 * ====================================================================== */

ul.products li.product {
	position: relative;
}

.gmcc-etiqueta {
	position: absolute;
	z-index: 3;
	top: 10px;
	left: 10px;
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--gmcc-fondo, #2f80ed);
	color: var(--gmcc-texto, #fff);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.4;
	pointer-events: none;
}

/* =========================================================================
 * Tabla de variaciones en la ficha de producto
 * ====================================================================== */

.gmcc-tabla {
	margin: 0 0 1.75rem;
}

.gmcc-tabla__intro {
	margin: 0 0 0.85rem;
	font-size: 0.875rem;
	opacity: 0.75;
}

.gmcc-tabla__grupo {
	margin: 1.25rem 0 0.4rem;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.gmcc-tabla__grupo:first-of-type {
	margin-top: 0;
}

.gmcc-tabla__filas {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid #e6e8eb;
}

/* Rejilla en vez de flex: cada dato tiene su celda, así ningún estilo
 * heredado del tema puede montar un elemento encima de otro. */
.gmcc-tabla__fila {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	align-items: center;
	column-gap: 14px;
	margin: 0;
	padding: 10px 0;
	border-bottom: 1px solid #e6e8eb;
	list-style: none;
}

.gmcc-tabla__fila.is-agotada {
	opacity: 0.55;
}

.gmcc-tabla__datos {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.gmcc-tabla__nombre {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
}

.gmcc-tabla__sku,
.gmcc-tabla__stock {
	font-size: 0.75rem;
	line-height: 1.3;
	opacity: 0.7;
}

/* El precio de una variación llega como HTML del tema o de otros plugins
 * (rebajas, precio referencial en Bs.). Se neutraliza cualquier margen o
 * posicionamiento heredado para que no se salga de su celda. */
.gmcc-tabla__precio {
	display: block;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.35;
	text-align: right;
	white-space: nowrap;
}

.gmcc-tabla__precio * {
	position: static !important;
	float: none !important;
	margin: 0 !important;
	padding: 0 !important;
	font-size: inherit;
	line-height: 1.35;
}

.gmcc-tabla__precio del {
	display: block;
	font-weight: 400;
	opacity: 0.55;
}

.gmcc-tabla__precio small,
.gmcc-tabla__precio .gm-ref,
.gmcc-tabla__precio .woocommerce-price-suffix {
	display: block;
	font-size: 0.75rem !important;
	font-weight: 400;
	opacity: 0.65;
}

.gmcc-tabla__accion {
	justify-self: end;
}

.gmcc-tabla__agotada {
	display: inline-block;
	font-size: 0.75rem;
	white-space: nowrap;
}

/* --- Control dentro de la tabla: compacto y visible también en cero ----- */

.gmcc--fila {
	--gmcc-alto: 40px;

	display: inline-block;
}

.gmcc--fila .gmcc__control {
	display: inline-flex;
	position: static;
	width: auto;
	opacity: 1;
}

.gmcc--fila:not(.is-activo) .gmcc__control {
	border: 1px solid #d5d8dd;
	background: transparent;
	color: #3c4149;
	box-shadow: none;
}

.gmcc--fila:not(.is-activo) .gmcc__paso:hover,
.gmcc--fila:not(.is-activo) .gmcc__paso:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

.gmcc--fila .gmcc__aviso {
	position: static;
	display: block;
	margin-top: 4px;
	padding: 0;
	background: none;
	box-shadow: none;
	font-size: 11px;
	text-align: right;
}

/* --- Pie con el total --------------------------------------------------- */

.gmcc-tabla__pie {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 1.15rem;
}

.gmcc-tabla__resumen {
	font-size: 0.9375rem;
}

.gmcc-tabla:not(.tiene-unidades) .gmcc-tabla__resumen {
	opacity: 0.6;
}

.gmcc-tabla:not(.tiene-unidades) .gmcc-tabla__ir {
	pointer-events: none;
	opacity: 0.4;
}

/* --- Pantallas estrechas ------------------------------------------------ */

@media (max-width: 600px) {
	.gmcc-tabla__fila {
		grid-template-columns: minmax(0, 1fr) auto;
		row-gap: 8px;
	}

	.gmcc-tabla__accion,
	.gmcc-tabla__agotada {
		grid-column: 2;
		grid-row: 1;
	}

	.gmcc-tabla__precio {
		grid-column: 1 / -1;
		text-align: left;
		white-space: normal;
	}

	.gmcc-tabla__pie {
		flex-direction: column;
		align-items: stretch;
	}

	.gmcc-tabla__ir {
		text-align: center;
	}
}

/* =========================================================================
 * Aviso flotante al cambiar la cantidad
 * ====================================================================== */

.gmcc-avisos {
	position: fixed;
	z-index: 999999;
	display: flex;
	flex-direction: column-reverse;
	gap: 8px;
	max-width: min(360px, calc(100vw - 32px));
	pointer-events: none;
}

.gmcc-avisos--abajo-derecha {
	right: 16px;
	bottom: 16px;
}

.gmcc-avisos--abajo-centro {
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
}

.gmcc-avisos--arriba-derecha {
	top: 16px;
	right: 16px;
}

.gmcc-aviso {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
	color: #1f2328;
	pointer-events: auto;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.gmcc-aviso.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.gmcc-aviso::before {
	content: "";
	flex: 0 0 3px;
	align-self: stretch;
	border-radius: 3px;
	background: var(--gmcc-fondo, #2f80ed);
}

.gmcc-aviso.is-quitado::before {
	background: #9aa1ab;
}

.gmcc-aviso__medio {
	flex: 0 0 auto;
}

.gmcc-aviso__medio img {
	display: block;
	width: 38px;
	height: 38px;
	border-radius: 6px;
	object-fit: contain;
}

.gmcc-aviso__texto {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.gmcc-aviso__nombre {
	overflow: hidden;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.gmcc-aviso__estado {
	font-size: 0.75rem;
	opacity: 0.7;
}

.gmcc-aviso__enlace {
	flex: 0 0 auto;
	font-size: 0.75rem;
	font-weight: 600;
	text-decoration: underline;
	white-space: nowrap;
}

.gmcc-aviso.is-quitado .gmcc-aviso__enlace {
	display: none;
}

.gmcc-aviso__cerrar {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.45;
}

.gmcc-aviso__cerrar:hover,
.gmcc-aviso__cerrar:focus-visible {
	opacity: 1;
}

@media (max-width: 600px) {
	.gmcc-avisos {
		right: 12px;
		left: 12px;
		max-width: none;
		transform: none;
	}

	.gmcc-avisos--abajo-derecha,
	.gmcc-avisos--abajo-centro {
		bottom: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gmcc-aviso {
		transform: none;
		transition: opacity 0.15s ease;
	}
}
