/* ================================================================
   organization-switcher.css
   Auth buttons / user menu state management
   Pure CSS — no inline styles needed.
   ================================================================ */

/* ── Visibility classes ──────────────────────────────────────── */
.nb-hidden {
    display: none !important;
}

a#pr-org-logout-btn {
    color: black;
}

/* ── Skeleton loader ─────────────────────────────────────────── */
.nb-skeleton {
    display: block;
    border-radius: 8px;
    background: linear-gradient(90deg,
            #e8e8e8 25%,
            #f5f5f5 50%,
            #e8e8e8 75%);
    background-size: 200% 100%;
    animation: nb-shimmer 1.5s ease-in-out infinite;
    /* Skeletons are non-interactive placeholders, not disabled real buttons */
    pointer-events: none;
}

/* ── Skeleton dimension variants (match button sizes) ────────── */
.nb-skeleton--login {
    width: 80px;
    height: 40px;
}

.nb-skeleton--cta {
    width: 130px;
    height: 40px;
}

/* ── Skeleton shimmer keyframes ──────────────────────────────── */
@keyframes nb-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}



/* ── User avatar skeleton (circular, matches profile pic) ───── */
.nb-skeleton--avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ── Mobile skeleton (full-width, taller) ────────────────────── */
.nb-skeleton--mobile-login {
    width: 100%;
    height: 45px;
    border-radius: 10px;
}

.nb-skeleton--mobile-cta {
    width: 100%;
    height: 48px;
    border-radius: 10px;
}

/* ── Error message ───────────────────────────────────────────── */
#nb-auth-buttons {
    position: relative;
}

.nb-auth-error {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 13px;
    color: #d32f2f;
    white-space: nowrap;
    background: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.nb-auth-error.nb-hidden {
    display: none;
}

/* ── User profile avatar ─────────────────────────────────────── */
#pr-org-user-profile-image {
    border-radius: 50%;
    overflow: hidden;
    width: 40px;
    height: 40px;
    border: 2px solid #00A1E0;
}

#pr-org-user-profile-image img {
    width: 100%;
    height: 106%;
    object-fit: cover;
}

/* ── Org-switcher trigger (avatar + name + chevron) ──────────── */
.pr-org-action {
    position: relative;
}

.pr-org-profile {
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: var(--nb-r-md);
    cursor: pointer;
    user-select: none;
    transition: background var(--nb-fast);
}

.pr-org-profile-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pr-org-profile-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

#pr-org-user-full-name {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--nb-txt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.pr-org-arrow-icon {
    font-size: 11px;
    color: #797979;
    flex-shrink: 0;
    transition: transform var(--nb-mid);
}

.pr-org-action.active .pr-org-arrow-icon {
    transform: rotate(180deg);
}

/* ── Org-switcher dropdown menu ───────────────────────────────── */
.pr-org-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 280px;
    max-width: 320px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--nb-border);
    border-radius: var(--nb-r-lg);
    padding: 12px;
    box-shadow: var(--nb-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity var(--nb-mid), transform var(--nb-mid);
    z-index: 300;
}

.pr-org-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.pr-org-menu-title {
    margin: 4px 6px 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9a9a9a;
}

/* ── Organization list ────────────────────────────────────────── */
.pr-org-organization-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.pr-org-organization-list::-webkit-scrollbar {
    width: 4px;
}

.pr-org-organization-list::-webkit-scrollbar-track {
    background: transparent;
}

.pr-org-organization-list::-webkit-scrollbar-thumb {
    background: var(--nb-border);
    border-radius: 4px;
}

.pr-org-organization-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px 6px;
    border-radius: var(--nb-r-md);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--nb-fast);
}

.pr-org-organization-item:hover {
    background: #F1F1F1;
}

.pr-org-organization-item.active {
    background: #E0F2FE;
}

.pr-org-organization-avatar-wrapper {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.pr-org-organization-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pr-org-organization-info {
    min-width: 0;
}

.pr-org-organization-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--nb-txt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pr-org-organization-info p {
    margin: 0;
    font-size: 12px;
    color: #797979;
}

/* ── Menu action buttons ──────────────────────────────────────── */
.pr-org-primary-btn,
.pr-org-secondary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--nb-r-md);
    cursor: pointer;
    transition: background var(--nb-fast), opacity var(--nb-fast);
}

