/* ============================================================
   Shared Top Navigation — 全站统一顶部导航组件
   以用户控制台顶栏（console-topbar）为唯一标准，
   支持 console / site / auth 三种形态。
   ============================================================ */

/* ===== Component base ===== */
.console-topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 110;
    display: flex; align-items: stretch;
    height: 56px;
}
.topbar-logo {
    width: 200px;
    display: flex; align-items: center; gap: 14px;
    padding: 0 var(--space-20);
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}
.topbar-body {
    flex: 1;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--space-28);
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--card-border);
    min-width: 0;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-brand .sidebar-brand-icon { width: 30px; height: 30px; }
.sidebar-brand-icon {
    width: 30px; height: 30px;
    background: var(--gradient-hero); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: var(--fs-14); font-weight: 900; flex-shrink: 0;
}
.sidebar-brand-text { font-size: var(--fs-15); font-weight: 800; color: var(--text-main); }
.sidebar-brand-ver { font-family: var(--font-mono); font-size: var(--fs-9); color: var(--text-5); letter-spacing: .5px; display: block; margin-top: 1px; }
.topbar-page-title { display: flex; align-items: center; }
.topbar-title { font-size: var(--fs-15); font-weight: 800; color: var(--text-main); }
.topbar-title-en { font-family: var(--font-mono); font-size: var(--fs-10); font-style: normal; font-weight: 600; color: var(--text-5); letter-spacing: 1px; margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-link {
    font-size: var(--fs-13); font-weight: 600; color: var(--text-3);
    padding: 6px var(--space-12); background: none; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 4px; white-space: nowrap;
    transition: color var(--motion-fast);
}
.topbar-link:hover { color: var(--brand-blue); }
.topbar-link svg { width: 12px; height: 12px; transition: transform var(--motion-base); }
.topbar-divider {
    width: 1px; height: 20px; background: var(--divider); margin: 0 4px;
}
.topbar-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: 0; color: var(--text-4); transition: var(--motion-base); position: relative;
}
.topbar-btn:hover { color: var(--brand-blue); background: var(--accent-soft); }
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-btn .notif-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger-bright); border: 1.5px solid var(--surface); }

/* theme toggle icon animation */
.topbar-btn .icon-moon,
.topbar-btn .icon-sun {
    display: flex; align-items: center; justify-content: center;
    transition: opacity .3s ease, transform .3s ease;
}
.topbar-btn .icon-sun { opacity: 0; transform: rotate(-90deg) scale(.4); position: absolute; }
.topbar-btn .icon-moon { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .topbar-btn .icon-sun { opacity: 1; transform: rotate(0) scale(1); position: relative; }
[data-theme="dark"] .topbar-btn .icon-moon { opacity: 0; transform: rotate(90deg) scale(.4); position: absolute; }

/* topbar user trigger */
.topbar-user-trigger {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; cursor: pointer;
    padding: var(--space-4) var(--space-8); color: var(--text-3);
    transition: color var(--motion-fast);
}
.topbar-user-trigger:hover { color: var(--brand-blue); }
.topbar-user-avatar {
    width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
}
.topbar-user-name {
    font-size: var(--fs-13); font-weight: 700; color: var(--text-main);
}
.topbar-user-trigger > svg { transition: transform var(--motion-base); }

/* topbar dropdown */
.topbar-dropdown {
    position: relative;
}
.topbar-dropdown-menu {
    position: absolute; top: 100%; left: 0;
    width: 268px;
    background: var(--surface);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-dropdown);
    visibility: hidden;
    clip-path: inset(0 0 100% 0);
    transform-origin: top;
    transition: clip-path .3s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .3s;
    z-index: 200;
    padding: var(--space-8) 0;
}
.topbar-dropdown-menu--right { left: auto; right: 0; width: 172px; }
.topbar-dropdown-menu--notify { left: auto; right: 0; width: 340px; }

