/* ==========================================================================
   KP — Checkout y carrito en movil
   Solo presentacion. Todo lo de abajo de 768px, salvo lo marcado.
   ========================================================================== */

:root {
	--kp-rojo: #e10600;
	--kp-borde: #d8d8d8;
	--kp-gris-texto: #555;
	--kp-radio: 10px;
	--kp-sombra-barra: 0 -6px 18px rgba(0, 0, 0, .14);
}

/* --- Metodo de pago seleccionado: que se note cual eligio ---------------- */

.woocommerce-checkout .wc_payment_method {
	border: 1px solid transparent;
	border-radius: var(--kp-radio);
	padding: 10px 12px;
	margin: 0 0 6px;
	transition: border-color .18s ease, background-color .18s ease;
}

.woocommerce-checkout .wc_payment_method:has(input:checked) {
	border-color: var(--kp-rojo);
	background: rgba(225, 6, 0, .04);
}

.woocommerce-checkout .payment_box {
	animation: kp-aparecer .22s ease both;
}

@keyframes kp-aparecer {
	from { opacity: 0; transform: translateY(-4px); }
	to   { opacity: 1; transform: none; }
}

/* --- Resumen plegable ---------------------------------------------------- */

.kp-resumen-boton {
	display: none;
	color: #111;
	width: 100%;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 14px 16px;
	margin: 0 0 10px;
	background: #fff;
	border: 1px solid var(--kp-borde);
	border-radius: var(--kp-radio);
	font: inherit;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
}

.kp-resumen-boton span {
	color: inherit;
}

.kp-resumen-boton__total {
	margin-left: auto;
	color: var(--kp-rojo);
}

.kp-resumen-boton__flecha {
	transition: transform .22s ease;
	flex: 0 0 auto;
}

.kp-resumen-boton[aria-expanded="true"] .kp-resumen-boton__flecha {
	transform: rotate(180deg);
}

/* --- Barra fija de abajo ------------------------------------------------- */

.kp-barra-fija {
	display: none;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9998;
	align-items: center;
	gap: 12px;
	padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
	background: #fff;
	border-top: 1px solid var(--kp-borde);
	box-shadow: var(--kp-sombra-barra);
	transform: translateY(110%);
	transition: transform .25s ease;
}

.kp-barra-fija.kp-visible {
	transform: none;
}

.kp-barra-fija__datos {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
	min-width: 0;
}

.kp-barra-fija__etiqueta {
	font-size: 12px;
	color: var(--kp-gris-texto);
}

.kp-barra-fija__total {
	font-size: 18px;
	font-weight: 700;
	white-space: nowrap;
}

.kp-barra-fija__boton {
	flex: 1 1 auto;
	min-height: 48px;
	padding: 12px 18px;
	border: 0;
	border-radius: var(--kp-radio);
	background: var(--kp-rojo);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	transition: transform .12s ease, opacity .18s ease;
}

.kp-barra-fija__boton:active {
	transform: scale(.97);
}

.kp-barra-fija__boton[disabled] {
	opacity: .6;
	cursor: default;
}

.kp-aviso-terminos {
	position: fixed;
	left: 14px;
	right: 14px;
	bottom: calc(76px + env(safe-area-inset-bottom));
	z-index: 9999;
	padding: 10px 14px;
	border-radius: var(--kp-radio);
	background: #222;
	color: #fff;
	font-size: 14px;
	text-align: center;
	animation: kp-aparecer .2s ease both;
}

/* ==========================================================================
   Celular
   ========================================================================== */

