/* ============================================================
   外壳 —— 深蓝轻奢侧边栏工作台
   只负责：双栏骨架 · 侧边栏 · 顶栏 · 页头 · 空态 · 响应式
   设计 token 与通用组件在 design-system.css
   加载顺序：design-system.css → shell.css
   ============================================================ */

/* ============================================================
   双栏骨架
   ============================================================ */
.ds-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* 登录闸门期间：外壳全部隐藏，登录页自己是全屏 fixed 层 */
body.is-login .ds-sidebar,
body.is-login .ds-topbar { display: none; }
body.is-login .ds-shell { grid-template-columns: minmax(0, 1fr); }
body.is-login .ds-main { padding: 0; max-width: none; }

/* ============================================================
   侧边栏
   ============================================================ */
.ds-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-3) 100%);
  /* 香槟脊线 —— 签名元素之一 */
  border-right: 1px solid var(--champagne-dim);
  z-index: 40;
}

/* ---------- 品牌区 ---------- */
.ds-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
/* 公司 logo 的浅色底片。
   必须是浅底：logo 墨色是深蓝 #1B3A66，对侧边栏底 --ink #0E1A2B 只有约 1.5:1
   的对比度，直接贴在深色上几乎看不见。浅底片同时保住可读性和品牌原色。
   inline-grid 让它在侧边栏(flex)和登录页(块级)两种上下文里都是收缩尺寸。 */
.ds-brand-mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  padding: 5px 5px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid var(--champagne-dim);
}
.ds-brand-logo { display: block; height: 28px; width: auto; }

/* 登录页用的大一号底片 */
.ds-brand-mark--lg { padding: 9px 12px; border-radius: 12px; margin-bottom: 1.7rem; }
.ds-brand-mark--lg .ds-brand-logo { height: 42px; }

.ds-brand-text { min-width: 0; }
.ds-brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}
.ds-brand-sub {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(198, 164, 114, 0.78);
  white-space: nowrap;
}

/* ---------- 导航滚动区 ---------- */
.ds-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 0 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.ds-nav::-webkit-scrollbar { width: 6px; }
.ds-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

/* 分组标题 */
.ds-nav-group {
  padding: 16px 20px 7px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.3);
}
.ds-nav-group:first-child { padding-top: 4px; }

/* ---------- 一级项 ---------- */
.ds-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: calc(100% - 20px);
  margin: 1px 10px;
  padding: 0 12px;
  height: 42px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.ds-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.ds-nav-item:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: -2px;
}
.ds-nav-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.18s ease;
}
.ds-nav-icon svg { width: 18px; height: 18px; }
.ds-nav-item:hover .ds-nav-icon { color: rgba(255, 255, 255, 0.8); }
.ds-nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 展开箭头 */
.ds-nav-caret {
  flex: none;
  width: 14px;
  height: 14px;
  color: rgba(255, 255, 255, 0.32);
  transition: transform 0.22s ease, color 0.18s ease;
}
.ds-nav-caret svg { width: 14px; height: 14px; stroke-width: 1.8; }
.ds-nav-item[aria-expanded="true"] .ds-nav-caret {
  transform: rotate(90deg);
  color: var(--champagne);
}

/* 选中态 —— 签名元素：内嵌面板 + 左缘香槟竖线 */
.ds-nav-item.is-active {
  background: var(--ink-2);
  color: var(--champagne);
  font-weight: 600;
}
.ds-nav-item.is-active .ds-nav-icon { color: var(--champagne); }
.ds-nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 17px;
  border-radius: 0 2px 2px 0;
  background: var(--champagne);
}

/* 父项展开但自身未选中时略提亮，表示"在这条路径上" */
.ds-nav-item[aria-expanded="true"]:not(.is-active) { color: rgba(255, 255, 255, 0.92); }

