/* ==========================================================================
   MENU PHẢI - FLOATING ACTION BUTTON (GÓC PHẢI DƯỚI MÀN HÌNH)
   ========================================================================== */

/* 1. KHUNG CHỨA MENU PHẢI (LUÔN NỔI TRÊN CÙNG KỂ CẢ FULLSCREEN) */
.menu-phai-container {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 2147483647; /* Z-Index cao nhất để không bị canvas WebGL hay Fullscreen che */
	display: flex;
	flex-direction: column-reverse;
	align-items: center;
	gap: 12px;
	user-select: none;
	-webkit-user-select: none;
	pointer-events: auto;
}

/* Đảm bảo luôn hiển thị trong mọi chế độ Fullscreen của trình duyệt */
:fullscreen .menu-phai-container,
:-webkit-full-screen .menu-phai-container,
:-moz-full-screen .menu-phai-container,
:-ms-fullscreen .menu-phai-container {
	position: fixed !important;
	bottom: 24px !important;
	right: 24px !important;
	z-index: 2147483647 !important;
	display: flex !important;
}

/* 2. NÚT CHÍNH (NÚT TRÒN GÓC PHẢI) */
.menu-phai-main-btn {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: linear-gradient(135deg, #3b82f6, #1d4ed8);
	border: 1px solid rgba(255, 255, 255, 0.3);
	box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
	color: #ffffff;
	cursor: pointer;
	outline: none;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
	position: relative;
}

.menu-phai-main-btn:hover {
	transform: scale(1.08);
	box-shadow: 0 8px 25px rgba(59, 130, 246, 0.65), 0 3px 8px rgba(0, 0, 0, 0.4);
}

.menu-phai-main-btn:active {
	transform: scale(0.95);
}

/* Icon dấu cộng / menu bên trong nút chính */
.menu-phai-icon {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Khi menu mở (Active): Nút chính đổi màu và xoay icon thành dấu ✕ */
.menu-phai-container.active .menu-phai-main-btn {
	background: linear-gradient(135deg, #ef4444, #b91c1c);
	box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.menu-phai-container.active .menu-phai-icon {
	transform: rotate(135deg);
}

/* 3. DANH SÁCH CÁC NÚT CON SỔ RA */
.menu-phai-list {
	display: flex;
	flex-direction: column-reverse;
	gap: 10px;
	padding: 0;
	margin: 0;
	list-style: none;
	pointer-events: none;
}

/* Khi mở menu: Cho phép tương tác với nút con */
.menu-phai-container.active .menu-phai-list {
	pointer-events: auto;
}

/* Từng mục nút con */
.menu-phai-item {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	opacity: 0;
	transform: translateY(20px) scale(0.5);
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Nút bấm con */
.menu-phai-sub-btn {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(18, 24, 38, 0.85);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #e2e8f0;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
	cursor: pointer;
	outline: none;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: all 0.25s ease;
	position: relative;
}

.menu-phai-sub-btn svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.25s ease, filter 0.25s ease;
}

.menu-phai-sub-btn:hover {
	transform: scale(1.12);
	background: rgba(30, 41, 59, 0.95);
	border-color: #38bdf8;
	color: #38bdf8;
	box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35);
}

.menu-phai-sub-btn:hover svg {
	transform: scale(1.1);
}

.menu-phai-sub-btn:active {
	transform: scale(0.92);
}

/* ==========================================================================
   TRẠNG THÁI ĐANG BẬT (IS-ACTIVE / SÁNG ĐÈN PHÁT SÁNG KHI ĐANG HOẠT ĐỘNG)
   ========================================================================== */
.menu-phai-sub-btn.is-active {
	background: rgba(14, 165, 233, 0.32) !important;
	border-color: #38bdf8 !important;
	color: #38bdf8 !important;
	box-shadow: 0 0 18px rgba(56, 189, 248, 0.6), 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.menu-phai-sub-btn.is-active svg {
	filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.9));
}

/* Nút tự động xoay khi đang BẬT: hiệu ứng xoay nhẹ biểu tượng */
#btn-autorotate.is-active svg {
	animation: rotateSpin 8s linear infinite;
}

@keyframes rotateSpin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* Chấm xanh lá phát sáng (ON Indicator) ở góc nút để nhận biết tính năng ĐANG BẬT */
.menu-phai-item.is-on::after {
	content: '';
	position: absolute;
	top: -1px;
	right: -1px;
	width: 10px;
	height: 10px;
	background: #22c55e;
	border-radius: 50%;
	border: 1.5px solid #0f172a;
	box-shadow: 0 0 10px #22c55e, 0 0 4px #22c55e;
	z-index: 10005;
	pointer-events: none;
	animation: indicatorGlow 2s infinite ease-in-out;
}

@keyframes indicatorGlow {
	0%, 100% {
		transform: scale(1);
		opacity: 1;
	}
	50% {
		transform: scale(1.2);
		opacity: 0.85;
	}
}

/* Nổi bật đặc biệt cho nút AR */
.btn-ar-highlight {
	background: rgba(14, 165, 233, 0.25) !important;
	border-color: rgba(56, 189, 248, 0.6) !important;
	color: #38bdf8 !important;
	box-shadow: 0 0 15px rgba(56, 189, 248, 0.35) !important;
}

.btn-ar-highlight:hover {
	background: rgba(14, 165, 233, 0.45) !important;
	box-shadow: 0 0 25px rgba(56, 189, 248, 0.65) !important;
}

/* Tooltip nhãn giải thích nút bên trái */
.menu-phai-tooltip {
	position: absolute;
	right: 54px;
	background: rgba(15, 23, 42, 0.92);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	color: #f8fafc;
	font-size: 12px;
	font-weight: 500;
	padding: 5px 10px;
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	white-space: nowrap;
	opacity: 0;
	transform: translateX(8px);
	pointer-events: none;
	transition: all 0.25s ease;
}

.menu-phai-item:hover .menu-phai-tooltip {
	opacity: 1;
	transform: translateX(0);
}

/* 4. HIỆU ỨNG XUẤT HIỆN LẦN LƯỢT (STAGGER ANIMATION) CHO 8 NÚT */
.menu-phai-container.active .menu-phai-item {
	opacity: 1;
	transform: translateY(0) scale(1);
}

.menu-phai-container.active .menu-phai-item:nth-child(1) {
	transition-delay: 0.03s;
}
.menu-phai-container.active .menu-phai-item:nth-child(2) {
	transition-delay: 0.06s;
}
.menu-phai-container.active .menu-phai-item:nth-child(3) {
	transition-delay: 0.09s;
}
.menu-phai-container.active .menu-phai-item:nth-child(4) {
	transition-delay: 0.12s;
}
.menu-phai-container.active .menu-phai-item:nth-child(5) {
	transition-delay: 0.15s;
}
.menu-phai-container.active .menu-phai-item:nth-child(6) {
	transition-delay: 0.18s;
}
.menu-phai-container.active .menu-phai-item:nth-child(7) {
	transition-delay: 0.21s;
}
.menu-phai-container.active .menu-phai-item:nth-child(8) {
	transition-delay: 0.24s;
}

/* ==========================================================================
   5. RESPONSIVE ĐIỆN THOẠI & TỰ ĐỘNG ẨN MENU PHẢI KHI MỞ POPUP/DANH MỤC
   ========================================================================== */
@media screen and (max-width: 768px) {
	.menu-phai-container {
		bottom: calc(18px + env(safe-area-inset-bottom, 0px));
		right: calc(18px + env(safe-area-inset-right, 0px));
		gap: 10px;
		transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
	}

	.menu-phai-main-btn {
		width: 48px;
		height: 48px;
	}

	.menu-phai-sub-btn {
		width: 38px;
		height: 38px;
	}

	.menu-phai-sub-btn svg {
		width: 16px;
		height: 16px;
	}

	.menu-phai-tooltip {
		right: 48px;
		font-size: 11px;
		padding: 4px 8px;
	}

	/* TỰ ĐỘNG ẨN MENU PHẢI KHI MỞ DANH MỤC HOẶC BẤT KỲ POPUP NÀO TRÊN ĐIỆN THOẠI */
	body:has(.menu-trai-drawer.active) #menu-phai-container,
	body:has(.menu-trai-backdrop.active) #menu-phai-container,
	body:has(.menu-trai-modal.active) #menu-phai-container,
	body:has(.menu-trai-lightbox-modal.active) #menu-phai-container,
	body:has(.bancovan-modal.active) #menu-phai-container,
	body:has(.visitor-modal-overlay.active) #menu-phai-container,
	body:has(.lang-modal-overlay.active) #menu-phai-container,
	body:has(.ar-simulator-modal.active) #menu-phai-container,
	body:has(.zalo-guide-overlay.active) #menu-phai-container,
	body.popup-open-mobile #menu-phai-container,
	#menu-phai-container.mobile-hidden {
		opacity: 0 !important;
		visibility: hidden !important;
		pointer-events: none !important;
		transform: translateX(45px) scale(0.8) !important;
	}
}
