/**
 * Profil-Dropdown — global (via navigation.js, nach Seiten-CSS).
 * Klassen: .kynx-profile-menu, .kynx-profile-trigger
 */

/* —— Trigger (Navbar-Avatar) —— */
.kynx-profile-trigger.profile-avatar,
.profile-section .profile-avatar.kynx-profile-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    position: relative;
    z-index: 1008;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kynx-profile-trigger .avatar-img,
.kynx-profile-trigger img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(88, 101, 242, 0.55);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.kynx-profile-trigger:hover .avatar-img,
.kynx-profile-trigger:hover img,
.kynx-profile-trigger:focus-visible .avatar-img,
.kynx-profile-trigger:focus-visible img {
    border-color: rgba(114, 137, 218, 0.9);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.22), 0 4px 16px rgba(88, 101, 242, 0.25);
    transform: scale(1.04);
}

.kynx-profile-trigger[aria-expanded='true'] .avatar-img,
.kynx-profile-trigger[aria-expanded='true'] img {
    border-color: #7289da;
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.35);
}

/* —— Panel (Desktop: unter Avatar) —— */
.profile-menu.kynx-profile-menu,
#profileMenu.kynx-profile-menu,
#profileMenuMobile.kynx-profile-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 268px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: rgba(4, 6, 12, 0.94);
    backdrop-filter: blur(36px) saturate(185%);
    -webkit-backdrop-filter: blur(36px) saturate(185%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow:
        0 22px 50px rgba(0, 0, 0, 0.72),
        0 0 0 1px rgba(88, 101, 242, 0.1) inset,
        0 1px 0 rgba(255, 255, 255, 0.06) inset;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
    z-index: 10050;
    pointer-events: none;
    isolation: isolate;
}

.profile-menu.kynx-profile-menu::before,
#profileMenu.kynx-profile-menu::before,
#profileMenuMobile.kynx-profile-menu::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        165deg,
        rgba(88, 101, 242, 0.1) 0%,
        rgba(0, 0, 0, 0.2) 42%,
        rgba(0, 0, 0, 0.45) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.profile-menu.kynx-profile-menu.active,
.profile-menu.kynx-profile-menu.show,
#profileMenu.kynx-profile-menu.active,
#profileMenu.kynx-profile-menu.show,
#profileMenuMobile.kynx-profile-menu.active,
#profileMenuMobile.kynx-profile-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* —— Header —— */
.kynx-profile-menu .kynx-profile-menu__head,
.kynx-profile-menu .profile-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 10px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
}

.kynx-profile-menu .menu-avatar,
.kynx-profile-menu .kynx-profile-menu__avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    margin: 0;
    object-fit: cover;
    border: 2px solid rgba(88, 101, 242, 0.45);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.kynx-profile-menu .profile-info,
.kynx-profile-menu .kynx-profile-menu__meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.kynx-profile-menu .username,
.kynx-profile-menu .kynx-profile-menu__name {
    font-size: 0.88rem;
    font-weight: 650;
    color: rgba(255, 255, 255, 0.96);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kynx-profile-menu .discriminator,
.kynx-profile-menu .kynx-profile-menu__sub {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.48);
    line-height: 1.2;
}

.kynx-profile-menu .discriminator:empty,
.kynx-profile-menu .kynx-profile-menu__sub:empty {
    display: none;
}

/* —— Actions —— */
.kynx-profile-menu .profile-actions,
.kynx-profile-menu .kynx-profile-menu__nav {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    margin: 0;
}

.kynx-profile-menu .profile-link,
.kynx-profile-menu .kynx-profile-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 0;
    border-radius: 9px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.2;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    background: transparent;
    border: 1px solid transparent;
}

.kynx-profile-menu .profile-link i,
.kynx-profile-menu .kynx-profile-menu__item i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    margin: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(200, 205, 255, 0.85);
    font-size: 0.78rem;
    flex-shrink: 0;
}

.kynx-profile-menu .profile-link span,
.kynx-profile-menu .kynx-profile-menu__item span {
    flex: 1;
    min-width: 0;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kynx-profile-menu .profile-link:hover,
.kynx-profile-menu .profile-link:focus-visible,
.kynx-profile-menu .kynx-profile-menu__item:hover,
.kynx-profile-menu .kynx-profile-menu__item:focus-visible {
    background: rgba(88, 101, 242, 0.2);
    border-color: rgba(114, 137, 218, 0.22);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.12) inset;
}

.kynx-profile-menu .profile-link:hover i,
.kynx-profile-menu .profile-link:focus-visible i,
.kynx-profile-menu .kynx-profile-menu__item:hover i,
.kynx-profile-menu .kynx-profile-menu__item:focus-visible i {
    background: rgba(88, 101, 242, 0.28);
    border-color: rgba(114, 137, 218, 0.35);
    color: #fff;
}

.kynx-profile-menu .kynx-profile-menu__item--admin i {
    color: #fbbf24;
    background: rgba(250, 176, 5, 0.12);
    border-color: rgba(250, 176, 5, 0.25);
}

.kynx-profile-menu .kynx-profile-menu__item--danger {
    margin-top: 2px;
}

.kynx-profile-menu .kynx-profile-menu__item--danger i {
    color: #f47e7e;
    background: rgba(237, 66, 69, 0.12);
    border-color: rgba(237, 66, 69, 0.28);
}

.kynx-profile-menu .kynx-profile-menu__item--danger:hover,
.kynx-profile-menu .kynx-profile-menu__item--danger:focus-visible {
    background: rgba(237, 66, 69, 0.16);
    border-color: rgba(237, 66, 69, 0.32);
}

/* Mobile close button */
.kynx-profile-menu .dropdown-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    line-height: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.kynx-profile-menu .dropdown-close-btn i {
    font-size: 14px;
    line-height: 1;
}

.kynx-profile-menu .dropdown-close-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.06);
}

/* —— Mobile: zentriertes Panel —— */
@media (max-width: 900px) {
    .nav-menu .mobile-auth-buttons .profile-menu.kynx-profile-menu,
    #profileMenuMobile.kynx-profile-menu {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        margin-top: 0 !important;
        transform: translate(-50%, -50%) scale(0.96) !important;
        transform-origin: center !important;
        max-width: min(92vw, 300px);
        width: min(92vw, 300px);
        z-index: 10060 !important;
    }

    .nav-menu .mobile-auth-buttons .profile-menu.kynx-profile-menu.active,
    #profileMenuMobile.kynx-profile-menu.active {
        transform: translate(-50%, -50%) scale(1) !important;
    }

    .kynx-profile-menu .kynx-profile-menu__head,
    .kynx-profile-menu .profile-header {
        padding-right: 40px;
    }
}

/* Desktop positioning in nav */
@media (min-width: 901px) {
    .nav-menu .profile-section.desktop-only .profile-menu.kynx-profile-menu,
    .nav-menu > li.profile-section .profile-menu.kynx-profile-menu,
    #profileMenu.kynx-profile-menu {
        position: absolute !important;
        top: calc(100% + 8px) !important;
        right: 0 !important;
        left: auto !important;
        margin-top: 0 !important;
    }

    #profileMenuMobile.kynx-profile-menu {
        display: none !important;
    }
}

.profile-section {
    position: relative;
}
