/**
 * SODI PDF Flipbook — giao diện khung đọc.
 */

.sfb-root {
	position: relative;
	width: 100%;
	max-width: 100%;
	min-height: 240px;
	margin: 0 0 1.5em;
	box-sizing: border-box;
}

.sfb-root * {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------------
 * Chống theme ghi đè.
 * Flatsome và nhiều theme khác đặt style rất mạnh cho button, canvas, img.
 * Nếu không khoá lại, nút công cụ phình to đẩy hết chiều cao khung đọc,
 * hoặc canvas bị ép max-width khiến trang hiển thị sai kích thước.
 * ------------------------------------------------------------------- */

.sfb-viewer canvas.sfb-canvas {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	background: transparent !important;
	object-fit: fill !important;
}

.sfb-viewer button.sfb-btn,
.sfb-lightbox button.sfb-lightbox-close {
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	font-family: inherit !important;
	font-size: 14px !important;
	font-weight: 400 !important;
	line-height: 1 !important;
	letter-spacing: 0 !important;
	text-transform: none !important;
	text-shadow: none !important;
	box-shadow: none !important;
	border: 0 !important;
	outline: none;
}

.sfb-viewer button.sfb-btn {
	width: 36px !important;
	height: 34px !important;
	padding: 0 !important;
	border-radius: 4px !important;
	background-color: transparent !important;
	color: #fff !important;
}

.sfb-viewer button.sfb-btn:hover,
.sfb-viewer button.sfb-btn:focus {
	background-color: rgba(255, 255, 255, 0.18) !important;
	color: #fff !important;
	transform: none !important;
}

.sfb-viewer .sfb-page,
.sfb-viewer .sfb-leaf,
.sfb-viewer .sfb-leaf-face {
	float: none !important;
	max-width: none !important;
	min-height: 0 !important;
}

.sfb-viewer .sfb-toolbar,
.sfb-viewer .sfb-stage,
.sfb-viewer .sfb-area,
.sfb-viewer .sfb-viewport {
	float: none !important;
	max-width: none !important;
}

.sfb-viewer p,
.sfb-viewer div,
.sfb-viewer span {
	line-height: normal;
}

.sfb-viewer {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 240px;
	overflow: hidden;
	border-radius: 6px;
	outline: none;
	color: #fff;
	font-family: inherit;
}

.sfb-viewer:focus-visible {
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45);
}

/* ------------------------------- sân khấu ------------------------------ */

.sfb-stage {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	min-height: 0;
}

.sfb-area {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-width: 0;
	overflow: hidden;
	touch-action: pan-y;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.sfb-area.sfb-zoomed {
	cursor: grab;
	touch-action: none;
}

.sfb-viewport {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	perspective: 2400px;
}

.sfb-book {
	position: relative;
	transform-style: preserve-3d;
	transform-origin: center center;
	transition: transform 150ms ease-in-out;
	will-change: transform;
}

/* --------------------------------- trang -------------------------------- */

.sfb-page {
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
	backface-visibility: hidden;
}

.sfb-page-left {
	border-radius: 3px 0 0 3px;
}

.sfb-page-right {
	border-radius: 0 3px 3px 0;
}

.sfb-book-single .sfb-page-right {
	border-radius: 3px;
}

.sfb-page-blank {
	background: transparent;
	box-shadow: none;
}

.sfb-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

/* Bóng gáy sách ở giữa hai trang. */
.sfb-book:not(.sfb-book-single)::after {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	width: 46px;
	height: 100%;
	margin-left: -23px;
	pointer-events: none;
	z-index: 4;
	background: linear-gradient(
		to right,
		rgba(0, 0, 0, 0) 0%,
		rgba(0, 0, 0, 0.16) 42%,
		rgba(0, 0, 0, 0.3) 50%,
		rgba(0, 0, 0, 0.16) 58%,
		rgba(0, 0, 0, 0) 100%
	);
}

/* ------------------------------ tờ đang lật ----------------------------- */

.sfb-leaf {
	position: absolute;
	top: 0;
	z-index: 6;
	transform-style: preserve-3d;
	will-change: transform;
}

.sfb-leaf-face {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #fff;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.sfb-leaf-back {
	transform: rotateY(180deg);
}

.sfb-shade {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	opacity: 0;
	background: linear-gradient(to right, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.05));
}

.sfb-leaf-back .sfb-shade {
	background: linear-gradient(to left, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.05));
}

/* ------------------------------ thanh công cụ --------------------------- */

.sfb-toolbar {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	gap: 4px;
	flex-wrap: wrap;
	padding: 6px 10px;
	background: rgba(0, 0, 0, 0.4);
	backdrop-filter: blur(4px);
}

.sfb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: transparent;
	color: #fff;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.15s ease;
}

.sfb-btn:hover,
.sfb-btn:focus-visible {
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
}

.sfb-btn[disabled] {
	opacity: 0.35;
	cursor: default;
}

.sfb-btn svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.sfb-pager {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 6px;
	font-size: 13px;
	line-height: 1;
	color: #fff;
}

.sfb-page-input {
	width: 62px;
	height: 28px;
	padding: 0 6px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.3);
	color: #fff;
	font-size: 13px;
	text-align: center;
	box-shadow: none;
}

