.profile-dropdown {
    position: relative;
}

.profile-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.profile-button:hover {
    background-color: var(--zf-primary-light);
}

.profile-avatar-wrap {
    position: relative;
    display: inline-flex;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-presence-dot {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--zf-primary, #6D28D9);
    bottom: -1px;
    right: -1px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.profile-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
}

.profile-name {
    font-weight: 500;
    color: #fff;
}

.profile-button i {
    color: #fff;
}

.profile-menu {
    min-width: 250px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    /* Pairs with the max-height the ProfileDropdown component sets on open. Inert until then
       (no max-height => nothing to overflow), so this cannot affect a panel that already fits. */
    overflow-y: auto;
    overscroll-behavior: contain;
}

.profile-info {
    padding: 0.5rem 0;
}

.profile-info strong {
    font-size: 0.875rem;
}

.profile-info small {
    font-size: 0.75rem;
}

.dropdown-item {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

.dropdown-item i {
    width: 1.25rem;
}

.dropdown-item:hover {
    background-color: var(--zf-primary-light);
    color: var(--zf-primary);
}

.dropdown-item.active {
    background-color: var(--zf-primary-light);
    color: var(--zf-primary);
}

.dropdown-item.text-danger:hover {
    background-color: #fee2e2;
}

/* Context badge */
.context-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.context-badge--tenant {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.context-badge--employee {
    background-color: #dcfce7;
    color: #15803d;
}

.context-badge--platform {
    background-color: #f3e8ff;
    color: #7c3aed;
}

/* Context group headers */
.context-group-header {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
}

/* Dark mode */
html[data-theme="dark"] .profile-button:hover {
    background-color: var(--zf-primary-light);
}

html[data-theme="dark"] .profile-name {
    color: #E6EDF3;
}

html[data-theme="dark"] .profile-menu {
    background: #161B22;
    border-color: #30363D;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .dropdown-item {
    color: #C9D1D9;
}

html[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--zf-primary-light);
    color: var(--zf-primary);
}

html[data-theme="dark"] .dropdown-item.active {
    background-color: var(--zf-primary-light);
    color: var(--zf-primary);
}

html[data-theme="dark"] .dropdown-item.text-danger {
    --bs-danger-rgb: 248, 81, 73;
}

html[data-theme="dark"] .dropdown-item.text-danger:hover {
    background-color: rgba(248, 81, 73, 0.15);
}

html[data-theme="dark"] .profile-menu .dropdown-header {
    color: #E6EDF3;
}

html[data-theme="dark"] .profile-info strong {
    color: #E6EDF3;
}

html[data-theme="dark"] .profile-menu .dropdown-divider {
    border-top-color: #30363D;
}

html[data-theme="dark"] .context-badge--tenant {
    background-color: rgba(59, 130, 246, 0.15);
    color: #93bbfd;
}

html[data-theme="dark"] .context-badge--employee {
    background-color: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

html[data-theme="dark"] .context-badge--platform {
    background-color: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
}

html[data-theme="dark"] .context-group-header {
    color: #6b7280;
}

@media (max-width: 768px) {
    .profile-name {
        display: none !important;
    }
}

/* .dropdown-menu-end right-aligns the panel to its containing block — .profile-dropdown,
   whose only job is to be that containing block (position: relative). The presence dot is
   anchored to .profile-avatar-wrap, not to this, so the relative can be dropped safely.

   On a phone the profile button moves depending on whether the navbar is collapsed open:
   stacked at the LEFT inside the open menu (measured 11 → 99), or at the RIGHT in the bar
   when closed (304 → 378). The panel is ~288px wide but the anchor is only ~89px, so right-
   aligning to the anchor put the panel's left edge at -189px when the navbar was open — the
   switcher hung off the left of the screen.

   Anchoring to the LEFT edge instead would just move the problem: from the closed-navbar
   position the panel would then run off the RIGHT. So drop the narrow anchor below the
   collapse breakpoint and let the panel position against the navbar (position: relative)
   instead. right: 0 then pins it to the navbar's right edge in BOTH states, and the
   max-width keeps it inside the viewport whatever the panel's content width. */
@media (max-width: 991.98px) {
    .profile-dropdown {
        position: static;
    }

    .profile-dropdown .profile-menu {
        right: 0;
        left: auto;
        min-width: 0;
        max-width: calc(100vw - 1.5rem);
    }
}
