/* ===== 顶栏工具区：搜索 / 通知 / 余额 / 语言 / 头像 =====
   控制台（.cs-topbar）与管理后台（.topbar）共用。
   只引用 tokens.css 的变量；rgba 仅用于阴影与遮罩。 */

.tb-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

/* ---- 通用按钮：32 高、圆角 999 ---- */
.tb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  min-width: 32px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-12);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.tb-btn:hover { background: var(--surface-2); color: var(--text); }
.tb-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.tb-btn .i { width: 17px; height: 17px; flex: none; }

/* ---- 搜索：宽屏是输入条，窄屏收成圆形按钮 ---- */
.tb-search {
  justify-content: flex-start;
  width: 208px;
  padding: 0 8px 0 10px;
  border-color: var(--border-2);
  background: var(--surface);
  color: var(--text-3);
}
.tb-search:hover { background: var(--surface); border-color: var(--primary); color: var(--text-2); }
.tb-search .tb-ph { flex: 1 1 auto; text-align: left; font-size: var(--fs-12); }
.tb-kbd {
  flex: none;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-3);
}

/* ---- 未读红点 ---- */
.tb-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--err);
  box-shadow: 0 0 0 1.5px var(--surface);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  color: var(--on-primary);
}
.tb-dot[hidden] { display: none; }

/* ---- 余额胶囊 ---- */
.tb-quota {
  gap: 5px;
  padding: 0 10px 0 8px;
  border-color: var(--border-2);
  background: var(--surface);
  color: var(--text);
}
.tb-quota:hover { background: var(--surface-2); border-color: var(--primary); }
.tb-quota .tb-num {
  font-family: var(--mono);
  font-size: var(--fs-12);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.tb-quota .tb-unit { font-size: var(--fs-11); color: var(--text-3); }
.tb-quota .i { color: var(--primary); }

/* ---- 语言 ---- */
.tb-lang { padding: 0 8px 0 6px; }
.tb-lang .tb-code {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: .02em;
}

/* ---- 弹出层（通知 / 语言） ---- */
.tb-wrap { position: relative; display: flex; align-items: center; }
.tb-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  width: 324px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  display: none;
}
.tb-pop.show { display: block; }
#tb-lang-pop { width: 216px; }

.tb-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.tb-pop-head b { font-size: var(--fs-13); font-weight: 600; color: var(--text); }
.tb-pop-head span { font-size: var(--fs-11); color: var(--text-3); }

