/* The application shell: header, module navigation, account chip.
 *
 * Loaded after `portal.css`, which styles bare `button` elements — every
 * control here therefore states its own background and colour rather
 * than inheriting that global.
 *
 * The module nav is the two-module end state (orders + product
 * lifecycle) made visible early: Products is present and explicitly
 * marked as not built yet, rather than absent or pretending to work.
 */

body {
    margin: 0;
    background: var(--sv-bg);
    /* The base typeface for every surface that mounts the shell. Lives
       here, not in a service stylesheet, so a presentation service with
       no portal.css (e.g. PLM) still inherits it rather than falling
       back to the browser default serif. */
    font-family: var(--sv-font);
}

/* ── Header ──────────────────────────────────────────────── */

.app-header {
    position: sticky;
    top: 0;
    z-index: 900;
    /* Border inside the declared height: page content sizes itself
       against --sv-header-h, and a border outside it costs a scrollbar. */
    box-sizing: border-box;
    height: var(--sv-header-h);
    background: var(--sv-surface);
    border-bottom: 1px solid var(--sv-border);
    box-shadow: var(--sv-shadow-sm);
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    max-width: var(--sv-content-max);
    margin: 0 auto;
    padding: 0 1rem;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: inherit;
    text-decoration: none;
    flex: none;
}

.app-brand-mark {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 7px;
    background: var(--sv-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    flex: none;
}

.app-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.app-brand-name {
    font-size: 0.9375rem;
    font-weight: 650;
    color: var(--sv-text);
}

.app-brand-sub {
    font-size: 0.6875rem;
    color: var(--sv-text-muted);
}

/* ── Module navigation ───────────────────────────────────── */

.app-modules {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-left: 1rem;
    border-left: 1px solid var(--sv-border);
    height: 1.75rem;
}

.app-module {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--sv-text-muted);
    text-decoration: none;
    border-radius: var(--sv-radius);
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

/* display:flex above would silently defeat the hidden attribute (class
   beats the UA's [hidden] rule) — and scope-gated modules ship hidden. */
.app-module[hidden] { display: none; }

.app-module:hover {
    color: var(--sv-text);
    background: #f8fafc;
}

.app-module.is-active {
    color: var(--sv-primary);
    background: var(--sv-primary-soft);
}

.app-module.is-disabled {
    color: #94a3b8;
    cursor: default;
}

.app-module.is-disabled:hover {
    color: #94a3b8;
    background: transparent;
}

.app-module-badge {
    padding: 0.0625rem 0.375rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sv-text-muted);
    background: var(--sv-border);
    border-radius: 999px;
}

/* ── Right-hand cluster ──────────────────────────────────── */

.app-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

/* ── Account chip ────────────────────────────────────────── */

.account {
    position: relative;
    flex: none;
}

.account-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    font-family: inherit;
    color: var(--sv-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 500;
}

.account-chip:hover {
    background: #f8fafc;
    border-color: var(--sv-border);
}

.account-chip[aria-expanded="true"] {
    background: #f1f5f9;
    border-color: var(--sv-border-strong);
}

.account-avatar {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    background: var(--sv-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    flex: none;
}

.account-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    max-width: 12rem;
}

.account-name {
    font-size: 0.8125rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 12rem;
}

.account-scope {
    font-size: 0.6875rem;
    color: var(--sv-text-muted);
}

.account-caret {
    width: 14px;
    height: 14px;
    color: var(--sv-text-muted);
}

.account-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 16rem;
    max-width: 20rem;
    background: var(--sv-surface);
    border: 1px solid var(--sv-border);
    border-radius: var(--sv-radius-lg);
    box-shadow: var(--sv-shadow-md);
    padding: 0.375rem;
    /* Only has to beat its siblings: .app-header is a sticky stacking
       context, so this value cannot compete with anything outside it.
       Ranking against the error banner happens on the banner. */
    z-index: 950;
}

.account-menu[hidden] { display: none; }

.account-menu-head {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--sv-border);
    margin-bottom: 0.375rem;
}

.account-menu-name {
    font-size: 0.875rem;
    font-weight: 600;
    word-break: break-word;
}

/* One line with an ellipsis rather than a mid-word wrap: long addresses
   and IdP subjects are common, and the full value is on the title. */
.account-menu-detail {
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--sv-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    color: var(--sv-text);
    background: transparent;
    border: none;
    border-radius: var(--sv-radius);
    cursor: pointer;
}

.account-menu-item:hover { background: #f1f5f9; }

.account-menu-item .lucide,
.account-menu-item svg {
    width: 15px;
    height: 15px;
    color: var(--sv-text-muted);
}

/* ── Page body ───────────────────────────────────────────── */

.app-main {
    max-width: var(--sv-content-max);
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ── Narrow screens ──────────────────────────────────────── */


@media (max-width: 760px) {
    .app-brand-text,
    .account-meta { display: none; }
}
