/* ============================================================
   TCE 部署手册 · 样式 v2
   ============================================================ */

:root {
  --primary:       #1e3a5f;
  --primary-light: #2563eb;
  --accent:        #0ea5e9;
  --bg:            #f0f4f8;
  --bg-card:       #ffffff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --radius:        12px;
  --shadow:        0 2px 16px rgba(0,0,0,.08);
  --shadow-hover:  0 8px 32px rgba(0,0,0,.14);
  --sidebar-w:     272px;
  --topbar-h:      58px;
  --sidebar-trans: width .22s ease, min-width .22s ease, opacity .22s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
}

/* ============================================================
   顶部导航
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--primary);
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.topbar-inner {
  max-width: 100%; height: 100%;
  padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: #fff;
  font-size: 16px; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
.brand-icon { font-size: 22px; }
.topnav {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: rgba(255,255,255,.65);
  overflow: hidden;
}
.topnav a {
  color: rgba(255,255,255,.85); text-decoration: none;
  white-space: nowrap;
}
.topnav a:hover { color: #fff; text-decoration: underline; }
.topnav .sep { opacity: .4; flex-shrink: 0; }
.topnav span { color: rgba(255,255,255,.9); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

main { margin-top: var(--topbar-h); }
.page { display: none; }
.page.active { display: block; }

/* ============================================================
   首页
   ============================================================ */
.hero {
  text-align: center;
  padding: 64px 24px 52px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 55%, #0ea5e9 100%);
  color: #fff;
}
.hero h1 {
  font-size: clamp(26px, 4.5vw, 44px);
  font-weight: 800; letter-spacing: -.5px;
  margin-bottom: 10px;
}
.hero-sub { font-size: 15px; opacity: .85; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  max-width: 1160px; margin: -28px auto 60px;
  padding: 0 20px;
}
.cat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.cat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 4px; background: var(--cat-color);
}
.cat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.cat-icon { font-size: 38px; margin-bottom: 14px; }
.cat-title { font-size: 19px; font-weight: 700; margin-bottom: 7px; }
.cat-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.cat-count {
  display: inline-flex; align-items: center;
  background: var(--bg); color: var(--text-muted);
  font-size: 12px; padding: 3px 10px; border-radius: 100px; gap: 4px;
}

/* ============================================================
   文档列表页
   ============================================================ */
.container { max-width: 900px; margin: 0 auto; padding: 36px 20px 60px; }
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.page-header p { color: var(--text-muted); }
.doc-list { display: grid; gap: 14px; }
.doc-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  cursor: pointer; transition: all .18s;
  display: flex; align-items: center; gap: 18px;
  box-shadow: var(--shadow);
}
.doc-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-hover); transform: translateX(4px);
}
.doc-item-icon {
  font-size: 32px; flex-shrink: 0;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 10px;
}
.doc-item-info { flex: 1; min-width: 0; }
.doc-item-title {
  font-size: 16px; font-weight: 600; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-item-sub { font-size: 12px; color: var(--text-muted); }
.doc-item-arrow { font-size: 22px; color: var(--text-muted); flex-shrink: 0; }

/* ============================================================
   文档阅读页布局
   左侧：侧边栏目录（固定宽度，sticky）
   右侧：正文（flex:1，自动撑满）
   ============================================================ */
.doc-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topbar-h));
}

/* ---- 左侧边栏 ---- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  transition: var(--sidebar-trans);
  display: flex;
  flex-direction: column;
}

/* 折叠状态：宽度归零，内容隐形 */
.sidebar.hidden {
  width: 0;
  min-width: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  font-weight: 600; font-size: 13px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
  white-space: nowrap;
}

/* ---- 目录切换按钮（在 topbar 内）---- */
.toc-toggle-topbar {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  transition: background .15s;
}
.toc-toggle-topbar:hover { background: rgba(255,255,255,.25); }

