/* ============================================================
   App Shell — shared left-sidebar layout (TJX red / white)
   Used by pages that call js/app-shell.js. Mimics the CI
   Platform look: red sidebar + white content w/ header bar.
   ============================================================ */

:root {
    --shell-red: #c31230;
    --shell-red-dark: #9c1028;
    --shell-red-deep: #7c0c1f;
    --shell-bg: #f5f6f8;
    --shell-width: 264px;
}

body.has-app-shell {
    background: var(--shell-bg);
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.shell-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--shell-width);
    background: linear-gradient(180deg, var(--shell-red) 0%, var(--shell-red-dark) 100%);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform 0.25s ease;
}

.shell-logo-wrap {
    padding: 22px 20px 18px;
}

.shell-logo-card {
    background: #fff;
    border-radius: 14px;
    padding: 10px 14px;
    display: inline-block;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.shell-logo-card img {
    height: 44px;
    width: auto;
    display: block;
}

.shell-logo-caption {
    color: rgba(255, 255, 255, 0.92);
    font-style: italic;
    font-size: 0.82rem;
    margin-top: 10px;
    letter-spacing: 0.01em;
}

/* ── Nav ──────────────────────────────────────────────────── */
.shell-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.shell-nav::-webkit-scrollbar { width: 5px; }
.shell-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 3px; }

.shell-nav-section {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: rgba(255, 255, 255, 0.5);
    padding: 14px 10px 5px;
}

.shell-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 500;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.shell-nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.9;
}

.shell-nav-item:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.shell-nav-item.active {
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #fff;
}

/* ── Sidebar bottom: user card ────────────────────────────── */
.shell-user {
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.shell-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.shell-user-meta { flex: 1; min-width: 0; }

.shell-user-name {
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-user-role {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-logout-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: none;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.shell-logout-btn:hover { background: rgba(0, 0, 0, 0.4); }

/* ── Content area + header bar ────────────────────────────── */
.shell-content {
    margin-left: var(--shell-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.shell-header {
    background: #fff;
    border-bottom: 1px solid #e8eaee;
    padding: 0 28px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.shell-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #374151;
    cursor: pointer;
    padding: 8px;
}

.shell-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #101010;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.shell-header-chip {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--shell-red);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pages put their existing markup inside .shell-page */
.shell-page { flex: 1; }

/* Mobile overlay */
.shell-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 55;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1023px) {
    .shell-sidebar { transform: translateX(-100%); }
    body.shell-sidebar-open .shell-sidebar { transform: translateX(0); }
    body.shell-sidebar-open .shell-overlay { display: block; }
    .shell-content { margin-left: 0; }
    .shell-hamburger { display: block; }
    .shell-header { padding: 0 16px; }
    .shell-title { font-size: 1.15rem; }
}

/* ── Deferred nav skeleton ─────────────────────────────────────────────
   Pages that set APP_SHELL.deferNav hold the menu in this state until the
   signed-in user's role is known, so a CDC auditor never sees the full NDC
   menu paint and then collapse to a single item. app-shell.js clears
   .shell-nav-pending on shellNavReady(), and always within 2.5s. */
.shell-nav-skeleton { display: none; }

body.shell-nav-pending .shell-nav { display: none; }
body.shell-nav-pending .shell-nav-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    flex: 1;
}
.shell-nav-skeleton span {
    display: block;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.13);
    animation: shellNavPulse 1.25s ease-in-out infinite;
}
.shell-nav-skeleton span:nth-child(2) { animation-delay: .1s; width: 88%; }
.shell-nav-skeleton span:nth-child(3) { animation-delay: .2s; width: 94%; }
.shell-nav-skeleton span:nth-child(4) { animation-delay: .3s; width: 80%; }
.shell-nav-skeleton span:nth-child(5) { animation-delay: .4s; width: 90%; }

@keyframes shellNavPulse {
    0%, 100% { opacity: .35; }
    50%      { opacity: .8; }
}

@media (prefers-reduced-motion: reduce) {
    .shell-nav-skeleton span { animation: none; opacity: .45; }
}
