/* ============================================================
   DPDNS 全局布局
   顶部栏（吸顶）+ 左侧栏目 + 主内容区
   ============================================================ */

/* —— 应用容器 —— */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ===================== 顶部栏 ===================== */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-4);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition: box-shadow var(--dur), background var(--dur);
}
.topbar.scrolled { box-shadow: var(--shadow-sm); }
.topbar__left, .topbar__right { display: flex; align-items: center; gap: var(--sp-3); }
.topbar__logo { height: 34px; display: flex; align-items: center; cursor: pointer; transition: opacity var(--dur); }
.topbar__logo:hover { opacity: .85; }
.topbar__logo img { height: 34px; width: auto; }
.topbar__banner { display: flex; align-items: center; gap: var(--sp-3); max-width: 50vw; }
.topbar__slogan {
  font-size: var(--fs-xs); color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .02em;
}
.topbar__banner-img { height: 32px; width: auto; border-radius: var(--r-xs); opacity: .9; }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-1); }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md); color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
  position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--c-danger); color: #fff; font-size: 10px; font-weight: 600;
  border-radius: var(--r-pill); display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* 菜单键（移动端） */
.menu-toggle { display: none; }

/* ===================== 主体区 ===================== */
.body-shell {
  display: flex; flex: 1; min-height: 0;
  position: relative;
}

/* ===================== 左侧栏目 ===================== */
.sidebar {
  position: sticky; top: var(--topbar-h);
  align-self: flex-start;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  z-index: var(--z-sidebar);
  overflow: hidden;
}
.sidebar__nav { flex: 1; padding: var(--sp-3) var(--sp-2); overflow-y: auto; overflow-x: hidden; }
.sidebar__nav::-webkit-scrollbar { width: 4px; }

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin: 2px 0;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), padding-left var(--dur);
  position: relative;
  white-space: nowrap;
  user-select: none;
}
.nav-item__icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
  transition: color var(--dur-fast);
}
.nav-item__label { flex: 1; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--dur); }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover .nav-item__icon { color: var(--dpdns-blue); }
.nav-item.active {
  background: linear-gradient(90deg, var(--c-info-bg) 0%, transparent 100%);
  color: var(--dpdns-blue);
  font-weight: 500;
}
.nav-item.active .nav-item__icon { color: var(--dpdns-deep); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
  background: var(--dpdns-deep); border-radius: 0 var(--r-xs) var(--r-xs) 0;
}

/* 收缩态 */
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-item__label { opacity: 0; width: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding: var(--sp-2); }
.sidebar.collapsed .sidebar__user-info,
.sidebar.collapsed .sidebar__username,
.sidebar.collapsed .sidebar__bottom-text { display: none; }
.sidebar.collapsed .sidebar__user { justify-content: center; }
.sidebar.collapsed .sidebar__user-avatar { margin: 0; }
.sidebar.collapsed .nav-item:hover .nav-item__label { display: block; }

/* tooltip（收缩态） */
.nav-item[data-tip] { position: relative; }
.nav-item[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  margin-left: var(--sp-2); padding: 4px 10px;
  background: var(--text-primary); color: var(--bg-surface);
  font-size: var(--fs-xs); border-radius: var(--r-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--dur-fast);
  z-index: var(--z-dropdown);
}
.nav-item[data-tip]:hover::after { opacity: .96; }

/* 分隔线 */
.sidebar__divider { height: 1px; background: var(--border-subtle); margin: var(--sp-2) var(--sp-3); }

/* 折叠按钮 */
.sidebar__toggle {
  margin: var(--sp-2); padding: var(--sp-2); border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  color: var(--text-tertiary); cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  font-size: var(--fs-xs);
}
.sidebar__toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar.collapsed .sidebar__toggle-text { display: none; }
.sidebar.collapsed .sidebar__toggle { justify-content: center; }
.sidebar__toggle .chevron { transition: transform var(--dur); }
.sidebar.collapsed .sidebar__toggle .chevron { transform: rotate(180deg); }

/* 底部用户区 */
.sidebar__user-section { padding: var(--sp-2); border-top: 1px solid var(--border-subtle); }
.sidebar__user {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-md); cursor: pointer;
  transition: background var(--dur-fast); margin-bottom: var(--sp-1);
}
.sidebar__user:hover { background: var(--bg-hover); }
.sidebar__user-avatar {
  width: 36px; height: 36px; border-radius: var(--r-pill); flex-shrink: 0;
  background: var(--bg-surface-alt); overflow: hidden; display: flex; align-items: center; justify-content: center;
  position: relative;
}
.sidebar__user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar__user-avatar.guest { background: var(--border-default); color: var(--text-tertiary); }
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__username { font-size: var(--fs-sm); font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__username.guest { color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--fs-xs); }
.sidebar__bottom-text { font-size: var(--fs-xs); color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* logo-max */
.sidebar__intexel {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-md); cursor: pointer;
  transition: background var(--dur-fast); font-size: var(--fs-xs); color: var(--text-tertiary);
}
.sidebar__intexel:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar__intexel img { height: 20px; width: auto; }

/* ===================== 主内容区 ===================== */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.main__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  padding: var(--sp-6) var(--sp-5);
  flex: 1;
}
.page-transition { animation: pageIn var(--dur-slow) var(--ease-out); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ===================== 遮罩（移动端抽屉） ===================== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg-overlay); z-index: calc(var(--z-sidebar) - 1);
  opacity: 0; transition: opacity var(--dur);
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ===================== 响应式 ===================== */
@media (max-width: 1279px) {
  :root { --sidebar-w: 64px; }
  .sidebar .nav-item__label,
  .sidebar__username, .sidebar__bottom-text, .sidebar__user-info, .sidebar__toggle-text { display: none; }
  .sidebar .nav-item { justify-content: center; padding: var(--sp-2); }
  .sidebar__user { justify-content: center; }
  .sidebar__intexel { justify-content: center; }
}

@media (max-width: 767px) {
  .menu-toggle { display: inline-flex; }
  .topbar__banner { display: none; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0;
    width: var(--sidebar-w); /* 恢复完整宽度 */
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    z-index: var(--z-overlay);
  }
  .sidebar.mobile-open { transform: none; width: 232px; }
  .sidebar.mobile-open .nav-item__label,
  .sidebar.mobile-open .sidebar__username,
  .sidebar.mobile-open .sidebar__user-info,
  .sidebar.mobile-open .sidebar__bottom-text { display: block; }
  .sidebar.mobile-open .nav-item { justify-content: flex-start; }
  .sidebar.mobile-open .sidebar__user { justify-content: flex-start; }
  .sidebar-overlay.show { display: block; }
  .main__inner { padding: var(--sp-4) var(--sp-3); }
}
