/* Shared product shell: suite bar, workspace rail, page canvas, and page
   headers. Layout grids are Bootstrap's row/col; only patterns Bootstrap has
   no equivalent for live here. */
.app-shell {
    /* Shared bottom-band height: the rail's collapse toggle and the
       workspace footer render as matching 40px rows so the two bottom
       bands line up. The footer lives inside .workspace-main (see
       base.html), so .app-frame no longer subtracts footer height. */
    --app-nav-toggle-height: 40px;
    --app-footer-height: var(--app-nav-toggle-height);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    min-width: 320px;
    color: var(--color-text);
    background: var(--color-canvas);
}

.app-shell .toast-container {
    z-index: var(--z-toast);
}

/* Suite bar */
.suite-bar {
    position: sticky;
    top: 0;
    z-index: var(--z-suite-bar);
    display: flex;
    align-items: center;
    height: var(--suite-bar-height);
    color: var(--color-on-primary);
    background: var(--color-suite-bar);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}

.suite-launcher {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--suite-bar-height);
    height: var(--suite-bar-height);
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
}

.suite-launcher:hover,
.suite-launcher:focus-visible {
    background: rgba(0, 0, 0, .16);
}

.suite-launcher-wrap { height: var(--suite-bar-height); }

.waffle {
    display: grid;
    grid-template-columns: repeat(3, 3px);
    gap: 3px;
}

.waffle i {
    width: 3px;
    height: 3px;
    background: currentColor;
}

.suite-product {
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-4);
    color: inherit;
    border-left: 1px solid rgba(255, 255, 255, .24);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
}

.suite-product:hover {
    color: inherit;
    background: rgba(0, 0, 0, .1);
}

.suite-environment {
    padding: 2px var(--space-2);
    color: rgba(255, 255, 255, .9);
    background: rgba(255, 255, 255, .14);
    border-radius: 10px;
    font-size: .6875rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.suite-utilities {
    display: flex;
    align-items: center;
    height: 100%;
    margin-left: auto;
}

.suite-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: var(--suite-bar-height);
    color: inherit;
    font-size: 1.25rem;
    text-decoration: none;
}

.suite-icon-button:hover {
    color: inherit;
    background: rgba(0, 0, 0, .14);
}

/* Suite-bar theme toggle matches other suite icon buttons. */
.suite-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: var(--suite-bar-height);
    padding: 0 8px;
    color: inherit;
    background: transparent;
    border: 0;
    font-size: 1.2rem;
    cursor: pointer;
}

.suite-theme-toggle:hover,
.suite-theme-toggle:focus-visible {
    background: rgba(0, 0, 0, .14);
    outline: none;
}

.suite-theme-toggle:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6);
}

.suite-language {
    height: 32px;
    margin: 0 var(--space-2);
    padding: 0 28px 0 10px;
    color: inherit;
    background-color: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: var(--radius-xs);
    font-size: var(--font-size-sm);
}

.suite-language option {
    color: var(--color-text);
    background: var(--color-surface);
}

.suite-account {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--suite-bar-height);
    padding: 0 12px 0 var(--space-2);
    color: inherit;
    background: transparent;
    border: 0;
    text-align: left;
}

.suite-account:hover,
.suite-account[aria-expanded="true"] {
    background: rgba(0, 0, 0, .14);
}

.suite-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--color-primary);
    background: var(--color-surface);
    border-radius: var(--radius-round);
    font-size: 1.15rem;
}

.suite-account-copy { line-height: 1.05; }
.suite-account-copy small,
.suite-account-copy strong { display: block; }
.suite-account-copy small {
    margin-bottom: 2px;
    color: rgba(255, 255, 255, .75);
    font-size: .625rem;
}
.suite-account-copy strong {
    max-width: 130px;
    overflow: hidden;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suite-bar .dropdown-menu {
    margin-top: 0 !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-card);
    font-size: var(--font-size-md);
}

