/* Cardinal dashboard shell — left sidebar + iframe content area.
   Loaded once on the root index.html. Each module is rendered inside the
   iframe in "embed" mode (its own top-toolbar collapses, shader skipped). */

body.dashboard {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    /* The shader canvas is z-index:-1 and parented to <body>; isolation
       confines its negative z-index so it sits behind the sidebar and iframe
       instead of escaping the stacking context. */
    isolation: isolate;
}

/* ===== Sidebar ===== */
.sidebar {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
            backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 2;
    transform: translateZ(0);
}

.sidebar-header {
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--fg);
}
.sidebar-header .sub {
    display: block;
    margin-top: 4px;
    color: var(--fg-mute);
    font-size: 11px;
    font-weight: 300;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-dim) transparent;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--fg-mute);
    margin: 18px 14px 6px;
    user-select: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    color: var(--fg-dim);
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    position: relative;
    transition: background 0.14s ease, color 0.14s ease;
    border-left: 2px solid transparent;
    user-select: none;
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--fg);
    text-decoration: none;
}
.nav-item.active {
    background: var(--accent-faint);
    color: var(--accent);
    box-shadow: inset 0 0 16px -8px var(--accent-glow);
}
.nav-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.nav-item.disabled:hover {
    background: transparent;
    color: var(--fg-dim);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}
.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Sidebar footer =====
   align-items: flex-start so the lang-toggle pill keeps its inline width.
   Children that need to span the full footer (.auth-widget) opt in via
   `align-self: stretch` or `width: 100%`. */
.sidebar-footer {
    padding: 14px 18px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}
/* The HTML5 `hidden` attribute is overridden by anything that sets
   `display: flex|grid|inline-flex`, which is the case for both .nav-item
   and .auth-* children below. Restore the expected behavior. */
.sidebar [hidden], .auth-widget [hidden] { display: none !important; }
.sidebar-footer .version {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--fg-mute);
    letter-spacing: 0.06em;
}

/* ===== Auth widget (Steam login state) ===== */
.auth-widget {
    width: 100%;
    min-height: 32px;
    align-self: stretch;
}
.auth-widget .auth-loading {
    color: var(--fg-mute);
    font-size: 11px;
    text-align: center;
    padding: 6px 0;
}
.auth-widget .auth-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--accent-faint);
    color: var(--accent);
    border: 1px solid var(--accent-dim);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.auth-widget .auth-signin:hover {
    background: rgba(220, 50, 80, 0.18);
    border-color: var(--accent);
    box-shadow: 0 0 14px -6px var(--accent-glow);
    color: var(--accent);
}
.auth-widget .auth-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
}
.auth-widget .auth-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    flex: 0 0 auto;
    border: 1px solid var(--border);
}
.auth-widget .auth-user-info {
    flex: 1;
    min-width: 0;
}
.auth-widget .auth-user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-widget .auth-user-role {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-mute);
}
.auth-widget .auth-logout {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--fg-dim);
    cursor: pointer;
    transition: color 0.14s ease, border-color 0.14s ease;
}
.auth-widget .auth-logout:hover {
    color: var(--fg);
    border-color: var(--accent-dim);
}

/* ===== Content frame ===== */
.dashboard-main {
    position: relative;
    overflow: hidden;
    background: transparent;
}
#module-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 760px) {
    body.dashboard {
        grid-template-columns: 64px 1fr;  /* collapsed icon-only sidebar */
    }
    .sidebar-header h1   { font-size: 0; }
    .sidebar-header h1::after { content: '◆'; font-size: 20px; color: var(--accent); }
    .sidebar-header .sub { display: none; }
    .nav-label,
    .nav-section-label,
    .sidebar-footer .version,
    [data-i18n-toggle] { display: none; }
    .sidebar-footer { padding: 10px 8px; }
    .nav-item { justify-content: center; padding: 10px; }
}
