/* AI辅助功能按钮样式 */

.ai-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px;
  border-bottom: 1px solid var(--border);
}

.ai-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.ai-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  transition: background 0.3s ease;
}

.ai-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateX(4px);
}

.ai-card:hover::before {
  background: var(--accent);
}

.ai-card.active {
  border-color: var(--accent);
  background: rgba(74, 144, 226, 0.1);
}

.ai-card.active::before {
  background: var(--accent);
}

.ai-card.running {
  opacity: 0.72;
  cursor: default;
  pointer-events: none;
}

.ai-card.running::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--accent);
  animation: ai-card-spin 0.8s linear infinite;
}

@keyframes ai-card-spin {
  to {
    transform: rotate(360deg);
  }
}

.icon-box {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.icon-box.blue {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.icon-box.green {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.icon-box.purple {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.ai-card:hover .icon-box {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ai-card .icon-box img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

.ai-card:hover .icon-box img {
  filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

.ai-card .text {
  flex: 1;
  min-width: 0;
}

.ai-card .text h4 {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.ai-card .text p {
  margin: 0;
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.4;
}

.ai-card.active .text h4 {
  color: var(--accent);
}

.ai-header {
  height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 600;
  flex-shrink: 0;
}

.ai-header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.close-ai {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.close-ai:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.ai-model-selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.status-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08);
}

.status-dot.ok {
  background: #2ecc71;
  box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.14);
}

.status-dot.ok:hover {
  box-shadow: 0 0 0 6px rgba(46, 204, 113, 0.24);
}

.status-dot.error {
  background: #ff4d4f;
  box-shadow: 0 0 0 4px rgba(255, 77, 79, 0.14);
}

.status-dot.error:hover {
  box-shadow: 0 0 0 6px rgba(255, 77, 79, 0.24);
}

.status-dot.idle {
  background: #f1c40f;
  box-shadow: 0 0 0 4px rgba(241, 196, 15, 0.14);
}

.status-dot.idle:hover {
  box-shadow: 0 0 0 6px rgba(241, 196, 15, 0.24);
}

.model-select {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}

.model-select option,
.model-select optgroup {
  background: #151924;
  color: #e8eeff;
}

.model-select:focus {
  border-color: var(--accent);
}

.btn-icon-small {
  height: 34px;
}

.btn-confirm-model {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(74, 144, 226, 0.12);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
  font-size: 13px;
}

.btn-confirm-model:hover {
  filter: brightness(1.05);
  background: rgba(74, 144, 226, 0.18);
}

.kb-module {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text-main);
  font-weight: 600;
  font-size: 13px;
}

.kb-header span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.kb-tabs {
  display: none;
}

.kb-tab-btn {
  display: none;
}

.kb-tab-panel {
  display: none;
}

.kb-tab-panel.active {
  display: block;
}

.kb-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.kb-btn:hover {
  border-color: rgba(74, 144, 226, 0.5);
  color: var(--accent);
}

.kb-view,
.kb-editor {
  width: 100%;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  box-sizing: border-box;
}

.kb-view {
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.kb-view.empty {
  color: var(--text-sub);
}

.kb-editor {
  min-height: 200px;
  max-height: 360px;
  resize: vertical;
  outline: none;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  position: relative;
  z-index: 1;
}

.kb-editor:focus {
  border-color: rgba(74, 144, 226, 0.5);
}

.kb-module .tag-add {
  opacity: 1;
}

.kb-notes-head {
  display: none;
}

.kb-note-select {
  display: none;
}

.kb-note-title {
  display: none;
}

.kb-note-btn {
  display: none;
}

.kb-note-editor {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.08);
}

.kb-note-editor-toolbar {
  display: none;
}

.kb-note-toolbar-left,
.kb-note-toolbar-right {
  display: none;
}

.kb-note-toolbar-sep {
  display: none;
}

.kb-note-toolbar-btn {
  display: none;
}

.kb-note-toolbar-btn i {
  display: none;
}

.kb-note-toolbar-select {
  display: none;
}

.kb-note-toolbar-color {
  display: none;
}

.kb-note-fontsize-input {
  display: none;
}

.kb-note-editor-content {
  min-height: 200px;
  max-height: 300px;
  overflow: auto;
  padding: 10px 12px;
  outline: none;
  color: var(--text-main);
  line-height: 1.6;
  word-break: break-word;
}

.kb-note-editor-content:empty:before {
  content: '在此输入便签内容...';
  color: var(--text-sub);
}

#kb-tags-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 32px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

/* 编辑模式下的hover效果 */
.kb-module.editing #kb-tags-row:hover {
  border-color: rgba(74, 144, 226, 0.5);
  background: rgba(74, 144, 226, 0.05);
}

#kb-tags-editor {
  margin-top: 8px;
}

#kb-tags-input {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  outline: none;
  box-sizing: border-box;
  font-size: 12px;
}

#kb-tags-input:focus {
  border-color: rgba(74, 144, 226, 0.5);
}