/* ---------- 子项列表（手风琴） ---------- */
.ds-nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.24s ease;
}
.ds-nav-sub.is-open { max-height: 260px; }
.ds-nav-subitem {
  position: relative;
  display: flex;
  align-items: center;
  width: calc(100% - 20px);
  margin: 1px 10px;
  padding: 0 12px 0 43px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.ds-nav-subitem::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.18s ease;
}
.ds-nav-subitem:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
}
.ds-nav-subitem:hover::before { background: rgba(255, 255, 255, 0.45); }
.ds-nav-subitem:focus-visible { outline: 2px solid var(--champagne); outline-offset: -2px; }
.ds-nav-subitem.is-active { color: var(--champagne); font-weight: 600; }
.ds-nav-subitem.is-active::before { background: var(--champagne); }

/* ============================================================
   内容列
   ============================================================ */
.ds-col { display: flex; flex-direction: column; min-width: 0; }

/* ---------- 顶栏（只覆盖内容区，不压侧边栏） ---------- */
.ds-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

/* 面包屑：上级用香槟 mono，当前页用正文色 */
.ds-crumb {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
}
.ds-crumb-parent {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--champagne-ink);
  white-space: nowrap;
}
.ds-crumb-sep { color: var(--faint); }
.ds-crumb-current {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 用户区 */
.ds-user {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
}
.ds-avatar,
.ds-user-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--navy);
  border: 1px solid var(--champagne-dim);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.ds-user-name { font-size: 13px; font-weight: 500; color: var(--text); }

/* 侧边栏开合按钮（窄屏才显示） */
.ds-menu-toggle {
  display: none;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.ds-menu-toggle svg { width: 17px; height: 17px; stroke-width: 1.6; }
.ds-menu-toggle:focus-visible { outline: 2px solid var(--champagne-ink); outline-offset: 2px; }

/* ---------- 主内容 ---------- */
.ds-main {
  flex: 1;
  width: 100%;
  max-width: 1480px;
  padding: 26px 24px 56px;
}

/* ---------- 页头 ---------- */
.ds-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.ds-page-title {
  margin-top: 7px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}
.ds-page-sub {
  margin-top: 7px;
  font-size: 13.5px;
  color: var(--muted);
}
.ds-page-actions { display: flex; align-items: center; gap: 9px; }

/* 页面切换时的加载态 */
.ds-loading {
  padding: 64px 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ============================================================
   空态 —— 占位页不是空白页，是行动邀请
   ============================================================ */
.ds-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 66px 32px 72px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.ds-empty-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  border: 1px solid var(--champagne-dim);
  border-radius: 13px;
  background: var(--champagne-wash);
  color: var(--champagne-ink);
}
.ds-empty-mark svg { width: 24px; height: 24px; }
.ds-empty-title {
  margin-top: 11px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.ds-empty-desc {
  margin-top: 9px;
  max-width: 400px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
}
.ds-empty-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.ds-meta-icon svg { width: 13px; height: 13px; }

/* ============================================================
   响应式
   ============================================================ */
/* 中屏：侧边栏收窄 */
@media (max-width: 1200px) {
  :root { --sidebar-w: 236px; }
  .ds-main { padding-left: 20px; padding-right: 20px; }
  /* 236px 宽放不下「底片 + 8个汉字」横排（约需 247px），改竖排 */
  .ds-brand { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* 窄屏：侧边栏改抽屉 */
@media (max-width: 980px) {
  .ds-shell { grid-template-columns: minmax(0, 1fr); }
  .ds-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 0.26s ease;
    box-shadow: 0 0 44px rgba(11, 21, 36, 0.34);
  }
  .ds-sidebar.is-open { transform: none; }
  /* 抽屉宽 272px，比中屏的 236px 还宽，横排放得下 —— 恢复横排 */
  .ds-brand { flex-direction: row; align-items: center; gap: 11px; }
  .ds-menu-toggle { display: grid; }
  .ds-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(11, 21, 36, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }
  .ds-scrim.is-on { opacity: 1; pointer-events: auto; }
}

@media (max-width: 620px) {
  .ds-main { padding: 18px 14px 44px; }
  .ds-page-title { font-size: 22px; }
  .ds-stat-value { font-size: 25px; }
  .ds-crumb-parent,
  .ds-crumb-sep,
  .ds-user-name { display: none; }
}

/* 尊重减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
