/* --- 1. OVERLAY (FIXED POSITION & Z-INDEX) --- */
.reaper-modal-overlay {
    /* Ensures it covers the entire viewport */
    position: fixed !important; 
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    
    background: rgba(0, 0, 0, 0.8);
    /* CRITICAL: Set Z-Index to MAX VALUE to ensure it's always on top */
    z-index: 2147483647 !important; 
    
    display: none; 
    justify-content: center;
    align-items: center;
}

/* --- 2. MODAL CONTENT (SIZING & CENTERING) --- */
.reaper-modal-content {
    background: #fff;
    padding: 0;
    border-radius: 5px;
    
    /* Centering Trick (confirmed working for you) */
    position: absolute; 
    top: 50%;           
    left: 50%;          
    transform: translate(-50%, -50%); 
    
    /* Sizing */
    max-width: 95%;
    /* Ensure width is responsive, not fixed */
    width: 90%; 
    min-width: 300px; 
    
    /* Scrolling: The body handles the scroll, content is the container */
    max-height: 90vh;
    overflow-y: hidden; /* CRITICAL: Ensure the entire content container does NOT show a scrollbar */
    
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    z-index: 2147483647; 
}

/* --- 3. HEADER (APPEARANCE TWEAKS & STICKINESS) --- */
.reaper-modal-header {
    flex-shrink: 0;
    padding: 15px 20px; 
    position: sticky; 
    top: 0;
    background: #f8f8f8; 
    z-index: 10;
    width: 100%;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    border-bottom: 1px solid #eee; 
    
    /* CRITICAL FIX: Use Flexbox to align the button to the right */
    display: flex;
    justify-content: flex-end; /* Pushes content (the close button) to the right */
}

/* --- 4. CLOSE BUTTON (APPEARANCE TWEAKS) --- */
.reaper-modal-close {
    /* CRITICAL FIXES: Use Flexbox for perfect centering */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0; /* Remove conflicting padding */

    background: #e0e0e0;
    /* NEW: Add 1px border */
    border: 1px solid #333; 
    
    font-size: 20px;
    cursor: pointer;
    color: #333;
    border-radius: 50%; 
    transition: background-color 0.2s ease, color 0.2s ease;
    /* Maintain dimensions */
    height: 32px; 
    width: 32px; 
}

.reaper-modal-close:hover {
    background-color: #d0d0d0;
    color: #111;
}

/* --- 5. MODAL BODY (SCROLLABLE AREA & SCROLLBAR HIDING) --- */
.reaper-modal-body {
    padding: 20px; /* Default padding */
    flex-grow: 1;
    overflow-y: auto; 
    width: 100%;

    /* --- Modal Body Scrollbar Hiding --- */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* NEW: Aggressively reduce modal body padding on small screens (e.g., mobile) */
@media (max-width: 500px) {
    .reaper-modal-body {
        /* Reduce vertical padding to reclaim screen space */
        padding-top: 10px; 
        padding-bottom: 10px;
    }
}

/* Hide scrollbar for Chrome, Safari and Opera (WebKit browsers) */
.reaper-modal-body::-webkit-scrollbar {
    display: none;
    width: 0 !important; 
    height: 0 !important; 
}


/* --- 6. MEDIA SIZING (Image, Video, PDF Canvas) --- */
.reaper-modal-body img,
.reaper-modal-body video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* CRITICAL FIX: PDF.js Canvas styles */
#pdf-viewer-container {
    width: 100%; 
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden; /* Prevent horizontal scroll from the PDF container itself */
}

/* The Canvas elements are the PDFs themselves (one per page) */
.pdf-page-canvas {
    /* CRITICAL: Ensure the canvas is treated as a block element */
    display: block;
    /* Optional: Add a subtle border */
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* The width and height attributes are set dynamically by JS, but max-width ensures we don't exceed the container */
    max-width: 100%; 
    /* Spacing between multiple pages */
    margin-bottom: 15px; 
}

/* --- 7. AUDIO PLAYER STYLES (UPDATED FOR MODERN LOOK) --- */
.audio-player-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; /* Increased gap */
    border-radius: 10px; /* Softer edges */
    padding: 30px 20px; /* More padding */
    /* CRITICAL FIX: Replace fixed width with max-width for responsiveness */
    max-width: 600px; 
    width: 100%; /* Now uses 100% of the modal body, up to 600px */
    margin: 0 auto;
    background: #ffffff; /* White background */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

.waveform-container {
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 5px 0;
    border-radius: 5px;
    /* Optional: Add a light border to the waveform area itself */
    border: 1px solid #eee;
}

#waveform-top {
    height: 90px;
    /* Ensure no visual artifacts are bleeding */
}

#waveform-bottom {
    transform: scaleY(-1);
    height: 90px;
    margin-top: -10px;
}

#play-pause-btn {
    /* CRITICAL CHANGE: Circular, prominent button */
    display: flex;
    justify-content: center;
    align-items: center;
    
    width: 60px; /* Larger size */
    height: 60px;
    padding: 0;
    
    background-color: #6e48aa; /* Progress color from JS */
    border: none;
    border-radius: 50%; /* Make it perfectly circular */
    
    cursor: pointer;
    color: #fff; /* White icon */
    font-size: 24px;
    
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Style the SVG icon inside the button */
#play-pause-btn svg {
    width: 28px;
    height: 28px;
    color: #fff;
    /* Adjust play button icon position for optical centering */
    transform: translateX(2px);
}

#play-pause-btn:hover {
    background-color: #5b3a8e; /* Slightly darker purple on hover */
    box-shadow: 0 4px 12px rgba(110, 72, 170, 0.4); /* Subtle hover shadow */
}