/* ---------- Base ---------- */
html.sidebar-boot .main-panel {
    transition: none !important;
}

html.sidebar-is-open .main-panel {
    margin-left: var(--sidebar-width);
}

/* Hide sidebar initially to prevent flash */
#sidebar {
    visibility: hidden;
}

/* Show sidebar once initialized */
html.sidebar-initialized #sidebar {
    visibility: visible;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html, body {
    height: 100%;
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin: 0;
    overflow-x: hidden;
}

/* ---------- Focus + floating labels ---------- */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---------- Login card ---------- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f5f5f5;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: #fff;
    border-radius: .5rem;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.1);
}

/* ---------- Layout ---------- */
:root {
    --sidebar-width: 280px;
}

#sidebar {
    width: var(--sidebar-width) !important;
}

main {
    flex-grow: 1;
}

.page-container {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* MODIFIED: Set a fixed height and prevent panel from scrolling */
.main-panel {
    position: relative;
    pointer-events: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: 0;
    transition: margin-left 200ms ease;
    height: 100vh;
    overflow: hidden;
}

    /* MODIFIED: Remove sticky positioning */
    .main-panel > header {
        z-index: 1020;
        flex-shrink: 0;
    }

/* MODIFIED: Make content area scrollable */
.main-content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* ---------- Syncfusion Sidebar ---------- */
.e-sidebar {
    background: #fff;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.08);
    z-index: 1040;
}

    .e-sidebar .e-content,
    .e-sidebar .sidebar {
        height: 100%;
        overflow-y: auto;
    }

    /* Ensure Push mode works correctly */
    .e-sidebar.e-push.e-open ~ .main-panel {
        margin-left: var(--sidebar-width) !important;
    }

/* ---------- Sidebar nav styles ---------- */
.sidebar-nav {
    padding-left: 0;
    list-style: none;
}

    .sidebar-nav .nav-link {
        display: flex;
        align-items: center;
        font-size: 16px;
        font-weight: 500;
        color: #444;
        transition: .3s;
        padding: 10px 15px;
        border-radius: 4px;
        text-decoration: none;
    }

        .sidebar-nav .nav-link i {
            font-size: 18px;
            margin-right: 10px;
            color: #555;
        }

        .sidebar-nav .nav-link:hover {
            color: #007bff;
            background: #f6f9ff;
        }

    .sidebar-nav .nav-heading {
        font-size: 12px;
        text-transform: uppercase;
        color: #899bbd;
        font-weight: 600;
        margin: 10px 0 5px 15px;
        padding-top: 10px;
    }

    .sidebar-nav .nav-link.active {
        background: #eef4ff;
        color: #0d6efd;
    }

/* ---------- Navbar & stacking contexts ---------- */
/* MODIFIED: Removed sticky positioning; Flexbox handles it now. */
#app-navbar {
    position: relative; /* Keep for stacking context for dropdowns */
    z-index: 4000 !important;
}

    #app-navbar .dropdown-menu {
        z-index: 4001;
    }

/* Ensure the sidebar can never cover the navbar */
#sidebar.e-sidebar {
    z-index: 1000 !important;
}

    /* ---------- Pointer events: allow clicks when open ---------- */
    /* Sidebar must not receive clicks only when CLOSED */
    #sidebar.e-sidebar:not(.e-open),
    #sidebar.e-sidebar.e-close {
        pointer-events: none !important;
        visibility: hidden !important; /* Add this line */
    }

    /* When open (even while animating/transitioning), allow clicks */
    #sidebar.e-sidebar.e-open {
        pointer-events: auto !important;
        visibility: visible !important;
    }

/* If any Syncfusion overlay exists, make sure it never intercepts clicks */
.e-sidebar-overlay,
.e-dlg-overlay,
.e-overlay {
    pointer-events: none !important;
}