:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-dark: #111111;
    --card-bg: #1a1a1a;
    --text-light: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    overflow-x: hidden;
}

/* Header fijo optimizado */
.pdf-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 0;
    background: rgba(17, 17, 17, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: transform 0.3s ease;
    text-align: center;
}

.pdf-header.hidden {
    transform: translateY(-100%);
}

.pdf-header h1 {
    font-size: 1.8rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 4px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.pdf-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Contenedor principal */
.pdf-container {
    width: 100%;
    min-height: 100vh;
    padding-top: 80px;
}

/* Viewer de imágenes */
#image-viewer {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Contenedor de cada página/imagen */
.image-page {
    width: 100%;
    margin: 0 auto 30px auto;
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.image-page.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Contenedor de imagen con lazy loading */
.image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.image-container img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.image-container img.loaded {
    opacity: 1;
}

/* Skeleton loading optimizado */
.skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            #222 0%,
            #2a2a2a 50%,
            #222 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Número de página */
.page-number {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
    z-index: 10;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Indicador de página actual */
.page-indicator {
    position: fixed;
    right: 20px;
    bottom: 100px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(20px);
    z-index: 900;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s ease;
}

/* Botón volver arriba */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 900;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s ease;
}

.back-to-top:hover {
    transform: translateY(-2px);
}

/* Toast de fin */
.end-toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-light);
    padding: 12px 24px;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    text-align: center;
}

.end-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Loading inicial */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 2000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

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

/* Barra de progreso */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--primary-gradient);
    z-index: 1001;
    transition: width 0.3s ease;
}

/* Zoom para imágenes */
.image-page.zoomed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-page.zoomed img {
    max-width: 90%;
    max-height: 90vh;
    width: auto;
    height: auto;
    cursor: zoom-out;
}

/* Responsive */
@media (max-width: 768px) {
    .pdf-header {
        padding: 12px 0;
    }

    .pdf-header h1 {
        font-size: 1.4rem;
    }

    #image-viewer {
        padding: 10px;
    }

    .image-page {
        margin-bottom: 20px;
        border-radius: 12px;
    }

    .page-indicator {
        right: 10px;
        bottom: 80px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .back-to-top {
        right: 10px;
        bottom: 20px;
        width: 44px;
        height: 44px;
    }

    .page-number {
        top: 8px;
        right: 8px;
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .pdf-header h1 {
        font-size: 1.2rem;
    }

    .pdf-header p {
        font-size: 0.8rem;
    }

    .image-page {
        border-radius: 10px;
        margin-bottom: 15px;
    }
}

/* Preloader para imágenes */
.image-preloader {
    position: fixed;
    top: -100%;
    left: -100%;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}