/**
 * LabPulse Layout
 * App shell: sidebar + topbar + content, and their responsive behavior.
 */

/* ---------------------------------------------------------------
 * App shell
 * --------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-base);
}

.app-shell[data-sidebar-collapsed="true"] .app-main {
    margin-left: var(--sidebar-width-collapsed);
}

/* v1.0.1: widened from 1280px - on a wide desktop (1920px+) that cap
   left most of the viewport as dead empty gutter on both sides of a
   comparatively narrow, centered table/card grid (the exact
   "professional application, not a narrow floating table" complaint).
   1600px still caps line length sensibly on an ultrawide monitor while
   letting every table/dashboard grid actually use the available
   space on a normal wide desktop - not simply 100% width (that would
   stretch a table's action column absurdly far from its data on a
   2560px+ monitor), just a substantially more generous ceiling. */
.app-content {
    flex: 1;
    padding: var(--space-6);
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-topbar);
    text-align: center;
}

.app-footer p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------------------------------------------------------------
 * Sidebar
 * --------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: width var(--transition-base), transform var(--transition-base),
                background var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease);
    overflow: hidden;
}

.app-shell[data-sidebar-collapsed="true"] .sidebar {
    width: var(--sidebar-width-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    min-height: var(--topbar-height);
    border-bottom: 1px solid var(--sidebar-divider);
}

/* Base .brand/.brand-name/.brand-sub: also used OUTSIDE the sidebar
   (includes/layout/minimal-start.php's minimal-shell header, currently
   the Student My Profile page + one unlinked legacy diagnostic page) -
   that context sits on --surface-topbar, not the sidebar, so the
   sensible default here is the ordinary theme-aware text tokens.
   .sidebar-brand below overrides both for the sidebar's own
   (independently theme-aware) tokens. */
.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-primary);
    min-width: 0;
    flex: 1;
}
.brand:hover { text-decoration: none; }

/* Dr. Yanga's Colleges seal (assets/img/yanga-seal.png) has its own
   opaque white square background baked into the source image - a
   small rounded "chip" keeps that square from showing hard corners
   against whichever surface it sits on (sidebar or minimal-topbar). */
.brand-mark {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: grid;
    place-items: center;
}
.brand-mark-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}
.brand-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand .brand,
.sidebar-brand .brand-name {
    color: var(--sidebar-text);
}
.sidebar-brand .brand-sub {
    color: var(--sidebar-text-muted);
}

.sidebar-collapse-btn {
    flex: none;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-icon);
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover-bg); }

@media (min-width: 993px) {
    .sidebar-collapse-btn { display: inline-flex; }
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-3);
}

.sidebar-section + .sidebar-section {
    margin-top: var(--space-5);
}

/* Sidebar Navigation & Spacing Cleanup: root cause of the "unexplained
   large gap" below Schoology on every role's sidebar - a section with
   no heading (.sidebar-heading never renders - see includes/layout/
   sidebar.php) still received the SAME top margin as a headed one,
   with no heading text to visually justify that space. A heading
   genuinely needs room to read as a new category; a plain continuation
   of nav items (e.g. Notifications/Settings/Logout) doesn't - this
   override (higher specificity than the rule above, since it also
   matches .sidebar-section-plain on the second element) shrinks it to
   the same breathing room already used elsewhere in this sidebar,
   rather than an arbitrary/negative value disconnected from the
   existing spacing scale. */
.sidebar-section + .sidebar-section.sidebar-section-plain {
    margin-top: var(--space-2);
}

/* 2026-11-17 (owner): My Profile + Logout - an unlabeled group pinned to the bottom of the sidebar for every role
   (the "Account" groups hold only the account pages the owner listed). When the menu is taller than the window it
   simply follows the last group. */
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-section-footer,
.sidebar-section + .sidebar-section.sidebar-section-footer {
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-section-footer { flex-shrink: 0; }
.sidebar-section:has(+ .sidebar-section-footer) { margin-bottom: var(--space-4); }
/* icon-only (collapsed) sidebar: the divider only */
.app-shell[data-sidebar-collapsed="true"] .sidebar-section-footer { padding-top: var(--space-2); }

.sidebar-heading {
    margin: 0 0 var(--space-2);
    padding: 0 var(--space-3);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 0.89rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-text);
    text-decoration: none;
}

/* Active nav item: a subtle gold-tinted wash plus a small gold
   indicator bar and gold-tinted icon, so the active item reads
   through the school's gold accent rather than just "some background
   changed" - the wash strength/active text color are theme-aware
   tokens now (a light sidebar needs a much lighter gold wash + dark
   text; the dark sidebar keeps its exact original look). */
.sidebar-link.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.sidebar-link.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: var(--radius-pill);
    background: var(--accent-500);
}
.sidebar-link.is-active .sidebar-icon {
    color: var(--sidebar-active-icon);
}

.sidebar-icon { flex: none; }

.sidebar-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-tag {
    flex: none;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    background: var(--sidebar-tag-bg);
    color: var(--sidebar-tag-text);
}

.sidebar-footer {
    padding: var(--space-3) var(--space-3) var(--space-4);
    border-top: 1px solid var(--sidebar-divider);
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--sidebar-text-muted);
    font-size: 0.85rem;
}
.sidebar-footer-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-text);
    text-decoration: none;
}

.sidebar-version {
    margin: var(--space-2) var(--space-3) 0;
    font-size: 0.7rem;
    color: var(--sidebar-text-muted);
    white-space: nowrap;
}

