/* ==========================================================================
   UNAMOS PDF VIEWER - Basado en la implementación de Biblioteca Virtual
   ========================================================================== */

.upv-wrapper {
	width: 100%;
	margin: 28px 0;
	background: #0f172a;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.08);
	display: flex;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	box-sizing: border-box;
}

.upv-wrapper *, .upv-wrapper *:before, .upv-wrapper *:after {
	box-sizing: border-box;
}

/* --- Barra de herramientas superior --- */
.upv-toolbar {
	background: #0f172a;
	padding: 10px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	user-select: none;
	min-height: 52px;
}

.upv-info-box {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	max-width: 45%;
}

.upv-badge {
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	background: #F88D11;
	color: #ffffff;
	padding: 3px 8px;
	border-radius: 4px;
	flex-shrink: 0;
}

.upv-title {
	font-size: 13.5px;
	font-weight: 600;
	color: #f1f5f9;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin: 0;
}

.upv-controls {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.upv-btn {
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff;
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 6px;
	height: 32px;
	min-width: 32px;
	padding: 0 9px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.15s ease;
	font-size: 12.5px;
	font-weight: 600;
	text-decoration: none;
	line-height: 1;
}

.upv-btn:hover {
	background: rgba(255, 255, 255, 0.22);
	border-color: rgba(255, 255, 255, 0.35);
	color: #ffffff;
}

.upv-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.upv-btn-download {
	background: rgba(0, 103, 255, 0.25);
	border-color: rgba(0, 103, 255, 0.5);
	color: #93c5fd;
	gap: 5px;
}

.upv-btn-download:hover {
	background: #0067FF;
	border-color: #0067FF;
	color: #ffffff;
}

.upv-btn-fs {
	background: rgba(248, 141, 17, 0.2);
	border-color: rgba(248, 141, 17, 0.45);
	color: #ffb866;
	gap: 6px;
}

.upv-btn-fs:hover {
	background: #F88D11;
	border-color: #F88D11;
	color: #ffffff;
}

.upv-page-info {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 13px;
	color: #e2e8f0;
	padding: 0 4px;
}

.upv-page-input {
	width: 44px;
	height: 28px;
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.25);
	color: #ffffff;
	border-radius: 4px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	padding: 0;
	outline: none;
}

.upv-page-input:focus {
	border-color: #F88D11;
	background: rgba(255, 255, 255, 0.22);
}

.upv-divider {
	width: 1px;
	height: 20px;
	background: rgba(255, 255, 255, 0.18);
	margin: 0 4px;
}

.upv-zoom-label {
	font-size: 12px;
	min-width: 40px;
	text-align: center;
	color: #cbd5e1;
	font-weight: 600;
}

/* --- Área de visualización del documento --- */
.upv-viewport {
	height: 780px;
	max-height: 82vh;
	min-height: 480px;
	overflow: auto;
	background: #1e293b;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 24px 16px;
	position: relative;
	-webkit-overflow-scrolling: touch;
}

.upv-canvas-wrapper {
	background: #ffffff;
	box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
	border-radius: 4px;
	overflow: hidden;
	transition: width 0.1s ease, height 0.1s ease;
	user-select: none;
	margin: 0 auto;
}

.upv-canvas {
	display: block;
	margin: 0 auto;
}

/* --- Spinner de carga --- */
.upv-spinner-box {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	color: #e2e8f0;
	font-size: 13.5px;
	background: rgba(15, 23, 42, 0.88);
	padding: 18px 28px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(4px);
	z-index: 10;
	pointer-events: none;
}

.upv-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid rgba(255, 255, 255, 0.15);
	border-top-color: #F88D11;
	border-radius: 50%;
	animation: upv-spin 0.8s linear infinite;
}

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

/* --- Barra inferior de respaldo / enlace directo --- */
.upv-footer {
	background: #0f172a;
	padding: 8px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	font-size: 12px;
	color: #94a3b8;
}

.upv-footer a {
	color: #60a5fa;
	text-decoration: underline;
	transition: color 0.15s ease;
}

.upv-footer a:hover {
	color: #93c5fd;
}

/* --- Fallback accesible cuando no carga JS --- */
.upv-fallback {
	padding: 24px;
	background: #f8fafc;
	border: 2px dashed #cbd5e1;
	border-radius: 8px;
	text-align: center;
	color: #334155;
	margin: 20px 0;
}

.upv-fallback-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: #003399;
	color: #ffffff !important;
	padding: 10px 20px;
	border-radius: 6px;
	text-decoration: none !important;
	font-weight: 600;
	margin-top: 10px;
	transition: background 0.2s ease;
}

.upv-fallback-btn:hover {
	background: #002266;
}

/* --- Modo Pantalla Completa --- */
.upv-wrapper:fullscreen,
.upv-wrapper:-webkit-full-screen,
.upv-wrapper.upv-is-fullscreen {
	width: 100vw !important;
	height: 100vh !important;
	max-width: none !important;
	border-radius: 0 !important;
	margin: 0 !important;
	z-index: 999999 !important;
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
}

.upv-wrapper:fullscreen .upv-viewport,
.upv-wrapper:-webkit-full-screen .upv-viewport,
.upv-wrapper.upv-is-fullscreen .upv-viewport {
	height: calc(100vh - 96px) !important;
	max-height: none !important;
}

/* --- Adaptabilidad Móvil --- */
@media (max-width: 768px) {
	.upv-info-box {
		width: 100%;
		max-width: 100%;
		justify-content: flex-start;
	}
	.upv-controls {
		width: 100%;
		justify-content: space-between;
	}
	.upv-btn span {
		display: none;
	}
	.upv-viewport {
		height: 520px;
		padding: 16px 8px;
	}
	.upv-footer {
		flex-direction: column;
		gap: 6px;
		text-align: center;
	}
}
