/* viewer-styles.css */

/* --- General PDF Viewer Styles --- */
#pdf-loading-spinner.hidden {
    display: none;
}

.neumorphic-outer {
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.1), -6px -6px 12px rgba(255, 255, 255, 0.8);
}

.neumorphic-inner {
    box-shadow: inset 4px 4px 8px rgba(0, 0, 0, 0.1), inset -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.blue-ball {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: #60a5fa;
    border-radius: 50%;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    top: 50%;
    left: 50%;
    transform-origin: 8px 8px; /* For rotation center */
}

#loading-percentage {
    margin-top: 1.5rem;
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 700;
    color: #374151; /* Tailwind gray-700 */
    text-align: center;
}

.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -2rem; /* Position below the element */
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.5rem;
    background-color: #1f2937; /* Tailwind gray-800 */
    color: white;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100; /* Ensure tooltip is above other elements */
}

.tooltip:hover::before {
    opacity: 1;
}

/* Toolbar visibility classes (if used by JS for specific fade effects, not for sticky) */
.toolbar-hidden {
    opacity: 0;
    pointer-events: none;
}

.toolbar-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Text Layer and Selection --- */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    opacity: 1; /* Should be visible by default once content is rendered */
    line-height: 1.0;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    z-index: 2; /* Above canvas, below UI elements */
    margin: auto; /* To align with canvas if canvas has margin auto */
    width: fit-content; /* Or match canvas width if needed */
    box-sizing: border-box;
    max-width: 100%;
}

.textLayer > span,
.textLayer > br {
    color: transparent; /* Makes the text invisible but selectable */
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0% 0%;
}

/* Standard selection style */
.textLayer ::selection {
    background: rgba(0, 0, 255, 0.2);
}
::selection { /* Global selection style for consistency */
    background: rgba(0, 0, 255, 0.2);
}
::-moz-selection { /* Firefox specific */
    background: rgba(0, 0, 255, 0.2);
    color: transparent; /* Some browsers need this for transparent text */
}

/* Search highlighting */
.search-highlight {
    background-color: rgba(255, 255, 0, 0.5); /* Yellow highlight */
    border-radius: 2px;
    /* color: black !important;  */
}

.search-highlight.active {
    background-color: rgba(255, 165, 0, 0.5); /* Orange for current active highlight */
}

/* Loading screens (if you have specific overlay elements) */
#loading-screen,
#fullscreen-loading-screen {
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999; /* High z-index to cover content */
}

#loading-progress,
#fullscreen-loading-progress {
    font-size: 1.25rem;
    font-weight: 600;
    color: #4a5568; /* Tailwind gray-600 */
}

/* --- Page Structure --- */
.page-container {
    margin-bottom: 1rem; /* Default margin, Tailwind 'mb-4' */
    margin-left: auto;
    margin-right: auto;
    position: relative; /* For absolutely positioned children like text layers */
    opacity: 0; /* JS manages this for fade-in on render */
    transition: opacity 0.15s ease-out; /* Matches JS class name duration */
    max-width: 100%; /* Prevents page-container from exceeding its parent's width */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.page-canvas {
    display: block; /* Removes extra space below inline elements */
    margin-left: auto;
    margin-right: auto;
    max-width: 100%; /* Critical to prevent overflow within its container */
    height: auto;    /* Maintain aspect ratio */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* Subtle shadow */
}


/* --- Main Viewer Container Styles --- */
/* IMPORTANT: Define how .my-pdf-viewer-main-container should look in NORMAL view */
/* This is crucial for restoring layout after exiting fullscreen */
.my-pdf-viewer-main-container {
    /* Adjust these values to fit your site's layout */
    max-width: 960px;  /* Example: Max width for the viewer in normal mode */
    width: 100%;       /* Takes available width up to max-width */
    margin: 20px auto; /* Example: Centers the viewer on the page with some top/bottom margin */
    padding: 0;        /* Reset padding if necessary */
    box-sizing: border-box;
    /* background-color: #f9f9f9; /* Optional: background for the container */
    /* border: 1px solid #ddd;   /* Optional: border for the container */
}

#pdf-container { /* This is inside .my-pdf-viewer-main-container */
    width: 100%;
    max-width: 100%; /* Takes full width of its parent (.my-pdf-viewer-main-container) */
    box-sizing: border-box;
    /* padding-top: 10px; /* Example padding inside pdf-container */
    /* padding-bottom: 10px; */
}

