/* ============================================
   知识库页面样式
   ============================================ */
.kb-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* Toolbar */
.kb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.kb-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.kb-title-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
  align-self: center;
}

.kb-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.kb-hint {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.kb-count {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.kb-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 个人档案表单 */
.kb-profile-form {
  padding: 0 24px 24px;
}

.kb-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.kb-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* 筛选栏 */
.kb-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px 16px;
  flex-wrap: wrap;
}

.kb-filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kb-filter-tab {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}

.kb-filter-tab:hover {
  border-color: var(--gray-300);
  color: var(--text);
}

.kb-filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.kb-search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
}

.kb-search-box svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.kb-search-box .form-control {
  padding-left: 36px;
  height: 36px;
  font-size: 13px;
}

/* 笔记列表 */
.kb-notes-list {
  padding: 0 24px 16px;
}

.kb-note-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: all var(--transition-fast);
  background: var(--bg-white);
  gap: 16px;
}

.kb-note-item:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-xs);
}

.kb-note-item:last-child {
  margin-bottom: 0;
}

.kb-note-info {
  flex: 1;
  min-width: 0;
}

.kb-note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.kb-note-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.kb-note-category {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
}

.kb-note-source {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--text-secondary);
}

.kb-note-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.kb-note-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.kb-note-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--gray-100);
  color: var(--text-tertiary);
  border-radius: 4px;
}

.kb-note-meta {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

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

.kb-note-action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.kb-note-action-btn:hover {
  border-color: var(--gray-300);
  color: var(--text);
}

.kb-note-action-btn.kb-delete-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.kb-note-action-btn svg {
  width: 15px;
  height: 15px;
}

/* 空状态 */
.kb-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
}

.kb-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.kb-empty h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kb-empty p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ====== AI 抽屉内的知识库快捷面板 ====== */
.ai-kb-trigger {
  position: relative;
}

.ai-kb-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 420px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-kb-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.ai-kb-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-kb-panel-title svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.ai-kb-panel-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-xs);
}

.ai-kb-panel-close:hover {
  background: var(--gray-100);
  color: var(--text);
}

.ai-kb-panel-close svg {
  width: 14px;
  height: 14px;
}

.ai-kb-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.ai-kb-panel-section {
  padding: 8px 16px;
}

.ai-kb-panel-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.ai-kb-profile-summary {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  background: var(--gray-50);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.ai-kb-profile-summary.empty {
  color: var(--text-tertiary);
  font-style: italic;
}

.ai-kb-note-mini {
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 12.5px;
}

.ai-kb-note-mini-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-kb-note-mini-category {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.ai-kb-note-mini-content {
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-kb-panel-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.ai-kb-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.ai-kb-panel-manage-btn {
  width: 100%;
  padding: 8px;
  font-size: 12.5px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ai-kb-panel-manage-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.ai-kb-panel-manage-btn svg {
  width: 14px;
  height: 14px;
}

/* ====== 自动学习记忆提示 ====== */
.ai-memory-toast {
  margin: 8px 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: #15803d;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: aiMemorySlideIn 0.3s ease;
}

.ai-memory-toast.has-updated {
  background: linear-gradient(135deg, #eff6ff, #eef2ff);
  border-color: #bfdbfe;
  color: #1e40af;
}

.ai-memory-toast.has-updated svg {
  color: #2563eb;
}

.ai-memory-toast svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-memory-toast-body {
  flex: 1;
  min-width: 0;
}

.ai-memory-toast-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.ai-memory-toast-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ai-memory-toast-item {
  font-size: 12px;
  color: #166534;
  padding-left: 8px;
  border-left: 2px solid #86efac;
}

@keyframes aiMemorySlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====== 记忆学习状态条 ====== */
.ai-memory-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
  border-top: 1px solid rgba(99, 102, 241, 0.12);
  font-size: 12.5px;
  color: #4f46e5;
  flex-shrink: 0;
  animation: aiMemoryStatusIn 0.25s ease;
}

.ai-memory-status.hidden {
  display: none;
}

.ai-memory-status-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #6366f1;
  animation: aiMemorySpin 0.9s linear infinite;
}

.ai-memory-status-text {
  font-weight: 500;
  letter-spacing: 0.01em;
}

@keyframes aiMemorySpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes aiMemoryStatusIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