/* 站内信下拉 */
.topbar-notify-header { padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between; }
.topbar-notify-title { color: var(--text-main); font-size: var(--fs-14); font-weight: 700; }
.topbar-notify-readall { color: var(--brand-blue); font-size: var(--fs-12); }
.topbar-notify-readall:hover { text-decoration: underline; }
.topbar-notify-list { max-height: 280px; overflow-y: auto; }
.topbar-notify-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 16px; color: var(--text-main); text-decoration: none; }
.topbar-notify-item:hover { background: var(--accent-tint); }
.topbar-notify-dot { width: 8px; height: 8px; margin-top: 5px; flex-shrink: 0; border-radius: 50%; background: transparent; }
.topbar-notify-item--unread .topbar-notify-dot { background: var(--brand-blue); }
.topbar-notify-body { flex: 1; min-width: 0; }
.topbar-notify-text { font-size: var(--fs-13); line-height: var(--lh-base); color: var(--text-main); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.topbar-notify-item--unread .topbar-notify-text { font-weight: 600; }
.topbar-notify-time { margin-top: 3px; font-size: var(--fs-11); color: var(--text-5); }
.topbar-notify-footer { display: block; padding: 10px 16px; border-top: 1px solid var(--divider); color: var(--brand-blue); font-size: var(--fs-12); font-weight: 600; text-align: center; text-decoration: none; }
.topbar-notify-footer:hover { background: var(--accent-tint); }
.topbar-dropdown.open .topbar-dropdown-menu,
.topbar-dropdown:hover .topbar-dropdown-menu,
.topbar-dropdown:focus-within .topbar-dropdown-menu {
    visibility: visible;
    clip-path: inset(0 0 0 0);
    transition: clip-path .36s cubic-bezier(.22, 1, .36, 1), visibility 0s;
}
.topbar-dropdown:hover .topbar-dropdown-trigger > svg,
.topbar-dropdown:hover .topbar-user-trigger > svg,
.topbar-dropdown:focus-within .topbar-dropdown-trigger > svg,
.topbar-dropdown:focus-within .topbar-user-trigger > svg,
.topbar-dropdown.open .topbar-dropdown-trigger svg {
    transform: rotate(180deg);
}
.topbar-btn.topbar-dropdown-trigger > svg { transform: none !important; }
.topbar-dropdown-header {
    padding: var(--space-16) var(--space-20) 14px;
    display: flex; flex-direction: column; gap: 10px;
}
.topbar-dropdown-label {
    display: flex; align-items: center; gap: 8px;
    font-size: var(--fs-13); color: var(--text-5);
}
.topbar-dropdown-label svg { width: 16px; height: 16px; color: var(--brand-blue); }
.topbar-dropdown-balance-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-dropdown-balance {
    font-family: var(--font-numbers); font-size: var(--fs-24); font-weight: 400;
    color: var(--text-main); line-height: var(--lh-solid);
}
.topbar-dropdown-charge {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    width: fit-content; padding: 7px 14px; font-size: var(--fs-12); font-weight: 700;
    background: var(--brand-blue); color: #fff; border: none; cursor: pointer;
    transition: background var(--motion-fast);
}
.topbar-dropdown-charge:hover { background: var(--brand-blue-dark); }
.topbar-dropdown-charge svg { width: 13px; height: 13px; }
.topbar-dropdown-divider {
    height: 1px; background: var(--divider); margin: 6px 0;
}
.topbar-dropdown-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 20px;
    font-size: var(--fs-14); color: var(--text-3);
    transition: background var(--motion-fast), color .15s;
    white-space: nowrap;
}
.topbar-dropdown-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-5); transition: color var(--motion-fast); }
.topbar-dropdown-item:hover { background: var(--accent-tint); color: var(--text-main); }
.topbar-dropdown-item:hover svg { color: var(--brand-blue); }
.topbar-dropdown-item--danger { color: var(--danger-bright); }
.topbar-dropdown-item--danger svg { color: currentColor; }
.topbar-dropdown-item--danger:hover { color: #fff; background: var(--danger-bright); }
.topbar-dropdown-item--danger:hover svg { color: currentColor; }

/* 语言选择 */
.topbar-lang-dropdown { display: inline-flex; align-items: center; }
.topbar-lang-trigger {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px;
    background: var(--accent-soft); border: none; cursor: pointer;
    color: var(--text-3); font-size: var(--fs-13); font-weight: 600;
    border-radius: 0;
    transition: color var(--motion-fast), background .15s;
}
.topbar-lang-trigger:hover { color: var(--brand-blue); background: var(--accent-tint); }
.topbar-lang-trigger svg { width: 12px; height: 12px; transition: transform var(--motion-base); }
.topbar-dropdown.open .topbar-lang-trigger svg { transform: rotate(180deg); }
.topbar-lang-flag { width: 18px; height: 12px; object-fit: cover; display: block; flex-shrink: 0; }
.topbar-lang-name { white-space: nowrap; }
.topbar-lang-menu { width: 128px; padding: 6px 0; border-radius: 0; }
.topbar-lang-item {
    width: 100%; display: flex; align-items: center; gap: 10px;
    padding: 9px 14px;
    background: transparent; border: none; cursor: pointer;
    color: var(--text-3); font-size: var(--fs-13); font-weight: 600; text-align: left;
    transition: background var(--motion-fast), color .15s;
}
.topbar-lang-item:hover { background: var(--accent-tint); color: var(--text-main); }
.topbar-lang-item.active { color: var(--brand-blue); }
.topbar-lang-item .topbar-lang-name { flex: 1; }
.topbar-lang-check { width: 14px; height: 14px; color: var(--brand-blue); }

/* 汉堡按钮 */
.sidebar-toggle {
    display: none; width: 36px; height: 36px;
    align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: 0; color: var(--text-4);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ===== Site mode（官网落地页）===== */
.topbar--site .topbar-logo { width: auto; }
.topbar--site .topbar-logo,
.topbar--site .topbar-body {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom-color: transparent;
}
.topbar--site.scrolled .topbar-logo,
.topbar--site.scrolled .topbar-body {
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom-color: var(--card-border);
    box-shadow: 0 4px 24px var(--shadow-soft);
}
.topbar-site-links {
    display: flex; align-items: center; gap: 2px;
    margin: 0 auto;
}
.topbar-site-link {
    position: relative;
    padding: var(--space-8) var(--space-12);
    font-family: var(--font-mono);
    font-size: var(--fs-12);
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1.5px;
    transition: color .2s ease;
}
.topbar-site-link::after {
    content: "";
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 20px;
    height: 2px;
    background: var(--brand-blue);
    transition: transform var(--motion-base) ease;
}
.topbar-site-link:hover { color: var(--text-main); }
.topbar-site-link:hover::after,
.topbar-site-link.active::after { transform: translateX(-50%) scaleX(1); }
.topbar-site-link.active { color: var(--brand-blue); }
.topbar-cta {
    padding: 7px 18px;
    background: var(--btn-bg);
    color: var(--btn-text);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: .5px;
    white-space: nowrap;
    transition: transform var(--motion-base) ease, box-shadow .2s ease, background .2s ease;
}
.topbar-cta:hover {
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--brand-blue);
    background: var(--btn-hover-bg);
}
.topbar-cta--ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1.5px solid var(--border-strong);
    padding: 5px var(--space-16);
}
.topbar-cta--ghost:hover {
    background: var(--btn-hover-bg);
    color: var(--btn-text);
    box-shadow: none;
    transform: none;
}
.topbar-mobile-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 56px; left: 0; right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-8) var(--space-20) 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease, padding .3s ease;
}
.topbar-mobile-menu.open {
    max-height: 460px;
    padding-bottom: var(--space-20);
}
.topbar-mobile-link {
    padding: 13px 6px;
    font-family: var(--font-mono);
    font-size: var(--fs-14);
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px dashed var(--border);
    letter-spacing: 1px;
}
.topbar-mobile-cta {
    margin-top: 14px;
    text-align: center;
    padding: 13px;
    background: var(--btn-bg);
    color: var(--btn-text);
    font-weight: 700;
    letter-spacing: .5px;
}
.topbar-mobile-cta--ghost {
    margin-top: 10px;
    background: transparent;
    color: var(--text-main);
    border: 1.5px solid var(--border-strong);
}

