/* ============================================================================
 * layout.css —— AppShell 骨架：移动端(顶部 Header + 底部 TabBar + 抽屉) / PC 端(左侧侧边栏)
 * 与 layout/AppShell.js 模板一一对应。移动优先，>=900px 切桌面形态。
 * ==========================================================================*/

/* ---------- 整体骨架 ---------- */
.app-shell { --side-w: 224px; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* ---------- 顶部 Header（移动端 = App 导航栏；PC 端 = topbar）---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: calc(var(--header-h) + var(--safe-t)); padding-top: var(--safe-t);
  background: rgba(26,26,26,.96); backdrop-filter: saturate(180%) blur(12px);
  color: #fff; display: flex; align-items: center; gap: 8px; padding-left: 8px; padding-right: 8px;
  border-bottom: 1px solid rgba(0,0,0,.2);
}
.hdr-menu, .hdr-msg {
  width: var(--tap); height: var(--tap); flex: none; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: #fff; font-size: 20px; border-radius: 10px; position: relative;
}
.hdr-menu:active, .hdr-msg:active { background: rgba(255,255,255,.12); }
.hdr-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-msg .tab-badge { position: absolute; top: 6px; right: 6px; }
/* PC 端用户区（移动端隐藏，改在抽屉里展示） */
.hdr-user { display: none; align-items: center; gap: 10px; }

/* 未读小红点 */
.tab-badge { min-width: 17px; height: 17px; padding: 0 5px; background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; }

/* ---------- 内容区 ---------- */
.app-content {
  flex: 1; width: 100%; max-width: 980px; margin: 0 auto;
  padding: 12px; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
}

