/* ============================================================
   ASIN 找竞品 · topbar.css
   顶部导航栏：品牌 + 主导航 + 用户区 + 服务器状态 + 版本条
   ============================================================ */

/* 始终为纵向滚动条预留空间，避免页面变长时导航整体横向跳动。 */
html {
  scrollbar-gutter: stable;
}

@supports not (scrollbar-gutter: stable) {
  html {
    overflow-y: scroll;
  }
}

/* ---- 顶部导航（轻微毛玻璃，固定位置） ---- */
.topbar {
  background: var(--c-paper-glass);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  background-image:
    linear-gradient(90deg, rgba(45, 106, 79, 0.02) 0%, transparent 30%, transparent 70%, rgba(59, 130, 246, 0.02) 100%);
  border-bottom: 1px solid var(--c-border);
  height: 64px;
  /* 三列等侧翼布局：中间导航始终相对整个视口居中，不受左右内容宽度影响。 */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  padding: 0 28px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(15, 40, 25, 0.02), 0 6px 24px -12px rgba(15, 40, 25, 0.08);
  z-index: 100;
  position: sticky;
  top: 0;
  column-gap: 20px;
  /* 防止内部元素挤压 */
  flex-wrap: nowrap;
  overflow: visible;
  width: 100%;
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-primary) 20%, var(--c-accent) 50%, var(--c-primary) 80%, transparent);
  opacity: 0.3;
}

/* ---- 左侧：品牌（固定宽度，不挤压） ---- */
.topbar-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 14px;
  white-space: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 22px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 60, "SOFT" 30;
  position: relative;
  padding-left: 0;
  text-decoration: none;
  white-space: nowrap;
}
.brand::before {
  content: none;
}
.brand-logo-mark {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  border-radius: 9px;
  box-shadow: 0 5px 12px rgba(45, 106, 79, 0.18);
}

.divider {
  color: var(--c-border-strong);
  font-size: 20px;
  font-weight: 200;
}

.user-tag {
  font-size: 13px;
  color: var(--c-text-dim);
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.user-tag-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.role-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: var(--c-accent-bg);
  color: var(--c-accent-h);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
  border: 1px solid rgba(59, 130, 246, 0.25);
  white-space: nowrap;
}

/* ---- 中部：主导航（固定在整条导航栏的几何中心） ---- */
.topbar-nav {
  width: max-content;
  min-width: max-content;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 4px;
  /* 关键：内部不换行不收缩，超出时整个 topbar 出现横向滚动 */
  flex-wrap: nowrap;
  /* 允许下拉菜单溢出可见（个人中心下拉） */
  overflow: visible;
}
.nav-item {
  position: relative;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-dim);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
  font-family: var(--font-body);
  /* 关键：不允许收缩、不换行 */
  flex-shrink: 0;
  white-space: nowrap;
}
.nav-item:hover {
  color: var(--c-text);
  background: var(--c-white);
  border-color: var(--c-border);
}
.nav-item.active {
  color: var(--c-primary-h);
  background: var(--c-primary-bg);
  border-color: var(--c-primary-soft);
  font-weight: 700;
}

/* 导航项右上角新消息红点 */
.nav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-danger);
  border: 1.5px solid var(--c-bg);
  display: none;
  box-shadow: 0 0 0 0 rgba(196, 69, 91, 0.6);
  animation: navBadgePulse 1.6s ease-out infinite;
  pointer-events: none;
}
.nav-badge.show {
  display: inline-block;
}
@keyframes navBadgePulse {
  0%   { box-shadow: 0 0 0 0 rgba(196, 69, 91, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(196, 69, 91, 0); }
  100% { box-shadow: 0 0 0 0 rgba(196, 69, 91, 0); }
}

/* ---- 中部：服务器状态（仍可放置） ---- */
.topbar-center {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--c-text-dim);
  padding: 6px 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 100px;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  flex-shrink: 0;
  white-space: nowrap;
}
.server-status #topStatusText {
  min-width: 24px;
  text-align: center;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-text-hint);
  flex-shrink: 0;
  position: relative;
  transition: background 0.3s, box-shadow 0.3s;
}
/* 在线状态（绿色）：JS 设置 background 为 var(--c-success) 时通过 box-shadow 强化 */
.server-status .status-indicator[style]:not([style*="text-hint"]) {
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.22);
  animation: pulseSoft 2.4s ease-in-out infinite;
}

