/* ============================================================================
 * shell.css — the ONE application shell (student + admin share this)
 *
 * Fixes critique finding #2: "two page shells in one product" (student sidebar
 * 264px, admin 250px, different header heights and paddings).
 *
 * RTL: sidebar is anchored to the INLINE-END edge (right under dir=rtl) using
 * logical properties only — no physical left/right anywhere in this file.
 * ========================================================================== */

/* ---- App shell: sidebar + main ----------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: 1fr var(--shell-sidebar-width);
    min-height: 100vh;
    min-height: calc(100vh / 0.85);
    background: var(--color-background);
}
.app-shell__main {
    display: flex;
    flex-direction: column;
    min-width: 0;              /* allows inner content to scroll, not the grid */
}
.app-shell__content {
    flex: 1 1 auto;
    padding: var(--shell-content-pad);
    min-height: calc(100vh - var(--shell-topbar-height));
    min-height: calc((100vh / 0.85) - var(--shell-topbar-height));
}

/* Sidebar sits on the inline-end edge (right in RTL). Under the md breakpoint
 * it becomes an off-canvas drawer. */
.app-sidebar {
    grid-column: -2 / -1;
    background: var(--shell-sidebar-bg);
    color: var(--color-text-on-inverse);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: calc(100vh / 0.85);
    overflow-y: auto;
    scrollbar-width: thin;
}

/* ---- Institutional top bar -------------------------------------------- */
.app-topbar {
    height: var(--shell-topbar-height);
    display: flex;
    align-items: center;
    gap: var(--space-inline-md);
    padding-block: 0;
    padding-inline: var(--shell-content-pad);
    background: var(--color-surface-1);
    border-block-end: var(--border-1) solid var(--color-border-subtle);
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-topbar__menu { display: none; }   /* shown under md only */
.app-topbar__heading { min-width: 0; }
.app-topbar__title {
    font-size: var(--font-size-h3);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-h3);
    color: var(--color-text-primary);
    margin: 0;
}
.app-topbar__crumb {
    font-size: var(--font-size-caption);
    color: var(--color-text-tertiary);
}
.app-topbar__spacer { flex: 1 1 auto; }
.app-topbar__user {
    display: flex;
    align-items: center;
    gap: var(--space-inline-sm);
}

/* ---- Sidebar internals (shared by both product halves) ----------------- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-inline-sm);
    padding: var(--space-inset-md);
    border-block-end: var(--border-1) solid var(--inverse-divider);
}
.sidebar-brand__crests { display: flex; gap: var(--space-inline-xs); }
.sidebar-brand__crest { height: var(--avatar-sm); width: auto; }
.sidebar-brand__names { display: flex; flex-direction: column; min-width: 0; }
.sidebar-brand__uni {
    font-size: var(--font-size-body);
    font-weight: var(--fw-bold);
    line-height: 1.3;
}
.sidebar-brand__fac {
    font-size: var(--font-size-caption);
    color: var(--color-text-on-inverse-2);
    font-weight: var(--fw-medium);
}
.sidebar-scope {
    padding-block: var(--s-2);
    padding-inline: var(--space-inset-md);
    font-size: var(--font-size-caption);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    color: var(--color-text-on-inverse-3);
}
.sidebar-foot {
    margin-top: auto;
    padding: var(--space-inset-sm) var(--space-inset-md);
    font-size: var(--font-size-caption);
    color: var(--color-text-on-inverse-3);
    border-block-start: var(--border-1) solid var(--inverse-divider);
}

/* ---- Nav list ----------------------------------------------------------- */
.nav-group {
    padding-block: var(--s-3) var(--s-1);
    padding-inline: var(--space-inset-md);
    font-size: var(--font-size-caption);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    color: var(--color-text-on-inverse-3);
}
.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-inline-sm);
    width: 100%;
    padding-block: var(--s-2);
    padding-inline: var(--space-inset-md);
    background: none;
    border: 0;
    color: var(--color-text-on-inverse-2);
    font-size: var(--font-size-body);
    font-weight: var(--fw-medium);
    line-height: var(--lh-body);
    text-align: start;              /* resolves to right under dir=rtl */
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur-1) var(--ease-standard),
                color var(--dur-1) var(--ease-standard);
}
.nav-link svg { flex: 0 0 auto; height: var(--icon-size-sm); width: var(--icon-size-sm); }
.nav-link:hover { background: var(--inverse-hover); color: var(--color-text-on-inverse); }
.nav-link[aria-current="page"] {
    background: var(--inverse-current);
    color: var(--color-text-on-inverse);
    font-weight: var(--fw-semibold);
    box-shadow: inset-inline-start: var(--focus-width) solid var(--brand-orange);
}
.nav-link[aria-current="page"] svg { color: var(--brand-orange); }

/* ---- Mobile drawer behaviour ------------------------------------------- */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 28, 48, 0.4);
    z-index: 40;
}
@media (max-width: 671px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-end: 0;
        width: min(var(--shell-sidebar-width), 86vw);
        z-index: 50;
        transform: translateX(100%);   /* hidden off the inline-end edge */
        transition: transform var(--dur-3) var(--ease-out);
    }
    .app-shell[data-drawer="open"] .app-sidebar { transform: none; }
    .app-shell[data-drawer="open"] .app-sidebar-backdrop { display: block; }
    .app-topbar__menu { display: inline-flex; }
}
