/* ════════════════════════════════════════════════════════════
   Knowledge Base Styles - Sidebar Mode
   ════════════════════════════════════════════════════════════ */

/* Knowledge panel is a right-side drawer, hidden by default */
/* Styles are inline in HTML for simplicity */

/* Tree container */
.kb-tree {
  width: 100%;
  box-sizing: border-box;
}

/* Tree items */
.kb-tree-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 2px;
  font-size: 12px;
  transition: background 0.15s;
}

.kb-tree-item:hover {
  background: var(--bg-msg-hover);
}

.kb-tree-item.child {
  padding-left: 28px;
}

.kb-toggle {
  width: 14px;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
}

.kb-toggle:hover {
  color: var(--text);
}

.kb-icon {
  font-size: 12px;
}

.kb-children-list {
  padding-left: 24px;
}

.kb-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
  font-size: 12px;
}

/* Content area */
.kb-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.kb-content-header h2 {
  margin: 0;
  font-size: 14px;
}

.kb-actions {
  display: flex;
  gap: 6px;
}

.kb-actions button {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}

.kb-actions button:hover {
  background: var(--bg-msg-hover);
}

.kb-actions button.danger {
  color: var(--red);
  border-color: var(--red);
}

.kb-content-body {
  font-size: 13px;
  line-height: 1.6;
}

.kb-content-text {
  color: var(--text);
}

.kb-content-text h1, .kb-content-text h2, .kb-content-text h3 {
  margin-top: 15px;
  margin-bottom: 8px;
}

.kb-content-text code {
  background: var(--bg-secondary);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.kb-content-text pre {
  background: var(--bg-secondary);
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

.kb-editor {
  width: 100%;
  min-height: 200px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text);
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  resize: vertical;
  box-sizing: border-box;
}

.kb-editor-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.kb-editor-actions button {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.kb-editor-actions button:first-child {
  background: var(--accent);
  color: white;
}

/* Toast */
.kb-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1000;
  animation: kb-toast-in 0.2s ease;
}

@keyframes kb-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Children */
.kb-children {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.kb-children-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kb-children-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 15px;
  font-size: 12px;
}

.kb-back-btn {
  width: 100%;
  padding: 8px;
  margin-top: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}

/* Scrollbar for KB file list */
#kb-file-tree::-webkit-scrollbar,
.kb-file-list::-webkit-scrollbar {
  width: 6px;
}

#kb-file-tree::-webkit-scrollbar-track,
.kb-file-list::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

#kb-file-tree::-webkit-scrollbar-thumb,
.kb-file-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#kb-file-tree::-webkit-scrollbar-thumb:hover,
.kb-file-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}