/* ---- 右侧：用户区 + 操作（不被挤压） ---- */
.topbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 8px;
  white-space: nowrap;
}

.usage-display {
  font-family: var(--font-mono);
  font-size: 12px !important;
  color: var(--c-text-dim) !important;
  padding: 6px 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 100px;
  letter-spacing: 0.02em;
}
.usage-display strong {
  color: var(--c-text);
  font-weight: 600;
  font-size: 13px;
}

/* ---- 顶部按钮（保留兼容，但主导航推荐用 .nav-item） ---- */
.btn-topbar {
  padding: 7px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-white);
  font-size: 12px;
  color: var(--c-text-dim);
  cursor: pointer;
  transition: all 0.18s ease;
  font-weight: 500;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-topbar:hover {
  background: var(--c-bg-tint);
  color: var(--c-text);
  border-color: var(--c-border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.btn-logout {
  color: var(--c-danger);
  border-color: rgba(196, 69, 91, 0.3);
  background: rgba(252, 232, 236, 0.5);
}
.btn-logout:hover {
  color: #fff;
  border-color: var(--c-danger);
  background: var(--c-danger);
  box-shadow: 0 4px 12px rgba(196, 69, 91, 0.28);
}

.btn-login {
  color: #fff;
  border-color: var(--c-primary);
  background: var(--c-primary);
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(45, 106, 79, 0.2);
}
.btn-login:hover {
  color: #fff;
  border-color: var(--c-primary-h);
  background: var(--c-primary-h);
  box-shadow: 0 6px 16px rgba(45, 106, 79, 0.3);
}

.btn-announce {
  color: var(--c-warn);
  border-color: rgba(194, 130, 12, 0.32);
  background: var(--c-warn-bg);
  font-weight: 600;
}
.btn-announce:hover {
  color: #fff;
  border-color: var(--c-warn);
  background: var(--c-warn);
  box-shadow: 0 4px 12px rgba(194, 130, 12, 0.28);
}

.btn-announce-new {
  animation: announcePulse 1.4s ease-in-out 3;
}
@keyframes announcePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 130, 12, 0.6); }
  50%      { box-shadow: 0 0 0 10px rgba(194, 130, 12, 0); }
}

.btn-admin-panel {
  color: var(--c-accent) !important;
  border-color: rgba(59, 130, 246, 0.32) !important;
  background: var(--c-accent-bg) !important;
  font-weight: 600;
}
.btn-admin-panel:hover {
  color: #fff !important;
  border-color: var(--c-accent) !important;
  background: var(--c-accent) !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.28);
}

