/**
 * 浦融智库 · 全站统一导航栏样式 v2
 * 配合 nav-snippet.js 使用
 * 包含：导航栏 + 主题切换 + 字号调节 + 用户登录/注册
 */

/* ── 主题变量 ────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --nav-bg:         rgba(13, 27, 42, 0.92);
  --nav-text:       #c4cdd8;
  --nav-text-hover: #f5f0ee;
  --nav-active:     #c9a84c;
  --nav-border:     rgba(201, 168, 76, 0.25);
  --nav-height:     72px;
  --body-bg:        #f5f2ee;
  --body-bg-alt:    #ffffff;
  --body-text:      #3a3a3a;
  --page-bg:        #f5f2ee;
}

[data-theme="light"] {
  --nav-bg:         rgba(13, 27, 42, 0.95);
  --nav-text:       #c4cdd8;
  --nav-text-hover: #f5f0ee;
  --nav-active:     #c9a84c;
  --nav-border:     rgba(201, 168, 76, 0.30);
  --nav-height:     72px;
  --body-bg:        #f8f6f2;
  --body-bg-alt:    #ffffff;
  --body-text:      #2d2d2d;
  --page-bg:        #f8f6f2;
}

/* 全局：为固定导航栏留出空间 */
html { padding-top: 72px; box-sizing: border-box; }

/* ── 全站导航栏 ──────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 60px;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--nav-border);
}

.site-nav-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  flex-shrink: 0;
}

.site-nav-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #c9a84c, #e8c96a);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif SC', Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  color: #0d1b2a;
  flex-shrink: 0;
}

.site-nav-name {
  font-family: 'Noto Serif SC', Georgia, serif;
  font-weight: 600;
  font-size: 17px;
  color: #f5f0ee;
  letter-spacing: 2px;
}

.site-nav-sub {
  font-size: 10px;
  font-weight: 300;
  color: #8a9bb0;
  letter-spacing: 3px;
  display: block;
  margin-top: -2px;
}

.site-nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav-link {
  text-decoration: none;
  color: var(--nav-text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 1px;
  transition: color 0.25s;
  position: relative;
  padding-bottom: 4px;
}

.site-nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: #c9a84c;
  transform: scaleX(0);
  transition: transform 0.3s;
}

.site-nav-link:hover {
  color: var(--nav-text-hover);
}

.site-nav-link:hover::after,
.site-nav-link.active::after {
  transform: scaleX(1);
}

.site-nav-link.active {
  color: var(--nav-active);
}

.site-nav-link.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── 右侧功能区 ──────────────────────────────────────────── */
.site-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* ── 字号调节 ────────────────────────────────────────────── */
.site-nav-fontwrap {
  position: relative;
}

.site-nav-fontbtn {
  cursor: pointer;
  color: #8a9bb0;
  font-size: 14px;
  padding: 4px 8px;
  transition: color 0.2s;
  user-select: none;
}

.site-nav-fontbtn:hover {
  color: #c9a84c;
}

.site-nav-fontpanel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(21, 35, 54, 0.98);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  padding: 16px;
  min-width: 180px;
  z-index: 10000;
}

[data-theme="light"] .site-nav-fontpanel {
  background: rgba(255, 255, 255, 0.98);
  border-color: #e5e2dc;
}

.site-nav-fontpanel-label {
  font-size: 11px;
  color: #8a9bb0;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

[data-theme="light"] .site-nav-fontpanel-label {
  color: #888;
}

.site-nav-fontrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-nav-fontrow input[type=range] {
  flex: 1;
  accent-color: #c9a84c;
  cursor: pointer;
}

.site-nav-fontrow span {
  font-size: 12px;
  color: #c9a84c;
}

/* ── 主题切换按钮 ────────────────────────────────────────── */
.site-nav-theme {
  background: none;
  border: 1px solid var(--nav-border);
  color: #c4cdd8;
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}

.site-nav-theme:hover {
  border-color: #c9a84c;
  color: #c9a84c;
  transform: scale(1.1);
}

/* ── 登录按钮 ────────────────────────────────────────────── */
.site-nav-login {
  font-size: 14px;
  color: #c9a84c;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #c9a84c;
  transition: all 0.2s;
  background: none;
  font-family: inherit;
}

.site-nav-login:hover {
  background: rgba(201, 168, 76, 0.15);
}

/* ── 已登录用户区域 ──────────────────────────────────────── */
.site-nav-user-wrap {
  position: relative;
  cursor: pointer;
}

.site-nav-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(201, 168, 76, 0.25);
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s;
}