@media (max-width: 767px) {

	/* Compactar el formulario: menos aire entre campos */
	.woocommerce-checkout .form-row,
	.woocommerce-checkout .woocommerce-billing-fields p,
	.woocommerce-checkout .woocommerce-additional-fields p {
		margin-bottom: 10px;
	}

	.woocommerce-checkout .form-row label {
		margin-bottom: 4px;
		font-size: 14px;
	}

	.woocommerce-checkout .input-text,
	.woocommerce-checkout select {
		min-height: 46px;
		padding: 10px 12px;
		font-size: 16px; /* 16px evita que iOS haga zoom al enfocar */
	}

	.woocommerce-checkout h3,
	.woocommerce-cart h2 {
		font-size: 18px;
		margin: 0 0 10px;
	}

	/* El resumen se pliega */
	.kp-resumen-boton {
		display: flex;
	}

	.kp-colapsable {
		overflow: hidden;
		max-height: 0;
		opacity: 0;
		transition: max-height .28s ease, opacity .2s ease;
	}

	.kp-colapsable.kp-abierto {
		max-height: 2200px;
		opacity: 1;
	}

	/* La barra fija aparece */
	.kp-barra-fija {
		display: flex;
	}

	/* Hueco para que la barra no tape el final de la pagina */
	body.kp-con-barra-fija {
		padding-bottom: 92px;
	}

	/* El boton flotante de WhatsApp vive abajo a la derecha, justo donde
	   aparece la barra. Se sube para que no se encimen. */
	body.kp-con-barra-fija .e-contact-buttons {
		bottom: calc(96px + env(safe-area-inset-bottom)) !important;
		transition: bottom .25s ease;
	}

	/* El boton original sigue existiendo y funcionando, solo deja de
	   ocupar la pantalla completa al final */
	.woocommerce-checkout #place_order {
		width: 100%;
	}

	/* ----------------------------------------------------------------
	   Carrito en dos columnas, al estilo de Mercado Libre:
	   la foto a la izquierda y todo lo del producto a la derecha.
	   Antes cada dato ocupaba su propio renglon de ancho completo y
	   la foto quedaba sola en medio de un hueco enorme.
	   ---------------------------------------------------------------- */

	.woocommerce-cart table.shop_table_responsive,
	.woocommerce-cart table.shop_table_responsive tbody {
		display: block;
		width: 100%;
	}

	/* El encabezado de columnas no sirve de nada ya apilado */
	.woocommerce-cart table.shop_table_responsive thead {
		display: none;
	}

	.woocommerce-cart table.shop_table_responsive tbody tr.cart_item {
		position: relative;
		display: grid;
		grid-template-columns: 84px minmax(0, 1fr);
		grid-template-areas:
			"foto nombre"
			"foto precio"
			"foto cantidad"
			"foto subtotal";
		column-gap: 12px;
		row-gap: 3px;
		align-items: start;
		margin: 0 0 10px;
		padding: 12px 34px 12px 12px;
		border: 1px solid var(--kp-borde);
		border-radius: var(--kp-radio);
		background: #fff;
	}

	.woocommerce-cart table.shop_table_responsive tbody tr.cart_item td {
		display: block;
		width: auto;
		border: 0;
		/* WooCommerce alinea a la derecha y mete relleno vertical desde su
		   propia hoja para pantallas chicas, y esa hoja carga despues que
		   esta. Sin esto cada renglon mide 42 px en vez de 24. */
		padding: 0 !important;
		text-align: left !important;
		/* Algo del tema le fija una altura explicita a cada celda y deja
		   cada renglon en 42 px aunque el texto mida 18. Con esto la
		   tarjeta pasa de 209 px a 146. */
		height: auto !important;
		min-height: 0 !important;
		font-size: 14px;
		line-height: 1.35;
	}

	/* La etiqueta que WooCommerce inyecta ("Precio:", "Cantidad:") */
	.woocommerce-cart table.shop_table_responsive tbody tr.cart_item td::before {
		display: inline !important;
		float: none !important;
		width: auto !important;
		margin-right: 6px;
		font-weight: 400;
		font-size: 12px;
		color: var(--kp-gris-texto);
		text-align: left;
	}

	/* Foto: ocupa la columna izquierda completa */
	.woocommerce-cart tr.cart_item td.product-thumbnail {
		grid-area: foto;
		align-self: center;
	}

	.woocommerce-cart tr.cart_item td.product-thumbnail::before {
		content: none;
	}

	.woocommerce-cart tr.cart_item td.product-thumbnail img {
		display: block;
		width: 84px;
		height: 84px;
		max-width: none;
		object-fit: contain;
		border-radius: 6px;
	}

	/* Nombre: lo primero que se lee, sin la etiqueta "Producto:" */
	.woocommerce-cart tr.cart_item td.product-name {
		grid-area: nombre;
		padding-right: 4px;
		font-size: 15px;
		font-weight: 600;
		line-height: 1.25;
	}

	.woocommerce-cart tr.cart_item td.product-name::before {
		content: none;
	}

	.woocommerce-cart tr.cart_item td.product-name a {
		color: #111 !important;
		text-decoration: none;
	}

	.woocommerce-cart tr.cart_item td.product-price {
		grid-area: precio;
		color: var(--kp-gris-texto);
	}

	.woocommerce-cart tr.cart_item td.product-quantity {
		grid-area: cantidad;
		justify-content: flex-start;
		display: flex !important;
		align-items: center;
		gap: 6px;
		margin-top: 4px;
	}

	.woocommerce-cart tr.cart_item td.product-quantity .quantity input.qty {
		width: 58px;
		min-height: 36px;
		padding: 4px 6px;
		text-align: center;
		font-size: 15px;
	}

	.woocommerce-cart tr.cart_item td.product-subtotal {
		grid-area: subtotal;
		margin-top: 2px;
		font-size: 16px;
		font-weight: 700;
	}

	/* La X, arrinconada arriba a la derecha en vez de ocupar un renglon.
	   Sin el !important se queda dentro de la cuadricula y estira todos
	   los renglones a su alto. */
	.woocommerce-cart tr.cart_item td.product-remove {
		position: absolute !important;
		top: 8px;
		right: 8px;
		width: auto !important;
		min-height: 0 !important;
	}

	.woocommerce-cart tr.cart_item td.product-remove::before {
		content: none;
	}

	.woocommerce-cart tr.cart_item td.product-remove a.remove {
		display: block;
		width: 24px;
		height: 24px;
		line-height: 24px;
		font-size: 18px;
	}

	/* La fila de "actualizar carrito" y el cupon tambien apretados */
	.woocommerce-cart table.shop_table_responsive tbody tr:not(.cart_item) td {
		display: block;
		padding: 8px 0 0;
		border: 0;
	}

	.woocommerce-cart table.shop_table_responsive tbody tr:not(.cart_item) td::before {
		content: none;
	}
}
