* {
    box-sizing: border-box;
}

@font-face {
    font-family: 'fira-code';
    src: url('/assets/fonts/fira-code.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

body,
html {
    margin: 0;
    padding: 0;
    font-family: 'fira-code';
}

/* ------------------------------------------------------------------ */
/* App shell: fixed-height sidebar with its own scroll, content scrolls */
/* independently, the page body itself never scrolls.                  */
/* ------------------------------------------------------------------ */

html,
body {
    height: 100%;
    overflow: hidden;
    /* the page never scrolls — only .app-sidebar / .app-content do */
}

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 12px;
    border-bottom: 1px solid #e3e3e0;
}

.app-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    /* required so flex children can scroll instead of growing the row */
    position: relative;
    /* positioning context for the mobile sidebar + backdrop */
}

.app-sidebar {
    flex: 0 0 auto;
    width: 260px;
    min-width: 220px;
    max-width: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    /* brand (fixed top) / nav (scrolls) / footer (fixed bottom) */
    overflow: hidden;
    /* the aside itself never scrolls — .sidebar-nav does, see below */
    border-right: 1px solid #e3e3e0;
    background: #fff;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    /* required so this can scroll instead of growing the column */
    overflow-y: auto;
    padding: 8px;
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
}

/* ------------------------------------------------------------------ */
/* Sidebar open/close toggle                                           */
/* ------------------------------------------------------------------ */

.sidebar-toggle {
    display: none;
    /* only shown on narrow screens, see media query below */
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    margin-right: 8px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #1b1b18;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: #f0f0f0;
}

.sidebar-backdrop {
    display: none;
}

/* Off-canvas sidebar below this width — matches typical tablet/phone breakpoint */
@media (max-width: 860px) {
    .sidebar-toggle {
        display: inline-flex;
    }

    .app-content { 
        padding-bottom: 72px;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.12);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 900;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* Prevent the page behind the open drawer from also scrolling on touch */
    body.sidebar-open {
        overflow: hidden;
    }
}

.menu-tree,
.submenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
}

.navbar-brand-logo {
    max-height: 28px;
    display: block;
}

.navbar-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 7px;
    background: #1b1b18;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.navbar-brand-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.2px;
    color: #1b1b18;
}

.navbar-brand img {
    max-height: 32px;
}

.submenu {
    display: none;
    padding-left: 16px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
}

.menu-link:hover {
    background: #f0f0f0;
}

.menu-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.menu-item.open>.menu-link>.menu-arrow {
    transform: rotate(90deg);
}

.menu-arrow::before {
    content: '›';
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user {
    font-size: 16px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user strong {
    color: #444;
}

.sidebar-logout {
    width: 100%;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
}