/* ============================================================
 * 统一界面框架：所有系统，同一副骨架
 * 全局顶栏 + 左侧导航（按角色显隐）+ 内容区；≤767px 收进底部标签栏
 * 依赖 tokens.css
 * ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--zx-paper);
  color: var(--zx-ink);
  font-family: var(--zx-font-body);
  font-size: var(--zx-fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 全局顶栏 ---------------- */
.zx-topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--zx-topbar-h);
  display: flex; align-items: center; gap: var(--zx-sp-2);
  padding: 0 var(--zx-sp-2);
  background: var(--zx-dark-bg);
  color: var(--zx-dark-text);
}

.zx-topbar__brand {
  display: flex; align-items: center; gap: var(--zx-sp-1);
  font-family: var(--zx-font-display);
  font-size: var(--zx-fs-section);
  font-weight: 700; letter-spacing: .02em;
  color: var(--zx-dark-text); text-decoration: none;
  white-space: nowrap;
}
.zx-topbar__brand img { height: 28px; width: auto; display: block; }

/* 系统切换器 */
.zx-sys-switch {
  position: relative;
}
.zx-sys-switch__btn {
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  background: var(--zx-dark-bg-2);
  color: var(--zx-dark-text);
  border: 1px solid rgba(237, 233, 224, .14);
  border-radius: var(--zx-radius-ctrl);
  font: inherit; font-size: var(--zx-fs-body);
  cursor: pointer;
}
.zx-sys-switch__btn:hover { border-color: rgba(237, 233, 224, .32); }
.zx-sys-switch__btn .zx-caret { font-size: 10px; color: var(--zx-dark-text-2); }

.zx-sys-switch__menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 240px;
  background: var(--zx-card); color: var(--zx-ink);
  border-radius: var(--zx-radius-card);
  box-shadow: var(--zx-shadow-float);
  padding: var(--zx-sp-1);
  display: none;
}
.zx-sys-switch--open .zx-sys-switch__menu { display: block; }
.zx-sys-switch__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--zx-radius-ctrl);
  text-decoration: none; color: var(--zx-ink);
}
.zx-sys-switch__item:hover { background: var(--zx-paper); }
.zx-sys-switch__item.is-current { background: var(--zx-paper); font-weight: 600; }
.zx-sys-switch__item small { margin-left: auto; color: var(--zx-ink-3); font-size: var(--zx-fs-caption); }
.zx-sys-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.zx-topbar__spacer { flex: 1; }

/* 顶栏右侧：通知 + 用户 */
.zx-icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: var(--zx-radius-ctrl);
  color: var(--zx-dark-text-2); cursor: pointer; font-size: 16px;
}
.zx-icon-btn:hover { background: var(--zx-dark-bg-2); color: var(--zx-dark-text); }
.zx-icon-btn__badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 14px; height: 14px; padding: 0 4px;
  border-radius: 999px; background: var(--zx-seal);
  color: #fff; font-size: 9px; line-height: 14px; text-align: center;
}

.zx-user {
  display: flex; align-items: center; gap: var(--zx-sp-1);
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--zx-dark-bg-2);
  color: var(--zx-dark-text); font-size: var(--zx-fs-body);
  cursor: pointer; border: 0; font-family: inherit;
}
.zx-user__avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--zx-role-admin, var(--zx-seal));
  color: #fff; font-size: 12px; font-weight: 600;
}
.zx-user__role { color: var(--zx-dark-text-2); font-size: var(--zx-fs-caption); }

/* ---------------- 左侧导航 ---------------- */
.zx-sidebar {
  position: fixed; z-index: 90;
  top: var(--zx-topbar-h); bottom: 0; left: 0;
  width: var(--zx-sidebar-w);
  background: var(--zx-dark-bg);
  color: var(--zx-dark-text);
  display: flex; flex-direction: column;
  padding: var(--zx-sp-2) var(--zx-sp-1);
  overflow-y: auto;
}

.zx-nav-group { margin-bottom: var(--zx-sp-2); }
.zx-nav-group__label {
  padding: 0 12px 6px;
  font-size: var(--zx-fs-caption);
  color: var(--zx-dark-text-2);
  letter-spacing: .12em;
}

