/* AG Giỏ hàng nổi – Author: August - https://augustcsgo.com */
.agfc {
	--fc-c1: #0f9d6c;
	--fc-c2: #4cc38a;
	--fc-size: 66px;
	--fc-nav: 0px;
	position: fixed;
	right: 18px;
	bottom: calc(92px + var(--fc-nav));
	z-index: 9990;
	width: var(--fc-size);
	height: var(--fc-size);
	pointer-events: none;
	-webkit-tap-highlight-color: transparent;
}
.agfc *, .agfc *::before, .agfc *::after { box-sizing: border-box; }
.agfc.is-left { right: auto; left: 18px; }
/* Ghim giữa cạnh màn hình (không đè nút "lên đầu trang" ở góc dưới) */
.agfc.is-mid { top: calc(50% - var(--fc-size) / 2); bottom: auto; }
.agfc > * { pointer-events: auto; }
.agfc-panel[hidden], .agfc-back[hidden] { display: none !important; }

/* Thiết bị */
@media (max-width: 849px) { .agfc.on-desktop { display: none; } }
@media (min-width: 850px) { .agfc.on-mobile { display: none; } }

/* ===== Bong bóng ===== */
.agfc-bub {
	position: relative;
	display: block;
	width: var(--fc-size);
	height: var(--fc-size);
	min-height: 0;
	margin: 0;
	padding: 0;
	color: #fff;
	background: none;
	border: 0;
	border-radius: 50%;
	box-shadow: none;
	cursor: pointer;
	opacity: 0;
	transform: translateX(160%) scale(.6);
	transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), opacity .3s;
}
.agfc.is-left .agfc-bub { transform: translateX(-160%) scale(.6); }
.agfc.is-show .agfc-bub { opacity: 1; transform: none; }
.agfc.is-show.is-peek .agfc-bub { opacity: .8; transform: translateX(58%) scale(.84); }
.agfc.is-left.is-show.is-peek .agfc-bub { transform: translateX(-58%) scale(.84); }
.agfc-bub:hover, .agfc-bub:focus { color: #fff; background: none; }
.agfc-bub:focus-visible { outline: 3px solid rgba(15, 157, 108, .35); outline-offset: 4px; }

.agfc-blob {
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, var(--fc-c1), var(--fc-c2));
	border-radius: 58% 42% 52% 48% / 46% 58% 42% 54%;
	box-shadow: 0 12px 26px rgba(11, 107, 74, .35), inset 0 -6px 12px rgba(0, 0, 0, .08);
	animation: agfc-morph 7s ease-in-out infinite alternate;
	transition: transform .25s;
}
.agfc-blob::after {
	content: "";
	position: absolute;
	right: -7px;
	bottom: 2px;
	width: 12px;
	height: 12px;
	background: var(--fc-c2);
	border-radius: 50%;
	box-shadow: 0 4px 8px rgba(11, 107, 74, .25);
}
.agfc.is-left .agfc-blob::after { right: auto; left: -7px; }
.agfc-bub:hover .agfc-blob { transform: scale(1.07) rotate(-4deg); }
@keyframes agfc-morph {
	0% { border-radius: 58% 42% 52% 48% / 46% 58% 42% 54%; }
	50% { border-radius: 44% 56% 40% 60% / 58% 42% 58% 42%; }
	100% { border-radius: 52% 48% 62% 38% / 42% 54% 46% 58%; }
}
.agfc-ico { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.agfc-ico svg { display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .15)); }
.agfc-bub .agfc-count {
	position: absolute;
	top: -3px;
	left: -5px;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	font-size: 12px;
	font-weight: 800;
	line-height: 20px;
	color: #4a3200;
	text-align: center;
	background: #f7b731;
	border: 2px solid #fff;
	border-radius: 999px;
	box-shadow: 0 3px 8px rgba(0, 0, 0, .15);
}
.agfc.is-left .agfc-bub .agfc-count { left: auto; right: -5px; }
.agfc-bub .agfc-count[data-n="0"] { display: none; }
.agfc-pill {
	position: absolute;
	top: calc(100% + 6px);
	left: 50%;
	padding: 3px 10px;
	font-size: 12px;
	font-weight: 800;
	line-height: 1.4;
	color: var(--fc-c1);
	white-space: nowrap;
	background: #fff;
	border-radius: 999px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
	transform: translateX(-50%);
}
.agfc-pill .amount { color: inherit; }
.agfc:not(.has-items) .agfc-pill { display: none; }

.agfc-bub.is-bounce .agfc-blob { animation: agfc-bounce .7s cubic-bezier(.34, 1.56, .64, 1), agfc-morph 7s ease-in-out infinite alternate; }
@keyframes agfc-bounce {
	0% { transform: scale(1); }
	30% { transform: scale(1.25) rotate(-8deg); }
	55% { transform: scale(.92) rotate(5deg); }
	100% { transform: scale(1); }
}

