/* Active Funnel — dùng màu/font của theme; chỉ có giá trị dự phòng. */
.af-root {
	/* M5: Accent của Elementor trước (nút cam trên site AM), rồi màu nút của Kadence (M8),
	   rồi Primary của theme khối / Elementor. */
	--af-accent: var(--e-global-color-accent, var(--global-palette-btn-bg, var(--wp--preset--color--primary, var(--e-global-color-primary, var(--wp--preset--color--contrast, #1f6feb)))));
	--af-accent-text: var(--global-palette-btn, var(--wp--preset--color--base, #fff));
	/* Nút chính: ghi đè bằng Cài đặt → Giao diện hoặc theo từng phễu (Frontend\Appearance). */
	--af-btn-bg: var(--af-accent);
	--af-btn-text: var(--af-accent-text);
	--af-btn-radius: var(--af-radius);
	--af-text: inherit;
	--af-muted: color-mix(in srgb, currentColor 60%, transparent);
	--af-border: color-mix(in srgb, currentColor 18%, transparent);
	--af-error: #c62828;
	--af-ok: #2e7d32;
	--af-radius: 8px;
	font-family: inherit;
	color: var(--af-text);
	box-sizing: border-box;
}
.af-root *, .af-root *::before, .af-root *::after { box-sizing: inherit; }

.af-btn, .af-root .af-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .5em;
	min-height: 48px;
	padding: .75em 1.5em;
	border: 0;
	border-radius: var(--af-btn-radius, var(--af-radius));
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	cursor: pointer;
	transition: opacity .15s ease;
}
/* M8: theme (vd Hello Elementor: [type=submit] { background: transparent; border: 1px solid #c36 }) có cùng độ ưu tiên
   với .af-btn--primary và nạp sau — thêm .af-root để nút của plugin luôn thắng, kể cả khi rê chuột. */
.af-btn--primary, .af-root .af-btn--primary { background: var(--af-btn-bg); color: var(--af-btn-text); border: 0; }
.af-btn--primary:hover, .af-btn--primary:focus-visible,
.af-root .af-btn--primary:hover, .af-root .af-btn--primary:focus-visible { opacity: .9; background: var(--af-btn-bg); color: var(--af-btn-text); }
/* Màu khi rê chuột: mặc định sáng hơn nền 15%; trình duyệt chưa có color-mix() giữ cách làm mờ ở trên. */
@supports (color: color-mix(in srgb, red 50%, white)) {
	.af-root { --af-btn-bg-hover: color-mix(in srgb, var(--af-btn-bg) 85%, #fff); }
	.af-btn--primary:hover, .af-btn--primary:focus-visible,
	.af-root .af-btn--primary:hover, .af-root .af-btn--primary:focus-visible { opacity: 1; background: var(--af-btn-bg-hover); }
}
.af-btn--ghost, .af-root .af-btn--ghost,
.af-root .af-btn--ghost:hover, .af-root .af-btn--ghost:focus { background: transparent; color: inherit; border: 1px solid var(--af-border); }
.af-btn[disabled], .af-root .af-btn[disabled] { opacity: .6; cursor: progress; }
.af-btn:focus-visible { outline: 2px solid var(--af-accent); outline-offset: 2px; }
/* M1: theme (vd Astra: .entry-content a) hay gạch chân / đổi màu thẻ a — nút của plugin không bao giờ gạch chân. */
a.af-btn, a.af-btn:hover, a.af-btn:focus, a.af-btn:visited, a.af-btn:active,
.af-root a.af-btn, .af-buy-sticky a.af-btn { text-decoration: none !important; box-shadow: none; }
.af-root a.af-btn--primary, .af-buy-sticky a.af-btn--primary { border: 0; }
.af-root a.af-btn.af-btn--primary, .af-buy-sticky a.af-btn.af-btn--primary,
.af-root a.af-btn.af-btn--primary:visited, .af-root a.af-btn.af-btn--primary:hover { color: var(--af-btn-text); }

.af-buy { margin: 1em 0; }
.af-buy__btn { width: 100%; max-width: 480px; }
.af-buy__price { font-weight: 400; opacity: .9; }

.af-buy-sticky { display: none; }
@media (max-width: 767px) {
	.af-buy-sticky {
		display: block;
		position: fixed;
		left: 0; right: 0; bottom: 0;
		z-index: 9990;
		/* M2: chừa vùng an toàn đáy iPhone (thanh Home / thanh công cụ Safari). */
		padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
		background: var(--wp--preset--color--base, #fff);
		box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
		transition: transform .2s ease;
	}
	.af-buy-sticky .af-buy__btn { max-width: none; }
	.af-buy-sticky.is-hidden { transform: translateY(110%); }
	body.af-has-sticky { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

.af-confirm {
	margin: 0 0 1em;
	padding: .75em 1em;
	border-left: 4px solid var(--af-ok);
	background: color-mix(in srgb, var(--af-ok) 8%, transparent);
	border-radius: var(--af-radius);
}

.af-editor-notice {
	padding: .5em .75em;
	border: 1px dashed var(--af-error);
	color: var(--af-error);
	font-size: .9em;
}

/* Thanh toán một cột */
.af-checkout { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
.af-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.af-field input, .af-field select, .af-coupon input {
	width: 100%;
	min-height: 48px;
	padding: 10px 12px;
	font: inherit;
	color: inherit;
	background: transparent;
	border: 1px solid var(--af-border);
	border-radius: var(--af-radius);
}
.af-field input:focus, .af-field select:focus, .af-coupon input:focus { outline: 2px solid var(--af-accent); outline-offset: 0; border-color: var(--af-accent); }
.af-field.is-invalid input, .af-field.is-invalid select { border-color: var(--af-error); }
/* Ô chọn (tỉnh, loại): mũi tên riêng, chữ đủ lớn để iOS không phóng to khi chạm. */
.af-field select {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 36px;
	font-size: max(16px, 1em);
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	text-overflow: ellipsis;
}
.af-field select option { color: #1d2327; background: #fff; }
.af-field__error { margin: 4px 0 0; min-height: 0; color: var(--af-error); font-size: .875em; }
.af-field__error:empty { display: none; }

.af-summary { border: 1px solid var(--af-border); border-radius: var(--af-radius); padding: 12px 14px; }
.af-summary__line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.af-summary__line > :last-child { white-space: nowrap; text-align: right; }
.af-summary__total { border-top: 1px solid var(--af-border); margin-top: 6px; padding-top: 10px; font-size: 1.1em; }

.af-bump {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	margin: 6px 0;
	padding: 12px 14px;
	border: 2px dashed var(--af-accent);
	border-radius: var(--af-radius);
	background: color-mix(in srgb, var(--af-accent) 6%, transparent);
	cursor: pointer;
}
.af-bump input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--af-accent); }
.af-bump__body { display: flex; flex-direction: column; gap: 4px; }
.af-bump__price { white-space: nowrap; }
.af-bump__desc { font-size: .95em; }

.af-coupon__row { display: flex; gap: 8px; margin-top: 8px; }
.af-coupon__row[hidden] { display: none; }
.af-link { background: none; border: 0; padding: 0; min-height: 44px; color: var(--af-accent); text-decoration: underline; cursor: pointer; font: inherit; }

.af-submit { width: 100%; font-size: 1.1em; min-height: 56px; }
.af-form-error { color: var(--af-error); }
.af-form-error:empty { display: none; }
.af-privacy { font-size: .85em; text-align: center; margin: 0; }

/* Trang QR */
.af-qr { max-width: 460px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.af-qr__img { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto; background: #fff; padding: 8px; border-radius: var(--af-radius); border: 1px solid var(--af-border); }
.af-qr__details { margin: 0; text-align: left; border: 1px solid var(--af-border); border-radius: var(--af-radius); padding: 4px 14px; }
.af-qr__row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--af-border); flex-wrap: wrap; }
.af-qr__row:last-child { border-bottom: 0; }
.af-qr__row dt { margin: 0; opacity: .8; }
.af-qr__row dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.af-copy { min-height: 44px; padding: .4em .9em; font-weight: 600; }
.af-qr__copy-msg { flex-basis: 100%; font-size: .875em; }
.af-qr__copy-msg:empty { display: none; }
.af-qr__copy-msg--fail { color: #b32d2e; font-weight: 600; }
.af-qr__row-note { flex-basis: 100%; margin: 0; font-size: .875em; font-weight: 600; }
[data-af-copy-value] { -webkit-user-select: text; user-select: text; }
.af-qr__notice--warn { padding: 12px 14px; border-radius: var(--af-radius); border-left: 4px solid #ed6c02; background: color-mix(in srgb, #ed6c02 10%, transparent); text-align: left; }
.af-qr__hint, .af-qr__expiry { font-size: .875em; margin: 0; }
.af-qr__status { font-weight: 600; margin: 0; }
.af-spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -2px; animation: af-spin .8s linear infinite; }
@keyframes af-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .af-spinner { animation: none; } }

/* Trang cảm ơn */
.af-thanks { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.af-thanks__title { margin: 0; }
.af-thanks__meta { margin: 0; opacity: .85; }
.af-thanks__section { border: 1px solid var(--af-border); border-radius: var(--af-radius); padding: 14px; }
.af-thanks__section h3 { margin: 0 0 8px; font-size: 1.05em; }
.af-deliver + .af-deliver { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--af-border); }
.af-deliver__download { display: flex; width: 100%; margin: 6px 0; }
.af-deliver__content { word-break: break-word; }
.af-next ol, .af-ship ul { margin: 0; padding-left: 1.25em; }
.af-next li { padding: 4px 0; }

/* R1: trang QR — logo (T2), báo thiếu nổi bật (U1), lưu ảnh QR (T3), chờ lâu (T4), hết hạn (F2). */
.af-brand { text-align: center; margin: 0 0 8px; }
.af-brand__logo { display: inline-block; max-height: 48px; width: auto; }
.af-qr__alert { padding: 16px; border-radius: var(--af-radius); border: 2px solid #ed6c02; background: color-mix(in srgb, #ed6c02 10%, #fff); text-align: center; scroll-margin-top: 16px; }
.af-qr__alert:focus { outline: none; }
.af-qr__alert p { margin: 0; }
.af-qr__alert-big { font-size: 1.5em; font-weight: 800; line-height: 1.25; margin: 0 0 6px !important; }
.af-qr__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.af-qr__actions .af-btn { flex: 1 1 200px; max-width: 320px; }
.af-qr__save-hint, .af-qr__rounding { font-size: .875em; margin: 0; }
.af-qr__save-fallback { margin: 0; padding: 10px 12px; border-radius: var(--af-radius); border: 1px solid var(--af-border); background: #fff; font-weight: 600; text-align: center; }
.af-qr__save-fallback[hidden] { display: none; }
.af-qr__late { padding: 12px 14px; border: 1px dashed var(--af-border); border-radius: var(--af-radius); }
.af-qr__late p { margin: 0 0 8px; }
.af-qr--expired { text-align: center; display: flex; flex-direction: column; gap: 12px; }
.af-qr--expired p { margin: 0; }
.af-contact { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 0; }
.af-thanks__notice { padding: 10px 14px; border-radius: var(--af-radius); border-left: 4px solid #ed6c02; background: color-mix(in srgb, #ed6c02 10%, transparent); }

/* T1 khối trấn an, T5 ghi chú giá. */
.af-reassure { list-style: none; margin: 0; padding: 0; font-size: .9em; display: grid; gap: 4px; }
.af-reassure li { position: relative; padding-left: 1.4em; margin: 0; }
.af-reassure li::before { content: "✓"; position: absolute; left: 0; color: var(--af-ok); font-weight: 700; }
.af-price-note { margin: 4px 0 0; font-size: .875em; opacity: .85; }
.af-qr__apps { display: grid; gap: 8px; }
.af-qr__apps[hidden], .af-qr__app-list a[hidden] { display: none; }
.af-qr__apps p { margin: 0; font-size: .875em; }
.af-qr__app-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.af-qr__app-list .af-btn { flex: 1 1 140px; min-height: 44px; padding: .5em .75em; font-size: .9em; }

/* M4: nút chat nổi của Active Growth Hub ([data-agh-chat-launcher], nút bên trong shadow root, position: fixed
   right/bottom 20px). Trang thanh toán và QR: ẩn để không đè ô mua kèm / nút Đặt hàng. Trang có thanh "Mua ngay"
   dính đáy (điện thoại): đẩy nút lên trên thanh — transform trên phần tử chứa tạo khung chứa mới nên nút fixed bên
   trong neo theo phần tử chứa (0×0 đặt ngay trên thanh). */
body.af-step-checkout [data-agh-chat-launcher],
body.af-step-qr [data-agh-chat-launcher] { display: none !important; }
@media (max-width: 767px) {
	body.af-has-sticky [data-agh-chat-launcher] {
		position: fixed !important;
		top: auto !important;
		left: auto !important;
		right: 0 !important;
		bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
		width: 0 !important;
		height: 0 !important;
		transform: translateZ(0);
		z-index: 9991;
	}
}

/* Lời mời nâng cấp / hạ cấp */
.af-offer-box { max-width: 520px; margin: 0 auto 20px; display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 16px; border: 2px solid var(--af-accent); border-radius: var(--af-radius); }
.af-offer-box__headline { margin: 0; }
.af-offer-box__desc, .af-offer-box__price { margin: 0; }
.af-offer-box__accept { width: 100%; min-height: 56px; font-size: 1.05em; flex-wrap: wrap; column-gap: .35em; row-gap: 0; }
/* V2: thành tiền trong nút nhận là một phần tử riêng — cho xuống dòng như chữ, không thành cột thứ hai. */
.af-offer-box__accept [data-af-offer-total] { white-space: nowrap; }
.af-offer-box__decline { width: 100%; }

/* V2: chọn loại (biến thể) và số lượng — trang thanh toán, ô mua kèm, trang lời mời. */
.af-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 12px; align-items: end; }
.af-choice[hidden] { display: none; }
.af-choice .af-field__error { grid-column: 1 / -1; }
.af-choice .af-qty { grid-column: 1 / -1; }
.af-qty__row { display: flex; align-items: center; gap: 8px; }
.af-qty__row input { width: 72px; flex: none; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.af-qty__row input::-webkit-outer-spin-button, .af-qty__row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.af-root .af-qty__btn, .af-qty__btn { width: 48px; min-width: 48px; min-height: 48px; padding: 0; font-size: 1.25em; line-height: 1; }
.af-bump-wrap { display: flex; flex-direction: column; gap: 10px; }
.af-choice--bump { padding: 0 14px 4px 50px; }
.af-choice--offer { text-align: left; }
@media (max-width: 400px) {
	.af-choice--bump { padding-left: 14px; }
}

/* V4: chọn cách thanh toán. */
.af-pay-methods { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 8px; }
.af-pay-methods__title { padding: 0; margin: 0 0 4px; font-weight: 600; }
.af-pay-methods__item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--af-border); border-radius: var(--af-radius); cursor: pointer; }
.af-pay-methods__item input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--af-accent); }
.af-pay-methods__item:has(input:checked) { border-color: var(--af-accent); box-shadow: inset 0 0 0 1px var(--af-accent); background: color-mix(in srgb, var(--af-accent) 6%, transparent); }
.af-pay-methods__item:focus-within { outline: 2px solid var(--af-accent); outline-offset: 2px; }

/* V3: địa chỉ giao + phí vận chuyển. */
.af-shipping { display: flex; flex-direction: column; gap: 14px; }
.af-shipping .af-ship { border: 1px solid var(--af-border); border-radius: var(--af-radius); padding: 10px 14px; }
.af-shipping .af-ship[hidden] { display: none; }
.af-ship__rates { display: grid; gap: 8px; }
.af-ship__rates[hidden] { display: none; }
.af-ship__rates label { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--af-border); border-radius: var(--af-radius); cursor: pointer; }
.af-ship__rates input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--af-accent); }
.af-ship__rates label:has(input:checked) { border-color: var(--af-accent); box-shadow: inset 0 0 0 1px var(--af-accent); }
.af-ship__hint { margin: -4px 0 0; font-size: .9em; color: var(--af-ok); font-weight: 600; }
.af-ship__hint[hidden] { display: none; }

/* V3: sản phẩm chính tạm hết hàng. */
.af-out-of-stock { padding: 14px 16px; border-left: 4px solid #ed6c02; border-radius: var(--af-radius); background: color-mix(in srgb, #ed6c02 10%, transparent); }
.af-out-of-stock p { margin: 0; }

/* 1.2 (AF-1.2 B1): khối "Đồng hồ (Phễu)". */
.af-countdown { margin: 1em 0; text-align: center; }
.af-countdown[hidden] { display: none; }
.af-countdown__label { margin: 0 0 .4em; font-weight: 600; }
.af-countdown--large .af-countdown__time { display: flex; justify-content: center; gap: .5em; }
.af-countdown__unit { display: flex; flex-direction: column; align-items: center; min-width: 3.6em; padding: .4em .3em; border-radius: var(--af-radius); background: color-mix(in srgb, currentColor 6%, transparent); }
.af-countdown__unit b { font-size: 1.8em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.af-countdown__unit small { font-size: .8em; opacity: .8; }
.af-countdown--no-days .af-countdown__unit--d, .af-countdown__unit[hidden] { display: none; }
.af-countdown--inline { text-align: inherit; }
.af-countdown--inline .af-countdown__time, .af-countdown__time--sticky { font-variant-numeric: tabular-nums; }
.af-countdown-sticky { display: none; }
@media (max-width: 767px) {
	.af-countdown-sticky {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: .75em;
		position: fixed;
		left: 0; right: 0; bottom: 0;
		z-index: 9990;
		padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
		background: var(--wp--preset--color--base, #fff);
		box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
	}
	.af-countdown-sticky .af-btn { flex: 1 1 auto; max-width: 60%; }
	.af-countdown-sticky .af-countdown__time { display: flex; gap: .25em; font-weight: 700; }
	.af-countdown-sticky .af-countdown__unit { min-width: 0; padding: 0; background: none; flex-direction: row; }
	.af-countdown-sticky .af-countdown__unit b { font-size: 1.1em; }
	.af-buy-sticky .af-countdown__time--sticky { display: block; margin: 0 0 6px; text-align: center; font-weight: 700; }
	.af-buy-sticky .af-countdown__time--sticky .af-countdown__unit { display: inline; min-width: 0; padding: 0; background: none; }
	/* Trong dải dính: "2 ngày 01:23:45" — chỉ giữ chữ "ngày", giờ/phút/giây nối bằng dấu hai chấm. */
	.af-countdown__time--sticky .af-countdown__unit--h small,
	.af-countdown__time--sticky .af-countdown__unit--m small,
	.af-countdown__time--sticky .af-countdown__unit--s small { display: none; }
	.af-countdown__time--sticky .af-countdown__unit--d small { margin: 0 .3em 0 .2em; font-size: 1em; opacity: 1; }
	.af-countdown__time--sticky .af-countdown__unit--m::before,
	.af-countdown__time--sticky .af-countdown__unit--s::before { content: ":"; }
	.af-buy-sticky .af-countdown__time--sticky .af-countdown__unit[hidden] { display: none; }
}
