
/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #333;
  display: flex;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 250px;
  min-width: 250px;
  background: linear-gradient(180deg, #001529 0%, #002140 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  z-index: 10;
  position: relative;
  transition: width 0.3s ease, min-width 0.3s ease;
}
.sidebar.collapsed {
  width: 40px;
  min-width: 40px;
  overflow: visible;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  transition: opacity 0.2s ease;
}
.sidebar.collapsed .sidebar-inner {
  opacity: 0;
  pointer-events: none;
}
.sidebar-header {
  padding: 18px 44px 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.15);
}
.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-header h1 {
  display: flex;
  align-items: center;
}

/* Search */
.search-box {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 10px center;
  color: #fff;
  outline: none;
  transition: all 0.2s;
}
.search-box input::placeholder { color: rgba(255,255,255,0.4); }
.search-box input:focus {
  border-color: #1890ff;
  background-color: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 3px rgba(24,144,255,0.15);
}

/* Catalog Tree */
.catalog-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.catalog-tree::-webkit-scrollbar { width: 5px; }
.catalog-tree::-webkit-scrollbar-track { background: transparent; }
.catalog-tree::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.catalog-tree::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.tree-item {
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  transition: all 0.15s;
  border-left: 3px solid transparent;
  min-height: 36px;
}
.tree-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.tree-item.active {
  background: rgba(24,144,255,0.15);
  color: #40a9ff;
  border-left-color: #1890ff;
  font-weight: 600;
}
.tree-item.indent-1 { padding-left: 32px; }
.tree-item.indent-2 { padding-left: 48px; }
.tree-item.indent-3 { padding-left: 64px; }

.tree-toggle {
  margin-right: 6px;
  font-size: 10px;
  transition: transform 0.2s;
  display: inline-block;
  color: rgba(255,255,255,0.35);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.tree-toggle.expanded { transform: rotate(90deg); color: rgba(255,255,255,0.6); }

.tree-icon { margin-right: 7px; font-size: 13px; flex-shrink: 0; }

.tree-children { display: none; }
.tree-children.show { display: block; }

/* Sidebar Toggle */
.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  transition: all 0.2s;
  padding: 0;
}
.sidebar-toggle:hover {
  background: #1890FF;
  color: #fff;
  border-color: #1890FF;
}
.sidebar.collapsed .sidebar-toggle {
  right: 7px;
}

/* ========== Content Area ========== */
.content {
  flex: 1;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.top-bar {
  flex-shrink: 0;
  background: linear-gradient(90deg, #f0f5ff 0%, #f5f5f5 100%);
  border-bottom: 1px solid #d9e8ff;
  padding: 9px 12px 9px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-text {
  font-size: 14px;
  color: #1890FF;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}
.top-bar-text .icon {
  font-size: 16px;
}
.top-bar-btns {
  display: flex;
  gap: 8px;
}
.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 12.5px;
  color: #444;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  white-space: nowrap;
}
.top-btn:hover {
  background: linear-gradient(180deg, #1890FF 0%, #096DD9 100%);
  color: #fff;
  border-color: #096DD9;
  box-shadow: 0 2px 8px rgba(24,144,255,0.35);
}
.top-btn .btn-icon {
  font-size: 13px;
  flex-shrink: 0;
}
.top-btn-refresh {
  padding: 5px 10px;
  margin-left: 4px;
}

/* Content Body */
.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  scrollbar-width: thin;
  scrollbar-color: #d9d9d9 transparent;
}
.content-body::-webkit-scrollbar { width: 6px; }
.content-body::-webkit-scrollbar-track { background: transparent; }
.content-body::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }
.content-body::-webkit-scrollbar-thumb:hover { background: #bfbfbf; }

.content-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid #f0f0f0;
}
.page-title {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}

/* ========== Markdown Content Styles ========== */
.page-content {
  font-size: 15px;
  line-height: 1.85;
  color: #333;
  max-width: 900px;
}

.page-content h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 32px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #1890ff;
  color: #1890ff;
}
.page-content h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e8e8e8;
  color: #222;
}
.page-content h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 22px 0 10px;
  color: #444;
}
.page-content h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 18px 0 8px;
  color: #555;
}
.page-content p { margin: 10px 0; }
.page-content a { color: #1890ff; text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.page-content a:hover { border-bottom-color: #1890ff; }

.page-content pre {
  background: #1e1e2e;
  border-radius: 10px;
  padding: 18px 22px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  white-space: pre;
}
.page-content pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: #cdd6f4;
  font-size: inherit;
}

