/* V4 登录弹窗 + 用户中心下拉面板 */
.v4-header-user {
    display: none !important;
}

.v4-user-center-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.v4-user-center-wrap #v4UserCenterBtn {
    cursor: pointer;
}

/* 登录态未确认前：登录/注册与用户中心都不显示，避免已登录先闪登录框 */
.v4-user-center-wrap:not(.auth-ready) .v4-header-auth,
.v4-user-center-wrap:not(.auth-ready) > #v4UserCenterBtn {
    display: none !important;
}

/* 未登录：顶栏登录/注册；已登录隐藏 */
.v4-header-auth {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}

.v4-user-center-wrap.is-logged-in .v4-header-auth {
    display: none;
}

/* 未登录隐藏「用户中心」；已登录显示（恢复旧逻辑时可去掉这两条并删掉 .v4-header-auth） */
.v4-user-center-wrap:not(.is-logged-in) > #v4UserCenterBtn {
    display: none !important;
}

.v4-header-auth-login,
.v4-header-auth-register {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 32px;
    border-radius: 999px;
    box-sizing: border-box;
    text-decoration: none;
    cursor: pointer;
}

.v4-header-auth-login {
    border: none;
    background: #fff;
    color: var(--v4-header-bg, #3a539b);
}

.v4-header-auth-login:hover {
    opacity: 0.92;
    color: var(--v4-header-bg, #3a539b);
}

.v4-header-auth-register {
    border: 1px solid rgba(255, 255, 255, 0.85);
    background: transparent;
    color: #fff;
}

.v4-header-auth-register:hover {
    background: #fff;
    color: var(--v4-header-bg, #3a539b);
}

.v4-user-panel {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(26, 38, 82, 0.18);
    z-index: 300;
    overflow: hidden;
    box-sizing: border-box;
}

.v4-user-panel.show {
    display: block;
    position: fixed;
    z-index: 1000;
}

/* 未登录：登录/注册；已登录：隐藏该块（浮层内 guest 已注释，样式保留便于恢复） */
.v4-user-panel-guest {
    display: flex;
    gap: 12px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--v4-border, #e5ecf5);
}

.v4-user-center-wrap.is-logged-in .v4-user-panel-guest {
    display: none;
}

.v4-user-panel-btn-login,
.v4-user-panel-btn-register {
    flex: 1;
    height: 40px;
    line-height: 40px;
    padding: 0;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    text-decoration: none;
    box-sizing: border-box;
    cursor: pointer;
    opacity: 1;
}

.v4-user-panel-btn-login {
    border: none;
    background: var(--v4-header-bg, #3a539b);
    color: #fff;
}

.v4-user-panel-btn-login:hover {
    background: #2f4685;
    color: #fff;
}

.v4-user-panel-btn-register {
    display: block;
    border: 1px solid #333;
    background: #fff;
    color: #222;
}

.v4-user-panel-btn-register:hover {
    background: #f7f7f7;
    color: #222;
}

.v4-user-panel-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--v4-border, #e5ecf5);
}

.v4-user-center-wrap.is-logged-in .v4-user-panel-head {
    display: flex;
}

.v4-user-panel-contact {
    display: none;
    padding: 0 18px 4px;
    border-bottom: 1px solid var(--v4-border, #e5ecf5);
    box-sizing: border-box;
}

.v4-user-center-wrap.is-logged-in .v4-user-panel-contact {
    display: block;
}

.v4-user-panel-contact p {
    margin: 0;
    padding: 2px 0;
    font-size: 13px;
    line-height: 22px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.v4-user-panel-contact p span + span {
    margin-left: 4px;
}

.v4-user-panel-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--v4-text, #333);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v4-user-panel-vip {
    display: none;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #8a5a00;
    background: linear-gradient(135deg, #ffe9a8 0%, #ffd56a 100%);
    border-radius: 999px;
}

.v4-user-panel-vip.show {
    display: inline-block;
}

.v4-user-panel-quick {
    display: flex;
    justify-content: space-around;
    padding: 14px 8px;
    border-bottom: 1px solid var(--v4-border, #e5ecf5);
}

.v4-user-panel-quick a {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--v4-text, #333);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 8px;
    background: transparent;
    opacity: 1;
    transition: background .2s;
}

.v4-user-panel-quick a:hover {
    background: #f0f4fb;
    color: var(--v4-header-bg, #3a539b);
}

.v4-user-panel-quick a img {
    display: block;
    width: 40px;
    height: 40px;
    margin-bottom: 6px;
    object-fit: contain;
}

.v4-user-panel-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

.v4-user-panel-list li {
    display: none;
}

.v4-user-panel-list li.show {
    display: block;
}

/* 未登录时展示完整列表 */
.v4-user-center-wrap:not(.is-logged-in) .v4-user-panel-list li {
    display: block;
}

.v4-user-panel-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    height: auto;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--v4-text, #333);
    text-decoration: none;
    background: transparent;
    border-radius: 0;
    opacity: 1;
    transition: background .2s;
    box-sizing: border-box;
}

.v4-user-panel-list a:hover {
    background: #f5f8fc;
    color: var(--v4-header-bg, #3a539b);
}

.v4-user-panel-list a img {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin: 0;
    object-fit: contain;
}

.v4-user-panel-list a::after {
    content: "›";
    margin-left: auto;
    color: #ccc;
    font-size: 18px;
}

.v4-user-panel-more {
    display: none;
    border-top: 1px solid var(--v4-border, #e5ecf5);
    padding: 8px 0 6px;
}

.v4-user-panel-more.show {
    display: block;
}

.v4-user-panel-more a {
    display: block;
    height: auto;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--v4-text, #333);
    text-decoration: none;
    background: transparent;
    border-radius: 0;
    opacity: 1;
}

.v4-user-panel-more a:hover {
    background: #f5f8fc;
    color: var(--v4-header-bg, #3a539b);
}

.v4-user-panel-foot {
    display: none;
    border-top: 1px solid var(--v4-border, #e5ecf5);
    padding: 4px 0;
}

.v4-user-center-wrap.is-logged-in .v4-user-panel-foot {
    display: block;
}

.v4-user-panel-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #e53935;
    cursor: pointer;
}

.v4-user-panel-logout img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.v4-user-panel-logout:hover {
    background: #fff5f5;
}

/* 登录弹窗样式见 login.css */

@media (max-width: 768px) {
    .v4-user-panel {
        right: -40px;
        width: 280px;
    }
}
