/* ============================================================
 * layout.css - 应用外壳布局
 * ============================================================ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* 侧边栏 */
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .2s; z-index: 20; }
.logo-area { height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border); position: relative; }
.logo-mark { width: 36px; height: 36px; flex-shrink: 0; background: var(--primary); color: #fff; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; }
.logo-text { margin-left: 10px; overflow: hidden; white-space: nowrap; }
.logo-text h2 { font-size: 16px; font-weight: 600; color: var(--text); }
.logo-text span { font-size: 11px; color: var(--text-3); }
.sidebar-toggle { position: absolute; right: -1px; top: 50%; transform: translateY(-50%); width: 18px; height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: 0 6px 6px 0; color: var(--text-3); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.sidebar-toggle:hover { color: var(--primary); background: var(--primary-light); }

.nav-menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0; }
.nav-group { margin-bottom: 10px; }
.nav-group-title { padding: 6px 20px; font-size: 11px; color: var(--text-3); font-weight: 500; letter-spacing: .5px; white-space: nowrap; }
.nav-item { height: 40px; display: flex; align-items: center; padding: 0 18px; gap: 11px; cursor: pointer; color: var(--text-2); position: relative; white-space: nowrap; transition: .15s; margin: 1px 8px; border-radius: 8px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-item.active::before { content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; background: var(--primary); border-radius: 0 3px 3px 0; }
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-ico svg { width: 18px; height: 18px; }
.nav-text { font-size: 13.5px; }

.sidebar-footer { flex-shrink: 0; border-top: 1px solid var(--border); padding: 8px; }
.sf-item { width: 100%; height: 38px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: none; background: transparent; color: var(--text-2); border-radius: 8px; font-size: 13px; white-space: nowrap; }
.sf-item:hover { background: var(--surface-2); color: var(--text); }
.sf-ico { width: 18px; text-align: center; font-size: 16px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-top: 4px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 8px; white-space: nowrap; }
.sidebar-user:hover { background: var(--surface-2); }
.user-avatar { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.user-info { flex: 1; overflow: hidden; }
.username { font-size: 13px; font-weight: 500; color: var(--text); }
.role { font-size: 11px; color: var(--text-3); }
.user-more { color: var(--text-3); }

/* 折叠态 */
body.sidebar-collapsed .sidebar { width: 64px; }
body.sidebar-collapsed .logo-text, body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .nav-group-title, body.sidebar-collapsed .sf-item span:last-child,
body.sidebar-collapsed .user-info, body.sidebar-collapsed .user-more { display: none; }
body.sidebar-collapsed .logo-area { padding: 0 14px; }
body.sidebar-collapsed .sidebar-toggle { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; margin: 2px 8px; }
body.sidebar-collapsed .nav-item.active::before { left: -8px; }
body.sidebar-collapsed .sf-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 10px 0; }

/* 主区域 */
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); min-width: 0; overflow: hidden; }
.crumb b { color: var(--border); font-weight: 400; flex-shrink: 0; }
.crumb span { white-space: nowrap; }
.crumb span:first-child { flex-shrink: 0; }
.crumb span:last-child { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mobile-toggle { display: none; border: none; background: transparent; font-size: 20px; color: var(--text); }
.top-date { font-size: 13px; color: var(--text-2); }
.tb-btn { width: 34px; height: 34px; border: none; background: var(--surface-2); border-radius: 8px; color: var(--text-2); font-size: 17px; }
.tb-btn:hover { background: var(--primary-light); color: var(--primary); }
.tb-btn:active { transform: rotate(90deg); transition: transform .2s; }
.tb-btn:disabled { opacity: .5; cursor: not-allowed; }
.tb-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; }
/* 联网状态指示 */
.net-status { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); white-space: nowrap; }
.net-dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 3px rgba(148,163,184,.18); }
.net-status.online { color: #16a34a; background: #f0fdf4; border-color: #bbf7d0; }
.net-status.online .net-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); animation: netpulse 2s infinite; }
.net-status.warn { color: #ea580c; background: #fff7ed; border-color: #fed7aa; }
.net-status.warn .net-dot { background: #ea580c; box-shadow: 0 0 0 3px rgba(234,88,12,.18); }
.net-status.offline .net-label { color: var(--text-3); }
@keyframes netpulse { 0%,100%{opacity:1} 50%{opacity:.45} }
[data-theme="dark"] .net-status.online { background: #14532d33; border-color: #166534; color: #4ade80; }
[data-theme="dark"] .net-status.warn { background: #7c2d1233; border-color: #9a3412; color: #fb923c; }

.page-content { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }

/* 移动端侧栏遮罩 */
@media (max-width: 860px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-md); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .mobile-toggle { display: block; }
  .page-content { padding: 16px; }
  .top-date { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left { flex: 1; min-width: 0; }
  .topbar-right { gap: 8px; flex-shrink: 0; }
  .crumb { flex: 1; min-width: 0; }
}

@media (max-width: 560px) {
  /* 窄屏下精简顶栏：隐藏日期/主题按钮，保留同步按钮，缩短状态胶囊，保证面包屑横向显示不竖排 */
  .top-date, #themeBtn2 { display: none; }
  .net-status { padding: 0 8px; height: 28px; font-size: 11px; }
  .net-status .net-label { max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
  .tb-avatar { width: 30px; height: 30px; }
  .topbar-right .tb-btn { width: 30px; height: 30px; }
}
