/*
 * F7 — Thanh mua hàng dính dưới màn hình: mobile tràn ngang, desktop là khung nổi giữa màn hình.
 * Chỉ nạp trên trang sản phẩm.
 * Màu lấy từ biến CSS của child theme (--kio-brand…) nếu có, kèm giá trị dự phòng.
 */

.kio-buy-bar[hidden] {
	display: none;
}

@media all {
	.kio-buy-bar {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 9998;
		display: flex;
		align-items: center;
		gap: 12px;
		padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
		/* Nền đậm: thanh này đè lên thẻ sản phẩm trắng, nền trắng thì không phân biệt được với nội dung. */
		background: var(--kio-brand-dark, #08347a);
		box-shadow: 0 -4px 20px rgba(8, 52, 122, 0.35);
		transform: translateY(110%);
		transition: transform 0.2s ease;
	}

	.kio-buy-bar.is-visible {
		transform: none;
	}

	/* Khi thanh mua hàng hiện thì tạm ẩn thanh công cụ dưới đáy của Storefront: 2 thanh chồng nhau chiếm quá nhiều màn hình. */
	.kio-buy-bar-visible .storefront-handheld-footer-bar {
		display: none;
	}

	.kio-buy-bar__info {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
	}

	.kio-buy-bar__name {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-size: 0.85rem;
		color: #fff;
	}

	.kio-buy-bar__price {
		font-weight: 700;
		color: #fff;
	}

	.kio-buy-bar__price .woocommerce-Price-amount,
	.kio-buy-bar__price ins {
		color: inherit;
	}

	.kio-buy-bar__price del {
		display: none; /* thanh nhỏ: chỉ hiện giá đang bán */
	}

	.kio-buy-bar__button {
		min-height: 44px;
		padding: 0 20px;
		border: 0;
		border-radius: var(--kio-radius, 12px);
		background: var(--kio-price, #d70018);
		color: #fff;
		font-weight: 700;
	}
}

@media (min-width: 769px) {
	.kio-buy-bar {
		right: auto;
		bottom: 16px;
		left: 50%;
		width: min(720px, calc(100vw - 32px));
		padding: 10px 12px 10px 20px;
		border-radius: var(--kio-radius, 12px);
		border: 1px solid rgba(255, 255, 255, 0.28); /* tách khỏi footer tối khi cuộn xuống cuối trang */
		box-shadow: 0 8px 28px rgba(8, 52, 122, 0.45);
		transform: translate(-50%, 160%);
	}

	.kio-buy-bar.is-visible {
		transform: translateX(-50%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.kio-buy-bar {
		transition: none;
	}
}
