/* ============================================================
   医学教材知识库 · 样式
   配色：医学蓝白为主，专业稳重，长时间阅读舒适
   ============================================================ */

:root {
  --blue-900: #0f3a5f;
  --blue-700: #1a5f9e;
  --blue-600: #2563a8;
  --blue-100: #e6f0f8;
  --blue-50:  #f3f8fc;
  --bg:       #f7f9fb;
  --surface:  #ffffff;
  --text:     #233240;
  --text-2:   #5a6b7b;
  --border:  #dce4ec;
  --accent:   #c0392b;       /* 鉴别/警示用暗红 */
  --green:    #1e7e4f;       /* 治疗有效色 */
  --shadow:   0 1px 3px rgba(15,58,95,.06), 0 4px 16px rgba(15,58,95,.05);
  --radius:   8px;
  --topbar-h: 56px;
  --sidebar-w: 280px;
  --toc-w:    200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶部栏 ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--blue-900);
  color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: #fff; color: var(--blue-700);
  font-weight: 700; font-size: 16px;
}
.brand-text { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.brand-sub { font-size: 12px; opacity: .7; }

.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; padding: 6px;
  flex-direction: column; justify-content: space-around;
}
.menu-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; }

.search-box { position: relative; flex: 1; max-width: 480px; margin-left: auto; }
.search-box input {
  width: 100%; height: 36px;
  border: none; border-radius: 18px;
  padding: 0 16px;
  font-size: 14px;
  background: rgba(255,255,255,.15);
  color: #fff;
  outline: none;
  transition: background .2s;
}
.search-box input::placeholder { color: rgba(255,255,255,.6); }
.search-box input:focus { background: rgba(255,255,255,.25); }

.search-results {
  position: absolute; top: 42px; left: 0; right: 0;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh; overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.search-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-item:hover { background: var(--blue-50); }
.search-item .si-name { font-weight: 600; color: var(--blue-700); }
.search-item .si-path { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.search-empty { padding: 14px; color: var(--text-2); font-size: 13px; }

/* ===== 布局 ===== */
.layout {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h) - 40px);
}

/* ===== 左侧导航 ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  z-index: 90;
}
.sidebar-banner {
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.sidebar-banner img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}
.nav { padding: 12px 0 24px; }

.nav-subject {
  font-size: 14px; font-weight: 700;
  padding: 10px 16px 6px;
  color: var(--blue-900);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-subject:hover { background: var(--blue-50); }
.nav-subject .arrow { transition: transform .2s; font-size: 12px; color: var(--text-2); }
.nav-subject.collapsed .arrow { transform: rotate(-90deg); }

.nav-system {
  font-size: 13.5px; font-weight: 600;
  padding: 6px 16px 6px 28px;
  color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-system:hover { background: var(--blue-50); }
.nav-system .arrow { font-size: 11px; color: var(--text-2); transition: transform .2s; }
.nav-system.collapsed .arrow { transform: rotate(-90deg); }

.nav-disease {
  font-size: 13px;
  padding: 5px 16px 5px 44px;
  color: var(--text-2);
  cursor: pointer;
  border-left: 3px solid transparent;
  display: block;
}
.nav-disease:hover { background: var(--blue-50); color: var(--blue-700); }
.nav-disease.active {
  background: var(--blue-100);
  color: var(--blue-900);
  border-left-color: var(--blue-700);
  font-weight: 600;
}

.sidebar-mask { display: none; }

/* ===== 内容区 ===== */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  margin-right: var(--toc-w);
  padding: 28px 36px;
  max-width: 900px;
}