/* TOC 列表 */
.toc { padding: 10px 0 20px; flex: 1; }
.toc a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 14px;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc a:hover {
  background: #eff6ff; color: var(--primary-light);
  border-left-color: #93c5fd;
}
.toc a.active {
  border-left-color: var(--primary-light);
  color: var(--primary-light);
  background: #eff6ff;
  font-weight: 600;
}
.toc a[data-level="2"] { padding-left: 14px; font-weight: 500; }
.toc a[data-level="3"] { padding-left: 26px; color: #475569; }
.toc a[data-level="4"] { padding-left: 38px; font-size: 12px; color: var(--text-muted); }
.toc a[data-level="5"] { padding-left: 50px; font-size: 12px; color: var(--text-muted); }

/* ---- 正文区 ---- */
.doc-content {
  flex: 1;
  min-width: 0;
  padding: 36px clamp(20px, 4vw, 56px) 80px;
  transition: padding .22s ease;
}

.doc-loading {
  display: flex; flex-direction: column;
  align-items: center; padding: 80px 0; gap: 16px; color: var(--text-muted);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Markdown 正文样式
   ============================================================ */
#doc-body {
  max-width: 860px;
}

#doc-body h1 {
  font-size: 28px; font-weight: 800;
  color: var(--primary);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 10px; margin: 0 0 24px;
}
#doc-body h2 {
  font-size: 20px; font-weight: 700;
  color: var(--primary);
  border-left: 4px solid var(--primary-light);
  padding: 2px 0 2px 12px;
  margin: 36px 0 14px;
  background: linear-gradient(to right, #eff6ff, transparent);
  border-radius: 0 6px 6px 0;
}
#doc-body h3 {
  font-size: 16px; font-weight: 700;
  color: #1e40af;
  margin: 26px 0 10px;
  padding-left: 10px;
  border-left: 3px solid #93c5fd;
}
#doc-body h4 {
  font-size: 14px; font-weight: 700;
  color: #334155; margin: 20px 0 8px;
}
#doc-body h5, #doc-body h6 {
  font-size: 13px; font-weight: 600;
  color: #475569; margin: 16px 0 6px;
}

/* 内嵌目录折叠块 */
#doc-body details.toc-block {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 20px; margin: 20px 0 28px;
}
#doc-body details.toc-block summary {
  cursor: pointer; font-weight: 600; font-size: 14px;
  color: var(--text-muted); user-select: none;
  list-style: none;
}
#doc-body details.toc-block summary::-webkit-details-marker { display: none; }
#doc-body details.toc-block li { font-size: 13px; }
#doc-body details.toc-block a { color: var(--primary-light); text-decoration: none; }
#doc-body details.toc-block a:hover { text-decoration: underline; }

#doc-body p { margin: 10px 0; }
#doc-body ul, #doc-body ol { margin: 8px 0 8px 24px; }
#doc-body li { margin: 3px 0; }
#doc-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

#doc-body code {
  background: #f1f5f9; padding: 2px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: .86em; color: #c7254e;
}
#doc-body pre {
  background: #1e293b; color: #e2e8f0;
  padding: 18px 20px; border-radius: 10px;
  overflow-x: auto; margin: 14px 0;
}
#doc-body pre code {
  background: none; padding: 0;
  color: inherit; font-size: 13.5px;
}

#doc-body table {
  border-collapse: collapse; width: 100%; margin: 14px 0;
  font-size: 13px; border-radius: 8px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}
#doc-body th {
  background: var(--primary); color: #fff;
  padding: 9px 12px; text-align: left; font-weight: 600;
}
#doc-body td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
#doc-body tr:last-child td { border-bottom: none; }
#doc-body tr:nth-child(even) td { background: #f8fafc; }

#doc-body img {
  max-width: 100%; height: auto;
  border-radius: 8px; margin: 10px 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  display: block; cursor: zoom-in;
  border: 1px solid var(--border);
}
#doc-body blockquote {
  border-left: 4px solid var(--accent);
  background: #f0f9ff; padding: 10px 14px;
  border-radius: 0 8px 8px 0; margin: 14px 0; color: #0369a1;
}
#doc-body strong { color: #0f172a; }
#doc-body a { color: var(--primary-light); text-decoration: none; }
#doc-body a:hover { text-decoration: underline; }

/* ============================================================
   图片灯箱
   ============================================================ */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; cursor: zoom-out; padding: 16px;
}
.lightbox img {
  max-width: 95vw; max-height: 92vh;
  border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
}
.lightbox-close {
  position: fixed; top: 14px; right: 18px;
  color: #fff; font-size: 30px; cursor: pointer;
  line-height: 1; opacity: .8; z-index: 1001;
}
.lightbox-close:hover { opacity: 1; }

/* ============================================================
   回到顶部
   ============================================================ */
.back-to-top {
  position: fixed; bottom: 28px; right: 28px;
  width: 42px; height: 42px;
  background: var(--primary-light); color: #fff;
  font-size: 18px; border: none; border-radius: 50%;
  cursor: pointer; box-shadow: 0 4px 14px rgba(37,99,235,.4);
  display: none; align-items: center; justify-content: center;
  transition: transform .15s; z-index: 50;
}
.back-to-top:hover { transform: translateY(-2px); }
.back-to-top.visible { display: flex; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0;
    height: calc(100vh - var(--topbar-h));
    z-index: 180;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
    transform: translateX(0);
  }
  .sidebar.hidden { transform: translateX(-100%); width: var(--sidebar-w); min-width: var(--sidebar-w); opacity: 1; pointer-events: none; }
  .doc-content { padding: 20px 14px 60px; }
}
