:root {
    --bg-color: #767676;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background-color: var(--bg-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    position: relative;
    /* Space for margins and bottom bar */
    padding-top: 5px;
    padding-bottom: 35px;
    box-sizing: border-box;
    background-color: var(--bg-color);
    /* Explicitly set to avoid parent leak or defaults */
}

/* Flipbook Container */
#book {
    max-width: 95vw;
    /* 100vh - (padding-top + padding-bottom + extra buffer) */
    max-height: calc(100vh - 75px);
    opacity: 0;
    /* Hidden initially */
    transition: opacity 0.5s ease-in;
    /* Transición suave para zoom */
    transform-origin: center center;
}

.page {
    background-color: white;
    box-shadow: inset -5px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    /* Para el posicionamiento de la sombra central */
}

/* Sombra central (Efecto 3D en el pliegue) */
.page::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50px;
    pointer-events: none;
    z-index: 5;
}

/* Páginas a la izquierda interiores: sombra a la derecha */
/* Excluimos la primera hoja (relleno inicial) y la penúltima (contraportada) */
.page:nth-child(odd):not(:first-child):not(:nth-last-child(2))::after {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.2) 0%, transparent 100%);
}

.page.page-blank {
    background-color: var(--bg-color);
    box-shadow: none;
}

.page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Loading Overlay */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 20px 40px;
    border-radius: 10px;
    z-index: 1000;
}

/* Bottom Bar */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 100;
    backdrop-filter: blur(5px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.page-counter-group {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 15px;
}

#page-info {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    color: #ccc;
}

#first-page-btn,
#last-page-btn {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
    padding: 2px 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#first-page-btn:hover,
#last-page-btn:hover {
    color: white;
}

.bar-actions {
    display: flex;
    gap: 15px;
    margin-left: auto;
}

#maximize-btn,
#download-btn {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#maximize-btn:hover,
#download-btn:hover {
    color: white;
}

/* Navigation Buttons (Arrows) */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: auto;
    background: transparent;
    border: none;
    color: #000;
    font-size: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 200;
    transition: all 0.3s ease;
    padding: 10px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.4);
    opacity: 0.8;
}

.nav-btn:hover {
    transform: translateY(-50%) scale(1.1);
    opacity: 1;
    text-shadow: 0 0 15px rgba(255, 255, 255, 1);
    background: transparent;
    box-shadow: none;
}

.nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.nav-btn.prev {
    left: 10px;
}

.nav-btn.next {
    right: 10px;
}