* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.visor-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #1a1a1a; /* Fondo un poco más claro que negro puro */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* --- SPINNER DE CARGA (NUEVO) --- */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #1a1a1a;
    z-index: 50; /* Encima del libro, debajo de controles */
    color: #fff;
    transition: opacity 0.5s ease-out;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #0bceaf; /* Tu color primario */
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-overlay p {
    font-size: 0.9rem;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* --- HEADER --- */
.visor-header {
    position: absolute; 
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    box-shadow: none;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    color: #fff;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    z-index: 100;
    pointer-events: none; 
}

.visor-header > * {
    pointer-events: auto;
}

.hidden-ui {
    transform: translateY(-100%);
    opacity: 0;
}

/* Para el footer, hidden-ui lo mueve hacia abajo */
.visor-controls.hidden-ui {
    transform: translate(-50%, 100%);
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.revista-titulo {
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.revista-fecha {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.btn-cerrar {
    text-decoration: none;
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-cerrar:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.visor-stage {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

#flipbook {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    /* Importante: centrado para page-flip */
}

/* Forzamos estilos al canvas de la librería */
.stf__wrapper {
    margin: 0 auto; 
}

.visor-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px;
    padding: 8px 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    backdrop-filter: blur(5px);
}

.btn-control {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 10px 15px;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
    border-radius: 8px;
    outline: none;
}

.btn-control:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-control:active {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
}

.divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
}

.page-counter {
    color: white;
    font-family: monospace;
    font-size: 0.95rem;
    min-width: 70px;
    text-align: center;
    user-select: none;
}

#zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    display: none;
    cursor: grab;
}

#zoom-overlay.active {
    display: block;
}

#zoom-overlay.active:active {
    cursor: grabbing;
}

@media (max-width: 768px) {
    .visor-header {
        padding: 12px 20px;
    }
    .revista-titulo { font-size: 1.2rem; }
    .revista-fecha { font-size: 0.75rem; }
    .btn-cerrar .text-cerrar { display: none; }
    .visor-controls { bottom: 15px; padding: 6px 10px; }
    .btn-control { font-size: 1rem; padding: 8px 12px; }
    .page-counter { font-size: 0.85rem; min-width: 60px; }
    .divider { height: 20px; }
}

.visor-container.is-fullscreen .visor-header {
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
}