/* Profile control: auth-aware icon/avatar with dropdown. */

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

.profile-control-toggle {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full, 9999px);
    cursor: pointer;
    transition: box-shadow var(--transition-base, 0.25s ease),
                transform var(--transition-base, 0.25s ease);
    position: relative;
    flex-shrink: 0;
}

.profile-control-toggle:focus-visible {
    outline: 2px solid var(--primary-500, #6366f1);
    outline-offset: 2px;
}

.profile-control-toggle:hover {
    transform: scale(1.05);
}

/* ── Anonymous icon ────────────────────────────────────────────── */
.profile-icon-anon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full, 9999px);
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #a1a1aa);
    transition: border-color var(--transition-base, 0.25s ease),
                background var(--transition-base, 0.25s ease);
}

.profile-control-toggle:hover .profile-icon-anon {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.08);
}

.profile-control-toggle[aria-expanded="true"] .profile-icon-anon {
    border-color: var(--primary-500, #6366f1);
    background: rgba(99, 102, 241, 0.12);
}

/* ── Authenticated avatar ──────────────────────────────────────── */
.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full, 9999px);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.12);
    transition: border-color var(--transition-base, 0.25s ease),
                box-shadow var(--transition-base, 0.25s ease);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Tier rings match the profile-page avatar. Business and Business Plus use
   the same indigo halo the profile header already shows for those plans.
   The glow sits outside the 34px circle so it stays visible in the navbar. */
.profile-avatar-tier-free {
    border-color: #6c757d;
    box-shadow: 0 0 8px rgba(108, 117, 125, 0.55), 0 0 16px rgba(108, 117, 125, 0.3);
}

.profile-avatar-tier-professional,
.profile-avatar-tier-business,
.profile-avatar-tier-business_plus {
    border-color: var(--primary-500, #6366f1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.75), 0 0 18px rgba(99, 102, 241, 0.45);
}

.profile-avatar-tier-enterprise {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.75), 0 0 18px rgba(255, 215, 0, 0.4);
}

.profile-control-toggle:hover .profile-avatar-tier-free {
    box-shadow: 0 0 12px rgba(108, 117, 125, 0.75), 0 0 22px rgba(108, 117, 125, 0.4);
}

.profile-control-toggle:hover .profile-avatar-tier-professional,
.profile-control-toggle:hover .profile-avatar-tier-business,
.profile-control-toggle:hover .profile-avatar-tier-business_plus {
    border-color: var(--primary-500, #6366f1);
    box-shadow: 0 0 14px rgba(99, 102, 241, 0.9), 0 0 24px rgba(99, 102, 241, 0.55);
}

.profile-control-toggle:hover .profile-avatar-tier-enterprise {
    border-color: #ffd700;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.9), 0 0 24px rgba(255, 215, 0, 0.5);
}

/* ── Profile dropdown ──────────────────────────────────────────── */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    padding: 4px;
    background: var(--dropdown-bg, rgba(22, 22, 30, 0.96));
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--dropdown-border, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(99, 102, 241, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 160ms ease,
                transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1),
                visibility 0s linear 160ms;
    z-index: var(--z-dropdown, 1000);
}

.profile-control.open .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition-delay: 0s;
}

/* ── Dropdown header (authenticated) ───────────────────────────── */
.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 2px;
}

.profile-dropdown-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.profile-dropdown-name {
    font-size: 0.8125rem;
    font-weight: var(--fw-semibold, 600);
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-tier {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 0.6875rem;
    font-weight: var(--fw-medium, 500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #707070);
}

.profile-dropdown-tier.tier-professional {
    color: var(--primary-500, #6366f1);
}

.profile-dropdown-tier.tier-enterprise {
    color: #ffd700;
}

/* ── Dropdown items ────────────────────────────────────────────── */
.profile-dropdown-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: calc(var(--radius-lg, 12px) - 4px);
    color: var(--menu-item-text, var(--text-secondary, #a1a1aa));
    font-size: 0.8125rem;
    font-weight: var(--fw-medium, 500);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition-fast, 150ms ease),
                color var(--transition-fast, 150ms ease);
}

.profile-dropdown-link:hover,
.profile-dropdown-link:focus-visible {
    background: var(--menu-item-hover-bg, rgba(255, 255, 255, 0.07));
    color: var(--menu-item-hover-text, var(--text-primary, #fff));
    outline: none;
}

.profile-dropdown-link:focus-visible {
    outline: 2px solid var(--menu-focus-ring, var(--primary-500, #6366f1));
    outline-offset: -2px;
}

.profile-dropdown-link[aria-disabled="true"] {
    opacity: var(--menu-item-disabled-opacity, 0.45);
    cursor: not-allowed;
    pointer-events: none;
}

.profile-dropdown-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.6;
}

.profile-dropdown-link:hover svg {
    opacity: 1;
}

.profile-dropdown-link.logout-link {
    color: var(--menu-item-danger, var(--severity-critical, #ef4444));
}

.profile-dropdown-link.logout-link:hover,
.profile-dropdown-link.logout-link:focus-visible {
    background: rgba(239, 68, 68, 0.1);
    color: var(--menu-item-danger, var(--severity-critical, #ef4444));
}

@media (prefers-reduced-motion: reduce) {
    .profile-dropdown,
    .profile-control-toggle,
    .profile-avatar,
    .profile-icon-anon {
        transition: none;
    }
}