/* ---------- 底部 TabBar（移动端固定；PC 隐藏）---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.94); backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border); display: flex;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); text-decoration: none; position: relative; padding-top: 4px; border: 0; background: transparent;
}
.tab-item .tab-icon { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.6); }
.tab-item .tab-label { font-size: 11px; line-height: 1; }
.tab-item.active { color: var(--gold); }
.tab-item.active .tab-icon { filter: none; }
.tab-item:active { background: rgba(0,0,0,.04); }
.tab-item .tab-badge { position: absolute; top: 4px; left: 50%; margin-left: 6px; }

/* ---------- 抽屉（移动端全量导航；PC 隐藏）---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 90; opacity: 0; animation: fade .2s forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; width: min(300px, 84vw);
  background: #1A1A1A; color: #c8c8cc; display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  padding-top: var(--safe-t); padding-bottom: var(--safe-b); box-shadow: 4px 0 24px rgba(0,0,0,.3);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 18px 14px; border-bottom: 1px solid #2a2a2e; }
.drawer-head .u-name { color: #fff; font-size: 16px; font-weight: 700; }
.drawer-head .u-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.drawer-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 0;
  /* 深色细滚动条：与侧栏/抽屉哑光黑底融合，替换 Windows 原生浅灰箭头滚动条 */
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent;
}
.drawer-scroll::-webkit-scrollbar { width: 6px; }
.drawer-scroll::-webkit-scrollbar-track { background: transparent; }
.drawer-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }
.drawer-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.26); }
.drawer-scroll::-webkit-scrollbar-thumb:active { background: rgba(255,255,255,.36); }
.drawer-scroll::-webkit-scrollbar-button { display: none; }   /* 去掉上下箭头按钮 */
.drawer-foot { padding: 12px 16px; border-top: 1px solid #2a2a2e; }
.drawer-foot .btn-plain { width: 100%; background: transparent; color: #c8c8cc; border-color: #3a3a40; }

/* ---------- 侧边栏 / 抽屉 共用导航 ---------- */
.nav-group { margin-bottom: 6px; }
.nav-group-title { padding: 12px 18px 6px; font-size: 11px; color: #7a7a82; letter-spacing: .6px; font-weight: 600; }
.nav-a {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; color: #c8c8cc;
  font-size: 14.5px; text-decoration: none; min-height: var(--tap); border: 0; background: transparent; width: 100%; text-align: left;
}
.nav-a .nav-ico { font-size: 17px; width: 22px; text-align: center; flex: none; }
.nav-a .nav-txt { flex: 1; min-width: 0; }
.nav-a.active { background: rgba(185,151,91,.16); color: var(--gold-bright); box-shadow: inset 3px 0 0 var(--gold); }
.nav-a:active { background: #26262b; }
.nav-a .tab-badge { margin-left: auto; background: var(--gold); color: #1A1A1A; }

/* ---------- PC 侧边栏（默认隐藏，>=900px 显示）---------- */
.sidebar { display: none; }
/* 侧栏折叠把手：仅 PC 显示（移动端用汉堡抽屉），默认隐藏 */
.side-toggle { display: none; }

/* ==========================================================================
 * >=900px 桌面形态：左侧常驻侧边栏 + 顶部 topbar，隐藏 TabBar / 汉堡 / 抽屉
 * ==========================================================================*/
@media (min-width: 900px) {
  .app-shell { display: flex; }
  .sidebar {
    display: flex; flex-direction: column; width: var(--side-w); flex-shrink: 0;
    background: #1A1A1A; color: #c8c8cc; position: sticky; top: 0; height: 100vh;
    overflow: hidden; transition: width .22s cubic-bezier(.4,0,.2,1);
  }
  /* 折叠时内层保持满宽被裁切（避免文字换行抖动） */
  .sidebar > * { width: var(--side-w); }
  .app-shell.side-collapsed .sidebar { width: 0; }
  /* 折叠把手（阿里云式）：贴侧栏右缘；折叠后移到屏幕左缘 */
  .side-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 50%; transform: translateY(-50%); left: var(--side-w);
    z-index: 60; width: 18px; height: 64px; padding: 0; border: 0; cursor: pointer;
    background: rgba(26,26,26,.5); color: #fff; font-size: 14px; line-height: 1;
    border-radius: 0 8px 8px 0;
    transition: left .22s cubic-bezier(.4,0,.2,1), background .15s;
  }
  .side-toggle:hover { background: rgba(26,26,26,.85); }
  .app-shell.side-collapsed .side-toggle { left: 0; }
  .sidebar .brand { padding: 20px 18px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid #2a2a2e; }
  .sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #8a8a90; margin-top: 3px; }
  .sidebar .drawer-scroll { flex: 1; }
  /* PC 菜单行高收紧：移动抽屉保留 var(--tap) 触控高，PC 鼠标操作换紧凑行距 */
  .sidebar .nav-a { min-height: 0; padding: 8px 18px; }
  .sidebar .nav-group { margin-bottom: 2px; }
  .sidebar .nav-group-title { padding: 10px 18px 4px; }
  .sidebar .side-foot { padding: 12px 16px; border-top: 1px solid #2a2a2e; }
  .sidebar .side-foot .btn-plain { width: 100%; background: transparent; color: #c8c8cc; border-color: #3a3a40; }
  .main { flex: 1; }
  /* Header 变 topbar：浅色、右对齐用户区 */
  .app-header {
    height: 56px; padding-top: 0; background: var(--card); color: var(--text);
    border-bottom: 1px solid var(--border); justify-content: flex-end; padding: 0 24px; gap: 16px;
    backdrop-filter: none;
  }
  .hdr-menu, .hdr-msg, .hdr-title { display: none; }
  .hdr-user { display: flex; margin-left: auto; }
  .hdr-user .u-name { color: var(--text-2); font-size: 14px; }
  .app-content { padding: 24px; padding-bottom: 40px; max-width: none; }
  .tabbar, .drawer, .drawer-mask { display: none !important; }
}

/* 抽屉打开时锁定背景滚动（JS 加 .no-scroll 到 body） */
body.no-scroll { overflow: hidden; }