#pages-container { /* This is inside #pdf-container */
    width: 92%; /* Content width relative to #pdf-container */
    padding-top: 20px; /* Space above first page */
    max-width: 100%; /* Ensures it doesn't exceed #pdf-container */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

/* --- Toolbar Styling --- */
/* Base style for the normal toolbar (ID from your JS) */
#toolbar {
    /* Add your normal toolbar styles here: background, padding, flex properties, etc. */
    /* background-color: white; */
    /* padding: 0.5rem 1rem; */
    /* box-shadow: 0 2px 4px rgba(0,0,0,0.1); */
    position: relative; /* Or static, its normal flow position */
    z-index: 40; /* Below sticky toolbar z-index */
    /* If you ever want a smooth transition for sticky, add it here: */
    /* transition: top 0.2s ease-out, box-shadow 0.2s ease-out; */
}

/* Styles for when the toolbar becomes sticky */
.toolbar-is-sticky {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    opacity: 1 !important; /* Ensure it's fully visible */
    pointer-events: auto !important;
    transition: none !important; /* CRITICAL: No CSS transition for immediate stickiness */
    z-index: 50; /* Higher z-index to stay on top */
    /* Add specific sticky styles if different from normal, e.g., different shadow */
    /* box-shadow: 0 4px 6px rgba(0,0,0,0.15); */
}

/* --- Form Elements and Buttons (Overrides for consistency) --- */
#current-page,
#full-current-page {
    width: 2rem !important; /* Tailored width */
    min-width: 2rem !important; /* Ensure it doesn't shrink too much */
    border: 1px solid #e5e7eb !important; /* Tailwind gray-200 */
    border-radius: 0.25rem !important;
    text-align: center !important;
    font-weight: 400 !important;
    padding: 0 !important; /* Remove default padding if any */
    box-sizing: border-box !important;
    height: auto; /* Or a specific height to match other elements */
    line-height: normal; /* Or a specific line-height */
    transition: none !important; /* No transitions on these inputs */
}

#search-input {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    padding-left: 0.25rem !important; /* Some padding for text */
    padding-right: 0.25rem !important;
    width: 150px !important;
    font-size: 0.875rem !important;
    line-height: 1.25rem !important;
    background-color: transparent !important;
    border: none !important; /* Explicitly no border */
    outline: none !important;
    color: #000000 !important; /* Ensure text color is visible */
    box-shadow: none !important; /* Remove any default shadow */
}
#search-input::placeholder {
    color: #9ca3af; /* Tailwind gray-400 */
}


/* Remove borders from specific buttons if they are styled elsewhere or should be borderless */
#fullscreen-btn, .download-btn, .fullscreen-download,
#exit-fullscreen-btn, #zoom-in, #zoom-out,
#exit-fullscreen-btn-fs, #zoom-in-fs, #zoom-out-fs, /* Assuming these IDs exist or are typos */
#close-popup-btn, #popup-download-confirm,
#copyShareUrlButton, #edit-submit-btn { /* Added from your snippet */
    border: none !important;
}

