/* PDF Container Styles */
.resource-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto; /* allow horizontal scroll when zoomed */
}

.resource-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.pdf-container {
    height: 85vh;
    width: 100%;
    overflow: hidden;
    position: relative;
    background-color: #a7a1a1;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* PDF Viewer Core Styles */
.pdf-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* stretch to allow full-width child */
    overflow-y: auto;
    overflow-x: auto; /* enable horizontal scroll */
    position: relative;
    scroll-behavior: smooth;
}

.pdf-pages-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.pdf-page-container {
    width: max-content; /* sized to page width so viewer can scroll both ways */
    display: flex;
    justify-content: flex-start; /* keep page left within its own container */
    margin: 0 auto; /* visually center when not scrolled */
    min-height: 100px;
    scroll-margin-top: 20px;
}

.pdf-page {
    max-width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    pointer-events: none;
    user-select: none;
}

/* Controls Styles */
.pdf-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 10px;
    gap: 10px;
    position: sticky;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px;
    width: 100%;
    z-index: 100;
    border-top: 1px solid #eee;
}

.pdf-controls button {
    padding: 5px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pdf-controls button:hover {
    background-color: #0056b3;
}

.pdf-controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#zoom-in, #zoom-out, #fullscreen {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    margin-left: 5px;
    background-color: #0056b3;
    transition: all 0.2s ease;
}

#zoom-in:hover, #zoom-out:hover, #fullscreen:hover {
    background-color: #003d7a;
    transform: scale(1.05);
}

#zoom-in i, #zoom-out i, #fullscreen i {
    font-size: 16px;
    color: white;
    display: inline-block !important;
}

.pdf-page-info {
    margin: 0 10px;
    line-height: 30px;
}

/* Watermark disabled */
.watermark { display: none !important; }

/* Fullscreen watermark styles */
.pdf-container:fullscreen .watermark,
.pdf-container:-webkit-full-screen .watermark,
.pdf-container:-moz-full-screen .watermark,
.pdf-container:-ms-fullscreen .watermark { display: none !important; }

/* Mobile Styles */
@media (max-width: 767px) {
    .pdf-container {
        height: 70vh;
    }
    .watermark {
        font-size: 40px; /* Smaller size for mobile */
    }
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    h1 {
        font-size: 1.5rem;
    }
    .breadcrumb {
        font-size: 0.8rem;
    }
    
    .pdf-controls {
        padding: 8px 5px;
        gap: 5px;
    }
    
    .pdf-controls button {
        padding: 4px 10px;
    }
    
    #zoom-in, #zoom-out, #fullscreen {
        width: 36px;
        height: 36px;
    }
    
    .fullscreen-active .pdf-controls {
        padding: 6px 3px;
        gap: 3px;
    }
    
    .fullscreen-active .pdf-controls button {
        padding: 3px 8px;
        font-size: 0.9rem;
    }
    
    .fullscreen-active #zoom-in,
    .fullscreen-active #zoom-out,
    .fullscreen-active #fullscreen {
        width: 32px;
        height: 32px;
    }
    
    .fullscreen-active .pdf-page-info {
        font-size: 0.9rem;
        margin: 0 5px;
    }
}

/* Protection Styles */
.blurred {
    filter: blur(20px);
    transition: filter 0.3s;
}

/* Chrome-specific fullscreen fixes */
.pdf-container:fullscreen,
.pdf-container:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    background-color: #a7a1a1 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.pdf-container:fullscreen .pdf-viewer,
.pdf-container:-webkit-full-screen .pdf-viewer {
    flex: 1 !important;
    height: calc(100vh - 60px) !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-y: auto !important;
}

/* Control visibility rules - update these styles */
/* Update the hide-controls rule for better mobile support */
.hide-controls.fullscreen-active .pdf-controls {
    opacity: 0;
    pointer-events: none;
    visibility: hidden; /* Add this */
    transform: translateY(100%); /* Add this for smoother animation */
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out, transform 0.3s ease-out;
    will-change: transform, opacity, visibility; /* Performance optimization */
}

.fullscreen-active .pdf-controls {
    opacity: 1;
    pointer-events: auto;
    visibility: visible; /* Add this */
    transform: translateY(0); /* Add this for smoother animation */
    transition: opacity 0.3s ease-in, visibility 0.3s ease-in, transform 0.3s ease-in;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    margin: 0 !important;
}

/* Improve touch handling */
.pdf-container {
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent; /* Prevent tap highlights */
}

.fullscreen-active .pdf-viewer {
    -webkit-overflow-scrolling: touch; /* Improve smooth scrolling on iOS */
}

/* Improve mobile controls in fullscreen */
.fullscreen-active .pdf-controls {
    background-color: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    padding: 12px 5px 0 !important; /* Adjust padding to remove bottom space */
}

.fullscreen-active .pdf-controls button {
    background-color: #0056b3 !important;
    color: white !important;
    border-radius: 4px !important;
    margin: 0 3px !important;
    min-width: 40px !important;
    height: 40px !important;
}

.fullscreen-active .scale-display {
    color: white !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    padding: 5px 8px !important;
    border-radius: 4px !important;
}

/* Ensure PDF pages maintain quality when zoomed */
.pdf-page {
    image-rendering: high-quality;
    max-width: none; /* Allow zooming beyond container width */
}

/* Improve mobile touch area for buttons */
@media (max-width: 767px) {
    .pdf-controls button {
        min-width: 36px;
        height: 36px;
        padding: 0;
    }
    
    .scale-display {
        min-width: 40px;
        font-size: 0.9rem;
    }
}