/* Báo nhỏ "Đã thêm vào giỏ" */
.agfc-toast {
	position: absolute;
	top: 50%;
	right: calc(100% + 12px);
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 800;
	color: var(--fc-c1);
	white-space: nowrap;
	background: #fff;
	border-radius: 999px;
	box-shadow: 0 8px 22px rgba(0, 0, 0, .14);
	opacity: 0;
	transform: translate(10px, -50%);
	transition: opacity .25s, transform .25s;
	pointer-events: none;
}
.agfc.is-left .agfc-toast { right: auto; left: calc(100% + 12px); transform: translate(-10px, -50%); }
.agfc.is-toast .agfc-toast { opacity: 1; transform: translate(0, -50%); }

/* ===== Hộp giỏ hàng (máy tính: hộp nổi cạnh bong bóng) ===== */
.agfc-back {
	position: fixed;
	inset: 0;
	z-index: 1;
	background: rgba(15, 23, 42, .18);
	opacity: 0;
	transition: opacity .3s;
}
.agfc.is-open .agfc-back { opacity: 1; }
.agfc-bub { z-index: 3; }
.agfc-panel {
	position: fixed;
	right: 100px;
	bottom: 24px;
	z-index: 2;
	display: flex;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - 130px);
	max-height: min(660px, calc(100vh - 48px));
	overflow: hidden;
	color: #1f2937;
	background: #fff;
	border-radius: 24px;
	box-shadow: 0 28px 70px rgba(15, 23, 42, .28);
	opacity: 0;
	transform: translateX(18px) scale(.9);
	transform-origin: 100% 85%;
	transition: transform .32s cubic-bezier(.34, 1.4, .64, 1), opacity .22s;
}
.agfc.is-left .agfc-panel { right: auto; left: 100px; transform: translateX(-18px) scale(.9); transform-origin: 0 85%; }
.agfc.is-open .agfc-panel { opacity: 1; transform: none; }
.agfc-grab { display: none; }

