/* PDF Viewer Overlay */
.pdf-viewer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Use dynamic viewport height to account for mobile browser chrome */
    background: rgba(255, 255, 255, 0.5);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.pdf-viewer-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.pdf-viewer-container {
    background: #525659;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.pdf-viewer-header {
    background: #323639;
    padding: 15px 20px;
    padding-top: max(15px, env(safe-area-inset-top)); /* Account for notch/status bar */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.pdf-viewer-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pdf-viewer-controls button {
    background: #8c8c8c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s ease;
}

.pdf-viewer-controls button:hover {
    background: #666;
}

.pdf-viewer-controls button:disabled {
    background: #8c8c8c;
    cursor: not-allowed;
}

#page-info {
    color: white;
    font-size: 14px;
}

#zoom-level {
    color: white;
    font-size: 14px;
    min-width: 50px;
    text-align: center;
}

.close-btn {
    background: transparent;
    color: white;
    border: none;
    width: 40px;
    height: 40px;    
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #666;
}

.pdf-viewer-content {
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    position: relative;
}

.pdf-pages-container {
    transform-origin: top center;
    transition: transform 0.1s ease-out;
}

#pdf-canvas {
    display: block;
    margin: 0 auto 10px auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: white;
}

.pdf-page {
    display: block;
    margin: 0 auto 10px auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: white;
}

/* Loading indicator */
.loading {
    color: white;
    font-size: 18px;
    text-align: center;
}

/* Responsive design */
@media (max-width: 768px) {
    .pdf-viewer-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for mobile */
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
    }

    .pdf-viewer-header {
        border-radius: 0;
        position: sticky;
        top: 0;
        z-index: 10;
        padding-top: max(15px, env(safe-area-inset-top));
    }

    .pdf-viewer-controls {
        gap: 8px;
    }

    .pdf-viewer-controls button {
        padding: 6px 10px;
        font-size: 14px;
    }

    #page-info,
    #zoom-level {
        font-size: 12px;
    }
    
    .pdf-viewer-content {
        padding: 0;
    }
    
    .pdf-pages-container {
        width: 100%;
    }
    
    .pdf-page {
        width: 100vw !important;
        height: auto !important;
        margin: 0 0 2px 0;
        box-shadow: none;
    }
}
