/* =========================================
   Base Styles & Variables
   ========================================= */
   :root {
    --sidebar-width: 300px; /* Define sidebar width */
    --button-spacing: 0.75rem; /* Define spacing for the toggle button from edges */
    --fixed-controls-height: 60px; /* Approx height of fixed controls area */
}

body {
    overflow-x: hidden;
    background-color: #f8f9fa;
}

/* =========================================
   Sidebar (#sidebar)
   ========================================= */
#sidebar {
    width: var(--sidebar-width);
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

#sidebar .flex-shrink-0 { flex-shrink: 0; }
#sidebar .flex-grow-1 { flex-grow: 1; overflow-y: auto; }

/* Accordion Customization */
.sidebar-unit-button {
    font-weight: 500;
    color: #495057;
    background-color: transparent;
    border: none;
    box-shadow: none !important;
}
.sidebar-unit-button:not(.collapsed) {
    background-color: #e9ecef;
    color: #000;
}
.sidebar-unit-button:focus { box-shadow: none; }
.sidebar-unit-button i { vertical-align: middle; }

/* Submenu items */
.submenu { padding-left: 0; margin-bottom: 0; }
.submenu-link {
    display: block;
    font-size: 0.9rem;
    color: #6c757d;
    text-decoration: none;
    padding: 0.5rem 1rem 0.5rem calc(1rem + 0.75rem);
    margin-left: 0.75rem;
    border-left: 3px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
}
.submenu-link:hover {
    background-color: #e9ecef;
    color: #212529;
    border-left-color: #ced4da;
}
.submenu-link.active {
    background-color: #ddeeff;
    color: #0056b3;
    font-weight: 500;
    border-left-color: #0056b3;
}

/* =========================================
   Main Content Area (#main-content)
   ========================================= */
#main-content {
    margin-left: var(--sidebar-width);
    width: auto;
    padding-top: var(--fixed-controls-height);
    box-sizing: border-box;
    transition: margin-left 0.3s ease-in-out;
}

/* =========================================
   Sidebar Toggle Button (#toggleSidebarBtn) - CORRECTED
   ========================================= */
/* Use 'body' prefix for increased specificity */
body #toggleSidebarBtn {
    position: fixed;
    top: var(--button-spacing);
    /* Default position: To the right of the visible sidebar */
    left: calc(var(--sidebar-width) + var(--button-spacing));
    z-index: 1050;
    /* Animate the 'left' property change */
    transition: left 0.3s ease-in-out;
    /* Add any other base styles for the button if needed */
}

/* =========================================
   Fixed Controls (.fixed-controls - Zoom)
   ========================================= */
.fixed-controls {
    position: fixed;
    top: 0;
    right: 0;
    padding: var(--button-spacing);
    z-index: 1050;
}

/* =========================================
   State: Sidebar Hidden (body.sidebar-hidden) - CORRECTED
   ========================================= */
body.sidebar-hidden #sidebar {
    transform: translateX(-100%);
}

body.sidebar-hidden #main-content {
    margin-left: 0;
}

/* Override button position when sidebar is hidden */
/* Use 'body.sidebar-hidden' prefix for increased specificity */
body.sidebar-hidden #toggleSidebarBtn {
    left: var(--button-spacing); /* Move to corner */
}

/* =========================================
   PDF Viewer
   ========================================= */
.pdf-viewer-container {
    display: flex;
    justify-content: center;
    min-height: calc(100vh - var(--fixed-controls-height));
    padding-bottom: 2rem;
}
.pdf-viewer {
    max-width: 850px;
    width: 95%;
    transform-origin: top center;
    transition: transform 0.2s ease-out;
}
.pdf-page-container {
    position: relative;
    margin-bottom: 1.5rem;
    background-color: #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
    overflow: hidden;
}
.pdf-image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}
.pdf-protector {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: default;
}

/* =========================================
   Zoom Percentage Label (#zoomLabel)
   ========================================= */
#zoomLabel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* =========================================
   Responsive Adjustments (Small Screens)
   ========================================= */
@media (max-width: 991.98px) {
    /* Sidebar starts hidden (JS adds .sidebar-hidden) */
    body:not(.sidebar-hidden) #sidebar {
        transform: translateX(0);
        box-shadow: 2px 0 15px rgba(0,0,0,0.15);
    }
    #closeSidebarInsideBtn { display: none; }
    body:not(.sidebar-hidden) #closeSidebarInsideBtn { display: inline-block; }
    /* The specific positioning rules for #toggleSidebarBtn based on */
    /* body.sidebar-hidden work correctly here too */
}

/* =========================================
   Utility Classes (Optional - From JS)
   ========================================= */
.no-transition {
    transition: none !important;
}