/* ============================================================
   MEMBER SHELL — sidebar + topbar + content
   Pure CSS interactions (no JS): the drawer and the account menu
   are driven by a checkbox and <details>, so the layout can stay
   statically rendered while pages opt into interactivity.
   ============================================================ */

.shell {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--rsa-page-bg);
}

/* --- drawer state (checkbox lives at the top of the shell) --- */
.shell__drawer-state {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.shell__sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    height: 100dvh;
    width: var(--rsa-sidebar-w);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 60% at 100% 0%, rgba(244, 0, 100, .22) 0%, transparent 55%),
        radial-gradient(120% 50% at 0% 100%, rgba(248, 184, 0, .16) 0%, transparent 55%),
        linear-gradient(180deg, #2e3192 0%, #1e205f 100%);
    color: rgba(255, 255, 255, .78);
    z-index: 1000;
    overflow-y: auto;
    overscroll-behavior: contain;
    transition: transform var(--rsa-base);
}

.shell__brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.25rem 1.15rem 1.1rem;
    position: relative;
}
.shell__brand::after {
    content: '';
    position: absolute;
    left: 1.15rem;
    right: 1.15rem;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16) 25%, rgba(255, 255, 255, .16) 75%, transparent);
}
.shell__brand img {
    height: 38px;
    width: auto;
}
.shell__brand-text { min-width: 0; line-height: 1.15; }
.shell__brand-name {
    font-family: var(--rsa-font-display);
    font-weight: 700;
    font-size: .9375rem;
    color: #fff;
    letter-spacing: -.01em;
}
.shell__brand-sub {
    font-size: .6875rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
    margin-top: .1rem;
}

.shell__nav {
    flex: 1;
    padding: 1rem .75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.shell__nav-label {
    padding: 1rem .8rem .4rem;
    font-size: .625rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .35);
}
.shell__nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .8rem;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .72);
    border-left: 3px solid transparent;
    transition: background var(--rsa-fast), color var(--rsa-fast), border-color var(--rsa-fast);
    position: relative;
}
.shell__nav .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--rsa-fast);
}
.shell__nav .nav-link:hover {
    background: rgba(255, 255, 255, .09);
    color: #fff;
}
.shell__nav .nav-link:hover i { transform: translateX(1px) scale(1.06); }
.shell__nav .nav-link.active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-weight: 600;
    border-left-color: var(--rsa-yellow-500);
}
.shell__nav .nav-link.active i { color: var(--rsa-yellow-500); }

.shell__nav-badge {
    margin-left: auto;
    font-size: .6875rem;
    font-weight: 700;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--rsa-pink-500);
    color: #fff;
    line-height: 1.55;
}

/* CTA that sits above the nav list */
.shell__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    margin: 1rem .75rem .25rem;
    padding: .65rem .9rem;
    border-radius: 10px;
    background: var(--rsa-yellow-500);
    color: var(--rsa-purple-800);
    font-size: .875rem;
    font-weight: 650;
    transition: background var(--rsa-fast), transform var(--rsa-fast), box-shadow var(--rsa-fast);
}
.shell__cta:hover {
    background: var(--rsa-yellow-400);
    color: var(--rsa-purple-900);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px -8px rgba(248, 184, 0, .8);
}