.ai-context-box {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#ai-context-input {
  width: 100%;
  min-height: 90px;
  max-height: 180px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

#ai-context-input:focus {
  border-color: var(--accent);
}

.ai-chat-area {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.ai-prompt-preview {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 12px;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.08);
  max-height: 90px;
  overflow: auto;
}

.ai-result-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-light);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  margin: 10px 0;
}

.ai-result-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid var(--border);
}

.ai-result-card-title {
  font-size: 12px;
  color: var(--text-sub);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-result-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ai-result-zoom {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.ai-result-zoom:hover {
  border-color: rgba(74, 144, 226, 0.5);
  color: var(--accent);
}

.ai-result-card-body {
  padding: 10px 12px 12px 12px;
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.ai-result-card-body.loading {
  color: var(--text-sub);
}

.ai-result-card-body.error {
  color: #ff7875;
}

.ai-result-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25000;
  backdrop-filter: blur(2px);
}

.ai-result-modal-box {
  width: min(860px, 94vw);
  max-height: min(78vh, 720px);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.6);
}

.ai-result-modal-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.ai-result-modal-title {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
}

.ai-result-modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ai-result-modal-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.ai-result-modal-btn:hover {
  border-color: rgba(74, 144, 226, 0.5);
  color: var(--accent);
}

.ai-result-modal-body {
  padding: 12px;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.ai-result-modal-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.65;
  font-family: inherit;
}

.kb-compare-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 26000;
  backdrop-filter: blur(2px);
}

.kb-compare-modal-box {
  width: min(980px, 96vw);
  max-height: min(82vh, 760px);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.6);
}

.kb-compare-modal-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.kb-compare-modal-title {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
}

.kb-compare-modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.kb-compare-modal-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.kb-compare-modal-btn:hover {
  border-color: rgba(74, 144, 226, 0.5);
  color: var(--accent);
}

.kb-compare-modal-body {
  padding: 12px;
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.kb-compare-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

@media (max-width: 860px) {
  .kb-compare-columns {
    grid-template-columns: 1fr;
  }
}

.kb-compare-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.10);
}

.kb-compare-col-title {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kb-compare-col-copy {
  height: 28px;
  width: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}

.kb-compare-col-copy:hover {
  border-color: rgba(74, 144, 226, 0.5);
}

.kb-compare-pre {
  margin: 0;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.65;
  font-family: inherit;
  min-height: 220px;
  max-height: 52vh;
  overflow: auto;
}

.kb-diff-del {
  background: rgba(239, 68, 68, 0.24);
  border-radius: 4px;
}

.kb-diff-add {
  background: rgba(34, 197, 94, 0.24);
  border-radius: 4px;
}

.kb-compare-modal-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.12);
}

.kb-compare-choice-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
}

.kb-compare-choice-btn:hover {
  border-color: rgba(74, 144, 226, 0.5);
  color: var(--accent);
}

.kb-compare-choice-btn.primary {
  border-color: rgba(74, 144, 226, 0.6);
  background: rgba(74, 144, 226, 0.18);
  color: var(--text-main);
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 16px 14px;
}

.ai-chat-bubble {
  max-width: 92%;
  margin: 10px 0;
  display: flex;
}

.ai-chat-bubble.user {
  justify-content: flex-end;
}

.ai-chat-bubble.ai {
  justify-content: flex-start;
}

.ai-chat-bubble .bubble-content {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-main);
  border: 1px solid var(--border);
  background: var(--bg-light);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  word-break: break-word;
}

.ai-chat-bubble.user .bubble-content {
  background: rgba(74, 144, 226, 0.16);
  border-color: rgba(74, 144, 226, 0.35);
}

.ai-loading {
  color: var(--text-sub);
}

.ai-error {
  color: #ff7875;
}

.chat-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

#ai-input {
  flex: 1 1 auto;
  min-height: 38px;
  max-height: 120px;
  resize: vertical;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.4;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  position: relative;
  z-index: 1;
}

#ai-input:focus {
  border-color: var(--accent);
}

#btn-send-ai {
  width: 44px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(74, 144, 226, 0.35);
  background: rgba(74, 144, 226, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

#btn-clear-chat {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}

#btn-send-ai:hover {
  filter: brightness(1.08);
  background: rgba(74, 144, 226, 0.22);
}

#btn-clear-chat:hover {
  filter: brightness(1.08);
  background: rgba(255, 255, 255, 0.12);
}

#btn-send-ai svg {
  color: rgba(255, 255, 255, 0.92);
  flex: 0 0 auto;
  display: block;
}

.kb-btn-label {
  display: none;
}

#kb-btn-tag-edit {
  display: none;
}

#kb-btn-save {
  display: none;
}

.ai-result-display {
  flex: 0 0 auto;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.08);
}

.ai-result-display:empty {
  display: none;
}

.ai-result-content {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}

.ai-result-content:last-child {
  margin-bottom: 0;
}

.ai-result-loading {
  color: var(--text-sub);
  font-style: italic;
}

.ai-result-error {
  color: #ff7875;
}