.suite-bar .suite-launcher-menu {
    width: 440px;
    max-width: calc(100vw - 16px);
    padding: 0;
    color: var(--color-text);
    border-top: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Microsoft-account-style user card (top-right dropdown) */
.suite-bar .suite-account-menu {
    width: 360px;
    max-width: calc(100vw - 16px);
    padding: 0;
    overflow: hidden;
    color: var(--color-text);
    background: var(--color-surface);
}

.suite-account-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 4px;
}

.suite-account-brand {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    letter-spacing: -0.01em;
}

.suite-account-signout {
    padding: 2px 0;
    color: var(--color-text);
    background: transparent;
    border: 0;
    font-size: var(--font-size-md);
}

.suite-account-signout:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.suite-account-body {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 12px 20px 20px;
}

.suite-account-avatar-lg {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    color: var(--color-primary);
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-round);
    font-size: 2.4rem;
}

.suite-account-avatar-lg .lucide {
    width: 36px;
    height: 36px;
}

.suite-account-identity { min-width: 0; }

.suite-account-name {
    overflow: hidden;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suite-account-email {
    overflow: hidden;
    margin: 4px 0 6px;
    font-size: var(--font-size-md);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suite-account-link {
    display: block;
    width: fit-content;
    padding: 1px 0;
    color: var(--color-primary);
    font-size: var(--font-size-md);
    text-decoration: none;
}

.suite-account-link:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.suite-account-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    color: var(--color-text);
    background: var(--color-surface-muted);
    border: 0;
    border-top: 1px solid var(--color-border-subtle);
    font-size: var(--font-size-md);
    text-align: left;
}

.suite-account-switch:hover { background: var(--color-surface-hover); }

.suite-account-switch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-round);
    font-size: 1.25rem;
}

.suite-account-switch-icon .lucide {
    width: 18px;
    height: 18px;
}

.suite-account-menu .suite-mobile-language {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border-subtle);
}

@media (max-width: 420px) {
    .suite-bar .suite-account-menu { width: calc(100vw - 16px); }
    .suite-account-name { white-space: normal; }
    .suite-account-email { white-space: normal; overflow-wrap: anywhere; }
}

.suite-launcher-heading {
    padding: 20px 24px 14px;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
}

.suite-launcher-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2) 12px;
    padding: 0 var(--space-4) 20px;
}

.suite-launcher-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 66px;
    padding: 10px 12px;
    color: var(--color-text);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    text-decoration: none;
}

.suite-launcher-tile[aria-current="page"] {
    background: var(--color-surface-selected);
    font-weight: var(--font-weight-semibold);
}

.suite-launcher-tile:hover,
.suite-launcher-tile:focus-visible {
    color: var(--color-text);
    background: var(--color-surface-hover-strong);
}

.suite-launcher-tile:focus-visible {
    outline: 2px solid var(--color-border-strong);
    outline-offset: -2px;
}

.suite-launcher-tile:active {
    background: var(--color-surface-pressed);
}

.suite-launcher-label {
    min-width: 0;
    overflow-wrap: break-word;
    text-transform: capitalize;
    white-space: normal;
}

.suite-tile-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    color: var(--color-on-primary);
    border-radius: var(--radius-sm);
    font-size: 1.35rem;
}

.tile-blue { background: var(--color-primary); }
.tile-teal { background: var(--color-teal); }
.tile-purple { background: var(--color-purple); }
.tile-orange { background: var(--color-orange); }
.tile-green { background: var(--color-green); }

.suite-mobile-language {
    min-width: 240px;
    padding: var(--space-2) var(--space-4) var(--space-1);
}

.suite-mobile-language label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* Lucide icons in the suite bar, launcher tiles, and account menu (kit
   default — pinned version vendored at /static/vendor/js/lucide.min.js).
   Inline SVGs ignore font-size, so each shell slot gets explicit dimensions. */
