/* Fresh Customer Web shell. Presentation only; API and authorization remain authoritative. */

.client-app-shell {
    --client-shell-topbar-height: 70px;
    --client-shell-bottom-navigation-height: 3.75rem;
    --client-shell-sidebar-width: clamp(272px, 19vw, 360px);
    display: grid;
    grid-template:
        "topbar topbar" var(--client-shell-topbar-height)
        "navigation content" minmax(0, 1fr) /
        var(--client-shell-sidebar-width) minmax(0, 1fr);
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    color: var(--rtu-color-text);
    background: var(--rtu-color-background);
}

.client-skip-link {
    position: fixed;
    z-index: 1500;
    top: 0.5rem;
    left: 0.5rem;
    translate: 0 -200%;
    min-height: var(--rtu-touch-target-min);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: var(--rtu-color-on-primary);
    background: var(--rtu-color-primary);
}

.client-skip-link:focus {
    translate: 0;
}

.client-shell-topbar {
    z-index: 20;
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-width: 0;
    min-height: var(--client-shell-topbar-height);
    padding: 0.625rem clamp(1rem, 2vw, 2rem);
    border-bottom: 1px solid var(--rtu-client-frame-border);
    background: var(--rtu-color-surface);
    box-shadow: var(--rtu-client-panel-shadow);
}

.client-shell-workspace {
    flex: 1 1 416px;
    max-width: 416px;
    min-width: 0;
}

.client-shell-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-inline-start: auto;
    min-width: 0;
}

.client-shell-avatar {
    position: relative;
    display: inline-grid;
    flex: 0 0 var(--rtu-touch-target-min);
    width: var(--rtu-touch-target-min);
    min-width: var(--rtu-touch-target-min);
    height: var(--rtu-touch-target-min);
    min-height: var(--rtu-touch-target-min);
    place-items: center;
    border-radius: 0.875rem;
    color: var(--rtu-color-text);
    text-decoration: none;
}

.client-shell-avatar:hover {
    background: var(--rtu-color-surface-subtle);
}

.client-shell-avatar {
    border: 1px solid var(--rtu-color-border);
    border-radius: 50%;
    color: var(--rtu-color-on-primary);
    background: var(--rtu-color-primary);
    font-weight: 800;
}

.client-shell-navigation {
    grid-area: navigation;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--rtu-client-frame-border);
    background: var(--rtu-color-surface);
}

