:host {
    display: inline-block;
    vertical-align: middle;
    position: relative;
}

.header-widget-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
}

/* Top control pill button */
.identity-pill-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--tab-background-color-active, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--tab-border-color-active, rgba(80, 250, 123, 0.3));
    border-radius: var(--radius-lg, 20px);
    color: var(--clr-text-primary, #ffffff);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
}

.identity-pill-btn:hover, .identity-pill-btn.locked {
    background: rgba(80, 250, 123, 0.15);
    border-color: var(--clr-accent, #50fa7b);
    box-shadow: 0 2px 8px rgba(80, 250, 123, 0.15);
}

.identity-pill-btn.unauth {
    background: rgba(255, 204, 68, 0.05);
    border: 1px dashed var(--clr-warn, #ffcc44);
    color: var(--clr-warn, #ffcc44);
}

.identity-pill-btn.unauth:hover, .identity-pill-btn.unauth.locked {
    background: rgba(255, 204, 68, 0.15);
    border-color: var(--clr-warn, #ffcc44);
    box-shadow: 0 0 10px rgba(255, 204, 68, 0.25);
}

.pill-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--clr-accent, #50fa7b);
    color: #11111b;
    flex-shrink: 0;
}

.avatar-circle.unauth-avatar {
    background: rgba(255, 204, 68, 0.18);
    color: #ffcc44;
    font-size: 0.85rem;
}

.username-text {
    font-weight: 600;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unauth-text {
    font-weight: 600;
}

.caret {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.identity-pill-btn.locked .caret {
    transform: rotate(180deg);
}

/* Glassmorphic Dropdown Menu Popup */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--clr-bg-surface, rgba(30, 30, 46, 0.95));
    border: 1px solid var(--clr-border, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

/* Invisible hover buffer to prevent drop gap */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
}

.dropdown-section {
    display: flex;
    flex-direction: column;
}

.dropdown-header-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--clr-text-muted, #9399b2);
    padding: 0.3rem 0.6rem 0.2rem 0.6rem;
}

.dropdown-divider {
    border: 0;
    height: 1px;
    background: var(--clr-border, rgba(255, 255, 255, 0.12));
    margin: 0.4rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--clr-text-primary, #cdd6f4);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

.dropdown-item:hover:not(.disabled) {
    background: var(--clr-accent-hover, rgba(137, 180, 250, 0.15));
    color: var(--clr-accent, #89b4fa);
}

.dropdown-item.active-identity {
    background: rgba(80, 250, 123, 0.12);
    font-weight: 600;
    color: var(--clr-accent, #50fa7b);
}

.dropdown-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dropdown-item .icon {
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
}

.identity-badge-active {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--clr-accent, #50fa7b);
}

.update-item {
    color: #ffb703;
    background: rgba(255, 183, 3, 0.1);
    font-weight: 600;
}

.update-item:hover {
    background: rgba(255, 183, 3, 0.25) !important;
    color: #ffc107 !important;
}

/* Glowing amber notification dot / badge */
.update-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    animation: pulse-amber 2s infinite ease-in-out;
}

@keyframes pulse-amber {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 2px #ffb703);
    }
    50% {
        transform: scale(1.25);
        filter: drop-shadow(0 0 8px #ffb703);
    }
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 2px #ffb703);
    }
}

/* Modal Sync Progress Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: #1e1e2e;
    border: 1px solid var(--clr-border, rgba(255, 255, 255, 0.15));
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    box-sizing: border-box;
}

.modal-spinner {
    font-size: 2.5rem;
    animation: spin-pulse 2s infinite ease-in-out;
    display: inline-block;
}

@keyframes spin-pulse {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.15);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--clr-text-primary, #ffffff);
}

.modal-msg {
    margin: 0;
    font-size: 0.9rem;
    color: var(--clr-text-muted, #a6adc8);
    line-height: 1.4;
}

.modal-status {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--clr-accent, #50fa7b);
}

.modal-close-btn {
    padding: 0.5rem 1.5rem;
    background: var(--clr-accent, #50fa7b);
    color: #11111b;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.modal-close-btn:hover {
    background: #62ff88;
    transform: translateY(-1px);
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .identity-pill-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center !important;
        gap: 0 !important;
    }

    .pill-content {
        gap: 0 !important;
        justify-content: center !important;
    }

    .unauth-text,
    .username-text,
    .caret,
    .update-badge {
        display: none !important;
    }

    .avatar-circle {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.85rem !important;
        margin: 0 !important;
    }
}