/* --- sidebar footer: signed-in identity + sign out --- */
.shell__sidebar-foot {
    margin-top: auto;
    flex-shrink: 0;
    padding: .85rem .75rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.shell__who {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .4rem .55rem .7rem;
    min-width: 0;
}
.shell__who .avatar { flex-shrink: 0; }
.shell__who .avatar {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    width: 36px;
    height: 36px;
    font-size: .78125rem;
}
/* Name over email, each clipped to the sidebar width. The children are <span>s:
   without display:block they sit inline on one line and the nowrap+ellipsis
   rules never apply, so a long email overflows the sidebar. */
.shell__who-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.shell__who-name,
.shell__who-mail { display: block; }
.shell__who-name {
    font-size: .8125rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell__who-mail {
    font-size: .6875rem;
    color: rgba(255, 255, 255, .5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell__signout {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .55rem .8rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(255, 255, 255, .6);
    font-size: .8125rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background var(--rsa-fast), color var(--rsa-fast);
}
.shell__signout:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.shell__signout i { width: 20px; text-align: center; }

/* ============================================================
   MAIN COLUMN
   ============================================================ */

.shell__main {
    margin-left: var(--rsa-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shell__topbar {
    position: sticky;
    top: 0;
    z-index: 500;
    height: var(--rsa-topbar-h);
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(1.6) blur(10px);
    -webkit-backdrop-filter: saturate(1.6) blur(10px);
    border-bottom: 1px solid var(--rsa-line);
}

.shell__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--rsa-line);
    background: #fff;
    color: var(--rsa-gray-600);
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
}
.shell__burger:hover { background: var(--rsa-gray-100); color: var(--rsa-gray-900); }

/* compact mark in the topbar — only when the sidebar (and its logo) is hidden */
.shell__topbar-logo { display: none; line-height: 0; flex-shrink: 0; }
.shell__topbar-logo img { height: 26px; width: auto; }
@media (max-width: 991.98px) {
    .shell__topbar-logo { display: inline-block; }
}

.shell__topbar-title {
    font-family: var(--rsa-font-display);
    font-size: .9375rem;
    font-weight: 650;
    color: var(--rsa-gray-800);
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.shell__topbar-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-left: auto;
}

/* balance pill in the topbar */
.shell__balance {
    display: inline-flex;
    align-items: baseline;
    gap: .4rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    font-size: .8125rem;
    border: 1px solid var(--rsa-line);
    background: #fff;
    white-space: nowrap;
}
a.shell__balance { transition: border-color var(--rsa-fast), box-shadow var(--rsa-fast); }
a.shell__balance:hover { border-color: var(--rsa-purple-300); box-shadow: var(--rsa-shadow-xs); }
.shell__balance span:first-child {
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--rsa-gray-400);
}

/* account menu — a JS-free <details> dropdown */
.shell__account { position: relative; }
.shell__account > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .55rem .2rem .2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
}
.shell__account > summary::-webkit-details-marker { display: none; }
.shell__account > summary:hover { background: var(--rsa-gray-100); }
.shell__account[open] > summary { background: var(--rsa-gray-100); border-color: var(--rsa-line); }
.shell__account > summary .bi-chevron-down {
    font-size: .7rem;
    color: var(--rsa-gray-400);
    transition: transform var(--rsa-fast);
}
.shell__account[open] > summary .bi-chevron-down { transform: rotate(180deg); }

.shell__account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--rsa-line);
    border-radius: var(--rsa-radius);
    box-shadow: var(--rsa-shadow-lg);
    padding: .35rem;
    z-index: 1100;
    animation: rsa-fade-up .14s ease-out both;
}
.shell__account-head {
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--rsa-line-soft);
    margin-bottom: .3rem;
}
.shell__account-head strong { display: block; font-size: .8125rem; color: var(--rsa-gray-800); }
.shell__account-head span { font-size: .75rem; color: var(--rsa-gray-500); word-break: break-all; }
.shell__account-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    padding: .5rem .7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rsa-gray-700);
    font-size: .8125rem;
    text-align: left;
    cursor: pointer;
    transition: background var(--rsa-fast), color var(--rsa-fast);
}
.shell__account-item:hover { background: var(--rsa-gray-100); color: var(--rsa-gray-900); }
.shell__account-item i { color: var(--rsa-purple-500); width: 18px; text-align: center; }
.shell__account-item--danger { color: var(--rsa-pink-600); }
.shell__account-item--danger:hover { background: var(--rsa-pink-50); color: var(--rsa-pink-700); }
.shell__account-item--danger i { color: var(--rsa-pink-500); }

/* ============================================================
   CONTENT
   ============================================================ */

.shell__content {
    flex: 1;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: clamp(1.25rem, 2.4vw, 2rem) clamp(1rem, 3vw, 2rem) 3rem;
}
.shell__content--narrow { max-width: 920px; }

.shell__foot {
    padding: 1.25rem clamp(1rem, 3vw, 2rem) calc(2rem + env(safe-area-inset-bottom, 0px));
    text-align: center;
    font-size: .75rem;
    color: var(--rsa-gray-400);
}

/* ============================================================
   OVERLAY + RESPONSIVE
   ============================================================ */

.shell__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(21, 22, 66, .45);
    z-index: 999;
}

@media (max-width: 991.98px) {
    .shell__sidebar { transform: translateX(-100%); box-shadow: var(--rsa-shadow-lg); }
    .shell__main { margin-left: 0; }
    .shell__burger { display: inline-flex; }

    .shell__drawer-state:checked ~ .shell__sidebar { transform: translateX(0); }
    .shell__drawer-state:checked ~ .shell__overlay { display: block; }
}

@media (max-width: 575.98px) {
    .shell__balance { display: none; }
    .shell__topbar-title { font-size: .875rem; }
}

/* The nav closes itself when a link inside it is followed on mobile:
   the checkbox is reset by the label wrapping the overlay. */

/* ============================================================
   ADMIN VARIANT — same shell, calmer skin, denser content
   ============================================================ */

.shell--admin .shell__sidebar {
    /* no pink/yellow glow — admins stare at this all day */
    background: linear-gradient(180deg, #262878 0%, #151642 100%);
}
.shell--admin .shell__nav .nav-link.active {
    border-left-color: var(--rsa-pink-500);
}
.shell--admin .shell__nav .nav-link.active i { color: var(--rsa-pink-400); }
.shell--admin .shell__cta {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}
.shell--admin .shell__cta:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    box-shadow: none;
}

/* Admin tables run wide; pages bring their own .container-fluid py-4,
   so the shell contributes almost no padding of its own. */
.shell--admin .shell__content {
    max-width: none;
    padding: .25rem .75rem 2rem;
}

.shell__topbar-date {
    font-size: .8125rem;
    color: var(--rsa-gray-400);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 575.98px) {
    .shell__topbar-date { display: none; }
}

/* Page-entrance animation is skipped for admin: list pages re-render
   constantly while filtering and the motion would get in the way. */
.shell--admin .shell__content > * { animation: none; }

/* Impersonation banner — only a super admin "logged in as" someone sees this. */
.shell__impersonating {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .6rem 1rem;
    margin: .75rem 1.25rem 0;
    padding: .6rem .9rem;
    border-radius: 10px;
    background: var(--rsa-yellow-500);
    color: var(--rsa-purple-900);
    font-size: .875rem;
}
.shell__impersonating form { margin-left: auto; }