.sfb-page-input:focus {
	border-color: rgba(255, 255, 255, 0.7);
	outline: none;
}

.sfb-total {
	opacity: 0.8;
	white-space: nowrap;
}

/* ------------------------------ trang thu nhỏ --------------------------- */

.sfb-thumbs {
	flex: 0 0 auto;
	width: 0;
	overflow-y: auto;
	overflow-x: hidden;
	background: rgba(0, 0, 0, 0.35);
	transition: width 0.2s ease;
}

.sfb-thumbs-open .sfb-thumbs {
	width: 148px;
	padding: 8px;
}

.sfb-thumb-item {
	display: block;
	width: 100%;
	margin: 0 0 10px;
	padding: 4px;
	border: 2px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: #fff;
	cursor: pointer;
	text-align: center;
}

.sfb-thumb-item.is-active {
	border-color: #ffb400;
	background: rgba(255, 255, 255, 0.12);
}

.sfb-thumb-box {
	display: block;
	min-height: 40px;
	background: rgba(255, 255, 255, 0.08);
}

.sfb-thumb-box canvas {
	display: block;
	width: 100%;
	height: auto;
}

.sfb-thumb-num {
	display: block;
	margin-top: 4px;
	font-size: 11px;
	opacity: 0.75;
}

/* --------------------------- tải & lỗi ---------------------------------- */

.sfb-loader {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	color: #fff;
	font-size: 13px;
}

.sfb-spinner {
	width: 34px;
	height: 34px;
	margin: 0 auto 10px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sfb-spin 0.9s linear infinite;
}

@keyframes sfb-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sfb-spinner {
		animation-duration: 2.5s;
	}

	.sfb-book,
	.sfb-thumbs {
		transition: none;
	}
}

.sfb-error {
	position: absolute;
	top: 50%;
	left: 50%;
	max-width: 90%;
	padding: 20px 24px;
	transform: translate(-50%, -50%);
	border-radius: 6px;
	background: rgba(255, 255, 255, 0.95);
	color: #23282d;
	text-align: center;
	font-size: 14px;
}

.sfb-error-title {
	margin: 0 0 6px;
	font-weight: 600;
}

.sfb-error-detail {
	margin: 0 0 10px;
	font-size: 12px;
	opacity: 0.7;
	word-break: break-word;
}

.sfb-error-link {
	color: #2271b1;
}

.sfb-page-error {
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(45deg, #f6f6f6, #f6f6f6 10px, #ececec 10px, #ececec 20px);
}

/* ------------------------------- lightbox ------------------------------- */

.sfb-mode-lightbox {
	height: auto !important;
}

.sfb-cover-btn {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	max-width: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.sfb-cover-img {
	display: block;
	max-width: 100%;
	height: auto;
	border-radius: 4px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease;
}

.sfb-cover-btn:hover .sfb-cover-img {
	transform: translateY(-3px);
}

.sfb-cover-label {
	display: inline-block;
	padding: 10px 22px;
	border-radius: 4px;
	background: #2271b1;
	color: #fff;
	font-size: 15px;
	line-height: 1.2;
}

.sfb-cover-btn:hover .sfb-cover-label {
	background: #135e96;
}

.sfb-lightbox,
.sfb-lightbox * {
	box-sizing: border-box;
}

.sfb-lightbox {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 24px;
	background: rgba(0, 0, 0, 0.88);
}

.sfb-lightbox-inner {
	width: min(1400px, 100%);
	height: 100%;
	max-height: 100%;
}

.sfb-lightbox .sfb-root,
.sfb-lightbox .sfb-viewer {
	height: 100%;
	margin: 0;
}

.sfb-lightbox-close {
	position: absolute;
	top: 12px;
	right: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	cursor: pointer;
}

.sfb-lightbox-close:hover {
	background: rgba(255, 255, 255, 0.28);
}

.sfb-lightbox-close svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

body.sfb-noscroll {
	overflow: hidden;
}

/* ----------------------------- toàn màn hình ---------------------------- */

.sfb-viewer:fullscreen,
.sfb-lightbox:fullscreen {
	width: 100vw;
	height: 100vh;
}

.sfb-pseudo-full {
	position: fixed !important;
	top: 0;
	left: 0;
	z-index: 999998;
	width: 100vw !important;
	height: 100vh !important;
	border-radius: 0;
}

/* -------------------------------- khác ---------------------------------- */

.sfb-noscript .sfb-fallback-link {
	display: inline-block;
	padding: 10px 18px;
	border-radius: 4px;
	background: #2271b1;
	color: #fff;
	text-decoration: none;
}

.sfb-admin-notice {
	padding: 12px 16px;
	border-left: 4px solid #d63638;
	background: #fcf0f1;
	color: #23282d;
	font-size: 14px;
}

@media (max-width: 640px) {
	.sfb-btn {
		width: 32px;
		height: 30px;
	}

	.sfb-btn svg {
		width: 16px;
		height: 16px;
	}

	.sfb-toolbar {
		gap: 2px;
		padding: 5px 6px;
	}

	.sfb-thumbs-open .sfb-thumbs {
		position: absolute;
		top: 0;
		left: 0;
		z-index: 8;
		height: 100%;
		width: 120px;
	}

	.sfb-lightbox {
		padding: 8px;
	}
}