/* --- Mobile Specific Styles --- */
@media (max-width: 768px) {
    /* Hide the entire desktop toolbar */
    #toolbar {
        display: none !important;
    }

    /* Prevent horizontal scroll on the entire page */
    html, body {
        overflow-x: hidden !important;
    }

    /*
     * CORE MOBILE FIX:
     * Force the main container to be full-width and apply a small, consistent
     * horizontal padding. This will be the *only* element responsible for side spacing.
    */
    .my-pdf-viewer-main-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 5px !important; /* Single source of horizontal padding */
        box-sizing: border-box !important;
    }

    /*
     * Reset all inner containers to prevent them from adding their own
     * conflicting padding or margins, which causes the "squeezed" look.
    */
    .my-pdf-viewer-main-container .maincontent,
    .my-pdf-viewer-main-container .paddingMobile,
    .my-pdf-viewer-main-container .mobilepage,
    .my-pdf-viewer-main-container #pdf-container,
    .my-pdf-viewer-main-container #pages-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-shadow: none !important;
    }

    /* Add back the necessary vertical spacing that was reset above */
    .my-pdf-viewer-main-container .paddingMobile {
        padding-top: 16px !important;
    }
    .my-pdf-viewer-main-container #pages-container {
        padding-top: 10px !important;
    }


    /* Ensure the individual pages and their canvases are full-width and have no shadow */
    .page-container,
    .page-canvas {
        max-width: 100% !important;
        height: auto !important;
        box-shadow: none !important;
    }

    .page-container {
        margin-bottom: 8px !important; /* Space between pages */
    }

    /* Hide the desktop fullscreen button on mobile */
    #fullscreen-btn {
        display: none !important;
    }
}


/* --- Fullscreen Mode Specific --- */
/* This is the main fullscreen wrapper div created by JS */
.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;  /* Use viewport units for true fullscreen */
    height: 100vh !important; /* Use viewport units for true fullscreen */
    z-index: 99998; /* Below FS toolbar, above everything else */
    background: #eef1ff; /* Your chosen FS background */
    margin: 0 !important;
    padding: 0 !important; /* Padding will be applied by JS for toolbar */
    overflow: hidden !important; /* Prevent scroll on the wrapper itself */
    box-sizing: border-box;
}

/* When .my-pdf-viewer-main-container is INSIDE .fullscreen-mode */
.fullscreen-mode .my-pdf-viewer-main-container {
    max-width: none !important; /* Override normal max-width */
    width: 100% !important;     /* Fill the .fullscreen-mode container */
    height: 100% !important;    /* Fill the .fullscreen-mode container */
    margin: 0 !important;       /* Reset margins */
    padding: 0 !important;      /* Reset padding */
    overflow: hidden;         /* Content scroll handled by #pdf-container */
}

.fullscreen-mode #pdf-container {
    height: 100% !important; /* Fill available height in .my-pdf-viewer-main-container */
    width: 100% !important;
    max-height: none !important;
    overflow-y: auto !important; /* Allow vertical scroll for PDF pages */
    overflow-x: hidden !important;/* Prevent horizontal scroll */
    position: relative !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    box-shadow: none !important; /* Remove normal shadow */
    padding-left: 0px !important; /* Adjust as needed for FS aesthetics */
    padding-right: 0px !important;
    padding-bottom: 10px !important; /* Space at the bottom */
}

.fullscreen-mode #pages-container {
    max-width: 100%; /* Ensure it doesn't try to be wider than its parent */
    margin-left: auto;
    margin-right: auto;
    display: flex; /* Helps with centering pages if they are narrower than container */
    flex-direction: column;
    align-items: center; /* Center pages horizontally if they don't fill width */
    transform-origin: center top; /* For CSS scaling in fullscreen */
    /* width is controlled by page-container elements inside it scaled by JS */
}

.fullscreen-mode #pages-container .page-container:last-child {
    margin-bottom: 0 !important; /* No extra margin after the last page in FS */
}

/* Custom footers in fullscreen */
.fullscreen-custom-footer {
    padding: 15px;
    border-top: 1px solid #ddd;
    box-sizing: border-box;
    width: 100%; /* Typically want footers to span width */
    text-align: center; /* Or as per content */
    background-color: #f9f9f9; /* Example background */
    margin-top: 10px; /* Space above footer */
}

/* Styles from your snippet - ensure they are correctly scoped or intended globally */
.uploads-area-divider {
    position: absolute;
    left: 0;
    /* Consider width, height, background for a visible divider */
}

#edit-form-message-area {
    visibility: hidden; /* Or display: none; depending on layout needs */
}

.file-block-content a {
    text-decoration: none !important;
    /* color: blue; /* Example link color */
}
.file-block-content a:hover {
    color: #ffffff; /* Your specified hover color */
    text-decoration: underline !important; /* Common hover behavior */
}