.tb-note {
  display: flex;
  gap: 9px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.tb-note:hover { background: var(--surface-2); }
.tb-note .tb-note-dot {
  flex: none;
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--border-2);
}
.tb-note.unread .tb-note-dot { background: var(--primary); }
.tb-note-body { min-width: 0; flex: 1 1 auto; }
.tb-note-title {
  font-size: var(--fs-12);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tb-note.unread .tb-note-title { font-weight: 600; }
.tb-note-time {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
}
.tb-empty {
  padding: 22px 8px;
  font-size: var(--fs-12);
  color: var(--text-3);
  text-align: center;
}
.tb-pop-foot {
  margin-top: 4px;
  padding: 7px 8px 5px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.tb-pop-foot a { font-size: var(--fs-12); }

/* 语言菜单项 */
.tb-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--fs-12);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.tb-menu-item:hover { background: var(--surface-2); }
.tb-menu-item .tb-mi-sub { font-size: 10.5px; color: var(--text-3); }
.tb-menu-item[disabled] { color: var(--text-3); cursor: default; }
.tb-menu-item[disabled]:hover { background: transparent; }

/* ---- 命令面板 ---- */
.tb-cmd-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 16px 16px;
  background: rgba(33, 28, 21, .34);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.tb-cmd {
  display: flex;
  flex-direction: column;
  width: 560px;
  max-width: 100%;
  max-height: 68vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(40, 28, 16, .26);
  overflow: hidden;
}
.tb-cmd-input {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.tb-cmd-input .i { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.tb-cmd-input input {
  flex: 1 1 auto;
  min-width: 0;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--fs-14);
  color: var(--text);
  outline: none;
}
.tb-cmd-input input::placeholder { color: var(--text-3); }
.tb-cmd-list { flex: 1 1 auto; overflow-y: auto; padding: 6px; }
.tb-cmd-group {
  padding: 8px 8px 4px;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.tb-cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.tb-cmd-item .i { width: 16px; height: 16px; flex: none; color: var(--text-2); }
.tb-cmd-item.active { background: var(--primary-bg); }
.tb-cmd-item.active .i { color: var(--primary); }
.tb-cmd-txt { min-width: 0; flex: 1 1 auto; }
.tb-cmd-t { font-size: var(--fs-13); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-cmd-s { margin-top: 2px; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-cmd-tag {
  flex: none;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}
.tb-cmd-empty { padding: 26px 10px; font-size: var(--fs-12); color: var(--text-3); text-align: center; }

/* 与两侧元素的呼吸感 */
.cs-topbar .tb-tools { margin-left: 6px; }
.cs-topbar .ct-user { margin-left: 6px; }
.topbar .tb-tools { margin-right: 8px; }

/* ---- 窄屏收缩：控制台为主导航预留空间 ---- */
@media (max-width: 1350px) {
  .cs-topbar .tb-search { width: 32px; padding: 0; justify-content: center; border-color: transparent; }
  .cs-topbar .tb-search:hover { border-color: transparent; }
  .cs-topbar .tb-search .tb-ph,
  .cs-topbar .tb-search .tb-kbd { display: none; }
}
@media (max-width: 1100px) {
  .cs-topbar .tb-quota,
  .cs-topbar .tb-lang { width: 32px; padding: 0; gap: 0; }
  .cs-topbar .tb-quota .tb-num,
  .cs-topbar .tb-quota .tb-unit,
  .cs-topbar .tb-lang .tb-code { display: none; }
  .cs-topbar .tb-tools { gap: 2px; margin-left: 0; }
}
@media (max-width: 1180px) {
  .tb-search { width: 32px; padding: 0; justify-content: center; border-color: transparent; }
  .tb-search:hover { border-color: transparent; }
  .tb-search .tb-ph, .tb-search .tb-kbd { display: none; }
}
@media (max-width: 980px) {
  .tb-quota .tb-unit { display: none; }
  .tb-quota { padding: 0 8px; }
}
@media (max-width: 860px) {
  .tb-tools { gap: 2px; }
  .tb-lang .tb-code { display: none; }
  .tb-lang { padding: 0 6px; }
  body[data-page="admin"] .user-name { max-width: 80px; }
}

/* 覆盖全局 input:focus 的光晕，命令面板输入框保持无框 */
.tb-cmd-input input,
.tb-cmd-input input:focus,
.tb-cmd-input input:focus-visible {
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
}

/* 轻提示 */
.tb-tip {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 400;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--text);
  font-size: var(--fs-12);
  color: var(--on-primary);
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .18s ease, transform .18s ease;
}
.tb-tip.show { opacity: 1; transform: translate(-50%, 0); }

/* 后台不再使用文字品牌，也不保留旧的伪元素印章。 */
body[data-page="admin"] .topbar { flex-wrap: nowrap; }
body[data-page="admin"] .topbar .brand { flex: 0 0 28px; min-width: 28px; }
body[data-page="admin"] .topbar .brand::before { content: none; }
body[data-page="admin"] .topbar .brand img { display: block; width: 28px; height: 28px; }
body[data-page="admin"] .topbar-user { min-width: 0; }
body[data-page="admin"] .user-trigger { flex: none; }
body[data-page="admin"] .tb-quota .tb-num {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 手机仅收文字，不移除搜索、通知、余额与语言入口。 */
@media (max-width: 720px) {
  .tb-quota,
  .tb-lang { width: 32px; padding: 0; gap: 0; }
  .tb-quota .tb-num,
  .tb-quota .tb-unit,
  .tb-lang .tb-code { display: none; }
  #tb-notify {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 64px;
    width: auto;
    max-height: calc(100vh - 76px);
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
  }
  body[data-page="admin"] .topbar {
    gap: 8px;
    padding: 12px 14px;
  }
  body[data-page="admin"] .topbar .topnav { display: none; }
  body[data-page="admin"] .tb-tools { margin-right: 0; }
  body[data-page="admin"] .user-name { display: none; }
  body[data-page="admin"] .user-trigger { padding: 0 6px 0 3px; }
}

@media (min-width: 721px) {
  body[data-page="admin"] .topbar {
    min-height: 60px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
}

/* 后台右上角只留头像圆，与控制台一致 */
body[data-page="admin"] .topbar .user-trigger {
  width: 32px;
  height: 32px;
  padding: 2px;
  justify-content: center;
}
body[data-page="admin"] .topbar .user-trigger .user-name,
body[data-page="admin"] .topbar .user-trigger .user-caret { display: none; }

/* 手机端后台不再显示语言入口，与前台保持一致 */
@media (max-width: 720px) {
  body[data-page="admin"] .tb-lang { display: none; }
}
