/* ===== 顶部通栏导航样式 ===== */

/* 移除父主题顶部导航后的清理 */
body { padding-top: 0 !important; }
.header, .mobile-header { display: none !important; }

/* =====================================================================
 * 通栏条：占满整行，左 = cube logo + 竖线 + 天气，右 = 工具按钮 + 头像
 * 中部留白（导航交给左侧边栏，这里不放栏目菜单）
 * ===================================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  height: 58px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px; box-sizing: border-box;
  background: color-mix(in srgb, var(--main-bg-color, #FBF9F5) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--main-color, #2B2622);
  border-bottom: 1px solid rgba(128, 128, 128, .12);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
  transition: background .35s, color .35s, border-color .35s, box-shadow .35s;
}

/* ===== 顶栏让位侧栏（侧栏到顶 top:0 / height:100vh） =====
   侧栏占 230px（展开）/72px（折叠），顶栏不能盖住侧栏。
   通用 .topbar 默认 left:0（无侧栏页面如弹窗页用），
   有侧栏页面下让位、过渡跟随侧栏宽度变化。 */
body.hezi-has-sidebar .topbar {
  left: var(--sb-w-expanded);
  transition: left var(--sb-tr), background .35s, color .35s, border-color .35s, box-shadow .35s;
}
body.hezi-has-sidebar.hezi-sb-collapsed .topbar {
  left: var(--sb-w-collapsed);
}

/* 左侧：cube logo + 竖线 + 天气 */
.tb-left { display: flex; align-items: center; gap: 12px; flex: none; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--theme-color, #f04494); color: #fff;
  display: grid; place-items: center; flex: none; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.logo-mark:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.logo-mark svg {
  width: 22px; height: 22px; display: block;
  /* SVG 三面 + 内部黑边描边，在粉底/白底都看得清，避免 20px 立方体太小糊成一点 */
  filter: drop-shadow(0 0 .6px rgba(0, 0, 0, .35));
}

.tb-sep { width: 1px; height: 18px; background: currentColor; opacity: .28; flex: none; }

.tb-weather {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: currentColor; white-space: nowrap;
}
.weather-icon { display: inline-flex; align-items: center; justify-content: center; }
.tb-weather svg { width: 16px; height: 16px; }

/* 中部留白 */
.tb-mid { flex: 1 1 auto; }

/* 右侧：工具按钮 + 用户 */
.tb-right { display: flex; align-items: center; gap: 2px; flex: none; }
.tb-icon {
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer; color: inherit;
  display: grid; place-items: center; padding: 0; text-decoration: none;
  transition: background .2s ease;
}
.tb-icon:hover { background: rgba(128, 128, 128, .16); }
.tb-icon svg { width: 19px !important; height: 19px !important; display: block; }
.tb-icon i { font-size: 17px; font-style: normal; line-height: 1; display: flex; align-items: center; justify-content: center; }
.tb-icon .hezi-icon { width: 19px; height: 19px; }

.tb-msg { position: relative; }
.msg-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; background: #ff4757; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1; z-index: 2;
}

.tb-user {
  display: flex; align-items: center; gap: 5px;
  padding: 0 0 0 12px; border-radius: 999px; color: inherit;
  cursor: pointer; position: relative; transition: background .2s ease;
}
.tb-user:hover { background: rgba(128, 128, 128, .16); }
.tb-user:focus, .tb-user:active, .tb-user.active { background: rgba(128, 128, 128, .22); }
.tb-uname { font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; }
.tb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(128, 128, 128, .18); display: grid; place-items: center;
  overflow: hidden; flex: none;
}
.tb-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.tb-avatar svg { width: 22px; height: 22px; color: currentColor; opacity: .7; }

/* 会员卡片下拉（自定义四行布局，原样保留）
   宽度 380 → 500 以充分容纳 8 个按钮（admin 4 + user 4）一行四列不溢出；
   同时给面板加 max-width + min(94vw) 兜底防止窄屏溢出。 */
