/* 前后端分离 —— 前端样式 */
:root {
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --brand: #2563eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

a { color: var(--brand); }

/* ---------- 顶部栏 ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #eef0f4;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.topbar-inner {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  max-width: 1600px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: #1f2937;
  text-decoration: none;
}
.brand i { color: var(--brand); font-size: 22px; }

/* ---------- 布局 ---------- */
.app-body {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
  max-width: 1600px;
  margin: 0 auto;
}

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #eef0f4;
  padding: 12px 8px 40px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link i { font-size: 16px; width: 18px; text-align: center; color: #6b7280; }
.nav-link:hover { background: #f1f5f9; }
.nav-link.active { background: #e8efff; color: var(--brand); font-weight: 600; }
.nav-link.active i { color: var(--brand); }
.nav-sub { padding: 2px 0 4px 18px; border-left: 2px solid #eef0f4; margin-left: 16px; }
.nav-sub .nav-link { font-size: 13px; padding: 7px 10px; }
.nav-toggle .ms-auto { transition: transform .2s; }
.nav-group .nav-link[aria-expanded="false"] .ms-auto { transform: rotate(-90deg); }

/* ---------- 主内容 ---------- */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 20px 24px 60px;
}

/* ---------- 卡片 / 封面 ---------- */
.article-card, .contact-card { transition: transform .15s, box-shadow .15s; }
.article-card:hover, .contact-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.article-cover { width: 100%; height: 160px; object-fit: cover; }
.article-cover-lg { width: 100%; max-height: 420px; object-fit: cover; }
.article-body { line-height: 1.8; }
.article-body img { max-width: 100%; height: auto; border-radius: 6px; }
.article-body pre { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; }
.article-body blockquote { border-left: 4px solid var(--brand); padding: 4px 16px; color: #4b5563; background: #f8fafc; }

.contact-avatar { width: 72px; height: 72px; object-fit: cover; font-size: 26px; }
.contact-avatar-lg { width: 128px; height: 128px; object-fit: cover; font-size: 48px; }

.info-item { padding: 8px 0; border-bottom: 1px dashed #eef0f4; }
.info-k { color: #9aa3af; font-size: 12px; }
.info-v { font-size: 14px; word-break: break-all; }

/* ---------- 认证页 ---------- */
.auth-wrap { min-height: calc(100vh - var(--topbar-h)); display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { font-size: 44px; color: var(--brand); }
body.guest-mode .app-body { display: block; }
body.guest-mode #sidebar { display: none; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 68px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.app-toast {
  display: flex; align-items: center;
  background: #fff; border: 1px solid #eef0f4;
  border-left-width: 4px; border-radius: 8px;
  padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  opacity: 0; transform: translateX(20px); transition: all .25s;
  font-size: 14px;
}
.app-toast.show { opacity: 1; transform: none; }
.app-toast.success { border-left-color: #10b981; }
.app-toast.error { border-left-color: #ef4444; }
.app-toast.warning { border-left-color: #f59e0b; }
.app-toast.info { border-left-color: #3b82f6; }

/* ---------- 封面裁剪 ---------- */
.cover-thumb { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px; }
.cover-placeholder {
  width: 84px; height: 84px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #9aa3af; background: #f8fafc; border-radius: 6px;
}

/* ---------- 富文本 ---------- */
.rich-editor { border: 1px solid #d8dee4; border-radius: 8px; overflow: hidden; }
.rich-toolbar { background: #f8fafc; padding: 6px; border-bottom: 1px solid #eef0f4; gap: 4px; }
.rich-tool { border: none !important; }
.rich-area {
  min-height: 220px; max-height: 460px; overflow-y: auto;
  border: none !important; padding: 12px 14px; font-size: 15px; line-height: 1.7;
}
.rich-area.is-empty:before { content: attr(data-placeholder); color: #9aa3af; }
.rich-area:focus { outline: none; box-shadow: none; }
.rich-area h2 { font-size: 20px; margin: 10px 0; }
.rich-area h3 { font-size: 17px; margin: 8px 0; }
.rich-area pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 6px; }
.rich-area blockquote { border-left: 4px solid var(--brand); padding: 4px 12px; color: #4b5563; background: #f8fafc; }

/* ---------- 菜单节点 ---------- */
.menu-node { padding-right: 8px; }
.menu-node:hover { background: #f8fafc; }

/* ---------- 部门树 ---------- */
.dept-tree { font-size: 14px; }
.dept-row {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  min-height: 40px;
  border-radius: 6px;
}
.dept-row:hover { background: #f1f5f9; }
.dept-node > .dept-children {
  margin-left: 16px;
  padding-left: 14px;
  border-left: 1px dashed #cbd5e1;
}
.dept-toggle {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: #64748b;
  flex: none;
}
.dept-toggle:hover { background: #e2e8f0; color: #0f172a; }
.dept-toggle i { font-size: .75rem; transition: transform .15s ease; }
.dept-node.collapsed > .dept-row .dept-toggle i { transform: rotate(-90deg); }
.dept-node.collapsed > .dept-children { display: none; }
.dept-node.collapsed > .dept-row .icon-open { display: none !important; }
.dept-node.collapsed > .dept-row .icon-closed { display: inline-block !important; }

/* ---------- 表格操作列 ---------- */
.table > tbody > tr > td { vertical-align: middle; }
.badge.bg-light { color: #374151 !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  #sidebar { position: fixed; left: -260px; z-index: 1040; transition: left .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  #sidebar.open { left: 0; }
  .app-main { padding: 14px 14px 60px; }
  .topbar-inner { padding: 0 14px; }
}
