/* Centered context selection dialogs for workspace, company and establishment switches. */
.context-selection {
    display: inline-flex;
    flex: 0 0 auto;
    margin-left: auto;
}

.context-selection__trigger {
    position: relative;
}

/* The establishment label already includes its company name. Keep company in the active context and modal, but do not repeat it in the horizontal navigation. */
body.app-ui .ui-primary-nav__context .hybrid-sidebar__context-item:has(.hybrid-sidebar__context-value--company) {
    display: none;
}

.context-selection-modal {
    width: min(42rem, calc(100vw - 2rem));
    max-width: 100%;
    max-height: min(80vh, 48rem);
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--ui-border-strong);
    border-radius: 16px;
    background: #ffffff;
    color: var(--ui-ink);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.context-selection-modal:not([open]) {
    display: none;
}

.context-selection-modal[open] {
    display: flex;
    flex-direction: column;
    animation: contextModalEnter 160ms ease-out both;
}

.context-selection-modal::backdrop {
    background: rgba(15, 23, 42, 0.62);
    backdrop-filter: blur(3px);
}

.context-selection-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex: 0 0 auto;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--ui-border);
    background: #ffffff;
}

.context-selection-modal__title {
    min-width: 0;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.context-selection-modal__close {
    width: 2.4rem;
    height: 2.4rem;
    flex: 0 0 auto;
}

.context-selection-modal__close svg {
    width: 1.2rem;
    height: 1.2rem;
}

.context-selection-modal__body {
    min-height: 0;
    padding: 0.85rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.context-selection-modal__options.dropdown__menu {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    display: grid !important;
    gap: 0.35rem;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.context-selection-modal__options form {
    width: 100%;
    margin: 0;
}

.context-selection-modal__options .workspace-switcher__option {
    min-height: 3rem;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
}

.context-selection-modal__options .workspace-switcher__option--button {
    width: 100%;
    background: transparent !important;
    color: var(--ui-ink);
}

.context-selection-modal__options .workspace-switcher__option--button:hover,
.context-selection-modal__options .workspace-switcher__option--button:focus-visible {
    border-color: rgba(29, 78, 216, 0.24);
    background: var(--ui-primary-soft) !important;
    color: var(--ui-primary);
}

.context-selection-modal__options .workspace-switcher__option--current {
    border-color: var(--ui-border);
    background: var(--ui-surface-muted);
}

.context-selection-modal__group-label {
    margin: 0.65rem 0 0.15rem;
    padding: 0.4rem 0.55rem 0.25rem;
    color: var(--ui-ink-muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.context-selection-modal__group-label:first-child {
    margin-top: 0;
}

@keyframes contextModalEnter {
    from {
        opacity: 0;
        transform: translateY(-0.65rem) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 720px) {
    .context-selection-modal {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        border-radius: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .context-selection-modal[open] {
        animation: none;
    }
}
