:root {
    --kwk-em-color-primary: #1E1E1E;
    --kwk-em-color-secondary: #000;
}

.kwk-em-menu {
    position: relative;
    display: inline-block;
}

.kwk-em-menu__button {
    color: var(--kwk-em-color-primary);
    border: none;
    padding: 5px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    background: none;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 44px;
}

/* Différencier visuellement connecté vs déconnecté */
.kwk-em-menu--logged-out .kwk-em-menu__button--logged-out {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.25);
}

.kwk-em-menu--logged-in .kwk-em-menu__button--logged-in {
    background: rgba(0, 0, 0, 0.04);
}

.kwk-em-menu__button:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.kwk-em-menu__button[aria-expanded="true"] .kwk-em-menu__chevron {
    transform: rotate(180deg);
}

.kwk-em-menu__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(000, 000, 000, 0.18);
}

.kwk-em-menu__avatar-initials {
    font-size: 13px;
    font-weight: 600;
    color: var(--kwk-em-color-primary);
    line-height: 1;
}

.kwk-em-menu__name {
    flex: 1;
    white-space: nowrap;
    text-align: left;
}

.kwk-em-menu__chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    width: 13px;
    height: 13px;
}

.kwk-em-menu__chevron svg {
    width: 100%;
    height: 100%;
}

.kwk-em-menu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    margin: 0;
    padding: 8px 0;
    list-style: none;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 240px;
    max-width: 320px;
    display: none !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    pointer-events: none;
}

.kwk-em-menu__list::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.kwk-em-menu.is-open .kwk-em-menu__list {
    display: block !important;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.kwk-em-menu__item {
    margin: 0;
}

.kwk-em-menu__link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--kwk-em-color-primary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
}

.kwk-em-menu__link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.kwk-em-menu__link:hover,
.kwk-em-menu__link:focus {
    padding-left: 24px;
}

.kwk-em-menu__link:hover::before,
.kwk-em-menu__link:focus::before {
    transform: scaleY(1);
}

/* Déconnexion (prioritaire) */
.kwk-em-menu__item--logout .kwk-em-menu__link,
.kwk-em-menu__link--logout {
    border-top: 1px solid #f3f4f6;
    margin-top: 4px;
    padding-top: 16px;
    color: var(--kwk-em-color-secondary);
}

.kwk-em-menu__item--logout .kwk-em-menu__link:hover,
.kwk-em-menu__item--logout .kwk-em-menu__link:focus,
.kwk-em-menu__link--logout:hover,
.kwk-em-menu__link--logout:focus {
    color: var(--kwk-em-color-secondary);
}

/* Fallback historique si Déconnexion est le dernier item */
.kwk-em-menu__item:last-child .kwk-em-menu__link {
    border-top: 1px solid #f3f4f6;
    margin-top: 4px;
    padding-top: 16px;
    color: var(--kwk-em-color-secondary);
}

.kwk-em-menu__item:last-child .kwk-em-menu__link:hover,
.kwk-em-menu__item:last-child .kwk-em-menu__link:focus {
    color: var(--kwk-em-color-secondary);
}

/* Bouton déconnecté */
.kwk-em-menu__button:not([aria-haspopup]) {
    text-decoration: none;
    display: inline-flex;
}

/* Animation d'apparition des items */
.kwk-em-menu.is-open .kwk-em-menu__item {
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(1) {
    animation-delay: 0.05s;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(2) {
    animation-delay: 0.1s;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(3) {
    animation-delay: 0.15s;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(4) {
    animation-delay: 0.2s;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(5) {
    animation-delay: 0.25s;
}

.kwk-em-menu.is-open .kwk-em-menu__item:nth-child(6) {
    animation-delay: 0.3s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

/* Responsive */
@media (max-width: 768px) {
    .kwk-em-menu__list {
        right: auto;
        left: 0;
    }
}