/* Pricing Engine layout: the shell (nav, top bar, main) and shared page layout.
   Shell values come only from the Uliverse block in tokens.css. */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--ground);
    color: var(--ink);
    font-size: var(--font-size-base);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: 28px; font-weight: 600; color: var(--ink); line-height: 32px; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: var(--font-size-xl); font-weight: 600; color: var(--ink); line-height: 1.3; }
h3 { font-size: var(--font-size-lg); font-weight: 500; color: var(--ink); line-height: 1.4; }
h4 { font-size: var(--font-size-sm); font-weight: 500; color: var(--ink-2); }
a { color: var(--empower-red); text-decoration: none; }
a:hover { color: var(--empower-red-hover); }

:focus-visible { outline: 2px solid var(--red-aa); outline-offset: 2px; }

/* ========================================
   SHELL: nav rail on desktop, glass tab bar on phones
   ======================================== */
.nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    display: flex;
    flex-direction: column;
    padding: var(--space-6) var(--space-4);
    background: var(--ground);
    z-index: 200;
}
.nav-logo {
    display: block;
    width: 168px;
    height: 36px;
    margin: 0 var(--space-3) var(--space-8);
    background: url("/static/brand/pricing-engine/wordmark-light.svg") left center / contain no-repeat;
}
.nav-list { flex: 1; display: flex; flex-direction: column; gap: var(--space-1); }
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--target);
    padding: 0 var(--space-3);
    border-radius: var(--radius-soft);
    color: var(--ink-2);
    font-size: 15px;
    font-weight: 500;
    transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}
.nav-link i, .nav-link svg { width: 20px; height: 20px; stroke-width: 1.75; flex-shrink: 0; }
.nav-link:hover { color: var(--ink); background: var(--container); }
.nav-link.is-active { color: var(--ink); background: var(--card); box-shadow: var(--shadow-sm); font-weight: 600; }
.nav-link.is-active::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--red-aa);
}
.nav-badge {
    margin-left: auto;
    min-width: 24px;
    height: 24px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--container);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-badge[hidden] { display: none; }
.nav-user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) 0 0 var(--space-3);
}
.nav-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nav-user-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user-role { font-size: 13px; color: var(--ink-2); }
.nav-signout, .topbar-signout {
    width: var(--target);
    height: var(--target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-soft);
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
}
.nav-signout:hover, .topbar-signout:hover { background: var(--container); color: var(--ink); }
.nav-signout svg, .topbar-signout svg { width: 20px; height: 20px; stroke-width: 1.75; }

.main { margin-left: 232px; min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }

/* Top bar: floating glass, carries only the data freshness line. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: 0 var(--space-8);
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-filter);
    backdrop-filter: var(--glass-filter);
}
.topbar-logo, .topbar-signout { display: none; }
.freshness {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.freshness::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--up);
}
.freshness.is-stale { color: var(--amber-text); }
.freshness.is-stale::before { background: var(--amber); }

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1360px;
    padding: var(--space-4) var(--space-8) var(--space-16);
}

@media (max-width: 768px) {
    .nav {
        inset: auto 0 0 0;
        width: auto;
        height: calc(64px + env(safe-area-inset-bottom));
        padding: 0 var(--space-1) env(safe-area-inset-bottom);
        flex-direction: row;
        background: var(--glass);
        -webkit-backdrop-filter: var(--glass-filter);
        backdrop-filter: var(--glass-filter);
        box-shadow: var(--shadow-md);
    }
    .nav-logo, .nav-user { display: none; }
    .nav-list { flex-direction: row; gap: 0; }
    .nav-link {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        min-height: 64px;
        padding: 0;
        font-size: 12px;
        border-radius: 0;
    }
    .nav-link.is-active { background: transparent; box-shadow: none; }
    .nav-link.is-active::before { left: 30%; right: 30%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 2px 2px; }
    .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); margin: 0; min-width: 20px; height: 20px; font-size: 12px; padding: 0 6px; }
    .main { margin-left: 0; padding-bottom: 72px; }
    .topbar { padding: 0 var(--space-4); gap: var(--space-2); }
    .topbar-logo {
        display: block;
        flex-shrink: 0;
        width: 132px;
        height: 28px;
        margin-right: auto;
        background: url("/static/brand/pricing-engine/wordmark-light.svg") left center / contain no-repeat;
    }
    .topbar-signout { display: none; }
    .freshness { font-size: 12px; }
    .app-main { padding: var(--space-2) var(--space-4) var(--space-8); }
}

/* Solid fallback for the glass chrome, after the phone rules so it wins. */
@media (prefers-reduced-transparency: reduce) {
    .topbar, .nav { background: var(--ground); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