/* 欢迎页 */
.welcome { padding: 40px 0; }
.welcome-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--blue-700);
}
.welcome-card h1 {
  margin: 0 0 12px;
  font-size: 28px;
  color: var(--blue-900);
}
.welcome-desc { color: var(--text-2); margin: 0 0 28px; font-size: 15px; }
.welcome-stats {
  display: flex; gap: 32px; margin-bottom: 32px; flex-wrap: wrap;
}
.welcome-stats .stat { }
.welcome-stats .stat-num { font-size: 28px; font-weight: 700; color: var(--blue-700); }
.welcome-stats .stat-label { font-size: 13px; color: var(--text-2); }
.welcome-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-primary {
  background: var(--blue-700); color: #fff; border: none;
  padding: 10px 20px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.btn-primary:hover { background: var(--blue-600); }
.btn-ghost {
  background: transparent; color: var(--blue-700);
  border: 1px solid var(--blue-700);
  padding: 10px 20px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.btn-ghost:hover { background: var(--blue-50); }

/* ===== 疾病详情 ===== */
.disease {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px 40px;
  box-shadow: var(--shadow);
}
.disease.hidden { display: none; }

.disease-header {
  border-bottom: 2px solid var(--blue-100);
  padding-bottom: 16px; margin-bottom: 24px;
}
.disease-breadcrumb {
  font-size: 12px; color: var(--text-2); margin-bottom: 8px;
}
.disease-title {
  margin: 0; font-size: 26px; color: var(--blue-900);
}
.disease-meta {
  margin-top: 8px; font-size: 13px; color: var(--text-2);
}

.section { margin-bottom: 32px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
.section h2 {
  font-size: 18px;
  color: var(--blue-900);
  border-left: 4px solid var(--blue-700);
  padding-left: 10px;
  margin: 0 0 14px;
}
.section h3 {
  font-size: 15px; color: var(--blue-700);
  margin: 18px 0 8px;
}
.section p { margin: 0 0 10px; }
.section ul, .section ol { margin: 6px 0 12px; padding-left: 22px; }
.section li { margin-bottom: 5px; }

.treat-block {
  background: var(--blue-50);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 10px 0;
}
.treat-block h4 {
  margin: 0 0 8px; font-size: 14px; color: var(--blue-900);
}
.dx-formula {
  background: #fff8e6;
  border-left: 4px solid #e0a800;
  padding: 10px 14px;
  margin: 10px 0;
  border-radius: 4px;
  font-size: 14px;
}
.dx-basis li strong { color: var(--blue-900); }
.diff-table {
  width: 100%; border-collapse: collapse; margin: 10px 0;
  font-size: 14px;
}
.diff-table th, .diff-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.diff-table th {
  background: var(--blue-100);
  color: var(--blue-900);
  font-weight: 600;
}
.guide-tag {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ===== 右侧页内目录 ===== */
.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  position: fixed;
  top: calc(var(--topbar-h) + 20px);
  right: 20px;
  font-size: 13px;
  max-height: calc(100vh - var(--topbar-h) - 40px);
  overflow-y: auto;
}
.toc-title {
  font-weight: 700; color: var(--text-2);
  font-size: 12px; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 1px;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin-bottom: 6px; }
.toc a { color: var(--text-2); display: block; padding: 3px 8px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--blue-700); text-decoration: none; background: var(--blue-50); }
.toc a.active { color: var(--blue-700); border-left-color: var(--blue-700); font-weight: 600; }

/* ===== 页脚 ===== */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-2);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .toc { display: none; }
  .content { margin-right: 0; }
}
@media (max-width: 768px) {
  .menu-toggle { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 280px;
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: block;
    position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(0,0,0,.3);
    z-index: 85;
  }
  .sidebar-mask.open { display: block; }
  .content {
    margin-left: 0;
    padding: 20px 16px;
  }
  .disease { padding: 20px 18px; }
  .welcome-card { padding: 28px 20px; }
  .brand-sub { display: none; }
  .search-box { max-width: none; }
}

/* ===== 顶部栏用户区 ===== */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.user-info {
  font-size: 13px;
  color: var(--text-2);
}
.logout-link {
  font-size: 13px;
  color: var(--blue-700);
  text-decoration: none;
  cursor: pointer;
}
.logout-link:hover {
  text-decoration: underline;
}
@media (max-width: 768px) {
  .header-right { gap: 8px; }
  .user-info { display: none; }
}
