@layer legacy {

/* Popover-owned legacy rules (#651 decision 3). MudBlazor renders popovers, their paper and
   list/menu items in the popover provider, outside the owner's scoped CSS, so these rules
   cannot move to the owner's .razor.css. Existing rules are kept here, grouped per owner.
   New UI styles popovers with MudBlazor parameters and its own ItemTemplate markup only;
   do not add rules here. */

/* --- OfferProductSection (PopoverClass="t-offer-product-price-popover") --- */

.mud-popover.mud-popover-adaptive-width.t-offer-product-price-popover,
.mud-popover-adaptive-width.t-offer-product-price-popover .mud-popover-paper,
.mud-popover-paper.mud-popover-adaptive-width.t-offer-product-price-popover {
    /* Adaptive MudSelect owns min-width and updates it on open/resize. Do not
       override it with an application-wide measurement from another select. */
    width: max-content;
    max-width: min(60rem, calc(100vw - 2rem)) !important;
}

.t-offer-product-price-popover .mud-list,
.t-offer-product-price-popover .mud-list-item,
.t-offer-product-price-popover .mud-list-item-text,
.mud-popover-paper.t-offer-product-price-popover .mud-list,
.mud-popover-paper.t-offer-product-price-popover .mud-list-item,
.mud-popover-paper.t-offer-product-price-popover .mud-list-item-text {
    width: 100%;
}

.t-offer-product-price-popover .mud-list-item {
    /* Match the selected field's text inset and reserve its dropdown arrow. */
    padding-inline: 12px 36px;
}

/* --- ChatPanel (MudPopover Class="t-chat-share-popover") --- */

.mud-popover.t-chat-share-popover,
.mud-popover-paper.t-chat-share-popover {
    margin-top: -12px;
}

/* --- OfferAccessoriesSectionV2 (PopoverClass="t-offer-accessory-group-popover") --- */

.mud-popover.t-offer-accessory-group-popover,
.t-offer-accessory-group-popover .mud-popover-paper,
.mud-popover-paper.t-offer-accessory-group-popover {
    max-width: min(900px, calc(100vw - 32px)) !important;
    min-width: min(820px, calc(100vw - 32px)) !important;
    width: min(900px, calc(100vw - 32px)) !important;
}

.t-offer-accessory-group-popover .mud-list,
.t-offer-accessory-group-popover .mud-list-item,
.t-offer-accessory-group-popover .mud-list-item-text,
.mud-popover-paper.t-offer-accessory-group-popover .mud-list,
.mud-popover-paper.t-offer-accessory-group-popover .mud-list-item,
.mud-popover-paper.t-offer-accessory-group-popover .mud-list-item-text {
    width: 100%;
}

.t-offer-accessory-group-popover .mud-list-item-text,
.mud-popover-paper.t-offer-accessory-group-popover .mud-list-item-text {
    min-width: 0;
}

/* --- OfferV2ActionRail (PopoverClass="offer-v2-status-popover") --- */

/* Offer rail status menu (OfferV2ActionRail, PopoverClass="offer-v2-status-popover"):
   matches the rail: small dense items, 16px check, framed like the tab box. The
   popover renders outside the offer workspace, so the frame line is repeated here. */
.mud-popover.offer-v2-status-popover {
    background: var(--mud-palette-surface);
    border: 1px solid light-dark(
        color-mix(in srgb, var(--mud-palette-text-primary) 36%, var(--mud-palette-surface)),
        color-mix(in srgb, var(--mud-palette-text-primary) 24%, var(--mud-palette-surface)));
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* Width follows the status row in the wide rail (RelativeWidth); no min-width so
   it never runs past the window edge and gets flipped. */
.offer-v2-status-popover .mud-menu-list {
    min-width: 0;
    padding: 4px;
}

.offer-v2-status-popover .mud-menu-item {
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 400;
    min-height: 32px;
    padding: 0 10px;
}

.offer-v2-status-popover .mud-menu-item .mud-menu-item-text {
    margin: 0;
}

.offer-v2-status-popover .mud-menu-item .mud-menu-item-icon {
    margin-inline-end: 8px;
}

.offer-v2-status-popover .mud-menu-item .mud-icon-root {
    font-size: 16px;
    height: 16px;
    width: 16px;
}

/* Items without a check line up with the checked one (16px icon + 8px gap). */
.offer-v2-status-popover .mud-menu-list:has(.mud-menu-item-icon) .mud-menu-item:not(:has(.mud-menu-item-icon)) .mud-menu-item-text {
    margin-inline-start: 24px;
}

/* --- LoanComponent, LeasingComponent (PopoverClass="t-finance-provider-popover") --- */

.t-finance-provider-popover {
    max-width: 13rem;
    min-width: 13rem;
}

/* --- LeasingComponent (PopoverClass="t-offer-leasing-vat-mode-popover") --- */

.t-offer-leasing-vat-mode-popover {
    max-width: 24rem;
}

/* --- AppearanceSettingsGroup (PopoverClass="t-settings-preview-popover") --- */

.t-settings-preview-popover {
    min-width: 280px !important;
}

.t-settings-preview-popover .mud-list-item {
    padding-block: 6px;
}

/* --- TeksterSettingsGroup (MudMenu PopoverClass="t-tekster-token-menu") --- */

.t-tekster-token-menu .mud-list {
    padding: 4px 0;
}

.t-tekster-token-menu .mud-list-item {
    min-height: 30px;
}

/* --- ProductListComponent column menu (MudMenu PopoverClass="t-mud-list-item-with-filter-checkboxes", items Class="t-mud-list-item-with-text-and-checkbox") --- */

.t-mud-list-item-with-text-and-checkbox .mud-typography {
    display: flex;
    align-items: center;
}

.t-mud-list-item-with-filter-checkboxes .mud-list {
    width: 400px;
    display: flex;
    flex-wrap: wrap;
}

.t-mud-list-item-with-filter-checkboxes .mud-list-item {
    max-width: 200px !important;
    padding: 0px !important;
}

.t-mud-list-item-with-filter-checkboxes .mud-list-item-text {
    margin-top: 0px !important;
    margin-bottom: 0px !important;
}

.t-mud-list-item-with-filter-checkboxes .mud-checkbox {
    padding: 8px 16px;
    gap: 8px;
}

/* --- TabMenu overflow menu (PopoverClass="tl-tabs-overflow-popover"; the tabs inside are in TabMenu.razor.css) --- */

.tl-tabs-overflow-popover .mud-popover-paper {
    min-width: 240px;
    max-width: 300px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--tab-border-color);
    padding: 4px 0;
}
/* --- Shell popovers (#727): TabMenu phone tab list, WorkspaceMenuPanel phone menu, profile menu ---
   Frames, lists and overlays are rendered by MudBlazor. The content the owners write inside them is in
   TabMenu.razor.css and WorkspaceMenuPanel.razor.css. responsiveWorkspace.module.js uses
   :not(.workspace-phone-menu). */

/* Shared list/calendar phone menus use the existing popover portal. Nested
   product workspaces cannot clip this viewport-owned presentation. */
.workspace-phone-menu.mud-popover {
    --workspace-menu-top: max(var(--shell-header-height, 56px), var(--shell-visible-top, 0px));
    --workspace-menu-label-width: 64px;
    --workspace-menu-padding: 0;
    --workspace-control-height: 44px;
    position: fixed !important;
    top: var(--workspace-menu-top) !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(var(--shell-visible-height, 100dvh) + var(--shell-visible-top, 0px) - var(--workspace-menu-top)) !important;
    max-width: none !important;
    max-height: none !important;
    overflow: hidden !important;
    transform: none !important;
    animation: none !important;
    border-radius: 0;
    background: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}
body.is-landscape-phone .workspace-phone-menu.mud-popover {
    left: var(--workspace-nav-width, var(--nav-width, 54px)) !important;
    width: calc(100% - var(--workspace-nav-width, var(--nav-width, 54px))) !important;
}

/* MudMenu's modal overlay is a portal sibling of its popover. */
.mud-popover-provider:has(.tl-tabs-mobile-popover.mud-popover-open) > .mud-overlay[data-modeless-ignore-element-id] {
    background: var(--mud-palette-overlay-dark);
}

.tl-tabs-mobile-popover.mud-popover {
    position: fixed;
    inset: var(--shell-header-height, var(--header-height)) 0 auto !important;
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - var(--shell-header-height, var(--header-height)) - env(safe-area-inset-bottom));
    transform: none;
    overflow-y: auto;
    background: var(--mud-palette-surface);
}

.tl-tabs-mobile-popover .mud-list {
    padding: 0;
}

.tl-tabs-mobile-popover .mud-menu-item .mud-menu-item-text {
    margin: 0;
}

.profile-menu-popup.mud-popover {
    width: min(300px, calc(100vw - 16px));
    max-height: calc(100dvh - var(--shell-header-height, var(--header-height)) - 16px);
    overflow-y: auto;
    border-radius: 12px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}
.profile-theme-options .mud-list-item {
    min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
    .workspace-phone-menu,
    .tl-tabs-mobile-popover,
    .profile-menu-popup {
        transition: none !important;
    }
}
}
