/* Top bar right-side alignment */
#page-topbar .navbar-header > .d-flex:last-child {
    display: flex;
    align-items: center;
    gap: 2px;
}

#page-topbar .navbar-header > .d-flex:last-child > .dropdown,
#page-topbar .navbar-header > .d-flex:last-child > .module-launcher,
#page-topbar .navbar-header > .d-flex:last-child > .topbar-user-menu {
    display: inline-flex;
    align-items: center;
}

#page-topbar .navbar-header > .d-flex:last-child .header-item.noti-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    position: relative;
}

#page-topbar .navbar-header > .d-flex:last-child .header-item.noti-icon:hover {
    background-color: rgba(60, 64, 67, 0.08);
}

#page-topbar .navbar-header > .d-flex:last-child .noti-icon .badge {
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
}

/* Top bar user profile menu */
.topbar-user-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
}

.topbar-user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 10px 0 4px;
    border: none;
    border-radius: 24px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.2s ease;
    max-width: 220px;
}

.topbar-user-toggle:hover,
.topbar-user-toggle.is-open {
    background-color: rgba(60, 64, 67, 0.08);
}

.topbar-user-avatar,
.topbar-user-dropdown-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: #e8eaed;
    flex-shrink: 0;
}

.topbar-user-dropdown-avatar {
    width: 48px;
    height: 48px;
}

.topbar-user-avatar img,
.topbar-user-dropdown-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar-user-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #5f6368;
    font-size: 18px;
}

.topbar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #3c4043;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    line-height: 1;
}

.topbar-user-chevron {
    font-size: 18px;
    color: #5f6368;
    line-height: 1;
}

.topbar-user-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 280px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 0 2px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 9999;
}

.topbar-user-panel.is-open {
    display: block;
    animation: topbarUserFadeIn 0.15s ease-out;
}

@keyframes topbarUserFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.topbar-user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--smart-bg-subtle, #f8fafc);
    border-bottom: 1px solid var(--smart-border-light, #eef2f6);
}

.topbar-user-dropdown-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-user-dropdown-meta strong {
    font-size: 15px;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-dropdown-meta small {
    font-size: 12px;
    color: #5f6368;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user-role-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--smart-primary-light, #eef4ff);
    color: var(--smart-primary, #5b8def);
    font-size: 11px;
    font-weight: 600;
    width: fit-content;
}

.topbar-user-dropdown-body,
.topbar-user-dropdown-footer {
    padding: 8px;
}

.topbar-user-dropdown-footer {
    border-top: 1px solid #e8eaed;
}

.topbar-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #3c4043;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s ease;
}

.topbar-user-dropdown-item i {
    font-size: 18px;
    color: #5f6368;
    width: 20px;
    text-align: center;
}

.topbar-user-dropdown-item:hover {
    background-color: rgba(60, 64, 67, 0.06);
    color: #202124;
}

.topbar-user-dropdown-item.is-danger {
    color: #d93025;
}

.topbar-user-dropdown-item.is-danger i {
    color: #d93025;
}

.topbar-user-dropdown-item.is-danger:hover {
    background-color: rgba(217, 48, 37, 0.08);
    color: #d93025;
}

@media (max-width: 1199.98px) {
    .topbar-user-toggle {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
    }
}
