/* Hallmark · macrostructure: Knowledge Workbench · genre: modern-minimal
 * design-system: prototype/design.md · page: 知识库
 */

.kb-page {
  min-height: calc(100vh - var(--nav-height));
  background: var(--bg-page);
}

.kb-shell {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px 22px 60px;
}

.kb-command {
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--border-light);
}

.kb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 11px;
}

.kb-breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.kb-breadcrumb a:hover { color: var(--brand); }

.kb-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.kb-title-row h1 {
  margin: 0;
  color: var(--text-title);
  font-size: 31px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.kb-title-row h1 span {
  display: block;
  margin-top: 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.kb-description {
  max-width: 820px;
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.75;
}

.kb-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kb-action {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--white);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.kb-action.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--on-brand);
}

.kb-action:hover { border-color: var(--brand); color: var(--brand); }
.kb-action.primary:hover { color: var(--on-brand); background: var(--brand-700); }

.kb-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--white);
}

.kb-stat {
  padding: 14px 15px;
  border-right: 1px solid var(--border-light);
}

.kb-stat:last-child { border-right: 0; }
.kb-stat span { color: var(--text-muted); font-size: 10px; }
.kb-stat b { display: block; margin-top: 6px; color: var(--text-title); font-size: 21px; }
.kb-stat small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 10px; }

.kb-workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 16px;
}

.kb-library,
.kb-answer {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: var(--white);
}

.kb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-light);
}

.kb-panel-head b { color: var(--text-title); font-size: 13px; }
.kb-panel-head span { color: var(--text-muted); font-size: 10px; }

.kb-upload-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px;
  padding: 12px;
  border: 1px dashed var(--border-default);
  border-radius: 8px;
  background: var(--bg-page);
  cursor: pointer;
}

.kb-upload-zone:hover,
.kb-upload-zone.dragging {
  border-color: var(--brand);
  background: var(--brand-50);
}

.kb-upload-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--white);
  color: var(--brand);
  font-size: 17px;
  flex-shrink: 0;
}

.kb-upload-copy { min-width: 0; flex: 1; }
.kb-upload-copy b { display: block; color: var(--text-title); font-size: 11px; }
.kb-upload-copy span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 9px; line-height: 1.45; }

.kb-doc-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 0 12px 10px;
}

.kb-doc-tools input {
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  background: var(--bg-page);
  color: var(--text-body);
  font-size: 10px;
  outline: none;
}

.kb-doc-tools input:focus { border-color: var(--brand); }

.kb-doc-list {
  max-height: 620px;
  overflow-y: auto;
  border-top: 1px solid var(--border-light);
}

.kb-doc-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
}

.kb-doc-row:last-child { border-bottom: 0; }
.kb-doc-row:hover { background: var(--bg-hover); }
.kb-doc-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--brand-50);
  color: var(--brand);
  font-size: 15px;
}

.kb-doc-main { min-width: 0; }
.kb-doc-name {
  overflow: hidden;
  color: var(--text-title);
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-doc-meta { margin-top: 4px; color: var(--text-muted); font-size: 9px; }
.kb-doc-state { color: var(--success); font-size: 9px; white-space: nowrap; }
.kb-doc-state.pending { color: var(--accent-orange); }

.kb-delete {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.kb-delete:hover { background: var(--red-light); color: var(--accent-red); }

.kb-empty {
  padding: 42px 18px;
  color: var(--text-muted);
  text-align: center;
  font-size: 11px;
}

.kb-empty i { display: block; margin-bottom: 9px; font-size: 29px; opacity: 0.55; }

.kb-answer {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
}

.kb-chat-list {
  min-height: 520px;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
  padding: 18px;
  background: var(--bg-page);
}

.kb-chat-empty {
  max-width: 620px;
  margin: 70px auto 0;
  padding: 24px;
  border: 1px solid var(--border-light);
  background: var(--white);
  color: var(--text-secondary);
  text-align: center;
  font-size: 12px;
  line-height: 1.75;
}

.kb-chat-empty i { display: block; margin-bottom: 10px; color: var(--brand); font-size: 30px; }

.kb-msg { max-width: 78%; margin-bottom: 14px; font-size: 12px; line-height: 1.75; }
.kb-msg.user {
  margin-left: auto;
  padding: 10px 13px;
  border-radius: 12px 12px 4px 12px;
  background: var(--brand);
  color: var(--on-brand);
}

.kb-msg.assistant {
  max-width: 100%;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: 4px 10px 10px 10px;
  background: var(--white);
  color: var(--text-body);
}

.kb-answer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--text-title);
  font-size: 12px;
  font-weight: 700;
}

.kb-answer-title i { color: var(--brand); }
.kb-source-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-light); }
.kb-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--brand-50);
  color: var(--brand);
  font-size: 9px;
}

.kb-input-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-light);
  background: var(--white);
}

.kb-input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  outline: none;
  color: var(--text-body);
  font: inherit;
  font-size: 11px;
}

.kb-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }

.kb-send {
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.kb-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 1200;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  background: var(--text-title);
  color: var(--white);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.kb-toast.show { opacity: 1; transform: translate(-50%, 0); }

.kb-spin { animation: kb-spin 0.9s linear infinite; }
@keyframes kb-spin { to { transform: rotate(360deg); } }

@media (max-width: 980px) {
  .kb-workspace { grid-template-columns: minmax(0, 1fr); }
  .kb-answer { position: static; }
  .kb-chat-list { max-height: none; min-height: 360px; }
}

@media (max-width: 700px) {
  .kb-shell { padding: 16px 14px 50px; }
  .kb-title-row { align-items: flex-start; flex-direction: column; }
  .kb-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kb-stat:nth-child(2n) { border-right: 0; }
  .kb-stat:nth-child(n+3) { border-top: 1px solid var(--border-light); }
  .kb-msg { max-width: 92%; }
}