.agfc-head { display: flex; align-items: center; gap: 8px; padding: 18px 18px 10px; }
.agfc-head b { font-size: 17px; font-weight: 800; }
.agfc-head .agfc-count { padding: 2px 9px; font-size: 12px; font-weight: 800; color: var(--fc-c1); background: #e8f7ef; border-radius: 999px; }
.agfc-x {
	width: 34px;
	height: 34px;
	min-height: 0;
	margin: 0 0 0 auto;
	padding: 0;
	font-size: 15px;
	line-height: 1;
	color: #6b7280;
	background: #f3f4f6;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}
.agfc-x:hover { color: #111827; background: #e5e7eb; }
.agfc-x:focus { outline: none; box-shadow: none; }
.agfc-x:focus-visible { outline: 2px solid var(--fc-c1); outline-offset: 2px; }

.agfc-ship { margin: 0 18px 8px; padding: 10px 12px; background: #f0faf5; border-radius: 12px; }
.agfc-ship p { margin: 0 0 7px; font-size: 13px; line-height: 1.4; color: #374151; }
.agfc-ship b { color: var(--fc-c1); }
.agfc-ship__bar { height: 7px; overflow: hidden; background: #d6efe2; border-radius: 999px; }
.agfc-ship__bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--fc-c1), var(--fc-c2)); border-radius: inherit; transition: width .5s; }
.agfc-ship.is-done { background: #fff8e6; }
.agfc-ship.is-done .agfc-ship__bar i { background: linear-gradient(90deg, #f7b731, #f59e0b); }

.agfc-body { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.agfc-body .widget_shopping_cart_content { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.agfc-panel ul.cart_list {
	flex: 1 1 auto;
	min-height: 0;
	margin: 0 !important;
	padding: 0 18px !important;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
	-webkit-overflow-scrolling: touch;
}
.agfc-panel ul.cart_list li.mini_cart_item {
	position: relative;
	min-height: 90px;
	margin: 0 !important;
	padding: 13px 34px 13px 78px !important;
	list-style: none;
	border-bottom: 1px dashed #e5efe9;
}
.agfc-panel ul.cart_list li.mini_cart_item:last-child { border-bottom: 0; }
.agfc-panel ul.cart_list li.mini_cart_item img {
	position: absolute !important;
	top: 13px;
	left: 0;
	width: 64px !important;
	height: 64px !important;
	max-width: none;
	margin: 0 !important;
	object-fit: cover;
	border-radius: 12px;
}
.agfc-panel ul.cart_list li.mini_cart_item > a:not(.remove) { display: block; font-size: 14px; font-weight: 700; line-height: 1.35; color: #1f2937; }
.agfc-panel ul.cart_list li.mini_cart_item > a:not(.remove):hover { color: var(--fc-c1); }
.agfc-panel dl.variation { margin: 4px 0 0 !important; padding: 0 !important; font-size: 12px; line-height: 1.5; color: #6b7280; border: 0 !important; }
.agfc-panel dl.variation dt, .agfc-panel dl.variation dd { display: inline; float: none; margin: 0; padding: 0; font-weight: 400; }
.agfc-panel dl.variation dd p { display: inline; margin: 0; }
.agfc-panel dl.variation dd::after { content: ""; display: block; }
.agfc-panel li.mini_cart_item .quantity { display: block; margin-top: 4px; font-size: 13px; color: #6b7280; opacity: 1; }
.agfc-panel li.mini_cart_item .quantity .amount { font-weight: 800; color: #ef4444; }
.agfc-panel ul.cart_list li a.remove {
	position: absolute !important;
	top: 13px;
	right: 0;
	left: auto !important;
	width: 26px;
	height: 26px;
	margin: 0;
	font-size: 17px;
	line-height: 23px;
	color: #9ca3af !important;
	text-align: center;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 50%;
}
.agfc-panel ul.cart_list li a.remove:hover { color: #ef4444 !important; background: #fee2e2; border-color: #fecaca; }

.agfc-panel .ux-mini-cart-footer {
	flex: 0 0 auto;
	margin: 0;
	padding: 12px 18px 16px;
	background: #fff;
	border-top: 1px solid #eef2f0;
	box-shadow: 0 -10px 22px rgba(15, 23, 42, .05);
}
.agfc-panel .woocommerce-mini-cart__total { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 10px !important; padding: 0 !important; font-size: 15px; border: 0 !important; }
.agfc-panel .woocommerce-mini-cart__total strong { font-weight: 700; color: #374151; }
.agfc-panel .woocommerce-mini-cart__total .amount { font-size: 19px; font-weight: 800; color: #ef4444; }
.agfc-panel .woocommerce-mini-cart__buttons { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; margin: 0 !important; padding: 0 !important; }
.agfc-panel .woocommerce-mini-cart__buttons a.button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	margin: 0 !important;
	padding: 0 10px;
	font-size: 14px;
	font-weight: 800;
	line-height: 1.2;
	color: var(--fc-c1);
	text-transform: none;
	letter-spacing: 0;
	background: #fff;
	border: 1.5px solid var(--fc-c1);
	border-radius: 14px;
	box-shadow: none;
}
.agfc-panel .woocommerce-mini-cart__buttons a.button:hover { color: #fff; background: var(--fc-c1); }
.agfc-panel .woocommerce-mini-cart__buttons a.button.checkout {
	color: #fff;
	background: linear-gradient(135deg, var(--fc-c1), var(--fc-c2));
	border: 0;
	box-shadow: 0 8px 18px rgba(15, 157, 108, .3);
}
.agfc-panel .woocommerce-mini-cart__buttons a.button.checkout:hover { filter: brightness(1.06); }
.agfc-panel .ux-mini-cart-empty { padding: 34px 18px 40px; }
.agfc-panel .woocommerce-mini-cart__empty-message { margin: 0; font-size: 15px; color: #6b7280; }
.agfc-panel .blockUI.blockOverlay { border-radius: 0; }

/* ===== Điện thoại / tablet: bong bóng nhỏ + tấm trượt từ dưới lên ===== */
@media (max-width: 849px) {
	.agfc { --fc-size: 54px; right: 12px; bottom: calc(16px + var(--fc-nav) + env(safe-area-inset-bottom, 0px)); }
	.agfc.is-mid { top: calc(50% - var(--fc-size) / 2); bottom: auto; right: 10px; }
	.agfc.is-left.is-mid { right: auto; left: 10px; }
	.agfc.is-left { left: 12px; }
	.agfc-pill { display: none; }
	.agfc-ico svg { width: 22px; height: 22px; }
	.agfc-bub .agfc-count { min-width: 21px; height: 21px; font-size: 11px; line-height: 17px; }
	.agfc-back { background: rgba(15, 23, 42, .38); z-index: 4; }
	.agfc-panel {
		top: auto;
		right: 0 !important;
		bottom: 0;
		left: 0 !important;
		z-index: 5;
		width: auto;
		max-width: none;
		max-height: 82vh;
		max-height: 82dvh;
		padding-bottom: env(safe-area-inset-bottom, 0px);
		border-radius: 22px 22px 0 0;
		box-shadow: 0 -12px 40px rgba(15, 23, 42, .22);
		opacity: 1;
		transform: translateY(105%) !important;
		transition: transform .34s cubic-bezier(.22, 1, .36, 1);
	}
	.agfc.is-open .agfc-panel { transform: translateY(var(--drag, 0px)) !important; }
	.agfc-panel.is-drag { transition: none; }
	.agfc-grab { display: flex; justify-content: center; padding: 8px 0 0; touch-action: none; }
	.agfc-grab i { width: 42px; height: 5px; background: #d1d5db; border-radius: 999px; }
	.agfc-head { padding: 8px 16px 10px; touch-action: none; }
	.agfc-ship { margin: 0 16px 8px; }
	.agfc-panel ul.cart_list { padding: 0 16px !important; }
	.agfc-panel .ux-mini-cart-footer { padding: 12px 16px 14px; }
	.agfc.is-open .agfc-bub { opacity: 0; pointer-events: none; }
}
html.agfc-lock, html.agfc-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
	.agfc-blob { animation: none; }
	.agfc-bub, .agfc-panel { transition-duration: .01s; }
}
