/**
 * TTVD PWA CSS — banner + modal cài app + safe-area standalone
 * PWA_BEST_PRACTICES.md mục 7 (UX), 8 (safe-area), 9 (modal cuộn được)
 * Z-index: modal (100000) > banner (99990) > mọi fixed element khác của site
 */

/* ---------- Banner (lớp 2) ---------- */
#a2hs-banner {
	position: fixed;
	left: 12px;
	right: 12px;
	bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	z-index: 99990;
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: 440px;
	margin: 0 auto;
	padding: 10px 12px;
	background: #fff;
	color: #1a2430;
	border: 1px solid #e3e8ee;
	border-radius: 12px;
	box-shadow: 0 8px 28px rgba(9, 25, 40, 0.22);
	opacity: 0;
	transform: translateY(16px);
	transition: opacity .25s ease, transform .25s ease;
	font-family: inherit;
}
#a2hs-banner.show { opacity: 1; transform: translateY(0); }
.ttvd-a2hs-banner-icon { width: 38px; height: 38px; border-radius: 9px; flex: 0 0 auto; }
.ttvd-a2hs-banner-text { flex: 1 1 auto; font-size: 13.5px; line-height: 1.35; }
.ttvd-a2hs-banner-btn {
	flex: 0 0 auto;
	background: #085571;
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 8px 14px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
}
.ttvd-a2hs-banner-btn:active { background: #066a8a; }
.ttvd-a2hs-banner-close {
	flex: 0 0 auto;
	background: none;
	border: none;
	color: #8b98a5;
	font-size: 15px;
	padding: 6px;
	cursor: pointer;
	line-height: 1;
}

/* ---------- Modal (lớp 3) — mẫu chống-lỗi-scroll mục 9 ---------- */
#a2hs-modal-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(9, 20, 30, 0.55);
	opacity: 0;
	transition: opacity .2s ease;
}
#a2hs-modal-overlay.show { opacity: 1; }
.ttvd-a2hs-modal {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 400px;
	max-height: 90vh;          /* BẮT BUỘC: giới hạn chiều cao */
	overflow: hidden;          /* cắt tròn góc, scroll do modal-body đảm nhiệm */
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}
.ttvd-a2hs-modal-header {
	flex-shrink: 0;            /* header luôn nhìn thấy */
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 14px 14px 10px 14px;
	border-bottom: 1px solid #eef1f4;
}
.ttvd-a2hs-modal-icon { width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto; }
.ttvd-a2hs-modal-title { font-size: 16px; font-weight: 700; color: #10354a; }
.ttvd-a2hs-modal-sub { font-size: 12.5px; color: #5b6b78; margin-top: 2px; }
.ttvd-a2hs-modal-body {
	flex: 1 1 auto;            /* body co giãn chiếm phần còn lại */
	overflow-y: auto;          /* BẮT BUỘC: body mới là nơi cuộn */
	-webkit-overflow-scrolling: touch;
	padding: 14px 16px 18px;
	font-size: 14px;
	color: #23303c;
}
.ttvd-a2hs-modal-body .hide { display: none; }
.ttvd-a2hs-install-btn {
	display: block;
	width: 100%;
	background: #085571;
	color: #fff;
	border: none;
	border-radius: 9px;
	padding: 12px 16px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	margin-top: 8px;
}
.ttvd-a2hs-install-btn:active { background: #066a8a; }
.ttvd-a2hs-steps { list-style: none; margin: 8px 0 0; padding: 0; }
.ttvd-a2hs-steps li {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px dashed #e6ebf0;
	line-height: 1.5;
}
.ttvd-a2hs-steps li:last-child { border-bottom: none; }
.ttvd-a2hs-steps .step-ico {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: #085571;
	color: #fff;
	font-size: 12.5px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 1px;
}
.step-ico-inline {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	border: 1.5px solid #9aa8b4;
	border-radius: 5px;
	font-size: 12px;
	vertical-align: middle;
}

/* Link entry ở footer */
#ttvd-a2hs-footer-link {
	display: inline-block;
	margin-right: 14px;
	font-size: 13px;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}
#ttvd-a2hs-footer-link:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.ttvd-a2hs-toast {
	position: fixed;
	left: 50%;
	bottom: calc(24px + env(safe-area-inset-bottom, 0px));
	transform: translateX(-50%) translateY(12px);
	z-index: 100010;
	background: #10354a;
	color: #fff;
	padding: 10px 18px;
	border-radius: 999px;
	font-size: 13.5px;
	opacity: 0;
	transition: opacity .3s ease, transform .3s ease;
	pointer-events: none;
	max-width: calc(100vw - 32px);
	text-align: center;
}
.ttvd-a2hs-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal trên mobile hẹp: card chiếm hết chiều ngang hữu dụng ---------- */
@media (max-width: 480px) {
	#a2hs-modal-overlay { padding: 12px; }
	.ttvd-a2hs-modal { max-width: none; }
}

/* ---------- Chế độ standalone: safe-area cho tai thỏ (mục 8) ----------
   Chỉ áp dụng khi đang chạy như app đã cài — browser thường thì env() = 0.
   Header Helix: #sp-header relative trong flow; khi cuộn JS thêm class
   .header-sticky → position:fixed top:0. Cả hai vị trí đều phải né notch:
   nội dung trong flow → đẩy cả trang xuống bằng body padding-top;
   header fixed → cộng top bằng env(). */
@media (display-mode: standalone) {
	body { padding-top: env(safe-area-inset-top, 0px); }
	#sp-header.header-sticky { top: env(safe-area-inset-top, 0px); }
	#a2hs-banner { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
	.ttvd-a2hs-toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
}