.suite-bar .lucide { flex: none; }
.suite-theme-toggle .lucide {
    width: 20px;
    height: 20px;
}
.suite-icon-button .lucide {
    width: 20px;
    height: 20px;
}
.suite-avatar .lucide {
    width: 18px;
    height: 18px;
}
.suite-account > .lucide {
    width: 16px;
    height: 16px;
}
.suite-tile-icon .lucide {
    width: 22px;
    height: 22px;
}
.suite-bar .dropdown-item .lucide,
.suite-mobile-language label .lucide {
    width: 16px;
    height: 16px;
}

/* Standard authenticated page */
.app-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--support-content-width);
    margin-inline: auto;
    padding: 28px 32px;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: auto;
    min-height: var(--app-footer-height);
    padding: var(--space-2) 0;
    border-top: 1px solid var(--color-border);
}

.app-footer .container { text-align: center; }

/* Workspace rail and canvas */
.app-frame {
    display: grid;
    grid-template-columns: var(--workspace-nav-width) minmax(0, 1fr);
    min-height: calc(100vh - var(--suite-bar-height));
}

.app-nav-pane {
    --bs-offcanvas-width: var(--workspace-nav-width);
    position: sticky;
    top: var(--suite-bar-height);
    width: var(--workspace-nav-width);
    height: calc(100vh - var(--suite-bar-height));
    color: var(--color-text);
    background: var(--color-nav);
    border-right: 1px solid var(--color-border);
}

.app-nav-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 18px var(--space-2) 0;
}

.app-nav-label {
    padding: 0 12px 12px;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}

.app-primary-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 2px;
}

.app-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: var(--space-2) 12px;
    color: var(--color-text-secondary);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    text-align: left;
    text-decoration: none;
}

.app-nav-item i,
.app-nav-item .lucide {
    width: 18px;
    height: 18px;
    flex: none;
    font-size: 1.15rem;
    text-align: center;
}

.app-nav-item:hover {
    color: var(--color-text);
    background: var(--color-nav-hover);
}

.app-nav-item.active {
    color: var(--color-text);
    background: var(--color-surface);
    overflow: hidden;
    font-weight: var(--font-weight-semibold);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.app-nav-item.active i,
.app-nav-item.active .lucide {
    color: var(--color-primary);
}

.app-nav-item.active::before {
    position: absolute;
    top: var(--space-2);
    bottom: var(--space-2);
    left: 0;
    width: 3px;
    background: var(--color-primary);
    border-radius: var(--radius-xs);
    content: "";
}

/* Rail labels never wrap: the rail width animates over .2s on expand/
   minimize (VPP reference behavior), so nowrap + ellipsis keeps rows stable
   instead of reflowing line breaks mid-flight. min-width: 0 lets the flex
   label shrink inside the narrowing row; the title attribute keeps the full
   label available as a native tooltip in the minimized rail. */
.app-nav-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.workspace-main {
    /* flex-grow covers shells without .app-frame (public share view) where
       workspace-main is a direct child of .app-shell; as a grid item inside
       .app-frame the flex properties are ignored and stretching is automatic. */
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-canvas);
}

/* Collapsible rail (ported from the VPP portal shell): the state lives in
   <html data-rail-state="expanded|minimized">, set pre-paint by
   static/js/sidebar.js (localStorage key "portal-sidebar", default
   expanded). Minimized restores an icon-only rail; mobile is unaffected —
   the rail hides below the desktop breakpoint and the offcanvas drawer
   takes over. */
.app-frame,
.app-nav-pane {
    transition: grid-template-columns .2s ease, width .2s ease;
}
@media (prefers-reduced-motion: reduce) {
    .app-frame,
    .app-nav-pane { transition: none; }
}

