/* Viewer page - PDF viewer, canvas, download FAB */

.viewer-page {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10000;
    background: #050b14;
    display: flex;
    flex-direction: column;
    padding-top: calc(40px + var(--safe-area-top, env(safe-area-inset-top, 0px)));
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.pdf-container {
    width: 100%;
    flex: 1;
    position: relative;
    min-height: 0;
}

.pdf-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

#pdf-loading-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #050b14;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.5s;
}

.spinner-view {
    width: 50px; height: 50px;
    border: 4px solid rgba(0,242,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin-anim 0.8s linear infinite;
}

.loading-text-viewer {
    margin-top: 20px;
    color: var(--primary);
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    letter-spacing: 2px;
}

.drive-blocker {
    position: absolute;
    top: 0; right: 0;
    width: 70px; height: 70px;
    background: transparent;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 12px;
}

.drive-download-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    backdrop-filter: blur(4px);
    padding: 0;
}

.drive-download-btn:hover {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
}

.viewer-close {
    position: absolute;
    top: 8px; left: 8px;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 18px;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.viewer-close:hover {
    background: rgba(255,255,255,0.15);
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Download FAB --- */
.fab-btn-custom {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 60px; height: 60px;
    background: rgba(5, 11, 20, 0.8);
    backdrop-filter: blur(5px);
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 16px;
    font-size: 24px;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
    cursor: pointer;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-btn-custom:hover {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 30px var(--primary);
    transform: translateY(-5px) scale(1.05);
}

.fab-btn-custom svg {
    fill: currentColor;
    width: 28px;
    height: 28px;
}

/* PDF.js canvas viewer */
.pdf-canvas-container {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    background: #0a0f1a;
    min-height: 0;
}

.pdf-canvas-container #pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 10px;
    width: 100%;
    box-sizing: border-box;
}

.pdf-canvas-page {
    display: block;
    max-width: 100%;
    height: auto !important;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.download-fallback {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 20px rgba(0,242,255,0.3);
    transition: 0.2s;
}

.download-fallback:hover {
    box-shadow: 0 0 40px rgba(0,242,255,0.5);
    transform: translateX(-50%) scale(1.05);
}

.loading-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 50px;
    font-family: 'Fira Code', monospace;
}