.client-shell-content {
    grid-area: content;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.client-shell-page {
    width: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

.client-page-menu .mud-icon-button {
    width: 44px;
    height: 44px;
}

.client-app-shell:not(.client-viewport--mobile) .client-page-mobile-only,
.client-app-shell.client-viewport--mobile .client-page-desktop-only {
    display: none !important;
}

/* The map owns the remaining shell viewport, not a padded document page. */
.client-shell-content:has(.client-map-page) {
    overflow: hidden;
    scrollbar-gutter: auto;
}

.client-shell-page:has(.client-map-page) {
    height: 100%;
    padding: 0;
    max-width: none;
}

.client-desktop-navigation,
.client-tablet-navigation {
    height: 100%;
    min-height: 0;
}

.client-desktop-navigation {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    padding: 1rem 0.75rem 0.75rem;
}

.client-navigation-scroll {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.client-navigation-group {
    display: grid;
    gap: 0.25rem;
    margin: 0 0 1rem;
}

.client-navigation-section {
    margin: 0;
    padding: 0.25rem 0.75rem;
    color: var(--rtu-color-text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-transform: uppercase;
}

.client-navigation-link,
.client-tablet-navigation-link {
    position: relative;
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
    min-height: var(--rtu-touch-target-min);
    padding: 0.625rem 0.75rem;
    border: 0;
    border-radius: 0.75rem;
    color: var(--rtu-color-text);
    background: transparent;
    font: inherit;
    font-weight: 650;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.client-navigation-link > span:not(.client-unread-badge) {
    overflow: visible;
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
}

.client-tablet-navigation-link > span:not(.client-unread-badge) {
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    white-space: nowrap;
}

.client-navigation-link:hover,
.client-tablet-navigation-link:hover,
.client-navigation-link.active,
.client-tablet-navigation-link.active {
    color: var(--rtu-color-primary-strong);
    background: var(--rtu-color-surface-subtle);
}

.client-navigation-link.active,
.client-tablet-navigation-link.active {
    box-shadow: inset 0.2rem 0 0 var(--rtu-color-primary);
}

.client-navigation-button {
    appearance: none;
}

.client-navigation-logout {
    border-top: 1px solid var(--rtu-color-border);
    border-radius: 0;
    color: var(--rtu-color-error);
}

.client-navigation-version {
    margin: 0;
    padding: 0.25rem 0.75rem;
    color: var(--rtu-color-text-muted);
    font-size: 0.75rem;
    line-height: 1.25;
}

.client-tablet-navigation {
    display: none;
    align-content: start;
    gap: 0.375rem;
    padding: 0.75rem 0.5rem;
    overflow: auto;
}

.client-tablet-navigation-link {
    grid-template-columns: 1.5rem minmax(0, 1fr);
    gap: 0.5rem;
    padding-inline: 0.625rem;
    font-size: 0.875rem;
}

.client-tablet-navigation-link .client-unread-badge {
    position: absolute;
    top: 0.2rem;
    left: 1.85rem;
}

.client-mobile-navigation-surface {
    display: none;
}

.client-unread-badge {
    display: inline-flex;
    min-width: 1.25rem;
    height: 1.25rem;
    align-items: center;
    justify-content: center;
    padding-inline: 0.3rem;
    border: 2px solid var(--rtu-color-surface);
    border-radius: 999px;
    color: #ffffff;
    background: var(--rtu-color-error);
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}

.client-workspace-selector {
    min-width: 0;
    max-width: 100%;
}

.client-workspace-selector-button {
    width: 100%;
    min-height: var(--rtu-touch-target-min);
    border-radius: 0.75rem;
}

.client-workspace-selector-button .mud-button-label {
    min-width: 0;
}

.client-workspace-selector-name {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    white-space: nowrap;
}

.client-workspace-selector.is-stale .client-workspace-selector-button {
    color: var(--rtu-color-warning);
}

.client-workspace-selector.is-access-lost .client-workspace-selector-button {
    color: var(--rtu-color-error);
}

.client-workspace-dialog .mud-dialog-content {
    display: grid;
    min-width: 0;
    gap: 1rem;
}

.client-workspace-dialog__search {
    min-width: 0;
}

.client-workspace-dialog__list {
    display: grid;
    min-width: 0;
    max-height: min(55dvh, 26rem);
    gap: 0.75rem;
    padding: 0.125rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.client-workspace-dialog__option {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: var(--rtu-touch-target-min);
    grid-template-columns: 1.5rem minmax(0, 1fr) 1.5rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--rtu-color-border);
    border-radius: var(--rtu-radius-control);
    color: var(--rtu-color-text);
    background: var(--rtu-color-surface);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.client-workspace-dialog__option > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.client-workspace-dialog__option:hover,
.client-workspace-dialog__option:focus-visible,
.client-workspace-dialog__option.is-selected {
    border-color: var(--rtu-color-primary);
    background: var(--rtu-surface-selected);
}

.client-workspace-dialog__option:focus-visible {
    outline: 3px solid var(--rtu-focus);
    outline-offset: 2px;
}

.client-workspace-dialog__empty {
    margin: 0;
    padding: 1rem;
    color: var(--rtu-color-text-muted);
    text-align: center;
}

@media (max-width: 599.98px) {
    .client-workspace-dialog__list {
        max-height: min(52dvh, 22rem);
    }

    .client-workspace-dialog__option {
        padding-inline: 0.75rem;
    }
}

@media (min-width: 720px) and (max-width: 1279px) {
    .client-app-shell {
        --client-shell-sidebar-width: clamp(160px, 18vw, 216px);
    }

    .client-desktop-navigation {
        display: none;
    }

    .client-tablet-navigation {
        display: grid;
    }

    .client-shell-topbar {
        gap: 0.625rem;
        padding-inline: 0.75rem;
    }

    .client-shell-workspace {
        flex-basis: 320px;
        max-width: 320px;
    }

    .client-shell-topbar .rtu-brand-name small {
        display: none;
    }
}

@media (max-width: 719px) {
    .client-app-shell {
        --client-shell-topbar-height: 3.75rem;
        grid-template:
            "topbar" var(--client-shell-topbar-height)
            "content" minmax(0, 1fr)
            "mobile-navigation" var(--client-shell-bottom-navigation-height) /
            minmax(0, 1fr);
    }

    .client-shell-topbar {
        grid-area: topbar;
        gap: 0.375rem;
        padding: 0.375rem 0.5rem;
    }

    .client-shell-topbar .rtu-brand-name,
    .client-shell-actions .client-theme-menu__label {
        display: none;
    }

    .client-shell-avatar {
        display: none;
    }

    .client-shell-workspace {
        flex: 1 1 auto;
        max-width: none;
    }

    .client-shell-actions {
        gap: 0.125rem;
    }

    .client-shell-actions .client-theme-menu__trigger {
        width: var(--rtu-touch-target-min);
        padding: 0;
        gap: 0;
    }

    .client-shell-actions .client-theme-menu__options {
        position: fixed;
        top: calc(env(safe-area-inset-top) + var(--client-shell-topbar-height) + 0.375rem);
        right: max(0.5rem, env(safe-area-inset-right));
        width: min(
            18rem,
            calc(100vw - 1rem - env(safe-area-inset-left) - env(safe-area-inset-right))
        );
        max-width: calc(100vw - 1rem - env(safe-area-inset-left) - env(safe-area-inset-right));
    }

    .client-shell-navigation {
        display: none;
    }

    .client-shell-content {
        grid-area: content;
        scrollbar-gutter: auto;
    }

    .client-mobile-navigation-surface {
        z-index: 30;
        grid-area: mobile-navigation;
        display: block;
        border-top: 1px solid var(--rtu-client-frame-border);
        background: var(--rtu-color-surface);
        box-shadow: 0 -0.25rem 1.25rem -1rem rgba(20, 32, 52, 0.45);
    }

    .client-mobile-navigation {
        display: grid;
        grid-template-columns: repeat(var(--client-navigation-columns, 5), minmax(0, 1fr));
        gap: 0;
        padding: 0.25rem max(0.25rem, env(safe-area-inset-right))
            max(0.25rem, env(safe-area-inset-bottom))
            max(0.25rem, env(safe-area-inset-left));
    }

    .client-mobile-navigation-item {
        position: relative;
        display: grid;
        min-width: 0;
        min-height: var(--rtu-touch-target-min);
        place-items: center;
        align-content: center;
        gap: 0.2rem;
        padding: 0.25rem 0.1rem;
        border: 0;
        border-radius: 0.65rem;
        color: var(--rtu-color-text-muted);
        background: transparent;
        font: inherit;
        text-align: center;
        text-decoration: none;
        cursor: pointer;
    }

    .client-mobile-navigation-item:hover,
    .client-mobile-navigation-item.is-active,
    .client-mobile-navigation-item.active {
        color: var(--rtu-color-primary-strong);
        background: var(--rtu-color-surface-subtle);
    }

    .client-mobile-navigation-item:disabled {
        color: var(--rtu-color-text-muted);
        background: transparent;
        cursor: default;
        opacity: 0.72;
    }

    .client-mobile-navigation-icon {
        position: relative;
        display: inline-grid;
        place-items: center;
    }

    .client-mobile-navigation-icon .client-unread-badge {
        position: absolute;
        top: -0.55rem;
        left: calc(50% + 0.2rem);
    }

    .client-mobile-navigation-label {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        overflow-wrap: normal;
        white-space: nowrap;
        font-size: clamp(0.625rem, 2.5vw, 0.75rem);
        font-weight: 650;
        line-height: 1;
    }
}

@media (max-width: 360px) {
    .client-app-shell.client-viewport--mobile {
        grid-template:
            "topbar" var(--client-shell-topbar-height)
            "content" minmax(0, 1fr)
            "mobile-navigation" auto /
            minmax(0, 1fr);
    }

    .client-shell-topbar {
        padding-inline: 0.25rem;
    }

    .client-mobile-navigation {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        row-gap: 0.25rem;
    }

    .client-mobile-navigation-label {
        font-size: 0.625rem;
    }
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--desktop {
    --client-shell-sidebar-width: 400px;
    --client-shell-topbar-height: 3.5rem;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet {
    --client-shell-sidebar-width: 128px;
    --client-shell-topbar-height: 3.5rem;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet .client-shell-topbar .rtu-brand-name,
html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet .client-shell-actions .client-theme-menu__label {
    display: none;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet .client-tablet-navigation-link {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 0.25rem;
    padding-inline: 0.25rem;
    text-align: center;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet .client-tablet-navigation-link > span:not(.client-unread-badge) {
    overflow: visible;
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
    line-height: 1.1;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--tablet .client-tablet-navigation-link .client-unread-badge {
    top: 0.1rem;
    left: calc(50% + 0.35rem);
}

html[data-client-text-scale="large"] .client-navigation-section,
html[data-client-text-scale="large"] .client-navigation-version {
    font-size: 0.875rem;
}

html[data-client-text-scale="large"] .client-navigation-link,
html[data-client-text-scale="large"] .client-tablet-navigation-link {
    min-height: 3.5rem;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--mobile {
    grid-template:
        "topbar" auto
        "content" minmax(0, 1fr)
        "mobile-navigation" auto /
        minmax(0, 1fr);
}

html[data-client-text-scale="large"] .client-mobile-navigation {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0.25rem;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--mobile .client-mobile-navigation-label {
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 1.1;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--mobile .client-workspace-selector-name {
    display: none;
}

html[data-client-text-scale="large"] .client-app-shell.client-viewport--mobile .client-shell-actions .client-theme-menu__trigger {
    display: inline-flex;
    width: var(--rtu-touch-target-min);
    min-width: var(--rtu-touch-target-min);
    height: var(--rtu-touch-target-min);
    min-height: var(--rtu-touch-target-min);
}

.client-body--keyboard-visible .client-app-shell {
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
}

.client-body--keyboard-visible .client-app-shell.client-viewport--mobile {
    grid-template:
        "topbar" auto
        "content" minmax(0, 1fr) /
        minmax(0, 1fr);
}

.client-body--keyboard-visible .client-shell-content {
    overflow-y: auto;
    scroll-padding-bottom: 1rem;
}

.client-body--keyboard-visible .client-mobile-navigation-surface {
    display: none;
}

@media (forced-colors: active) {
    .client-shell-topbar,
    .client-shell-navigation,
    .client-mobile-navigation-surface {
        border-color: CanvasText;
        box-shadow: none;
    }

    .client-navigation-link.active,
    .client-tablet-navigation-link.active,
    .client-mobile-navigation-item.is-active,
    .client-mobile-navigation-item.active {
        outline: 2px solid Highlight;
        outline-offset: -2px;
    }

    .client-unread-badge {
        border: 2px solid CanvasText;
        color: HighlightText;
        background: Highlight;
    }
}

@media (prefers-reduced-motion: reduce) {
    .client-skip-link {
        transition: none;
    }
}