@media (min-width: 992px) {
    :root[data-rail-state="minimized"] .app-frame {
        grid-template-columns: var(--workspace-nav-collapsed-width) minmax(0, 1fr);
    }
    :root[data-rail-state="minimized"] .app-nav-pane {
        width: var(--workspace-nav-collapsed-width);
    }
    /* Clip (never scroll) the rail horizontally on desktop: while the grid
       column and the pane width animate, in-flight text is cut at the rail
       edge exactly like the VPP reference instead of spilling into content.
       `clip` (unlike `hidden`) creates no scroll container, so the sticky
       rail and the bottom-pinned toggle are unaffected. */
    .app-nav-pane,
    .app-nav-content {
        overflow-x: clip;
    }
    :root[data-rail-state="minimized"] .app-nav-content {
        padding-inline: var(--space-2);
    }
    :root[data-rail-state="minimized"] .app-nav-label,
    :root[data-rail-state="minimized"] .app-nav-text {
        display: none;
    }
    :root[data-rail-state="minimized"] .app-primary-nav {
        padding: 0;
    }
    :root[data-rail-state="minimized"] .app-nav-item,
    :root[data-rail-state="minimized"] .app-nav-toggle {
        justify-content: center;
        padding-inline: 0;
    }
}

/* Rail sections: primary destinations at the top, secondary admin
   destinations pinned above the toggle (kit pattern for settings-type
   entries). The toggle band sits flush at the rail bottom. */
.app-nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: auto;
    padding: 0 2px;
}

.app-nav-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: var(--app-nav-toggle-height);
    margin-top: var(--space-2);
    padding: var(--space-2) 12px;
    color: var(--color-text-secondary);
    background: transparent;
    border: 0;
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: var(--font-size-md);
    text-align: left;
    cursor: pointer;
}

.app-nav-toggle i,
.app-nav-toggle .lucide {
    width: 18px;
    height: 18px;
    flex: none;
    font-size: 1.15rem;
    text-align: center;
    transition: transform .2s ease;
}

.app-nav-toggle:hover {
    color: var(--color-text);
    background: var(--color-nav-hover);
}

:root[data-rail-state="minimized"] .app-nav-toggle i,
:root[data-rail-state="minimized"] .app-nav-toggle .lucide {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
    .app-nav-toggle i, .app-nav-toggle .lucide { transition: none; }
}

/* Page grid gutter matching the old 12-column product grid (1rem gap). */
.g-compact {
    --bs-gutter-x: .75rem;
    --bs-gutter-y: .75rem;
}

/* Canonical page heading used by support and workspace pages. */
.c-page {
    width: 100%;
    max-width: var(--content-width);
    margin-inline: auto;
}

.app-main .c-page { max-width: none; }

.c-page__breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
}

.c-page__breadcrumb i,
.c-page__breadcrumb .lucide { font-size: .9rem; }

.c-page__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: var(--space-5);
}

.c-page__title {
    margin: 0 0 4px;
    color: var(--color-text);
    font-size: var(--font-size-h3);
    font-weight: var(--font-weight-semibold);
    letter-spacing: -.015em;
    line-height: var(--line-height-tight);
}

.c-page__subtitle {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-md);
}

@media (max-width: 991.98px) {
    .app-frame { display: block; }
    .workspace-main { min-height: calc(100vh - var(--suite-bar-height)); }
    .app-nav-toggle { display: none; }
    .app-nav-pane {
        position: fixed;
        top: 0;
        width: var(--bs-offcanvas-width);
        height: 100vh;
    }
    .app-nav-content { height: calc(100% - 58px); }
}

@media (max-width: 575.98px) {
    .suite-bar .suite-launcher-menu {
        max-height: calc(100dvh - var(--suite-bar-height));
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .suite-launcher-grid { grid-template-columns: 1fr; }
    .suite-product {
        padding-inline: 10px;
        font-size: var(--font-size-md);
    }
    .suite-environment,
    .suite-language { display: none; }
    .suite-account { padding-right: var(--space-2); }
    .app-main { padding: 18px 12px; }
    .c-page__title-row {
        flex-direction: column;
        gap: 10px;
        margin-bottom: var(--space-4);
    }
    .c-page__title { font-size: 1.45rem; }
}