.tb-user-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: min(94vw, 500px); max-width: 500px;
  background: #fff; color: #1a1a1a;
  border-radius: 16px; box-shadow: 0 12px 44px rgba(0, 0, 0, .18);
  border: 1px solid rgba(128, 128, 128, .12);
  padding: 12px; z-index: 10000;
  box-sizing: border-box;
  cursor: default; /* 面板内默认箭头，不继承 .tb-user 的 pointer；仅链接/按钮显手型 */
  /* 弹出动效：默认隐藏（不占交互、不挡点击），打开时淡入+下滑+轻微放大 */
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-10px) scale(.97);
  transform-origin: top right;
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .2s;
}
.topbar.card-open .tb-user-panel {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity .22s ease, transform .22s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}
/* 面板内普通链接仍显手型（覆盖可能的全局 a 默认箭头规则） */
.tb-user-panel a { cursor: pointer; }
.hezi-user-card-wrap { padding: 0; width: 100%; }

/* =====================================================================
 * 模态 / 搜索打开时的层级处理
 * ===================================================================== */
body.modal-open .topbar,
body:has(.modal.in) .topbar { z-index: 10 !important; }
body:has(.navbar-search.show) .topbar { opacity: 0; pointer-events: none; }

/* =====================================================================
 * 页面形态变体（由 <body> 上的 hezi-tn-* 类驱动）
 * ===================================================================== */

