/* ===== App shell + sidebar (shared): templates/layouts/vnv.html, vnv/templates/vnv/includes/sidebar.html =====
   Sidebar on the left, the page on the right. Bootstrap offcanvas-lg: below 992px the sidebar is a drawer
   (opened by .app-shell__menu-btn), from 992px a sticky column under the fixed navbar that "Thu gọn" collapses to
   its icons (static/js/utils/app-sidebar.js, .app-shell.is-collapsed). Mobile-first. */
.app-shell {
    --app-sidebar-width: 240px;
    --app-sidebar-collapsed-width: 64px;
    --app-sidebar-bg: #fff;
    --app-sidebar-border: var(--gray-100, #f3f4f6);
    --app-sidebar-active-bg: var(--primary-light, #eff6ff);
    --app-sidebar-active-color: var(--primary, #2563eb);
}

/* ----- Sidebar: the drawer (phones, tablets) ----- */
.app-sidebar {
    /* Above the navbar and the fixed mobile footer (--z-dropdown), like a modal */
    --bs-offcanvas-zindex: var(--z-modal);
    --bs-offcanvas-width: min(300px, 85vw);
    background: var(--app-sidebar-bg);
}

.app-sidebar__header {
    border-bottom: 1px solid var(--app-sidebar-border);
}

.app-sidebar__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.app-sidebar__body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem;
}

.app-sidebar__group-label {
    margin: 0 0 0.25rem;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9ca3af;
}

.app-sidebar__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
}

.app-sidebar__link:hover,
.app-sidebar__link:focus-visible {
    background: #f3f4f6;
    color: #111827;
}

.app-sidebar__link.is-active {
    background: var(--app-sidebar-active-bg);
    color: var(--app-sidebar-active-color);
}

.app-sidebar__icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

/* A long label wraps onto a second line instead of being cut */
.app-sidebar__text {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* "Thu gọn": desktop only */
.app-sidebar__collapse {
    display: none;
}

/* "Menu VNV" above the page: phones and tablets only */
.app-shell__menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: var(--space-3, 0.75rem) var(--space-4, 1rem) 0;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--app-sidebar-border);
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Off (the default until switched on in /tai-khoan/; app-sidebar.js, .is-disabled): the page alone, as before */
.app-shell.is-disabled .app-sidebar,
.app-shell.is-disabled .app-shell__menu-btn {
    display: none;
}

/* ----- Desktop: a column next to the page ----- */
@media (min-width: 992px) {
    .app-shell {
        display: flex;
        align-items: flex-start;
    }

    .app-shell.is-disabled {
        display: block;
    }

    .app-shell__menu-btn {
        display: none;
    }

    .app-shell__main {
        flex: 1;
        min-width: 0;
    }

    .app-sidebar {
        position: sticky;
        top: var(--navbar-height);
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        width: var(--app-sidebar-width);
        height: calc(100vh - var(--navbar-height));
        border-right: 1px solid var(--app-sidebar-border);
        transition: width 0.2s ease;
    }

    /* offcanvas-lg makes the body a row without scrolling at this width: a scrolling column instead */
    .app-sidebar .app-sidebar__body {
        flex: 1;
        flex-direction: column;
        padding: 0.75rem;
        overflow-y: auto;
    }

    .app-sidebar__collapse {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin: 0.5rem 0.75rem 0.75rem;
        padding: 0.55rem 0.75rem;
        border: 0;
        border-radius: 8px;
        background: none;
        color: #6b7280;
        font-size: 0.875rem;
        font-weight: 600;
        white-space: nowrap;
    }

    .app-sidebar__collapse:hover {
        background: #f3f4f6;
        color: #111827;
    }

    /* Collapsed: icons only (the links keep their title as tooltip) */
    .app-shell.is-collapsed .app-sidebar {
        width: var(--app-sidebar-collapsed-width);
    }

    .app-shell.is-collapsed .app-sidebar__text,
    .app-shell.is-collapsed .app-sidebar__group-label {
        display: none;
    }

    .app-shell.is-collapsed .app-sidebar__body,
    .app-shell.is-collapsed .app-sidebar__collapse {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .app-shell.is-collapsed .app-sidebar__link,
    .app-shell.is-collapsed .app-sidebar__collapse {
        justify-content: center;
    }

    .app-shell.is-collapsed .app-sidebar__collapse .app-sidebar__icon {
        transform: rotate(180deg);
    }
}
