/**
 * CSS nền của khung nổi — phần KHÔNG phụ thuộc cấu hình.
 *
 * File này được browser cache lại giữa các trang. Toàn bộ phần thay đổi theo
 * thiết lập (màu, kích thước, vị trí) do BOFB_CSS_Generator sinh ra và in inline.
 * Nhờ chia đôi như vậy, mỗi trang chỉ tải thêm vài trăm byte CSS động.
 *
 * Cạm bẫy: selector ở đây phải khớp HTML trong BOFB_Frontend::render_frame().
 */

.bofb-frame {
	position: fixed;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: calc(100vw - 20px);
	/* Không cho theme/plugin khác kế thừa kiểu chữ lạ vào trong khung. */
	box-sizing: border-box;
}

.bofb-frame *,
.bofb-frame *::before,
.bofb-frame *::after {
	box-sizing: border-box;
}

.bofb-frame__inner {
	display: flex;
	max-width: 100%;
	box-sizing: border-box;
}

/* Trạng thái thu gọn: ẩn hộp button, chỉ còn nút toggle. */
.bofb-frame[data-bofb-collapsed="true"] .bofb-frame__inner {
	display: none;
}

/* --- Button ------------------------------------------------------------- */

.bofb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	/* Chặn theme ghi đè các thuộc tính plugin không quản lý. */
	background-clip: padding-box;
	transition-property: color, background-color, background-image, border-color, box-shadow, opacity, transform;
	transition-timing-function: ease;
	/* transition-duration do CSS sinh động quyết định (theo thiết lập từng button). */
	transition-duration: 300ms;
	-webkit-tap-highlight-color: transparent;
}

/* Ghi đè gạch chân/màu mà nhiều theme đặt cho thẻ a ở mọi trạng thái. */
.bofb-frame .bofb-btn,
.bofb-frame .bofb-btn:hover,
.bofb-frame .bofb-btn:focus,
.bofb-frame .bofb-btn:active,
.bofb-frame .bofb-btn:visited {
	text-decoration: none;
}

.bofb-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bofb-btn__label {
	display: block;
}

/* --- Icon --------------------------------------------------------------- */

.bofb-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	line-height: 1;
}

.bofb-icon--svg svg,
.bofb-icon--img img {
	display: block;
	width: 100%;
	height: 100%;
	/* Ảnh/SVG luôn vừa trong ô icon, bất kể width/height khai báo trong file. */
	object-fit: contain;
}

/* Icon font: class của theme tự lo font-family và glyph. */
.bofb-icon > i {
	font-size: inherit;
	line-height: 1;
}

/* --- Nút thu gọn -------------------------------------------------------- */

.bofb-frame__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	padding: 0;
	border: 0;
	cursor: pointer;
	font: inherit;
	transition: transform 200ms ease, opacity 200ms ease;
	-webkit-tap-highlight-color: transparent;
}

.bofb-frame__toggle:hover {
	opacity: 0.9;
}

.bofb-frame__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Icon mặc định của nút toggle khi người dùng chưa chọn icon riêng:
   ba vạch ngang vẽ bằng CSS, không cần thêm file nào. */
.bofb-frame__toggle-bars {
	position: relative;
	display: block;
	width: 18px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

.bofb-frame__toggle-bars::before,
.bofb-frame__toggle-bars::after {
	content: "";
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform 200ms ease;
}

.bofb-frame__toggle-bars::before {
	top: -6px;
}

.bofb-frame__toggle-bars::after {
	top: 6px;
}

/* Khi đang mở, ba vạch chuyển thành dấu X để người dùng biết bấm là đóng. */
.bofb-frame:not([data-bofb-collapsed="true"]) .bofb-frame__toggle-bars {
	background: transparent;
}

.bofb-frame:not([data-bofb-collapsed="true"]) .bofb-frame__toggle-bars::before {
	transform: translateY(6px) rotate(45deg);
}

.bofb-frame:not([data-bofb-collapsed="true"]) .bofb-frame__toggle-bars::after {
	transform: translateY(-6px) rotate(-45deg);
}

/* --- Hiệu ứng ----------------------------------------------------------- */

@keyframes bofb-pulse {
	0%,
	100% {
		transform: scale(1);
	}

	50% {
		transform: scale(1.06);
	}
}

/* Tôn trọng thiết lập giảm hiệu ứng của hệ điều hành. */
@media (prefers-reduced-motion: reduce) {
	.bofb-btn,
	.bofb-frame__toggle,
	.bofb-frame__toggle-bars::before,
	.bofb-frame__toggle-bars::after {
		transition: none !important;
	}

	.bofb-btn:hover,
	.bofb-btn:focus-visible {
		animation: none !important;
		transform: none !important;
	}
}