.pr-org-primary-btn {
    color: #fff;
    background: var(--nb-accent);
}

.pr-org-primary-btn:hover {
    opacity: 0.9;
}

.pr-org-secondary-btn {
    color: var(--nb-txt);
    background: #F1F1F1;
}

.pr-org-secondary-btn:hover {
    background: #E5E5E5;
}

/* ── Menu footer / logout ─────────────────────────────────────── */
.pr-org-menu-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--nb-border);
}

.pr-org-menu-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--nb-r-sm);
    text-decoration: none;
    transition: background var(--nb-fast);
}

.pr-org-menu-footer a:hover {
    background: rgba(211, 47, 47, 0.08);
}

/* ── Fade-in / slide-up transition, shared by Button 1 and Button 2 ──
   Button 2 gets it on success; Button 1 gets it on error/guest/retry. */
#nb-user-buttons.nb-visible,
#nb-auth-buttons.nb-visible,
#nb-mobile-auth-buttons.nb-visible {
    animation: nb-fade-in 0.3s ease-out;
}

@keyframes nb-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

/* ── Disable interaction while a request is in flight ────────── */
#nb-navbar[data-nb-state="loading"] .nb-right {
    pointer-events: none;
}

/* ── Respect reduced-motion preference ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .nb-skeleton {
        animation: none;
    }

    #nb-user-buttons.nb-visible,
    #nb-auth-buttons.nb-visible,
    #nb-mobile-auth-buttons.nb-visible {
        animation: none;
    }
}

/* ── Mobile skeletons are hidden on desktop and vice versa ───── */
@media (min-width: 981px) {

    .nb-skeleton--mobile-login,
    .nb-skeleton--mobile-cta {
        display: none;
    }
}

/* ── User skeleton visible on mobile only ───────────────────── */
@media (max-width: 980px) {
    #nb-user-skeleton {
        display: flex;
        align-items: center;
        margin-left: auto;
    }
}

/* ── User name hidden on mobile (avatar + chevron only) ──────── */
@media (max-width: 980px) {
    #pr-org-user-full-name {
        display: none;
    }

    /* Hide the dropdown chevron on mobile — avatar only. */
    .pr-org-arrow-icon {
        display: none;
    }

    /* navbar.css hides .nb-right below 981px, which also hides the
       signed-in menu. Re-show #nb-user-buttons in the top bar on mobile
       (id beats .nb-right on specificity; :not(.nb-hidden) keeps it hidden
       while logged out / loading). Name is already hidden above, so only
       the avatar + chevron show — next to the hamburger. */
    #nb-user-buttons:not(.nb-hidden) {
        display: flex;
        align-items: center;
        margin-left: auto;
        margin-right: 12px;
    }

    /* The desktop dropdown is position:absolute inside the header, whose
       Divi wrapper can clip it (and the desktop right offset pushes it
       off-screen on small viewports). Anchor it to the viewport with
       position:fixed on mobile: it escapes any overflow:hidden ancestor,
       sits just below the header, and is capped to the screen width so it
       can never run off the right edge. */
    .pr-org-menu {
        position: fixed;
        top: calc(var(--nb-nav-h) + 24px);
        right: 12px;
        left: auto;
        max-width: calc(100vw - 24px);
    }
}

@media (min-width: 981px) {
    #nb-user-skeleton {
        display: none;
    }
}

/* ── No-JS fallback: show the real buttons instead of a permanently-
   shimmering skeleton. `scripting: none` only matches when JS is
   disabled — requires Firefox 65+/Safari 17+/Chrome 120+; older
   browsers with JS disabled will still see the skeleton. ──────── */
@media (scripting: none) {

    #nb-auth-skeleton,
    #nb-mobile-auth-skeleton {
        display: none !important;
    }

    #nb-auth-buttons,
    #nb-mobile-auth-buttons {
        display: flex !important;
    }
}