/* ==========================================================================
   css/index/auth.css
   用途：登录 / 注册 弹窗（M13）——全站复用，避免跳页
   依赖：css/index/base.css（设计变量与 .btn/.field 基础），本文件负责遮罩、弹窗与标签页
   ========================================================================== */

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-modal[hidden] {
    display: none;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 22, .72);
    backdrop-filter: blur(4px);
}

.auth-dialog {
    position: relative;
    width: 100%;
    max-width: 430px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px 22px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
    animation: auth-pop .16s ease-out;
}

@keyframes auth-pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.auth-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.auth-close:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.auth-tabs {
    display: flex;
    gap: 6px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.auth-tab {
    flex: 1 1 0;
    padding: 9px 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.auth-tab:hover {
    color: var(--text);
    background: var(--bg-soft);
}

.auth-tab.active {
    background: var(--primary);
    color: #fff;
}

.auth-pane h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.auth-sub {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 13px;
}

.auth-pane .field {
    margin-bottom: 14px;
}

.auth-submit {
    width: 100%;
    border: 0;
    cursor: pointer;
    padding: 11px 18px;
    font-size: 15px;
}

.auth-hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
}

.auth-hint a {
    color: var(--primary);
}

/* 弹窗打开时锁滚动 */
body.auth-open {
    overflow: hidden;
}

/* 页头触发按钮：与链接视觉一致 */
[data-auth-open] {
    cursor: pointer;
}

/* 页头账户区（未登录=登录/注册；已登录=用户名 + 退出，由 auth.js 渲染） */
.nav-account {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-account .btn {
    padding: 7px 14px;
    font-size: 13px;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-account .btn.ghost {
    padding: 7px 12px;
}

/* ---------------------------------------------------------------------------
   M47：页头账户菜单 —— 桌面端点击显示下拉菜单（.nav-menu）
        移动端点击显示右侧抽屉（.nav-drawer + 遮罩）；退出登录收纳在菜单内
   --------------------------------------------------------------------------- */
.nav-account { position: relative; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    background: transparent; border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 12px 5px 6px; color: var(--text); font-size: 13px; }
.nav-user:hover { border-color: var(--primary); }
.nav-avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center;
    justify-content: center; background: rgba(61,123,255,.22); color: #9dc0ff; font-size: 13px; font-weight: 700; }
.nav-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-caret { width: 14px; height: 14px; color: var(--muted); transition: transform .2s; }
.nav-user[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

.nav-menu { position: absolute; top: 56px; right: 0; min-width: 210px; z-index: 60; display: none;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
    box-shadow: 0 18px 44px rgba(0,0,0,.45); }
.nav-menu.open { display: block; }
.nav-menu-head { color: var(--muted); font-size: 12px; padding: 6px 10px 8px;
    border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.nav-menu-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
    color: var(--text); font-size: 13px; background: transparent; border: 0; cursor: pointer; }
.nav-menu-item:hover { background: rgba(61,123,255,.12); }
.nav-menu-item.danger { color: #ff8b8b; border-top: 1px solid var(--line); margin-top: 6px;
    border-radius: 0 0 8px 8px; }

.nav-drawer-mask { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 68;
    background: rgba(6,10,20,.62); }
.nav-drawer-mask.open { display: block; }
.nav-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 84vw); z-index: 70;
    background: var(--bg-soft); border-left: 1px solid var(--line); padding: 16px;
    transform: translateX(102%); transition: transform .26s ease; overflow-y: auto; }
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nav-drawer-head span { font-weight: 700; }
.nav-drawer-close { background: transparent; border: 0; color: var(--muted); font-size: 24px;
    line-height: 1; cursor: pointer; }
.nav-drawer-body { display: flex; flex-direction: column; gap: 4px; }

@media (min-width: 901px) { .nav-drawer, .nav-drawer-mask { display: none !important; } }
@media (max-width: 900px) { .nav-menu { display: none !important; } }

/* ---------------------------------------------------------------------------
   M50：移动端页头 —— 左：返回 / 首页图标；中：页面标题；右：语言货币 + 用户图标
        桌面端保持原有「logo + 导航 + 语言货币 + 账户」布局，本段仅窄屏生效
   --------------------------------------------------------------------------- */
.nav-back { display: none; }
.nav-title { display: none; }
.nav-back-icon { width: 22px; height: 22px; display: block; }
.nav-back[data-nav-back="back"] .nav-back-home { display: none; }
.nav-back[data-nav-back="home"] .nav-back-arrow { display: none; }
/* 未登录入口的「用户图标」（桌面端与文案并列，窄屏只留图标） */
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.nav-user-guest { color: var(--text); }

@media (max-width: 900px) {
    .nav { position: relative; gap: 8px; }

    /* 左侧：返回 / 首页（圆形点击区） */
    .nav-back { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
        width: 34px; height: 34px; border-radius: 50%; color: var(--text); cursor: pointer; }
    .nav-back:hover { background: rgba(255, 255, 255, .07); }
    /* 左侧位置交给返回图标，隐藏 logo（桌面导航 .nav-links 已由 base.css 在窄屏隐藏） */
    .logo { display: none; }

    /* 中间：标题占据「左侧图标」与「右侧区域」之间的剩余空间
       （M51：原为绝对定位居中，窄屏右侧变窄后会与语言/货币重叠，改为 flex 自适应） */
    .nav-title { display: block; flex: 1 1 auto; min-width: 0; text-align: center;
        font-size: 15px; font-weight: 600; color: var(--text);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

    /* 右侧：语言 / 货币**短标签**紧凑显示 + 用户图标（不显示用户名与下拉箭头）
       M51：短标签（中文 / EN / RU、¥ CNY）由 /static/js/switcher.js 按视口切换 */
    .nav-right { gap: 5px; margin-left: auto; flex: 0 0 auto; }
    .nav-right .pill.switcher { background: rgba(255, 255, 255, .05); }
    .nav-right .pill.switcher select { font-size: 11.5px; padding: 5px 4px; }
    .nav-right .switcher-lang select { width: 50px; }
    .nav-right .switcher-currency select { width: 62px; }
}

/* ---------------------------------------------------------------------------
   M52：移动端「语言 / 货币」入口 —— 一个图标 + 选择抽屉
        桌面端仍显示两个下拉（.pill.switcher）；窄屏把它们收起，只留图标入口，
        点击弹出右侧抽屉（选项由 /static/js/switcher.js 依据两个 select 生成）
   --------------------------------------------------------------------------- */
.nav-locale { display: none; }
.locale-mask { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 68;
    background: rgba(6, 10, 20, .62); }
.locale-mask.open { display: block; }
.locale-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 84vw); z-index: 70;
    background: var(--bg-soft); border-left: 1px solid var(--line); padding: 16px;
    transform: translateX(102%); transition: transform .26s ease; overflow-y: auto; }
.locale-drawer.open { transform: translateX(0); }
.locale-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.locale-head span { font-weight: 700; }
.locale-group { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.locale-options { display: flex; flex-wrap: wrap; gap: 8px; }
.locale-option { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
    background: transparent; color: var(--text); font-size: 13px; cursor: pointer; }
.locale-option:hover { border-color: var(--primary); }
.locale-option.active { border-color: var(--primary); background: rgba(61, 123, 255, .18); color: #cfe0ff; }
@media (min-width: 901px) { .locale-drawer, .locale-mask { display: none !important; } }

@media (max-width: 900px) {
    /* 窄屏：收起两个下拉，只保留一个图标入口 */
    .nav-right .pill.switcher { display: none; }
    .nav-locale { display: inline-flex; align-items: center; justify-content: center;
        width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent;
        color: var(--text); cursor: pointer; flex: 0 0 auto; }
    .nav-locale:hover { background: rgba(255, 255, 255, .07); }
    .nav-user .nav-name, .nav-user .nav-caret { display: none; }
    .nav-user { padding: 5px; gap: 0; }
    .nav-avatar { width: 24px; height: 24px; }
    .nav-icon { width: 21px; height: 21px; }
}

@media (max-width: 520px) {
    .auth-dialog {
        max-width: 100%;
        border-radius: 14px;
        padding: 18px;
    }
}