/* ===== Auth mode（登录 / 注册页）===== */
.topbar--auth .sidebar-toggle { display: none; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .topbar-link { display: none; }
    .topbar-divider { display: none; }
    .topbar--site .sidebar-toggle { display: flex; }
    .topbar-site-links { display: none; }
    .topbar-cta { display: none; }
    .topbar-mobile-menu { display: flex; }
    .topbar--site .topbar-logo,
    .topbar--site .topbar-body {
        background: var(--nav-bg);
        backdrop-filter: blur(20px) saturate(1.4);
        -webkit-backdrop-filter: blur(20px) saturate(1.4);
        border-bottom-color: var(--card-border);
    }
}
@media (max-width: 700px) {
    .sidebar-toggle { display: flex; }
    .topbar--auth .sidebar-toggle { display: none; }
    .topbar-logo { width: auto; padding: 0 16px; }
    .topbar-body { padding: 0 16px; }
    .topbar-brand { width: auto; }
    .topbar-brand-text { display: none; }
    .topbar-page-title { padding-left: 10px; }
    .topbar-user-name { display: none; }
    .topbar-dropdown-menu { right: 0; left: auto; }
    .topbar-lang-name { display: none; }
    .topbar-lang-trigger { padding: 0 8px; }
}
@media (max-width: 480px) {
    .topbar--site .topbar-logo { padding: 0 12px; }
}