/* home：透明叠在首图上，向下滚动超过 60px 变实心 */
body.hezi-tn-home .topbar {
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  color: #fff; border-bottom-color: transparent; box-shadow: none;
}
body.hezi-tn-home.hezi-tn-scrolled .topbar {
  background: color-mix(in srgb, var(--main-bg-color, #FBF9F5) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #1a1a1a; border-bottom-color: rgba(128, 128, 128, .12); box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}

/* workshop：主题色实心底 */
body.hezi-tn-workshop .topbar {
  background: var(--theme-color, #f04494); color: #fff; border-bottom-color: transparent; box-shadow: none;
}
body.hezi-tn-workshop .logo-mark { background: #fff; color: var(--theme-color, #f04494); }
body.hezi-tn-workshop .tb-icon:hover,
body.hezi-tn-workshop .tb-user:hover { background: rgba(255, 255, 255, .18); }

/* tool：深色实心底 */
body.hezi-tn-tool .topbar {
  background: #161616; color: #eee; border-bottom-color: rgba(255, 255, 255, .08); box-shadow: none;
}
body.hezi-tn-tool .tb-icon:hover,
body.hezi-tn-tool .tb-user:hover { background: rgba(255, 255, 255, .12); }

/* =====================================================================
 * 暗色模式（body.dark-theme 由父主题切换）
 * 顺序：基础 .topbar → 暗色实心 → 各形态变体（变体优先于暗色实心，
 *       但 home/workshop/tool 在暗色下单独兜底，保证可读）
 * ===================================================================== */
body.dark-theme .topbar {
  background: color-mix(in srgb, var(--main-bg-color, #242019) 85%, transparent); color: var(--main-color, #F2EDE6); border-bottom-color: rgba(255, 255, 255, .08);
}
body.dark-theme .tb-icon:hover,
body.dark-theme .tb-user:hover { background: rgba(255, 255, 255, .12); }
body.dark-theme .tb-user-panel { background: #232323; color: #eee; border-color: rgba(255, 255, 255, .1); }

/* 暗色下 home 滚动后的实心态 */
body.dark-theme.hezi-tn-home.hezi-tn-scrolled .topbar {
  background: color-mix(in srgb, var(--main-bg-color, #242019) 90%, transparent); color: var(--main-color, #F2EDE6); border-bottom-color: rgba(255, 255, 255, .08);
}

/* 暗色下各形态兜底（特异性 (0,3,1)，压过上面的 body.dark-theme .topbar）
   亮色下走前面的 body.hezi-tn-X 规则即可，这里不再重复 */
body.dark-theme.hezi-tn-home .topbar {
  background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none;
  color: #fff; border-bottom-color: transparent; box-shadow: none;
}
body.dark-theme.hezi-tn-workshop .topbar {
  background: var(--theme-color, #f04494); color: #fff; border-bottom-color: transparent; box-shadow: none;
}
body.dark-theme.hezi-tn-workshop .logo-mark { background: #fff; color: var(--theme-color, #f04494); }
body.dark-theme.hezi-tn-workshop .tb-icon:hover,
body.dark-theme.hezi-tn-workshop .tb-user:hover { background: rgba(255, 255, 255, .18); }
body.dark-theme.hezi-tn-tool .topbar {
  background: #161616; color: #eee; border-bottom-color: rgba(255, 255, 255, .08); box-shadow: none;
}
body.dark-theme.hezi-tn-tool .tb-icon:hover,
body.dark-theme.hezi-tn-tool .tb-user:hover { background: rgba(255, 255, 255, .12); }

/* =====================================================================
 * 内容让位：通栏条占 58px，除首页（首图满铺到顶）外，其他页面内容下移
 * ===================================================================== */
body:not(.hezi-tn-home) { padding-top: 58px !important; }

/* =====================================================================
 * 会员卡片样式（四行布局，原样保留）
 * ===================================================================== */

/* 主容器 */
.hezi-user-card {
  display: flex; flex-direction: column; gap: 10px; padding: 6px 0;
}

/* ── Row 1：左栏幻灯片 + 右栏 ── */
.huc-row1 {
  display: flex; gap: 10px; align-items: stretch;
}
.huc-slides-wrap {
  flex: 0 0 45%; min-width: 0;
}
.huc-row1-right {
  flex: 1; display: flex; flex-direction: column; gap: 6px; justify-content: flex-start;
  min-width: 0;
}

/* 幻灯片广告（自定义样式） */
.huc-slides {
  position: relative; width: 100%; height: 100%; min-height: 120px; border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, .05);
}
.huc-slide {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  opacity: 0; transition: opacity .6s ease; border-radius: 10px;
}
.huc-slide.active { opacity: 1 }
.huc-slide-video {
  width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block;
}
.huc-slide-dots {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 2;
}
.huc-slide-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .5); cursor: pointer; transition: all .3s;
}
.huc-slide-dots i.active { background: #fff; width: 18px; border-radius: 3px }

/* 右栏子项容器（父主题样式提供内容，这里仅做布局微调） */
.huc-wallet, .huc-vip, .huc-checkin { margin: 0; padding: 0 }
/* 银牌会员按钮：整块可点击 → /user/；flex+min-height 让 <a> 包住整个徽章，仅会员图标（class=em12）放大到 35px 高，不影响过期日期里的时钟图标 */
.huc-vip-link { display: flex; align-items: stretch; min-height: 40px; line-height: 40px; text-decoration: none; color: inherit; transition: opacity .2s ease }
.huc-vip-link:hover { opacity: .92 }
.huc-vip-link > * { min-height: inherit }
.huc-vip-link svg.em12 { height: 35px; width: auto; vertical-align: middle }
.huc-guest-tip { font-size: 13px; color: rgba(0, 0, 0, .4); padding: 20px 0; text-align: center }

/* ── Row 2：管理员按钮（左）+ 用户按钮（右） ── */
.huc-row2 {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.huc-admin-links, .huc-user-links {
  flex: 1; min-width: 0;
}
/* 让父主题的 header-user-href 适配卡片布局 */
.huc-row2 .header-user-href {
  padding: 0 !important; margin: 0 !important; gap: 4px !important;
}
/* 图标在上、文字在下，两者水平居中（默认 inline-block 左对齐，图标会偏左） */
.huc-row2 .header-user-href a {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none !important;
}

/* ── Row 3：统计数据栏（色块风格） ── */
.huc-stats-bar {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end;
}
/* 统计项可点击跳转（后台配置了链接时渲染为 <a>） */
a.huc-stat-chip { text-decoration: none; cursor: pointer }
a.huc-stat-chip:hover { filter: brightness(.96); text-decoration: none }
.huc-stat-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; line-height: 1;
  white-space: nowrap; flex: none;
  cursor: default;
}
/* CSS tooltip */
.huc-stat-chip::after {
  content: attr(title);
  position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: rgba(0, 0, 0, .82); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1;
  padding: 3px 8px; border-radius: 4px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s ease;
  z-index: 10;
}
.huc-stat-chip:hover::after { opacity: 1 }
.huc-stat-icon {
  width: 12px; height: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.huc-stat-icon svg { width: 100%; height: 100% }

/* 暗色模式 tooltip */
body.dark-theme .huc-stat-chip::after { background: rgba(255, 255, 255, .9); color: #111 }

/* 色块颜色（浅色模式） */
.huc-stat-chip[data-key="posts"] { background: #e8f4fd; color: #096dd9 }
.huc-stat-chip[data-key="forum_posts"] { background: #e6fffb; color: #006d75 }
.huc-stat-chip[data-key="fans"] { background: #f6ffed; color: #389e0d }
.huc-stat-chip[data-key="follow"] { background: #f9f0ff; color: #531dab }
.huc-stat-chip[data-key="views"] { background: #fff0f6; color: #c41d7f }
.huc-stat-chip[data-key="likes"] { background: #fff1f0; color: #cf1322 }
.huc-stat-chip[data-key="income"] { background: #fffbe6; color: #d48806 }
.huc-stat-chip[data-key="withdraw"] { background: #f0f5ff; color: #1d39c4 }
.huc-stat-chip[data-key="favorites"] { background: #fcffe8; color: #7cb305 }
.huc-stat-chip[data-key="comments"] { background: #fff2e8; color: #d46b08 }
.huc-stat-chip[data-key="favorite_posts"] { background: #f5f7fa; color: #1d39c4 }
.huc-stat-chip[data-key="rebate"] { background: #f0faf0; color: #237804 }

/* 色块颜色（深色模式） */
body.dark-theme .huc-stat-chip[data-key="posts"] { background: rgba(24, 144, 255, 0.15); color: #58a6ff }
body.dark-theme .huc-stat-chip[data-key="forum_posts"] { background: rgba(19, 194, 194, 0.15); color: #5cdbd3 }
body.dark-theme .huc-stat-chip[data-key="fans"] { background: rgba(82, 196, 26, 0.15); color: #73d13d }
body.dark-theme .huc-stat-chip[data-key="follow"] { background: rgba(114, 46, 209, 0.15); color: #b37feb }
body.dark-theme .huc-stat-chip[data-key="views"] { background: rgba(235, 47, 150, 0.15); color: #f759ab }
body.dark-theme .huc-stat-chip[data-key="likes"] { background: rgba(245, 34, 45, 0.15); color: #ff7875 }
body.dark-theme .huc-stat-chip[data-key="income"] { background: rgba(250, 173, 20, 0.15); color: #ffc53d }
body.dark-theme .huc-stat-chip[data-key="withdraw"] { background: rgba(47, 84, 235, 0.15); color: #85a5ff }
body.dark-theme .huc-stat-chip[data-key="favorites"] { background: rgba(160, 217, 17, 0.15); color: #bae637 }
body.dark-theme .huc-stat-chip[data-key="comments"] { background: rgba(250, 140, 22, 0.15); color: #ffc53d }
body.dark-theme .huc-stat-chip[data-key="favorite_posts"] { background: rgba(47, 84, 235, 0.12); color: #85a5ff }
body.dark-theme .huc-stat-chip[data-key="rebate"] { background: rgba(35, 120, 4, 0.12); color: #95de64 }

/* ── Row 4：自定义签名（自定义样式） ── */
.huc-signature {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .03); font-size: 13px; line-height: 1.5;
}
.huc-sign-text {
  flex: 1; color: rgba(0, 0, 0, .6); word-break: break-word;
}
.huc-sign-edit {
  flex: none; border: none; background: transparent; cursor: pointer; font-size: 15px;
  color: rgba(0, 0, 0, .3); transition: color .2s; padding: 0 4px; line-height: 1;
}
.huc-sign-edit:hover { color: rgba(0, 0, 0, .6) }
.huc-sign-submit {
  flex: none; border: none; background: transparent; cursor: pointer; font-size: 16px;
  color: #52c41a; transition: color .2s; padding: 0 4px; line-height: 1; font-weight: 700;
}
.huc-sign-submit:hover { color: #3da716 }

/* 暗色模式 — 会员卡片 */
body.dark-theme .huc-slides { background: rgba(255, 255, 255, .05) }
body.dark-theme .huc-slide-dots i { background: rgba(255, 255, 255, .3) }
body.dark-theme .huc-slide-dots i.active { background: #fff }

/* 幻灯片控件（上一张 / 下一张） */
.huc-slide-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .35); color: #fff; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease, background .2s ease; z-index: 3;
}
.huc-slide-btn:hover { background: rgba(0, 0, 0, .55) }
.huc-slide-btn svg { display: block }
.huc-slides:hover .huc-slide-btn { opacity: 1 }
.huc-slide-prev { left: 8px }
.huc-slide-next { right: 8px }

body.dark-theme .huc-guest-tip { color: rgba(255, 255, 255, .4) }

body.dark-theme .huc-signature { background: rgba(255, 255, 255, .04) }
body.dark-theme .huc-sign-text { color: rgba(255, 255, 255, .5) }
body.dark-theme .huc-sign-edit { color: rgba(255, 255, 255, .3) }
body.dark-theme .huc-sign-edit:hover { color: rgba(255, 255, 255, .6) }
body.dark-theme .huc-sign-submit { color: #73d13d }
body.dark-theme .huc-sign-submit:hover { color: #52c41a }

/* 暗色模式 — 签名输入框 */
body.dark-theme .huc-sign-input { background: rgba(255, 255, 255, .1) !important; border-color: rgba(255, 255, 255, .2) !important; color: #eee !important }

/* ===== 移动端 ===== */
@media (max-width: 768px) {
  body:not(.hezi-tn-home) { padding-top: 54px !important; }
  .topbar { padding: 0 14px; gap: 8px; height: 54px; }
  /* 移动端不用让位侧栏（侧栏变抽屉） */
  body.hezi-has-sidebar .topbar,
  body.hezi-has-sidebar.hezi-sb-collapsed .topbar { left: 0; }
  .tb-weather { display: none; }
  .tb-icon { width: 34px; height: 34px; }
  .tb-icon svg { width: 17px !important; height: 17px !important; }
  .tb-icon i { font-size: 15px; }
  .tb-icon .hezi-icon { width: 17px; height: 17px; }
  .tb-uname { display: none; }
  .tb-avatar { width: 30px; height: 30px; }
  .tb-user { padding-left: 8px; }
  .tb-user-panel { width: min(88vw, 500px); right: 8px; max-width: none; }
  /* 移动端会员卡片 */
  .huc-row1 { flex-direction: column; }
  .huc-slides-wrap { flex: none; }
  .huc-slides { min-height: 100px; }
  .huc-slide-btn { opacity: 1; }
  .huc-row2 { flex-direction: column; gap: 6px; }
  .huc-row3 .user-statistic { flex-wrap: wrap; }
  .huc-signature { font-size: 12px; padding: 8px 10px; }
}
