/* ==========================================================================
   达播工作台 — base.css
   全局 reset / 排版 / 工具类 / 布局骨架（app-shell + 侧栏）
   规则：所有颜色/间距/圆角引用 design-tokens.css 变量，禁止裸 hex（#fff/#000 例外）
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--font-line-height-body);
  letter-spacing: var(--font-letter-spacing-body);
  color: var(--color-fg);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

/* 数字统一等宽：金额/数量/百分比/场次 */
.num {
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 价格：醒目红色 + 加粗（货品售价/达播价等） */
.price {
  color: var(--color-price);
  font-weight: var(--font-weight-semibold);
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums;
}

/* 页面内容切换：淡入 + 轻微上移（每次路由渲染新节点即触发） */
.page > * {
  animation: page-fade-in var(--motion-base) var(--motion-ease-standard);
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 编号/订单号/SKU/佣金编码等宽 */
.mono {
  font-family: var(--font-family-mono);
}

/* 超长文本截断 */
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ 布局骨架 ============================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- 侧栏（圆角悬浮窗） ---- */
.sidebar {
  position: fixed;
  top: var(--sidebar-offset);
  left: var(--sidebar-offset);
  bottom: var(--sidebar-offset);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-raised);
  overflow: hidden;
  z-index: var(--z-sticky);
  transition: width var(--motion-base) var(--motion-ease-standard);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border-soft);
  flex-shrink: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

.brand-name__en {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.03em;
  color: var(--color-meta);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-name__zh {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--font-letter-spacing-body);
  color: var(--color-fg);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
  scrollbar-width: thin;                       /* Firefox */
  scrollbar-color: transparent transparent;
}
.sidebar__nav:hover {
  scrollbar-color: var(--color-gray-300) transparent;
}
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar__nav:hover::-webkit-scrollbar-thumb { background: var(--color-gray-300); }
.sidebar__nav::-webkit-scrollbar-track { background: transparent; }

.nav-group-label {
  padding: var(--space-3) var(--space-3) var(--space-2);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--font-letter-spacing-body);
  color: var(--color-fg-2);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-3);
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--color-fg-2);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--motion-fast) var(--motion-ease-standard),
    color var(--motion-fast) var(--motion-ease-standard);
}

.nav-item:hover {
  background: var(--color-surface-2);
  color: var(--color-fg);
}

/* 激活态：浅底 + 主色文字 + 图标（禁用左侧色条边框） */
.nav-item.is-active {
  background: var(--color-primary-50);
  color: var(--color-accent-text);
  font-weight: var(--font-weight-medium);
}

.nav-item .nav-icon {
  flex-shrink: 0;
  display: inline-flex;
}

.nav-item .nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__footer {
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--color-border-soft);
  flex-shrink: 0;
}

/* 折叠态 */
.app-shell.is-collapsed .sidebar {
  width: var(--sidebar-width-icon);
}

.app-shell.is-collapsed .sidebar .brand-name,
.app-shell.is-collapsed .sidebar .nav-text,
.app-shell.is-collapsed .sidebar .nav-group-label,
.app-shell.is-collapsed .sidebar .user-meta {
  display: none;
}

.app-shell.is-collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 0;
}

.app-shell.is-collapsed .sidebar .brand-logo {
  margin: 0 auto;
}

/* === 二级分组菜单：8 个一级分组，每组可折叠 === */
/* 参考微信小店后台：紧凑间距、无分隔线、子项单列无图标、文字缩进对齐一级菜单文字起点 */
.nav-group {
  margin-bottom: var(--space-1);   /* 4px，分组间紧凑 */
  padding-bottom: 0;
  position: relative;
}

/* 移除分隔线（对齐微信小店风格：无横线分隔） */

/* 一级菜单：icon + 名称 + (可选红点) + chevron；
   当前所在分组（has-active）：图标与文字用主色突出 */
.nav-group-label {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--font-letter-spacing-body);
  color: var(--color-fg-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: color var(--motion-fast) var(--motion-ease-standard),
    background-color var(--motion-fast) var(--motion-ease-standard);
}

.nav-group-label:hover {
  color: var(--color-fg);
  background: var(--color-surface-2);
}

.nav-group-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-fg-2);
  transition: color var(--motion-fast) var(--motion-ease-standard);
}

/* 当前所在分组：图标与文字用主色、加粗 */
.nav-group.has-active .nav-group-icon,
.nav-group.has-active .nav-group-label {
  color: var(--color-accent-text);
}
.nav-group.has-active .nav-group-label {
  font-weight: var(--font-weight-semibold);
}

.nav-group-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 通知红点（参考微信小店一级菜单右侧的小圆点；dot:true 启用） */
.nav-group-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff4d4f;
  flex-shrink: 0;
  margin-right: 4px;
  align-self: center;
}

.nav-group-chevron {
  display: inline-flex;
  color: var(--color-muted);
  transition: transform var(--motion-fast) var(--motion-ease-standard);
}

/* 统一用 chevronDown，折叠时旋转 -90° 指向右侧 */
.nav-group.is-collapsed .nav-group-chevron {
  transform: rotate(-90deg);
}

.nav-subitems {
  display: block;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height var(--motion-fast) var(--motion-ease-standard);
}

.nav-subitems.is-hidden {
  max-height: 0;
}

/* 子项：单列、无图标、字号略小、缩进对齐一级菜单文字起点；
   选中态：浅主色底 + 主色文字（与微信小店「首页」选中态一致） */
.nav-item--sub {
  height: 32px;
  padding: 0 12px 0 40px;     /* 40px ≈ 一级菜单内边距(12)+图标(18)+gap(10)，让文字对齐 */
  font-size: 13px;
  font-weight: var(--font-weight-regular);
  color: var(--color-fg-2);
}

/* 隐藏子项图标（参考微信小店：子项仅文字） */
.nav-item--sub .nav-icon {
  display: none;
}

.nav-item--sub:hover {
  background: var(--color-surface-2);
  color: var(--color-fg);
}

.nav-item--sub.is-active {
  background: var(--color-primary-50);
  color: var(--color-accent-text);
  font-weight: var(--font-weight-medium);
}
