/* ==========================================================================
   layout.css — App shell (sidebar + header + content) and shared components.
   Mobile-first: on narrow screens the sidebar becomes a slide-in drawer opened
   by the header hamburger.
   ========================================================================== */

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

/* ---------------- Header ---------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.header__hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.header__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    height: 100%;
}

.header__brand svg {
    height: 30px;
    width: auto;
    display: block;
}

.header__spacer {
    flex: 1;
}

.header__user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.header__role {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px var(--sp-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

/* Inline variant, sized to sit next to a page title instead of in the header. */
.icon-btn--sm {
    width: 30px;
    height: 30px;
}

/* ---------------- Body: sidebar + content ---------------- */
.body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: var(--sp-4) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--surface);
    color: var(--text);
}

.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-section {
    margin-top: var(--sp-4);
    padding: 0 var(--sp-3) var(--sp-2);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.content {
    flex: 1;
    min-width: 0;
    padding: var(--sp-6);
    overflow-x: hidden;
}

.page-title {
    font-size: var(--fs-xl);
    font-weight: 700;
    margin: 0 0 var(--sp-2);
    letter-spacing: -0.01em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    margin: 0 0 var(--sp-6);
}

/* Backdrop for the mobile drawer. */
.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.btn--primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

.btn--primary:hover {
    opacity: 0.9;
    background: var(--accent);
}

.btn--danger {
    border-color: var(--status-red);
    color: var(--status-red);
}

.btn--danger:hover {
    background: var(--status-red-dim);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------------- Cards / surfaces ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-5);
}

/* ---------------- Responsive: tablet / mobile ---------------- */
@media (max-width: 900px) {
    .content {
        padding: var(--sp-4);
    }

    /* Sidebar becomes an off-canvas drawer. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 35;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: var(--shadow);
    }

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

    .app.is-drawer-open .backdrop {
        display: block;
    }
}

/* Hamburger only on small screens. */
@media (min-width: 901px) {
    .header__hamburger {
        display: none;
    }
}

@media (max-width: 480px) {
    .header__user .header__username {
        display: none;
    }
}
