/* CSS Document */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html, body {
	width: 100%;
	height: 100vh;
	overflow: hidden;
	touch-action: manipulation;
}

body {
	background-color: #1e1e24;
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

/* Área de trabajo principal */
.main-container {
	flex: 1;
	width: 100%;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
}

/* ESTILOS PARA LA BARRA DE PROGRESO DE CARGA */
#loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	row-gap: 12px;
}
.progress-container {
	width: 260px;
	max-width: 80vw;
	height: 10px;
	background-color: rgba(255, 255, 255, 0.2);
	border-radius: 5px;
	overflow: hidden;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
	margin-top: 5px;
}
.progress-bar {
	width: 0%;
	height: 100%;
	background-color: #337ab7;
	background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
	background-size: 1rem 1rem;
	transition: width 0.2s ease-in-out;
}
	
/* Asegura que el contenedor evite cualquier scrollbar durante el Zoom */
.flipbook-viewport{ overflow: hidden !important; }
#flipbook{ will-change: transform; }
	
/* LOGO SUPERIOR IZQUIERDO */
.top-left-logo {
	position: absolute;
	top: 15px;
	left: 20px;
	z-index: 2500;
	pointer-events: none;
	transition: all 0.3s ease;
}

.top-left-logo img {
	max-height: 110px;
	max-width: 320px;
	object-fit: contain;
	filter: drop-shadow(0px 4px 8px rgba(0,0,0,0.6));
	transition: opacity 0.2s ease-in-out;
}

/* BARRA DE HERRAMIENTAS */
.toolbar {
	width: 100%;
	min-height: 65px;
	background: rgba(45, 45, 45, 0.78);
	backdrop-filter: blur(10px);
	border-top: 1px solid #525256;
	color: #f4f4f5;
	padding: 0 20px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	z-index: 3000;
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
	position: relative;
	flex-shrink: 0;
}

.toolbar-left-spacer {
	width: 140px;
	display: flex;
	align-items: center;
}

.toolbar-center {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: nowrap;
}

.toolbar button {
	background: #1e1e24;
	color: #e4e4e7;
	border: 1px solid #525256;
	padding: 8px 14px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: all 0.2s ease-in-out;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
	white-space: nowrap;
}

.toolbar button:hover {
	background: #4b4b54;
	color: #ffffff;
	border-color: #52525b;
}

.page-control {
	display: flex;
	align-items: center;
	gap: 6px;
	background: #18181b;
	padding: 4px 10px;
	border-radius: 6px;
	border: 1px solid #3f3f46;
	font-size: 13px;
	color: #a1a1aa;
	white-space: nowrap;
}

.page-control span {
	color: #f4f4f5;
	font-weight: 600;
}

.toolbar input[type="number"] {
	width: 44px;
	background: #27272a;
	color: #fff;
	border: 1px solid #3f3f46;
	padding: 4px;
	border-radius: 4px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	outline: none;
}

.toolbar input[type="number"]::-webkit-inner-spin-button, 
.toolbar input[type="number"]::-webkit-outer-spin-button { 
	-webkit-appearance: none;
	margin: 0;
}

/* LOGO INFERIOR */
.toolbar-right {
	width: 140px;
	display: flex;
	justify-content: flex-end;
	align-items: center;
}

.toolbar-right img {
	max-height: 50px;
	max-width: 100%;
	object-fit: contain;
	filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.3));
}


/* Visor del Flipbook */
.flipbook-viewport {
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	position: relative;
	padding: 5px;
	overflow: hidden;
	display: none;
}

.flipbook-container {
	position: relative;
	/*box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);*/
	z-index: 1;
	margin: auto !important;
	transform: translate3d(0, 0, 0);
	cursor:pointer;
}

.stpageflip--portrait, .stpageflip--landscape {
	margin: auto !important;
}

/* Páginas */
.page {
	background-color: #fff;
	overflow: hidden;
	width: 100%;
	height: 100%;
}

.page canvas {
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
	display: block;
}

.page.--left {
	border-right: 1px solid rgba(0, 0, 0, 0.1);
	box-shadow: inset -15px 0 20px -10px rgba(0, 0, 0, 0.4);
}

.page.--right {
	border-left: 1px solid rgba(0, 0, 0, 0.1);
	box-shadow: inset 15px 0 20px -10px rgba(0, 0, 0, 0.4);
}

/* Cartel de Carga */
#loading {
	position: absolute;
	width:25%;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: white;
	font-size: 15px;
	background:#000;
	border: 1px solid #525256;
	padding: 20px 30px;
	border-radius: 12px;
	z-index: 2000;
	text-align: center;
	box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#loading .spinner {
	margin-bottom: 10px;
	font-size: 24px;
	color: #6366f1;
}

/* ==========================================================================
   ADAPTACIONES MÓVILES Y MEDIA QUERIES (MÓVIL VERTICAL Y HORIZONTAL)
   ========================================================================== */

/* 1. MÓVIL EN VERTICAL (Portrait: Pantallas hasta 768px de ancho) */
@media (max-width: 768px) and (orientation: portrait) {
	.top-left-logo{ top:10px; left:10px; }
	.top-left-logo img{ max-height:40px; max-width:130px; }
	
	.toolbar{ flex-direction:column; height:auto; gap:6px; padding-top:6px; }
	.toolbar-left-spacer{ display:none; }
	.toolbar-center{ width:100%; justify-content:center; gap:4px; }
	.toolbar button{ padding:8px 10px; font-size:13px; min-width:38px; min-height:38px; /* Target táctil óptimo */ }

	/* Ocultar texto de los botones para ahorrar espacio */
	.btn-text{ display:none; }

	.toolbar-right{ width:100%; justify-content:center; }
	.toolbar-right img{ max-height:28px; }

	.page-control{ font-size:12px; padding:4px 6px; }

	/* Ocultar botones de Ir al inicio / Ir al final en móviles estrechos */
	#btnFirst, #btnLast{ display:none; }
}

/* 2. MÓVIL EN HORIZONTAL (Landscape: Pantallas de poca altura, <= 500px) */
@media (max-height: 500px) and (orientation: landscape) {
	/* Reduce el logo superior para que no tape la lectura */
	.top-left-logo{ top:8px; left:10px; }
	.top-left-logo img{ max-height:30px; max-width:100px; opacity:0.7; }

	/* Compacta la barra para maximizar el visor */
	.toolbar{
		min-height: 45px;
		padding: 4px 12px;
		padding-left: max(12px, env(safe-area-inset-left));
		padding-right: max(12px, env(safe-area-inset-right));
		padding-bottom: max(4px, env(safe-area-inset-bottom));
	}

	.toolbar-left-spacer { display:none; }
	.toolbar-center { gap:6px; }
	.toolbar button { padding:4px 8px; font-size:12px; height:32px; }
	.btn-text { display:none; 	}
	.toolbar-right img{ max-height:25px; }
	.page-control{ font-size:11px; padding:2px 6px; }
	.toolbar input[type="number"]{ width:36px; padding:2px; font-size:11px; }
}

/* 3. DISPOSITIVOS MUY PEQUEÑOS (< 360px) */
@media (max-width: 360px) {
	.page-control{ font-size:10px; }
	.toolbar button{ padding:6px; }
}