/* ============================================================
   Layout — Shell application : sidebar + topbar + content.
   ============================================================ */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content";
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    grid-area: sidebar;
    background: var(--c-primary);
    border-right: 1px solid var(--c-primary-d);
    color: rgba(255,255,255,.85);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-5);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-md);
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.10);
    letter-spacing: .02em;
}

.sidebar__nav {
    padding: var(--sp-3) var(--sp-2);
    flex: 1;
}

/* Groupe pliable */
.sidebar__group {
    margin-bottom: var(--sp-2);
}
.sidebar__group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: 0;
    padding: var(--sp-2) var(--sp-3);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.55);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.sidebar__group-title:hover { color: #fff; }
.sidebar__group-title::after {
    content: "›";
    font-size: 16px;
    transition: transform var(--transition);
    transform: rotate(90deg);
    color: rgba(255,255,255,.55);
}
.sidebar__group.is-collapsed .sidebar__group-title::after {
    transform: rotate(0deg);
}
.sidebar__group-items {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 180ms ease-out;
}
.sidebar__group.is-collapsed .sidebar__group-items {
    max-height: 0;
}

.sidebar__link {
    display: block;
    padding: 7px var(--sp-3);
    margin: 1px 0;
    color: rgba(255,255,255,.80);
    border-radius: var(--radius);
    font-size: var(--fs-base);
    line-height: 1.4;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.sidebar__link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}
.sidebar__link.is-active {
    background: var(--c-secondary);
    color: #fff;
    font-weight: var(--fw-medium);
}

.sidebar__footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid rgba(255,255,255,.10);
    font-size: var(--fs-xs);
    color: rgba(255,255,255,.45);
}

/* ===== Topbar ===== */
.topbar {
    grid-area: topbar;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0 var(--sp-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}
.topbar__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--c-primary);
}
.topbar__right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}
.topbar__user {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}
.topbar__user-name { color: var(--c-text); font-weight: var(--fw-medium); }
.topbar__user-role { color: var(--c-text-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; }
.topbar__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--c-secondary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
}

/* ===== Content ===== */
.content {
    grid-area: content;
    padding: var(--sp-5);
    overflow-x: auto;
}
.content__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
    gap: var(--sp-3);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--c-border);
}
.content__title { margin: 0; font-size: var(--fs-xl); color: var(--c-primary); }
.content__subtitle { margin: 4px 0 0; color: var(--c-text-muted); font-size: var(--fs-sm); }

/* ===== Layout auth ===== */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
    background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-secondary) 100%);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-6);
}
.auth-brand {
    text-align: center;
    margin-bottom: var(--sp-5);
}
.auth-brand h1 {
    font-size: var(--fs-xl);
    margin: 0 0 4px;
    color: var(--c-primary);
}
.auth-brand p {
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }
    .sidebar {
        display: none;
        position: fixed;
        z-index: 100;
        width: var(--sidebar-w);
    }
    .sidebar.is-open { display: flex; }
}
