/* —— 知识库 · Wiki 文档 —— */
#module-view:has(.kb-wiki-page) {
  padding: 0;
  width: 100%;
}

.kb-wiki-page {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 400px;
  min-height: calc(100vh - var(--topbar-h));
  background: #f5f7fa;
}

.kb-wiki-side {
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: #fff;
  border-right: 1px solid #e8e8e8;
  min-height: 0;
}

.kb-wiki-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.kb-wiki-side-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #262626;
}

.kb-wiki-new-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: #1677ff;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.kb-wiki-new-btn:hover {
  background: #4096ff;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.35);
}

.kb-wiki-side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  margin-bottom: 14px;
  background: #f5f5f5;
  border: 1px solid #f0f0f0;
  border-radius: 18px;
}

.kb-wiki-side-search svg {
  flex-shrink: 0;
  color: #bfbfbf;
}

.kb-wiki-side-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: #262626;
}

.kb-wiki-cat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.kb-wiki-cat-card {
  display: block;
  width: 100%;
  padding: 14px 14px 12px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.kb-wiki-cat-card:hover {
  border-color: #d6e4ff;
  box-shadow: 0 2px 8px rgba(22, 119, 255, 0.08);
}

.kb-wiki-cat-card.active {
  background: #e6f4ff;
  border-color: #91caff;
  box-shadow: inset 3px 0 0 #1677ff;
}

.kb-wiki-cat-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #262626;
  margin-bottom: 6px;
}

.kb-wiki-cat-meta {
  margin: 0 0 4px;
  font-size: 12px;
  color: #8c8c8c;
  line-height: 1.4;
}

.kb-wiki-cat-date {
  margin: 0;
  font-size: 11px;
  color: #bfbfbf;
}

.kb-wiki-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
  border-right: 1px solid #e8e8e8;
}

.kb-wiki-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #f0f0f0;
}

.kb-wiki-breadcrumb {
  font-size: 13px;
  color: #8c8c8c;
}

.kb-wiki-main-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.kb-wiki-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #595959;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.kb-wiki-tool-btn:hover {
  background: #f5f5f5;
  color: #1677ff;
}

.kb-wiki-tool-btn.active {
  background: #e6f4ff;
  color: #1677ff;
}

.kb-wiki-upload-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.kb-wiki-upload-btn {
  width: auto;
  min-width: 32px;
  padding: 0 10px;
  gap: 4px;
  color: #1677ff;
}

.kb-wiki-upload-btn:hover {
  background: #e6f4ff;
  color: #0958d9;
}

.kb-wiki-upload-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

.kb-wiki-file-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 18px 10px;
  padding: 0 12px;
  height: 34px;
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
}

.kb-wiki-file-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
}

.kb-wiki-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 12px 16px;
}

.kb-wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.kb-wiki-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  text-align: left;
  font-weight: 500;
  color: #8c8c8c;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}

.kb-wiki-table tbody td {
  padding: 12px;
  border-bottom: 1px solid #f5f5f5;
  color: #595959;
  vertical-align: middle;
}

.kb-wiki-col-check {
  width: 44px;
  text-align: center;
}

.kb-wiki-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.kb-wiki-row:hover {
  background: #fafafa;
}

.kb-wiki-row.active {
  background: #e6f4ff;
}

.kb-wiki-row.active td {
  color: #262626;
}

.kb-wiki-name-cell {
  max-width: 280px;
}

.kb-wiki-name-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: #262626;
  cursor: pointer;
  text-align: left;
}

.kb-wiki-name-btn:hover .kb-wiki-name-text {
  color: #1677ff;
}

.kb-wiki-file-icon {
  flex-shrink: 0;
  color: #1677ff;
}

.kb-wiki-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-wiki-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.kb-wiki-status.ready {
  color: #389e0d;
  background: #f6ffed;
  border: 1px solid #b7eb8f;
}

.kb-wiki-status.pending {
  color: #d48806;
  background: #fffbe6;
  border: 1px solid #ffe58f;
}

.kb-wiki-row-more {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #8c8c8c;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.kb-wiki-row-more:hover {
  background: #f5f5f5;
  color: #262626;
}

.kb-wiki-empty {
  text-align: center;
  color: #bfbfbf;
  padding: 40px !important;
}

.kb-wiki-preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f5f7fa;
}

.kb-wiki-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #e8e8e8;
  background: #fff;
  min-height: 48px;
}

.kb-wiki-preview-label {
  font-size: 13px;
  font-weight: 600;
  color: #262626;
  flex-shrink: 0;
}

.kb-wiki-preview-fname {
  font-size: 12px;
  color: #8c8c8c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-wiki-preview-body {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
}

.kb-wiki-preview-scroll {
  height: 100%;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.kb-wiki-preview-doc {
  padding: 20px 22px 28px;
  font-size: 14px;
  line-height: 1.75;
  color: #434343;
}

.kb-wiki-preview-doc h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: #262626;
}

.kb-wiki-preview-doc h3 {
  margin: 20px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: #262626;
}

.kb-wiki-preview-doc p {
  margin: 0 0 12px;
}

.kb-wiki-preview-doc ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.kb-wiki-preview-doc li {
  margin-bottom: 6px;
}

.kb-wiki-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px;
  font-size: 13px;
}

.kb-wiki-md-table th,
.kb-wiki-md-table td {
  border: 1px solid #e8e8e8;
  padding: 10px 12px;
  text-align: left;
}

.kb-wiki-md-table th {
  background: #fafafa;
  font-weight: 500;
  color: #595959;
}

.kb-wiki-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #bfbfbf;
  font-size: 14px;
}

.kb-wiki-preview-editor {
  width: 100%;
  min-height: 100%;
  height: 420px;
  padding: 16px;
  border: none;
  outline: none;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #262626;
  background: #fff;
  border-radius: 8px;
  box-sizing: border-box;
}

.kb-wiki-preview-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 14px 16px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
}

.kb-wiki-act-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
  padding: 8px 6px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  background: #fff;
  color: #595959;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.kb-wiki-act-btn svg {
  color: #8c8c8c;
}

.kb-wiki-act-btn:hover:not(:disabled) {
  border-color: #91caff;
  color: #1677ff;
  background: #f0f7ff;
  box-shadow: 0 2px 6px rgba(22, 119, 255, 0.12);
}

.kb-wiki-act-btn:hover:not(:disabled) svg {
  color: #1677ff;
}

.kb-wiki-act-btn.primary {
  background: #1677ff;
  border-color: #1677ff;
  color: #fff;
}

.kb-wiki-act-btn.primary svg {
  color: #fff;
}

.kb-wiki-act-btn.primary:hover:not(:disabled) {
  background: #4096ff;
  border-color: #4096ff;
  color: #fff;
}

.kb-wiki-act-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 1200px) {
  .kb-wiki-page {
    grid-template-columns: 220px minmax(0, 1fr) 340px;
  }
}

@media (max-width: 992px) {
  .kb-wiki-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .kb-wiki-side {
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
  }

  .kb-wiki-preview-panel {
    max-height: 420px;
    border-top: 1px solid #e8e8e8;
  }
}
