/**
 * Gremza PDF Flipbook - frontend viewer styles.
 * All classes use the "gremza-fb-" prefix. Self-contained (no external fonts).
 *
 * DOM map (matches gremza-flipbook.js):
 *   .gremza-flipbook                 (PHP container, gets .gremza-fb-ready)
 *     .gremza-fb-viewport            (clips zoom/pan overflow)
 *       .gremza-fb-stage-wrap        (zoom/pan transform target)
 *         .gremza-fb-stage           (StPageFlip mounts here)
 *           .gremza-fb-page          (one per PDF page)
 *             canvas.gremza-fb-canvas
 *     .gremza-fb-toolbar
 *       .gremza-fb-group
 *         button.gremza-fb-btn (.gremza-fb-prev/.gremza-fb-next/...)
 *         .gremza-fb-pagebox > input.gremza-fb-page-input + .gremza-fb-page-total
 *     .gremza-fb-thumbs
 *       .gremza-fb-thumbs-header > .gremza-fb-thumbs-title + .gremza-fb-thumbs-close
 *       .gremza-fb-thumbs-list > button.gremza-fb-thumb > canvas.gremza-fb-thumb-canvas
 *     .gremza-fb-spinner > .gremza-fb-spinner-inner > .gremza-fb-spinner-ring + .gremza-fb-spinner-text
 *     .gremza-fb-error
 *
 * State classes on container:
 *   .gremza-fb-thumbs-open, .gremza-fb-is-fullscreen
 * State classes on viewport:
 *   .gremza-fb-zoomed, .gremza-fb-panning
 */

/* ----------------------------- Wrapper ----------------------------- */

.gremza-flipbook {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	margin: 0 auto;
	background: #f3f4f6;
	border-radius: 6px;
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: #1f2937;
	-webkit-user-select: none;
	user-select: none;
}

.gremza-flipbook *,
.gremza-flipbook *::before,
.gremza-flipbook *::after {
	box-sizing: border-box;
}

/* ----------------------------- Viewport ---------------------------- */

.gremza-fb-viewport {
	position: relative;
	width: 100%;
	min-height: 320px;
	padding: 16px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: pan-y;
}

.gremza-fb-viewport.gremza-fb-zoomed {
	cursor: grab;
	touch-action: none;
}

.gremza-fb-viewport.gremza-fb-panning {
	cursor: grabbing;
}

.gremza-fb-stage-wrap {
	transform-origin: center center;
	transition: transform 0.08s linear;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gremza-fb-stage {
	width: 100%;
	margin: 0 auto;
}

/* ------------------------------ Pages ------------------------------ */

.gremza-fb-page {
	background: #ffffff;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.gremza-fb-canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/* ----------------------------- Toolbar ----------------------------- */

.gremza-fb-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 8px 12px;
	background: #1f2937;
	color: #f9fafb;
}

.gremza-fb-group {
	display: flex;
	align-items: center;
	gap: 4px;
}

.gremza-fb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 8px;
	font-size: 18px;
	line-height: 1;
	color: #f9fafb;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.gremza-fb-btn:hover {
	background: rgba(255, 255, 255, 0.12);
}

.gremza-fb-btn:focus-visible {
	outline: none;
	border-color: #60a5fa;
}

.gremza-fb-btn:active {
	background: rgba(255, 255, 255, 0.22);
}

.gremza-fb-pagebox {
	display: flex;
	align-items: center;
	gap: 2px;
	font-size: 14px;
	color: #e5e7eb;
}

.gremza-fb-page-input {
	width: 48px;
	height: 30px;
	padding: 0 6px;
	text-align: center;
	font-size: 14px;
	color: #f9fafb;
	background: #111827;
	border: 1px solid #374151;
	border-radius: 4px;
}

.gremza-fb-page-input:focus {
	outline: none;
	border-color: #60a5fa;
}

.gremza-fb-page-total {
	white-space: nowrap;
}

/* --------------------------- Thumbnails ---------------------------- */

.gremza-fb-thumbs {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 180px;
	max-width: 70%;
	background: #111827;
	color: #f9fafb;
	transform: translateX(-100%);
	transition: transform 0.2s ease;
	display: flex;
	flex-direction: column;
	z-index: 5;
}

.gremza-fb-thumbs-open .gremza-fb-thumbs {
	transform: translateX(0);
	box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
}

.gremza-fb-thumbs-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 10px;
	border-bottom: 1px solid #374151;
	flex: 0 0 auto;
}

.gremza-fb-thumbs-title {
	font-size: 14px;
	font-weight: 600;
}

.gremza-fb-thumbs-close {
	min-width: 28px;
	height: 28px;
	font-size: 20px;
}

.gremza-fb-thumbs-list {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.gremza-fb-thumb {
	position: relative;
	display: block;
	width: 100%;
	min-height: 60px;
	padding: 4px;
	background: #1f2937;
	border: 2px solid transparent;
	border-radius: 4px;
	cursor: pointer;
}

.gremza-fb-thumb:hover {
	border-color: #60a5fa;
}

.gremza-fb-thumb-canvas {
	display: block;
	width: 100%;
	height: auto;
	border-radius: 2px;
}

.gremza-fb-thumb-num {
	position: absolute;
	bottom: 4px;
	right: 6px;
	padding: 1px 5px;
	font-size: 11px;
	color: #f9fafb;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 3px;
}

/* ----------------------------- Spinner ----------------------------- */

.gremza-fb-spinner {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(243, 244, 246, 0.85);
	z-index: 8;
	transition: opacity 0.2s ease;
}

.gremza-fb-spinner.gremza-fb-hidden {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
}

.gremza-fb-spinner-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}

.gremza-fb-spinner-ring {
	width: 40px;
	height: 40px;
	border: 4px solid #d1d5db;
	border-top-color: #2563eb;
	border-radius: 50%;
	animation: gremza-fb-spin 0.8s linear infinite;
}

.gremza-fb-spinner-text {
	font-size: 14px;
	color: #4b5563;
}

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

/* ------------------------------ Error ------------------------------ */

.gremza-fb-error {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	text-align: center;
	font-size: 15px;
	color: #b91c1c;
	background: rgba(243, 244, 246, 0.95);
	z-index: 9;
}

/* ---------------------------- Fullscreen --------------------------- */

.gremza-flipbook:fullscreen,
.gremza-flipbook.gremza-fb-is-fullscreen {
	width: 100vw;
	height: 100vh;
	max-width: none;
	margin: 0;
	border-radius: 0;
	background: #0b0f1a;
	display: flex;
	flex-direction: column;
}

.gremza-flipbook:fullscreen .gremza-fb-viewport,
.gremza-flipbook.gremza-fb-is-fullscreen .gremza-fb-viewport {
	flex: 1 1 auto;
	min-height: 0;
}

.gremza-flipbook:fullscreen .gremza-fb-toolbar,
.gremza-flipbook.gremza-fb-is-fullscreen .gremza-fb-toolbar {
	flex: 0 0 auto;
}

/* --------------------------- Responsive ---------------------------- */

@media (max-width: 768px) {
	.gremza-fb-viewport {
		padding: 8px;
		min-height: 260px;
	}

	.gremza-fb-toolbar {
		flex-direction: column;
		gap: 8px;
		padding: 8px;
	}

	.gremza-fb-group {
		justify-content: center;
	}

	.gremza-fb-thumbs {
		width: 60%;
	}
}
