.flipbook-wrapper {
	position: relative;
	margin: 20px 0;
}

.flipbook-container {
	margin: 0 auto;
	position: relative;
	overflow: auto;
}

.flipbook-stage {
	transform-origin: top center;
	transition: transform .15s ease;
	display: inline-block;
}

.flipbook-loading,
.flipbook-error {
	text-align: center;
	padding: 40px;
	color: #666;
	font-size: 16px;
}
.flipbook-error { color: #c0392b; }

.flipbook-page {
	background: #fff;
	box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}
.flipbook-page canvas {
	width: 100%;
	height: 100%;
	display: block;
}

/* --- Popup style: รูปปกที่คลิกได้ --- */
.flipbook-cover-trigger {
	position: relative;
	display: inline-block;
	cursor: pointer;
	max-width: 320px;
}
.flipbook-cover-img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: 4px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	transition: transform .2s ease;
}
.flipbook-cover-trigger:hover .flipbook-cover-img {
	transform: scale(1.02);
}
.flipbook-open-label {
	display: block;
	text-align: center;
	margin-top: 8px;
	font-size: 14px;
	color: #333;
}

/* --- Button style --- */
.flipbook-cover-static {
	max-width: 200px;
	display: block;
	margin-bottom: 10px;
	border-radius: 4px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.flipbook-open-button {
	background: #2c3e50;
	color: #fff;
	border: none;
	padding: 12px 24px;
	font-size: 15px;
	border-radius: 6px;
	cursor: pointer;
	transition: background .2s ease;
}
.flipbook-open-button:hover {
	background: #1a252f;
}

/* --- Toolbar: ซูมเข้า/ออก + เต็มจอ --- */
.flipbook-toolbar {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 10px;
}
.flipbook-btn {
	background: #f1f1f1;
	border: 1px solid #ddd;
	color: #333;
	font-size: 14px;
	min-width: 40px;
	padding: 6px 10px;
	border-radius: 4px;
	cursor: pointer;
	transition: background .15s ease;
}
.flipbook-btn:hover {
	background: #e2e2e2;
}
.flipbook-zoom-reset {
	min-width: 56px;
	font-variant-numeric: tabular-nums;
}

/* --- Modal (ใช้ร่วมกับ popup / button) --- */
.flipbook-modal {
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0, 0, 0, 0.85);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
}
.flipbook-modal-inner {
	position: relative;
	max-width: 95vw;
	max-height: 95vh;
	display: flex;
	flex-direction: column;
}
.flipbook-modal-close {
	position: absolute;
	top: -40px;
	right: 0;
	background: none;
	border: none;
	color: #fff;
	font-size: 32px;
	cursor: pointer;
	line-height: 1;
}

/* --- โหมดเต็มจอ --- */
.flipbook-is-fullscreen {
	background: #111;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100vw;
	height: 100vh;
}
.flipbook-is-fullscreen .flipbook-container {
	max-width: 100% !important;
	max-height: 85vh;
}

/* --- [flipbook_gallery]: tab หมวดหมู่ + viewer เดียว --- */
.flipbook-gallery-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-bottom: 18px;
}
.flipbook-gallery-tab {
	background: #f1f1f1;
	border: 1px solid #ddd;
	color: #333;
	font-size: 14px;
	padding: 8px 18px;
	border-radius: 999px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.flipbook-gallery-tab:hover { background: #e2e2e2; }
.flipbook-gallery-tab.is-active {
	background: #2c3e50;
	color: #fff;
	border-color: #2c3e50;
}
.flipbook-gallery-viewer .flipbook-container {
	margin: 0 auto;
}

/* --- ลูกศร ←→ + ตัวเลขหน้า (flipbook / slider mode) --- */
.flipbook-nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-top: 10px;
}
.flipbook-nav-btn {
	background: #2c3e50;
	color: #fff;
	border: none;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	font-size: 18px;
	cursor: pointer;
	transition: background .15s ease;
}
.flipbook-nav-btn:hover { background: #1a252f; }
.flipbook-nav-label {
	font-size: 14px;
	color: #555;
	min-width: 60px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* --- Slider mode: หน้าเดียวเต็มพื้นที่ สลับด้วยลูกศร --- */
.flipbook-slider-stage {
	position: relative;
	margin: 0 auto;
	max-width: 100%;
	overflow: hidden;
}
.flipbook-slide {
	position: absolute;
	top: 0; left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease;
}
.flipbook-slide.is-active {
	opacity: 1;
	visibility: visible;
	position: relative;
}
.flipbook-slide canvas {
	max-width: 100%;
	max-height: 100%;
	box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

/* --- Vertical mode: สกอลล์ดูทุกหน้าต่อกัน --- */
.flipbook-vertical-stage {
	margin: 0 auto;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	padding: 8px;
	background: #f6f6f6;
	border-radius: 6px;
}
.flipbook-vpage canvas {
	max-width: 100%;
	height: auto;
	display: block;
	box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
	.flipbook-cover-trigger { max-width: 220px; }
	.flipbook-btn { font-size: 13px; padding: 5px 8px; }
	.flipbook-gallery-tab { font-size: 13px; padding: 6px 14px; }
	.flipbook-nav-btn { width: 34px; height: 34px; font-size: 16px; }
}
