/* Navigation shell: quiet, compact, and workspace-first. */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 2000;
    display: flex;
    width: var(--hms-sidebar-width);
    flex-direction: column;
    overflow: visible;
    background: var(--hms-sidebar-surface);
    border-right: 1px solid #d8e2ec;
    color: var(--hms-ink);
    transition: width .2s ease, transform .2s ease;
}

    .sidebar.collapsed {
        /* A labeled rail needs more room than an icon-only one did, so this
       sets its own fixed width instead of reusing --hms-sidebar-rail
       (that token may still be tuned for an icon-only rail elsewhere —
       adjust the value below to taste, e.g. wire it to a new
       --hms-sidebar-rail-labeled variable if you'd rather keep it themeable). */
        width: 104px;
    }

.sidebar-header {
    display: flex;
    min-height: var(--hms-topbar-height);
    align-items: center;
    padding: 0 22px;
    border-bottom: 1px solid #d8e2ec;
    background: rgba(255, 255, 255, .48);
}

.logo {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 12px;
    min-width: 0;
}

.logo-img {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 10px;
    object-fit: contain;
}

.logo-text {
    overflow: hidden;
    color: var(--hms-ink);
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.sidebar.collapsed .logo {
    width: 100%;
    justify-content: center;
}

.sidebar.collapsed .logo-text {
    display: none;
}

.nav {
    width: 100%;
    margin: 0;
    padding: 14px 10px 28px;
    overflow-y: auto;
    overflow-x: visible;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: #b8c5d2 transparent;
}

    .nav > li {
        position: relative;
        width: 100%;
        margin-bottom: 3px;
    }

.menu-section {
    padding: 18px 12px 7px;
    color: #9aa8b7;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav-link,
.menu-item {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #526477;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.menu-item {
    text-align: left;
}

    .nav-link:hover,
    .menu-item:hover {
        background: #f5f6ff;
        color: var(--hms-primary);
    }

.nav-link.active,
.nav > li:has(.submenu .active) > .menu-item {
    background: var(--hms-primary-soft);
    border-color: #dedbff;
    color: var(--hms-primary);
}

.menu-left {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.icon {
    display: inline-flex;
    width: 24px;
    min-width: 24px;
    align-items: center;
    justify-content: center;
    color: currentColor;
}

    .icon .mdi {
        font-size: 22px;
        line-height: 1;
    }

.text {
    overflow: hidden;
    flex: 1;
    font-size: 14px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.arrow {
    display: inline-flex;
    width: 18px;
    min-width: 18px;
    align-items: center;
    justify-content: center;
    color: #9aa8b7;
    font-size: 10px;
    transition: transform .15s ease;
}

    .arrow.rotate {
        transform: rotate(180deg);
    }

.submenu {
    max-height: 0;
    margin: 2px 0 5px;
    padding: 0 0 0 36px;
    overflow: hidden;
    border-left: 1px solid #e8ebf0;
    opacity: 0;
    transition: max-height .2s ease, opacity .15s ease, padding .2s ease;
}

    .submenu.open {
        max-height: 520px;
        padding-top: 3px;
        padding-bottom: 3px;
        opacity: 1;
    }

    .submenu li {
        width: 100%;
    }

        .submenu li a {
            display: flex;
            min-height: 38px;
            align-items: center;
            gap: 7px;
            padding: -1px 11px;
            border-radius: 6px;
            color: #4f6275;
            font-size: 13px;
            font-weight: 600;
            text-decoration: none;
            transition: background .15s ease, color .15s ease;
        }

            .submenu li a::before {
                width: 5px;
                height: 5px;
                min-width: 5px;
                border-radius: 50%;
                background: #91a0b0;
                content: "";
            }

            .submenu li a:hover,
            .submenu li a.active {
                background: #f5f6ff;
                color: var(--hms-primary);
            }

                .submenu li a.active::before {
                    background: var(--hms-primary);
                }

.submenu-icon {
    display: none;
}

/* =========================================================
   COMPACT RAIL — icon over label, like the reference layout,
   instead of icon-only. Arrows and section headers stay hidden;
   the flyout submenu still opens to the right on click.
========================================================= */

.sidebar.collapsed .nav {
    padding-right: 6px;
    padding-left: 6px;
}

.sidebar.collapsed .arrow,
.sidebar.collapsed .menu-section {
    display: none;
}

.sidebar.collapsed .nav > li {
    margin-bottom: 6px;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .menu-item {
    width: 100%;
    min-height: 72px;
    margin: 0;
    flex-direction: column;
    justify-content: center;
    padding: 10px 4px;
    border-radius: 14px;
    gap: 4px;
}

.sidebar.collapsed .menu-left {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.sidebar.collapsed .icon {
    width: 26px;
    min-width: 26px;
}

    .sidebar.collapsed .icon .mdi {
        font-size: 22px;
    }

.sidebar.collapsed .text {
    overflow: visible;
    flex: none;
    max-width: 92px;
    color: inherit;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
}

.sidebar.collapsed .submenu {
    display: none;
}

.sidebar.collapsed .nav {
    overflow-y: auto;
    overflow-x: visible;
}

.sidebar.collapsed .submenu.open {
    position: fixed;
    top: var(--flyout-top, 80px);
    left: 116px;
    z-index: 2200;
    display: block;
    width: 236px;
    max-height: calc(100vh - var(--flyout-top, 80px) - 24px);
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--hms-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 44px rgba(32, 48, 64, .18);
    opacity: 1;
}

    .sidebar.collapsed .submenu.open li a {
        min-height: 38px;
        border-radius: 8px;
    }

    .sidebar.collapsed .submenu.open::before {
        display: none;
    }

.sidebar::-webkit-scrollbar,
.nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-thumb,
.nav::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #b8c5d2;
}

.mobile-toggle,
.sidebar-overlay {
    display: none;
}

@media (max-width: 992px) {
    .sidebar {
        left: 0;
        width: var(--hms-sidebar-width);
        transform: translateX(-100%);
        box-shadow: 12px 0 32px rgba(32, 48, 64, .16);
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

        .sidebar.collapsed {
            width: var(--hms-sidebar-width);
        }

            /* On mobile the "collapsed" rail isn't used — the sidebar is either
       fully open (slid in) or fully hidden — so it reverts to the normal
       horizontal icon+label row instead of the stacked rail layout. */
            .sidebar.collapsed .menu-section {
                display: inline-flex;
            }

            .sidebar.collapsed .arrow {
                display: inline-flex;
            }

            .sidebar.collapsed .nav-link,
            .sidebar.collapsed .menu-item {
                width: 100%;
                min-height: 46px;
                flex-direction: row;
                margin: 0;
                justify-content: space-between;
                padding: 0 12px;
                border-radius: 8px;
            }

            .sidebar.collapsed .menu-left {
                flex-direction: row;
                justify-content: flex-start;
                gap: 12px;
            }

            .sidebar.collapsed .submenu {
                display: block;
            }

            .sidebar.collapsed .text {
                max-width: none;
                font-size: 14px;
                text-align: left;
                white-space: nowrap;
            }

            .sidebar.collapsed .submenu,
            .sidebar.collapsed .submenu.open {
                position: static;
                width: auto;
                max-height: 520px;
                margin: 2px 0 5px;
                padding: 3px 0 3px 36px;
                border: 0;
                border-left: 1px solid #e8ebf0;
                border-radius: 0;
                box-shadow: none;
                background: transparent;
            }

    .sidebar-overlay.show {
        position: fixed;
        inset: 0;
        z-index: 1900;
        display: block;
        background: rgba(32, 48, 64, .28);
    }

    .mobile-toggle {
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 3000;
        display: inline-flex;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--hms-border);
        border-radius: 8px;
        background: #fff;
        color: var(--hms-ink);
    }
}
