/* =========================================================
   全站登录态样式（由 js/auth.js 注入节点）
   ---------------------------------------------------------
   - 顶部导航右侧：未登录显示"登录/注册"，登录后显示头像+下拉菜单
   - 下拉菜单：更改头像 / 更改密码 / 退出登录（复用聊天室账号体系）
   - 弹窗与提示均跟随 :root 主题令牌，无硬编码主题色
   - 右侧预留 76px 给固定定位的昼夜切换开关（daynight.css，电脑端 58×26 椭圆滑块）
   ========================================================= */

/* ---------- 导航栏挂件容器 ---------- */
.topbar-auth {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 76px; /* 避开固定在视口右上角的昼夜切换开关 */
    padding-left: 18px;
    border-left: 1px solid rgba(255, 255, 255, 0.28); /* 分隔线：与首页/文章等导航链接明确区隔 */
    z-index: 2002;
}

/* ---------- 未登录：登录 / 注册 链接 ---------- */
.auth-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.auth-links a {
    color: var(--menu-ink);
    font-size: 1em;
    font-weight: 500;
    padding: 0 12px;
    line-height: 56px;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.auth-links a:hover {
    color: var(--tint);
}

/* 未登录：登录按钮——与注册一致的胶囊样式，成对呈现，区别于导航文字链接 */
.auth-links .auth-link-login {
    border: 1px solid var(--switch-hairline);
    border-radius: 999px;
    line-height: 30px;
    padding: 0 16px;
    background: var(--switch-fill);
    transition: all 0.3s ease;
}

.auth-links .auth-link-login:hover {
    color: var(--tint);
    border-color: var(--tint);
}

.auth-links .auth-link-register {
    border: 1px solid var(--switch-hairline);
    border-radius: 999px;
    line-height: 30px;
    padding: 0 16px;
    margin-left: 6px;
    background: var(--switch-fill);
    transition: all 0.3s ease;
}

.auth-links .auth-link-register:hover {
    color: var(--tint);
    border-color: var(--tint);
}

/* ---------- 已登录：头像按钮 ---------- */
.auth-user {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    border: 2px solid var(--switch-hairline);
    background: var(--cta-grad);
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.3s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.auth-user:hover,
.auth-user.is-open {
    border-color: var(--tint);
    transform: scale(1.06);
}

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

/* 无上传头像时：用户名首字的渐变字模头像 */
.auth-user-letter {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}

/* ---------- 下拉菜单 ---------- */
.auth-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 200px;
    background: var(--topbar-fill-solid);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    border: 1px solid var(--switch-hairline);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
    padding: 6px;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.auth-menu.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 菜单小三角 */
.auth-menu::before {
    content: "";
    position: absolute;
    top: -5px;
    right: 14px;
    width: 9px;
    height: 9px;
    background: var(--topbar-fill-solid);
    border-left: 1px solid var(--switch-hairline);
    border-top: 1px solid var(--switch-hairline);
    transform: rotate(45deg);
}

.auth-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--switch-hairline);
    margin-bottom: 6px;
}

.auth-menu-head .auth-menu-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cta-grad);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.auth-menu-head .auth-menu-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-menu-head .auth-menu-name {
    color: var(--switch-ink);
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--switch-ink);
    font-size: 0.86rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.auth-menu-item:hover {
    background: var(--switch-fill);
    color: var(--tint);
}

.auth-menu-item .ic {
    width: 15px;
    height: 15px;
    color: var(--tint);
}

.auth-menu-item--danger:hover {
    color: var(--tint);
}

/* ---------- 弹窗（更改头像 / 更改密码） ---------- */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: auth-fade-in 0.2s ease;
}

.auth-modal {
    width: 100%;
    max-width: 400px;
    background: var(--panel-fill);
    border-radius: 14px;
    box-shadow: var(--panel-shadow-strong);
    padding: 26px 26px 22px;
    animation: auth-rise 0.25s ease;
}

.auth-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.auth-modal-head h3 {
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 700;
}

.auth-modal-close {
    width: 30px;
    height: 30px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: transparent;
    color: var(--ink-faint);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-modal-close:hover {
    color: var(--tint);
    border-color: var(--tint);
}

.auth-field {
    margin-bottom: 14px;
}

.auth-field label {
    display: block;
    color: var(--ink-faint);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
    border-color: var(--tint);
    box-shadow: 0 0 0 3px var(--tint-wash);
}

.auth-input::placeholder {
    color: var(--ink-faint);
}

.auth-error-text {
    color: var(--ink-faint);
    font-size: 0.8rem;
    margin: 4px 0 0;
    display: none;
}

.auth-error-text.is-visible {
    display: block;
    animation: auth-shake 0.35s ease;
}

.auth-modal-foot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

.auth-btn {
    padding: 9px 22px;
    border: none;
    border-radius: 9px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-btn--primary {
    color: #fff;
    background-image: var(--cta-grad);
}

.auth-btn--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(116, 235, 213, 0.4);
}

.auth-btn--ghost {
    background: transparent;
    color: var(--ink-faint);
    border: 1px solid var(--hairline);
}

.auth-btn--ghost:hover {
    color: var(--tint);
    border-color: var(--tint);
}

/* ---------- 头像上传弹窗 ---------- */
.auth-avatar-edit {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-avatar-preview {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    background: var(--cta-grad);
    color: #fff;
    font-size: 2.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 14px;
    cursor: pointer;
    border: 3px solid var(--hairline);
    transition: border-color 0.2s ease;
}

.auth-avatar-preview:hover {
    border-color: var(--tint);
}

.auth-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-avatar-hint {
    color: var(--ink-faint);
    font-size: 0.78rem;
    text-align: center;
    line-height: 1.7;
    margin-bottom: 4px;
}

/* ---------- 顶部居中 Toast ---------- */
.auth-toast {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translate(-50%, -8px);
    max-width: 86vw;
    padding: 9px 20px;
    border-radius: 999px;
    background: var(--topbar-fill-solid);
    color: #fff;
    font-size: 0.85rem;
    z-index: 3200;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.auth-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- 加载圈（按钮内 / 查重状态） ---------- */
.auth-spin {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--switch-hairline);
    border-top-color: var(--tint);
    border-radius: 50%;
    animation: auth-rotate 0.7s linear infinite;
}

/* ---------- 动画 ---------- */
@keyframes auth-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes auth-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    50%      { transform: translateX(4px); }
    75%      { transform: translateX(-2px); }
}

@keyframes auth-rotate {
    to { transform: rotate(360deg); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .topbar-auth {
        margin-right: 56px; /* 手机端昼夜开关在 right:12px，同样避开 */
    }

    .auth-links a {
        padding: 0 8px;
        font-size: 0.92rem;
    }

    .auth-links .auth-link-register {
        padding: 0 12px;
        margin-left: 2px;
    }

    .auth-menu {
        right: -12px;
    }
}