/* Collapsed state: hide text, center icons */
.app-shell[data-sidebar-collapsed="true"] .brand-text,
.app-shell[data-sidebar-collapsed="true"] .sidebar-heading,
.app-shell[data-sidebar-collapsed="true"] .sidebar-label,
.app-shell[data-sidebar-collapsed="true"] .sidebar-tag,
.app-shell[data-sidebar-collapsed="true"] .sidebar-footer-link .sidebar-label,
.app-shell[data-sidebar-collapsed="true"] .sidebar-version {
    display: none;
}
.app-shell[data-sidebar-collapsed="true"] .sidebar-link,
.app-shell[data-sidebar-collapsed="true"] .sidebar-footer-link {
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 20, 0.5);
    z-index: 30;
}

/* ---------------------------------------------------------------
 * Topbar
 * --------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--topbar-height);
    padding: 0 var(--space-6);
    background: var(--surface-topbar);
    border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.topbar-menu-btn {
    display: none;
}

.topbar-heading {
    min-width: 0;
}

.page-title {
    margin: 0;
    font-size: 1.15rem;
}

.breadcrumb ol {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.breadcrumb li:not(:last-child)::after {
    content: "/";
    margin-left: var(--space-1);
    color: var(--neutral-300);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: none;
}

.topbar-divider {
    width: 1px;
    height: 26px;
    background: var(--border-subtle);
}

/* Responsive header: the left side (title + breadcrumb) takes the remaining space and shrinks/truncates instead of
   overflowing into the right-hand controls (the breadcrumb used to be one row of items that could not shrink below
   their text, so it ran under the Workspace selector / bell / account menu). Less important text goes first:
   the "LabPulse" root crumb, then the Workspace label, then the whole breadcrumb on phones. The controls stay. */
.topbar-left { flex: 1 1 auto; }
.topbar-heading { flex: 1 1 auto; overflow: hidden; }
.topbar .page-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .breadcrumb { min-width: 0; }
.topbar .breadcrumb ol { flex-wrap: nowrap; min-width: 0; margin: 0; padding: 0; white-space: nowrap; }
.topbar .breadcrumb li { flex: none; }
.topbar .breadcrumb li:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.user-menu-name { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1199px) {
    .topbar .breadcrumb li:first-child:not(:last-child) { display: none; }
}
@media (max-width: 1100px) {
    .topbar .dev-ws-label { display: none; }
    .user-menu-name { max-width: 110px; }
}
@media (max-width: 640px) {
    .topbar .breadcrumb { display: none; }
    .topbar { padding: 0 var(--space-3); gap: var(--space-2); }
    .topbar-right { gap: var(--space-2); }
}
@media (max-width: 420px) {
    .topbar-divider { display: none; }
    .topbar-right { gap: var(--space-1); }
    .topbar-left { gap: var(--space-2); }
}
/* Developer workspace on phones: the Workspace selector + theme + bell + account need the whole row, so the header
   becomes two rows (menu + title; selector + controls) instead of squeezing the title to a few letters.
   --topbar-height follows (scoped to the main column) so the sticky editor toolbar still sits below the header. */
@media (max-width: 480px) {
    .app-shell[data-workspace="developer"] .app-main { --topbar-height: 104px; }
    .app-shell[data-workspace="developer"] .app-main .topbar { flex-wrap: wrap; align-content: center; row-gap: 4px; padding-top: 6px; padding-bottom: 6px; }
    .app-shell[data-workspace="developer"] .app-main .topbar-left,
    .app-shell[data-workspace="developer"] .app-main .topbar-right { flex: 1 0 100%; }
    .app-shell[data-workspace="developer"] .app-main .topbar-right { justify-content: flex-end; }
    .app-shell[data-workspace="developer"] .dev-ws-switch { margin-right: auto; }
    .app-shell[data-workspace="developer"] .app-main .dev-ws-switch .select { max-width: none; min-width: 140px; }
}

/* ---------------------------------------------------------------
 * Responsive: below 993px the sidebar becomes an off-canvas overlay
 * --------------------------------------------------------------- */
@media (max-width: 992px) {
    .app-main {
        margin-left: 0;
    }
    .app-shell[data-sidebar-collapsed="true"] .app-main {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 84vw);
        box-shadow: var(--shadow-lg);
    }
    .app-shell[data-sidebar-open="true"] .sidebar {
        transform: translateX(0);
    }
    .app-shell[data-sidebar-open="true"] .brand-text,
    .app-shell[data-sidebar-open="true"] .sidebar-heading,
    .app-shell[data-sidebar-open="true"] .sidebar-label,
    .app-shell[data-sidebar-open="true"] .sidebar-tag,
    .app-shell[data-sidebar-open="true"] .sidebar-version {
        display: revert;
    }

    .app-shell[data-sidebar-open="true"] .sidebar-overlay {
        display: block;
    }

    .topbar-menu-btn {
        display: inline-flex;
    }

    .app-content {
        padding: var(--space-4);
    }
}

@media (min-width: 993px) {
    .sidebar-overlay { display: none !important; }
}

/* Developer workspace preview: an item of the role's menu this Developer may not open (includes/nav-roles.php). */
.sidebar-link.is-preview-locked { opacity: 0.5; cursor: not-allowed; }
.sidebar-link.is-preview-locked:hover { background: transparent; color: var(--sidebar-text); }