/* ---- 版本更新提示条（清新绿蓝） ---- */
.reload-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 28px;
  background:
    linear-gradient(90deg, #2d6a4f 0%, #3b82f6 50%, #2d6a4f 100%);
  background-size: 200% 100%;
  animation: shimmerBar 4s linear infinite;
  color: #f3f8f5;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(45, 106, 79, 0.35);
}
@keyframes shimmerBar {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

.btn-reload-now {
  padding: 5px 18px;
  border: none;
  border-radius: var(--radius-xs);
  background: #fff;
  color: var(--c-primary-h);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: var(--font-body);
  text-transform: uppercase;
}
.btn-reload-now:hover {
  background: var(--c-primary-bg);
  color: var(--c-primary-h);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   响应式：窄屏隐藏部分导航
   ============================================================ */
/* 常见笔记本宽度提前收紧导航，管理员多一个菜单时也不会与两侧重叠。 */
@media (max-width: 1500px) {
  .topbar { padding: 0 18px; column-gap: 12px; }
  .topbar-nav { gap: 2px; }
  .nav-item { padding: 7px 10px; font-size: 12px; }
  .user-tag { display: none; }
  .divider { display: none; }
}
@media (max-width: 1100px) {
  .usage-display { display: none; }
}
@media (max-width: 860px) {
  .topbar {
    /* 小屏空间不足时改为横向滚动，避免导航项相互覆盖。 */
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar-left,
  .topbar-nav,
  .topbar-right {
    flex: 0 0 auto;
    justify-self: auto;
  }
  .topbar-nav {
    width: auto;
    min-width: max-content;
    justify-content: flex-start;
    overflow: visible;
  }
}

/* ============================================================
   右下角微信客服 · 扫码咨询 / 工单双入口
   ============================================================ */
.support-fab {
  --support-fab-width: 52px;
  --support-fab-height: 145px;
  position: fixed;
  right: 0;
  bottom: 28px;
  width: var(--support-fab-width);
  min-width: var(--support-fab-width);
  max-width: var(--support-fab-width);
  height: var(--support-fab-height);
  min-height: var(--support-fab-height);
  max-height: var(--support-fab-height);
  padding: 13px 8px 15px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 16px 4px 4px 16px;
  background: linear-gradient(165deg, #79d5a0 0%, #43b978 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 14px 34px rgba(35, 122, 77, 0.24), 0 3px 10px rgba(15, 40, 25, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  appearance: none;
  -webkit-appearance: none;
}
.support-fab:hover {
  transform: translateY(-3px);
  filter: saturate(1.06);
  box-shadow: 0 18px 40px rgba(35, 122, 77, 0.3), 0 5px 14px rgba(15, 40, 25, 0.14);
}
.support-fab:active { transform: translateY(-1px) scale(0.98); }
.support-fab:focus-visible {
  outline: 3px solid rgba(67, 185, 120, 0.26);
  outline-offset: 3px;
}
.support-fab-icon {
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.support-fab-icon svg {
  display: block;
  width: 24px;
  height: 24px;
}
.support-fab-label {
  display: block;
  width: 1em;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0.06em;
  color: #fff;
}
.support-fab-badge {
  position: absolute;
  top: -7px;
  left: -7px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--c-danger);
  color: #fff;
  border: 2px solid #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font: 700 11px/1 var(--font-mono);
  box-shadow: 0 4px 10px rgba(196, 69, 91, 0.3);
  pointer-events: none;
}
.support-fab-badge.show { display: inline-flex; }

.support-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 28, 18, 0.48);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.18s ease both;
}
.support-panel-card {
  position: relative;
  width: min(500px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 34px 38px 30px;
  border: 1px solid rgba(183, 228, 199, 0.9);
  border-radius: 22px;
  background: linear-gradient(180deg, #f7fff9 0%, #fff 42%);
  box-shadow: 0 30px 80px rgba(8, 35, 21, 0.28);
  text-align: center;
  animation: supportPanelIn 0.24s ease both;
}
@keyframes supportPanelIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.support-panel-close {
  position: absolute;
  top: 14px;
  right: 15px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--c-primary-bg);
  color: var(--c-primary-h);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.support-panel-close:hover { background: var(--c-primary-soft); transform: rotate(5deg); }
.support-panel-kicker {
  color: #3da56c;
  font: 700 10px/1 var(--font-mono);
  letter-spacing: 0.16em;
}
.support-panel-heading h2 {
  margin: 8px 0 6px;
  color: var(--c-text);
  font: 700 30px/1.25 var(--font-display);
}
.support-panel-heading p {
  max-width: 390px;
  margin: 0 auto;
  color: var(--c-text-dim);
  font-size: 14px;
  line-height: 1.7;
}
.support-panel-qr {
  width: min(300px, 76vw);
  margin: 18px auto 10px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid var(--c-primary-soft);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(45, 106, 79, 0.1);
}
.support-panel-qr img { display: block; width: 100%; height: auto; border-radius: 10px; }
.support-panel-scan-tip { color: var(--c-primary-h); font-size: 12px; font-weight: 600; }
.support-panel-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 19px 0 14px;
  color: var(--c-text-hint);
  font-size: 11px;
}
.support-panel-divider::before,
.support-panel-divider::after { content: ''; height: 1px; flex: 1; background: var(--c-border-soft); }
.support-panel-ticket-link {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, #67cc91, #3eae70);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(62, 174, 112, 0.2);
}
.support-panel-ticket-link:hover { color: #fff; filter: brightness(0.97); }
.support-panel-footnote { margin-top: 10px; color: var(--c-text-hint); font-size: 11px; }
body.support-panel-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .support-fab,
  .support-panel-backdrop,
  .support-panel-card { animation: none; transition: none; }
}

/* 小屏：避免被遮挡，限制在视口内 */
@media (max-width: 480px) {
  .support-fab {
    --support-fab-width: 46px;
    --support-fab-height: 131px;
    right: 0;
    bottom: 18px;
    padding: 10px 6px 12px;
  }
  .support-fab-icon { flex-basis: 31px; width: 31px; height: 31px; }
  .support-fab-icon svg { width: 21px; height: 21px; }
  .support-fab-label { font-size: 14px; }
  .support-panel-backdrop { padding: 12px; }
  .support-panel-card { padding: 26px 18px 22px; border-radius: 18px; }
}