.page-content code {
  background: #f0f4ff;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 13px;
  color: #d63384;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.page-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 18px 0;
  font-size: 14px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.page-content table th,
.page-content table td {
  border: 1px solid #e8e8e8;
  padding: 10px 14px;
  text-align: left;
}
.page-content table th {
  background: linear-gradient(180deg, #fafbfc 0%, #f0f2f5 100%);
  font-weight: 600;
  color: #333;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.page-content table tr:nth-child(even) { background: #fafbfc; }
.page-content table tr:hover { background: #e6f7ff; transition: background 0.15s; }

.page-content ul, .page-content ol { margin: 10px 0; padding-left: 24px; }
.page-content li { margin: 5px 0; }
.page-content li > ul, .page-content li > ol { margin: 4px 0; }

.page-content blockquote {
  border-left: 4px solid #1890ff;
  padding: 12px 18px;
  margin: 16px 0;
  background: linear-gradient(90deg, #f0f7ff 0%, #fafbff 100%);
  color: #555;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}
.page-content blockquote p { margin: 4px 0; }

/* Markdown links */
.page-content a.md-link {
  color: #1890ff;
  text-decoration: none;
  border-bottom: 1px solid rgba(24,144,255,0.3);
  transition: all 0.2s;
}
.page-content a.md-link:hover {
  color: #40a9ff;
  border-bottom-color: #40a9ff;
}

.page-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d9d9d9, transparent);
  margin: 28px 0;
}

.page-content img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin: 12px 0;
}

/* ========== Empty State ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
  text-align: center;
  transform: translateY(-70px);
}
.empty-state-top { margin-bottom: 40px; }
.empty-state-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: #999; font-weight: 500; }
.empty-state p { font-size: 14px; color: #bbb; }

/* Quick Cards */
.quick-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.quick-card {
  width: 200px;
  height: 110px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #fff;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
}
.quick-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.quick-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.9;
}
.quick-card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}
.quick-card-sub {
  font-size: 12px;
  opacity: 0.85;
  letter-spacing: 1px;
}
.card-client { background: linear-gradient(135deg, #13C2C2 0%, #36CFC9 100%); }
.card-server { background: linear-gradient(135deg, #1890FF 0%, #40A9FF 100%); }
.card-engine { background: linear-gradient(135deg, #722ED1 0%, #B37FEB 100%); }
.quick-card.active {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.5), 0 8px 24px rgba(0,0,0,0.2);
  filter: brightness(1.15);
  transform: scale(1.05);
}

/* ========== Search Results ========== */
.search-results { display: none; }
.search-results.show { display: block; max-height: calc(100vh - 110px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
.search-results.show::-webkit-scrollbar { width: 4px; }
.search-results.show::-webkit-scrollbar-track { background: transparent; }
.search-results.show::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.search-result-item {
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: all 0.15s;
}
.search-result-item:hover { background: rgba(255,255,255,0.08); }
.search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
}
.search-result-breadcrumb {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 4px;
}
.highlight {
  background: rgba(255,200,0,0.35);
  padding: 1px 3px;
  border-radius: 3px;
  color: #fff;
  font-weight: 600;
}

/* ========== Loading ========== */
.loading-text { color: rgba(255,255,255,0.4); font-size: 13px; padding: 20px; text-align: center; }

/* ========== Toolbar Button ========== */
.toolbar-btn {
  flex-shrink: 0;
  align-self: center;
  margin: 8px 12px 12px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #002140 0%, #003A5C 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #B0C4DE;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toolbar-btn:hover {
  background: linear-gradient(135deg, #003A5C 0%, #005080 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,40,80,0.3);
  transform: translateY(-1px);
}
.toolbar-btn i {
  font-size: 15px;
}

/* ========== Toolbox Iframe ========== */
.toolbox-iframe {
  width: calc(100% + 96px);
  height: calc(100% + 64px);
  margin: -32px -48px;
  border: none;
  display: block;
}

/* ========== Footer ========== */
.footer {
  flex-shrink: 0;
  padding: 10px 24px;
  text-align: center;
  font-size: 12px;
  color: #999;
  border-top: 1px solid #f0f0f0;
  background: #FAFBFC;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar { width: 250px; min-width: 250px; }
  .content { padding: 20px 24px; }
  .page-title { font-size: 22px; }
}