.zx-nav-item {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0; padding: 9px 12px;
  border-radius: var(--zx-radius-ctrl);
  color: var(--zx-dark-text); text-decoration: none;
  font-size: var(--zx-fs-body);
}
.zx-nav-item:hover { background: var(--zx-dark-bg-2); }
.zx-nav-item.is-active {
  background: var(--zx-seal);
  color: #fff; font-weight: 600;
}
.zx-nav-item__icon { width: 18px; text-align: center; flex: none; opacity: .92; }
.zx-nav-item__badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--zx-seal);
  color: #fff; font-size: 10px; line-height: 18px; text-align: center;
}
.zx-nav-item.is-active .zx-nav-item__badge { background: rgba(255, 255, 255, .25); }

/* 侧栏底部用户卡 */
.zx-sidebar__user {
  margin-top: auto;
  display: flex; align-items: center; gap: var(--zx-sp-1);
  padding: 10px 12px; border-radius: var(--zx-radius-ctrl);
  background: var(--zx-dark-bg-2);
}
.zx-sidebar__user .zx-user__avatar { width: 30px; height: 30px; }
.zx-sidebar__user-name { font-size: var(--zx-fs-body); color: var(--zx-dark-text); }
.zx-sidebar__user-role { font-size: var(--zx-fs-caption); color: var(--zx-dark-text-2); }
.zx-sidebar__logout {
  margin-left: auto; color: var(--zx-dark-text-2);
  background: none; border: 0; cursor: pointer; font-size: 14px;
}
.zx-sidebar__logout:hover { color: var(--zx-dark-text); }

/* ---------------- 内容区 ---------------- */
.zx-main {
  padding-top: var(--zx-topbar-h);
  padding-left: var(--zx-sidebar-w);
  min-height: 100vh;
}
.zx-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--zx-sp-3) var(--zx-sp-3) calc(var(--zx-sp-4) * 2);
}

/* 页面头：问候语 + 副标题 */
.zx-page-head { margin-bottom: var(--zx-sp-3); }
.zx-page-title {
  margin: 0;
  font-family: var(--zx-font-display);
  font-size: var(--zx-fs-title);
  font-weight: 700;
}
.zx-page-sub { margin: 4px 0 0; color: var(--zx-ink-3); font-size: var(--zx-fs-body); }

/* 入场动效：一次编排好的入场，仅此一处 */
@keyframes zx-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.zx-page > * { animation: zx-rise var(--zx-dur) var(--zx-ease) both; }
.zx-page > *:nth-child(2) { animation-delay: .04s; }
.zx-page > *:nth-child(3) { animation-delay: .08s; }
.zx-page > *:nth-child(4) { animation-delay: .12s; }
/* 动态挂载的浮层（toast/modal）不参与入场动画，否则会常驻 */
.zx-page > .toast, .zx-page > #toast, .zx-page > .modal-mask, .zx-page > .zx-toast { animation: none; }

/* ---------------- 移动端：底部标签栏 ---------------- */
.zx-tabbar { display: none; }

@media (max-width: 767px) {
  .zx-sidebar { display: none; }
  .zx-main { padding-left: 0; padding-bottom: var(--zx-tabbar-h); }
  .zx-page { padding: var(--zx-sp-2) var(--zx-sp-2) calc(var(--zx-tabbar-h) + var(--zx-sp-3)); }
  .zx-topbar .zx-sys-switch__btn .zx-sys-switch__domain { display: none; }
  .zx-sys-switch__btn { max-width: 132px; overflow: hidden; }
  .zx-sys-switch__btn span:not(.zx-caret):not(.zx-sys-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .zx-user__name, .zx-user__role { display: none; }
  .zx-user { padding: 4px; background: transparent; }

  .zx-tabbar {
    display: flex;
    position: fixed; inset: auto 0 0 0; z-index: 100;
    height: var(--zx-tabbar-h);
    background: var(--zx-dark-bg);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .zx-tabbar__item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--zx-dark-text-2); text-decoration: none;
    font-size: 10px;
    min-height: 44px; /* 触控热区 ≥44px */
  }
  .zx-tabbar__item.is-active { color: var(--zx-dark-text); }
  .zx-tabbar__item.is-active .zx-tabbar__icon { color: #fff; }
  .zx-tabbar__icon { font-size: 18px; position: relative; }
  .zx-tabbar__badge {
    position: absolute; top: -4px; right: -10px;
    min-width: 14px; height: 14px; padding: 0 4px;
    border-radius: 999px; background: var(--zx-seal);
    color: #fff; font-size: 9px; line-height: 14px;
  }
}