.site-nav-user-btn:hover {
  border-color: #c9a84c;
}

.site-nav-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #152336;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #c9a84c;
  overflow: hidden;
}

.site-nav-user-name {
  font-size: 14px;
  color: #f5f0ee;
}

/* 下拉菜单 */
.site-nav-user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(21, 35, 54, 0.98);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  padding: 6px 0;
  min-width: 160px;
  z-index: 10000;
  backdrop-filter: blur(8px);
}

.site-nav-user-menu.show {
  display: block;
}

[data-theme="light"] .site-nav-user-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: #e5e2dc;
}

[data-theme="light"] .site-nav-user-name {
  color: #333;
}

.site-nav-user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 18px;
  font-size: 14px;
  color: #c4cdd8;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.site-nav-user-menu-item:hover {
  background: rgba(201, 168, 76, 0.12);
  color: #c9a84c;
}

[data-theme="light"] .site-nav-user-menu-item {
  color: #555;
}

[data-theme="light"] .site-nav-user-menu-item:hover {
  color: #c9a84c;
}

/* ══════════════════════════════════════════════════════════
 *  登录 / 注册弹窗（注入到 body）
 * ══════════════════════════════════════════════════════════ */

.sn-auth-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100000;
  align-items: center;
  justify-content: center;
}

.sn-auth-overlay.show {
  display: flex;
}

.sn-auth-box {
  background: #152336;
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 12px;
  padding: 32px;
  width: 380px;
  max-width: 90vw;
  position: relative;
}

[data-theme="light"] .sn-auth-box {
  background: #ffffff;
  border-color: #e5e2dc;
}

.sn-auth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.sn-auth-title {
  font-size: 18px;
  font-weight: 600;
  color: #f5f0e8;
}

[data-theme="light"] .sn-auth-title {
  color: #1a3050;
}

.sn-auth-close {
  background: none;
  border: none;
  color: #8a9bb0;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.sn-auth-close:hover {
  color: #c9a84c;
}

.sn-auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.sn-auth-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  color: #8a9bb0;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}

.sn-auth-tab.active {
  color: #c9a84c;
  border-bottom-color: #c9a84c;
}

.sn-auth-field {
  margin-bottom: 16px;
}

.sn-auth-field label {
  display: block;
  font-size: 12px;
  color: #8a9bb0;
  margin-bottom: 6px;
}

[data-theme="light"] .sn-auth-field label {
  color: #888;
}

.sn-auth-field input {
  width: 100%;
  padding: 10px 12px;
  background: #0d1b2a;
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 6px;
  color: #f5f0e8;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

[data-theme="light"] .sn-auth-field input {
  background: #f5f2ee;
  border-color: #ddd;
  color: #333;
}

.sn-auth-field input:focus {
  outline: none;
  border-color: #c9a84c;
}

.sn-auth-msg {
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
}

.sn-auth-msg.error {
  color: #e74c3c;
}

.sn-auth-msg.success {
  color: #2ecc71;
}

.sn-auth-msg.show {
  display: block;
}

.sn-auth-btn {
  width: 100%;
  padding: 12px;
  background: #c9a84c;
  color: #0d1b2a;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
  margin-top: 4px;
}

.sn-auth-btn:hover {
  background: #e8c96a;
}

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

/* ── 响应式 ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .site-nav {
    padding: 0 24px;
  }
  .site-nav-links {
    gap: 20px;
  }
  .site-nav-link {
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .site-nav {
    padding: 0 16px;
    height: 60px;
  }
  .site-nav-links {
    display: none;
  }
  .site-nav-name {
    font-size: 15px;
  }
  .site-nav-sub {
    display: none;
  }
}
