/* panel.css — AI产品经理插件 侧边栏面板样式
   前缀 .aic- 用于隔离，避免与宿主页面样式冲突
   注入到页面的元素均使用 aic- 前缀
*/

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-width: 280px;
  height: 100%;
  min-height: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  color: #1a1a2e;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 面板头 ===== */
.panel-header {
  background: #6c63ff;
  color: white;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-logo {
  width: 26px; height: 26px;
  background: rgba(255,255,255,0.2);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.panel-title { font-size: 13px; font-weight: bold; line-height: 1.2; }
.panel-close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.panel-close-btn:hover {
  color: #ff4d4f;
  background: #fff1f0;
}

/* ===== 上下文条 ===== */
.panel-context-bar {
  background: #f7f8fa;
  border-bottom: 1px solid #eee;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.context-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #666;
  overflow: hidden;
}
.context-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #d9d9d9;
  flex-shrink: 0;
  transition: background 0.3s;
}
.context-dot.active { background: #52c41a; }
.context-dot.warn { background: #faad14; }
.context-dot.loading {
  background: #6c63ff;
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.context-refresh {
  font-size: 14px;
  color: #bbb;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s;
}
.context-refresh:hover { color: #6c63ff; }

/* ===== URL 解析条 ===== */
.url-context-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid #eceff3;
  background: #ffffff;
  flex-shrink: 0;
}
.url-context-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12px;
  color: #1f2933;
  outline: none;
  font-family: inherit;
}
.url-context-input:focus {
  border-color: #126b68;
  box-shadow: 0 0 0 2px rgba(18,107,104,0.12);
}
.url-context-btn {
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: #126b68;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.url-context-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===== 顶部设置按钮 ===== */
.panel-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-settings-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.2s, background 0.2s;
}
.panel-settings-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

/* ===== Skill 浮层（输入框 / 调出） ===== */
.skill-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-bottom: 4px;
  z-index: 100;
  overflow: hidden;
}
.skill-popup-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.skill-popup-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}
.skill-popup-item {
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.skill-popup-item:hover {
  background: #f0f0ff;
  color: #6c63ff;
}
.skill-popup-item .skill-popup-badge {
  font-size: 11px;
  opacity: 0.6;
}
.skill-popup-empty {
  padding: 12px;
  text-align: center;
  color: #999;
  font-size: 12px;
}

/* ===== 选中 Skill 标签 ===== */
.selected-skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f0ff;
  color: #6c63ff;
  border: 1px solid #d9d0ff;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  margin: 4px 0;
  white-space: nowrap;
}
.selected-skill-tag .tag-remove {
  cursor: pointer;
  font-size: 13px;
  opacity: 0.6;
  margin-left: 2px;
}
.selected-skill-tag .tag-remove:hover {
  opacity: 1;
}

/* ===== 输出区 ===== */
.panel-output {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}
.panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #bbb;
  text-align: center;
  padding: 20px;
}
.panel-empty-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.panel-empty-text { font-size: 12px; line-height: 1.7; }

.stream-output {
  padding: 12px;
  font-size: 12px;
  line-height: 1.8;
  color: #333;
  display: none;
}
.stream-loading {
  color: #999;
  font-size: 12px;
  padding: 8px 0;
  animation: pulse 1.2s infinite;
}
.stream-error {
  color: #ff4d4f;
  font-size: 12px;
  padding: 6px 0;
}
.section-tag {
  color: #6c63ff;
  font-weight: bold;
}
.risk-high { color: #cf1322; }
.risk-mid { color: #d46b08; }
.risk-ok { color: #389e0d; }

/* 离线提示 */
.offline-hint {
  text-align: center;
  padding: 20px 12px;
  color: #888;
}
.offline-icon { font-size: 28px; margin-bottom: 8px; }
.offline-title { font-size: 13px; font-weight: bold; color: #1a1a2e; margin-bottom: 8px; }
.offline-body { font-size: 11px; line-height: 1.8; margin-bottom: 12px; }
.offline-body code {
  display: block;
  background: #f5f5f5;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: monospace;
  color: #333;
  margin: 2px 0;
}
.btn-retry {
  background: #6c63ff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 12px;
  cursor: pointer;
}
.btn-retry:hover { opacity: 0.85; }

/* ===== 操作区（填入结果按钮现在在chat-label里，保留样式） ===== */
.btn-fill {
  background: white;
  color: #6c63ff;
  border: 1.5px solid #6c63ff;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-fill:hover { background: #6c63ff; color: white; }

/* ===== 底部状态栏 ===== */
.panel-footer {
  background: #fafafa;
  border-top: 1px solid #eee;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.footer-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #bbb;
}

/* ===== 对话框（现在是主输出区，flex:1 撑满） ===== */
.panel-chat {
  border-top: 2px solid #ede9ff;
  background: white;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-label {
  padding: 6px 12px 5px;
  font-size: 10px;
  color: #bbb;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  border-bottom: 1px solid #f5f5f5;
}
.chat-label-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-clear {
  cursor: pointer;
  opacity: 0.5;
  font-size: 11px;
  transition: opacity 0.2s;
}
.chat-clear:hover { opacity: 1; }
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.chat-msg {
  max-width: 92%;
  font-size: 12px;
  line-height: 1.6;
  padding: 7px 10px;
  border-radius: 8px;
  word-break: break-word;
  white-space: pre-wrap;
}
/* 气泡外层包裹（用于放工具栏） */
.chat-msg-wrap {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}
.chat-msg-wrap.user {
  align-items: flex-end;
}
.chat-msg-wrap.ai {
  align-items: flex-start;
}
/* AI 消息底部工具栏 */
.chat-msg-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  padding-left: 4px;
}

.chat-msg.user {
  background: #6c63ff;
  color: white;
  border-bottom-right-radius: 2px;
}
.chat-msg.ai {
  background: #f4f3ff;
  color: #333;
  border-bottom-left-radius: 2px;
  border: 1px solid #e0dcff;
  position: relative;
}
/* 分析结果使用更宽的气泡 */
.chat-msg.ai.analysis {
  max-width: 100%;
  background: #fafafe;
  border-color: #c9c4ff;
}
/* ===== 追问建议按钮 ===== */
.followup-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 0 4px;
  border-top: 1px dashed #e5e7eb;
}
.followup-btn {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #c4b5fd;
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: #5b21b6;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(107, 33, 168, 0.08);
}
.followup-btn:hover {
  background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
  border-color: #7c3aed;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(107, 33, 168, 0.15);
  color: #4c1d95;
}
.followup-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(107, 33, 168, 0.1);
}

/* ===== 文档生成进度指示器 ===== */
.doc-gen-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #86efac;
  border-radius: 12px;
  animation: doc-gen-pulse 2s ease-in-out infinite;
}
.doc-gen-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #d1fae5;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: doc-gen-spin 0.8s linear infinite;
  flex-shrink: 0;
}
.doc-gen-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.doc-gen-label {
  color: #065f46;
  font-weight: 500;
}
.doc-gen-timer {
  background: #d1fae5;
  color: #047857;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: center;
}
@keyframes doc-gen-spin {
  to { transform: rotate(360deg); }
}
@keyframes doc-gen-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}
/* 文档生成完成提示 */
.doc-gen-done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: 10px;
  font-size: 13px;
  color: #166534;
  font-weight: 500;
  animation: doc-gen-appear 0.3s ease-out;
}
/* 文档生成失败提示 */
.doc-gen-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  border-radius: 10px;
  font-size: 13px;
  color: #991b1b;
  font-weight: 500;
  animation: doc-gen-appear 0.3s ease-out;
}
/* 文档生成步骤指示器 */
.doc-gen-steps {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.doc-gen-step {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #d1fae5;
  color: #6b7280;
  transition: all 0.3s ease;
}
.doc-gen-step.active {
  background: #10b981;
  color: #fff;
  animation: doc-gen-step-pulse 1s ease-in-out infinite;
}
.doc-gen-step.done {
  background: #6ee7b7;
  color: #065f46;
}
@keyframes doc-gen-step-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
@keyframes doc-gen-appear {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid #f0f0f0;
}
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 12px 0;
}
.attach-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0eeff;
  border: 1px solid #d0caff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: #5a50cc;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-remove {
  cursor: pointer;
  color: #999;
  font-size: 10px;
  flex-shrink: 0;
}
.attach-remove:hover { color: #ff4d4f; }
.chat-attach-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 1.5px solid #e0dcff;
  background: #fafafe;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-attach-btn:hover { background: #f0eeff; }
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 12px 8px;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e0dcff;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  min-height: 32px;
  line-height: 1.5;
  color: #1a1a2e;
  transition: border-color 0.2s;
  background: #fafafa;
}
.chat-input:focus { outline: none; border-color: #6c63ff; background: white; }
.chat-input::placeholder { color: #ccc; }
.chat-send-btn {
  width: 32px; height: 32px;
  background: #6c63ff;
  border: none;
  border-radius: 7px;
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.chat-send-btn:hover { background: #5a52e0; }
.chat-send-btn:disabled { background: #d9d9d9; cursor: not-allowed; }

/* ===== 语音输入 ===== */
.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
}
.chat-input-wrapper .chat-input {
  width: 100%;
  padding-right: 30px; /* 给麦克风腾位置 */
}
.chat-voice-btn {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1;
}
.chat-voice-btn:hover { opacity: 0.9; transform: scale(1.1); }
.chat-voice-btn.recording {
  opacity: 1;
  color: #ff4d4f;
  filter: drop-shadow(0 0 4px rgba(255,77,79,0.5));
  animation: voice-pulse 1.2s ease-in-out infinite;
}
.chat-voice-btn.paused { opacity: 0.7; }

@keyframes voice-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 语音状态提示条 */
.voice-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: #f0eeff;
  border-bottom: 1px solid #e0dcff;
  font-size: 11px;
  color: #6c63ff;
}
.voice-status-text { flex: 1; }
.voice-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 14px;
}
.voice-wave span {
  display: inline-block;
  width: 3px;
  background: #6c63ff;
  border-radius: 2px;
  animation: wave-bar 0.9s ease-in-out infinite;
}
.voice-wave span:nth-child(1) { animation-delay: 0s;    height: 4px; }
.voice-wave span:nth-child(2) { animation-delay: 0.15s; height: 8px; }
.voice-wave span:nth-child(3) { animation-delay: 0.3s;  height: 12px; }
.voice-wave span:nth-child(4) { animation-delay: 0.15s; height: 8px; }
.voice-wave span:nth-child(5) { animation-delay: 0s;    height: 4px; }
.voice-status-bar.paused .voice-wave span {
  animation-play-state: paused;
  height: 4px !important;
}
@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.4); }
  50%       { transform: scaleY(1); }
}
.voice-pause-btn, .voice-stop-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  color: #6c63ff;
  transition: background 0.15s;
}
.voice-pause-btn:hover { background: #ddd8ff; }
.voice-stop-btn { color: #999; }
.voice-stop-btn:hover { background: #ffe0e0; color: #ff4d4f; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,46,0.88);
  color: white;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 9999;
}
.toast.show { opacity: 1; }
.toast.warn { background: rgba(212,107,8,0.9); }

/* ===== Skill 管理按钮 ===== */
.btn-skill-mgr {
  width: 24px; height: 24px;
  background: #f0eeff;
  border: 1px solid #d3ceff;
  border-radius: 4px;
  color: #6c63ff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-skill-mgr:hover { background: #6c63ff; color: white; }

/* ===== Skill 管理抽屉 ===== */
/* ===== 设置面板（全屏覆盖） ===== */
.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.settings-container {
  background: #fff;
  border-radius: 12px;
  width: 92%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.settings-header-title { font-size: 14px; font-weight: bold; color: #1a1a2e; }
.settings-close { cursor: pointer; color: #aaa; font-size: 14px; padding: 4px; }
.settings-close:hover { color: #333; }

.settings-tabs {
  display: flex;
  border-bottom: 1px solid #f0f0f0;
}
.settings-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 12px;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.settings-tab.active { color: #6c63ff; border-bottom-color: #6c63ff; font-weight: bold; }
.settings-tab:hover { color: #6c63ff; }

.settings-panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  max-height: calc(88vh - 100px);
}

/* Skill 子Tab */
.skill-sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: #f5f5f7;
  border-radius: 8px;
  padding: 3px;
}
.skill-sub-tab {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  color: #888;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.skill-sub-tab.active { background: #fff; color: #6c63ff; font-weight: bold; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.skill-sub-tab:hover { color: #6c63ff; }

.skill-sub-panel {
  flex: 1;
}

/* 模型状态卡片 */
.model-current-card {
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
  border: 1px solid #e0e4ff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.model-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.model-card-label { font-size: 11px; color: #888; }
.model-card-status {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: bold;
}
.model-card-info { font-size: 13px; color: #444; font-weight: 500; }

/* 知识库 */
.kb-upload-zone {
  border: 2px dashed #d9d9d9;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}
.kb-upload-zone:hover, .kb-drag-over {
  border-color: #6c63ff;
  background: #f5f3ff;
}
.kb-upload-icon { font-size: 28px; margin-bottom: 6px; }
.kb-upload-text { font-size: 13px; color: #555; margin-bottom: 4px; }
.kb-upload-hint { font-size: 11px; color: #aaa; }

.kb-header-info { margin-bottom: 12px; }
.kb-count { font-size: 11px; color: #888; font-weight: normal; }

.kb-list { max-height: 300px; overflow-y: auto; }
.kb-empty { text-align: center; color: #bbb; padding: 24px; font-size: 12px; }

.kb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.1s;
}
.kb-item:hover { background: #fafafa; }
.kb-item-icon { font-size: 18px; }
.kb-item-info { flex: 1; min-width: 0; }
.kb-item-name { font-size: 12px; color: #333; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-item-desc { font-size: 10px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.kb-item-delete {
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.1s;
}
.kb-item-delete:hover { color: #ff4d4f; background: #fff0f0; }

/* 知识库：状态栏 */
.kb-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #86efac;
  border-radius: 8px;
  margin-bottom: 12px;
}
.kb-status-icon { font-size: 16px; }
.kb-status-text { flex: 1; font-size: 11px; color: #166534; }
.kb-status-count { font-size: 11px; color: #389e0d; font-weight: bold; white-space: nowrap; }

/* 知识库：进度条 */
.kb-progress {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f0f9ff;
  border: 1px solid #bae7ff;
  border-radius: 8px;
}
.kb-progress-bar {
  width: 100%;
  height: 6px;
  background: #e6f7ff;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.kb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #8b85ff);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.kb-progress-text {
  font-size: 11px;
  color: #1890ff;
}

/* 知识库：上传结果摘要 */
.kb-result-summary {
  position: relative;
  margin-top: 8px;
  padding: 10px 32px 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}
.kb-result-summary.kb-result-success {
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
}
.kb-result-summary.kb-result-error {
  background: #fff2f0;
  border: 1px solid #ffccc7;
  color: #cf1322;
}
.kb-result-summary.kb-result-warn {
  background: #fffbe6;
  border: 1px solid #ffe58f;
  color: #ad6800;
}
.kb-result-summary-content {
  white-space: pre-wrap;
  word-break: break-all;
}
.kb-result-close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #999;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
}
.kb-result-close:hover {
  color: #333;
  background: rgba(0,0,0,0.06);
}

/* 知识库：来源文件分组头 */
.kb-source-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
  font-size: 12px;
  font-weight: bold;
  color: #555;
  border-bottom: 1px solid #e8e8e8;
  margin-top: 6px;
}
.kb-source-header:first-child { margin-top: 0; }
.kb-seg-count {
  font-size: 10px;
  font-weight: normal;
  color: #aaa;
}
.kb-source-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.15s;
}
.kb-source-delete:hover { color: #ff4d4f; background: #fff0f0; }

/* 已安装列表 */
.skill-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; overflow-y: auto; max-height: 260px; }
.skill-list-loading, .skill-list-empty, .skill-list-error {
  font-size: 11px; color: #aaa; text-align: center; padding: 12px 0;
}
.skill-list-error { color: #ff4d4f; }

/* 搜索行 */
.skill-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.skill-search-input {
  flex: 1;
  padding: 5px 10px;
  border: 1px solid #e0dcff;
  border-radius: 6px;
  font-size: 12px;
  color: #333;
  outline: none;
  background: #fafafa;
}
.skill-search-input:focus { border-color: #6c63ff; background: #fff; }
.skill-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: white;
  border: 1px solid #eee;
  border-radius: 5px;
}
.skill-item-name { flex: 1; font-size: 12px; color: #1a1a2e; font-weight: 500; }
.skill-item-info { flex: 1; min-width: 0; }
.skill-item-desc { font-size: 11px; color: #888; margin-top: 2px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.badge-builtin { background: #f0f0f0; color: #888; }
.badge-local   { background: #e6f4ff; color: #1677ff; }
.badge-remote  { background: #f6ffed; color: #52c41a; }
.btn-use-skill {
  font-size: 10px;
  padding: 2px 8px;
  background: #6c63ff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
.btn-use-skill:hover { opacity: 0.85; }
.btn-refresh-skills {
  padding: 5px 10px;
  background: none;
  border: 1px solid #e0dcff;
  border-radius: 6px;
  color: #6c63ff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.btn-refresh-skills:hover { background: #f0eeff; }

/* 安装区 */
.install-section { margin-bottom: 10px; }
.install-label { font-size: 11px; font-weight: bold; color: #555; margin-bottom: 4px; }
.install-input {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  margin-bottom: 4px;
  color: #1a1a2e;
}
.install-input:focus { outline: none; border-color: #6c63ff; }
.install-textarea {
  width: 100%;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
  margin-bottom: 4px;
  color: #1a1a2e;
}
.install-textarea:focus { outline: none; border-color: #6c63ff; }
.install-divider { text-align: center; font-size: 11px; color: #ccc; margin: 6px 0; }
.btn-install {
  width: 100%;
  background: #6c63ff;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-install:hover { opacity: 0.85; }
.install-result {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.install-result.ok      { background: #f6ffed; color: #389e0d; }
.install-result.err     { background: #fff1f0; color: #cf1322; }
.install-result.pending { background: #f0f0f0; color: #888; }

/* 设置区 */
.settings-section { margin-bottom: 10px; }
.settings-label { font-size: 11px; font-weight: bold; color: #555; margin-bottom: 2px; }
.settings-hint  { font-size: 10px; color: #aaa; margin-bottom: 4px; }

::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e0dcff; border-radius: 2px; }

/* 即时回显气泡：用户发送后立刻显示 */
.chat-msg.quick-ack {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f3ff;
  border: 1px dashed #c9c4ff;
  color: #888;
  font-size: 12px;
  padding: 6px 10px;
}
.chat-msg.quick-ack::before {
  content: '';
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: url('icons/icon48.png') center/cover no-repeat, #6c63ff;
  flex-shrink: 0;
}
.quick-ack-text {
  color: #9b92ff;
  font-style: italic;
}
/* 三点跳动动画 */
.chat-msg.quick-ack::after {
  content: '···';
  animation: quickDot 1.2s infinite;
  color: #b3aeff;
  letter-spacing: 2px;
}
@keyframes quickDot {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== 工具调用折叠区块样式 ===== */
.tool-result-block {
  margin: 8px 0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #f8f9fa;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tool-result-block.error {
  border-color: #ff4d4f;
  background: #fff2f0;
}

.tool-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f0f0;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  font-size: 13px;
}

.tool-result-block.error .tool-result-header {
  background: #ffccc7;
}

.tool-result-header:hover {
  background: #e0e0e0;
}

.tool-result-block.error .tool-result-header:hover {
  background: #ffa39e;
}

.tool-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.tool-name {
  flex: 1;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-result-block.error .tool-name {
  color: #cf1322;
}

.tool-status {
  font-size: 12px;
  color: #52c41a;
  flex-shrink: 0;
}

.tool-result-block.error .tool-status {
  color: #ff4d4f;
}

.tool-toggle {
  font-size: 10px;
  color: #999;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tool-result-block.expanded .tool-toggle {
  transform: rotate(180deg);
}

.tool-result-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.tool-result-block.expanded .tool-result-content {
  max-height: 500px;
}

.tool-code {
  margin: 0;
  padding: 12px;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.tool-code.error {
  background: #2b1818;
  color: #ff4d4f;
}

.tool-code code {
  font-family: inherit;
}

.tool-preview {
  padding: 8px 12px;
  font-size: 12px;
  color: #666;
  background: #f0f0f0;
  border-top: 1px dashed #d0d0d0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 60px;
  overflow: hidden;
}

.tool-result-block.expanded .tool-preview {
  display: none;
}

/* ===== Mermaid 流程图渲染 ===== */
.mermaid-container {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  overflow: auto;
  min-height: 60px;
  transition: border-color 0.3s;
}
.mermaid-container.mermaid-rendered {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #fafafe, #f5f3ff);
}
.mermaid-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 0;
  color: #999;
  font-size: 13px;
}
.mermaid-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e0dcff;
  border-top-color: #6c63ff;
  border-radius: 50%;
  animation: mermaid-spin 0.8s linear infinite;
}
@keyframes mermaid-spin {
  to { transform: rotate(360deg); }
}
.mermaid-container svg {
  max-width: 100%;
  height: auto;
}
.mermaid-expand-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  background: rgba(255,255,255,0.85);
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s, background 0.2s;
  z-index: 5;
  padding: 0;
}
.mermaid-container:hover .mermaid-expand-btn {
  opacity: 1;
}
.mermaid-expand-btn:hover {
  color: #6c63ff;
  background: #fff;
}

/* ===== Mermaid 全屏弹窗 ===== */
.mermaid-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.75);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mermaid-fadein 0.2s ease-out;
}
@keyframes mermaid-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
.mermaid-fullscreen-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.mermaid-fullscreen-close:hover {
  background: #fff;
  color: #333;
  transform: scale(1.1);
}
.mermaid-fullscreen-content {
  width: calc(100vw - 80px);
  height: calc(100vh - 80px);
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.mermaid-fullscreen-content svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

/* ===== 右下角复制按钮（输出完成后出现，定位在气泡上） ===== */
.msg-copy-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s, color 0.2s, background 0.2s;
  z-index: 5;
  padding: 0;
}
.chat-msg.ai:hover .msg-copy-btn {
  opacity: 1;
}
.msg-copy-btn:hover {
  color: #6c63ff;
  background: rgba(108,99,255,0.08);
}
.msg-copy-btn.copied {
  color: #10b981;
  opacity: 1;
}

/* Word 导出按钮（hover 才显示，定位在气泡上） */
.doc-export-btn {
  position: absolute;
  right: 36px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s, color 0.2s, background 0.2s;
  font-size: 12px;
  z-index: 5;
  padding: 0;
}
.chat-msg.ai:hover .doc-export-btn {
  opacity: 0.6;
}
.doc-export-btn:hover {
  opacity: 1 !important;
  color: #1f5bbf;
  background: rgba(31, 91, 191, 0.08);
}

/* ===== 对话消息操作按钮（hover显示） ===== */
.chat-msg-wrap {
  position: relative;
}

.chat-msg-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 10;
}

.chat-msg-wrap:hover .chat-msg-actions {
  opacity: 1;
  visibility: visible;
}

.chat-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-action-btn:hover {
  background: #fff;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.chat-msg-wrap.user .chat-msg-actions {
  right: auto;
  left: 8px;
}

/* 工具提示 */
.chat-tooltip {
  animation: tooltipFadeIn 0.2s ease;
}

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

/* ===== Skill 思考沙箱区块 ===== */
.skill-thinking-block {
  margin: 0 0 6px 0;
  border: 1px solid rgba(110, 99, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(110, 99, 255, 0.04);
}

.skill-thinking-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: #6c63ff;
  font-weight: 500;
  background: rgba(110, 99, 255, 0.06);
  transition: background 0.15s;
}

.skill-thinking-header:hover {
  background: rgba(110, 99, 255, 0.12);
}

.skill-thinking-icon { font-size: 13px; }
.skill-thinking-label { flex: 1; }

.skill-thinking-toggle {
  font-size: 10px;
  transition: transform 0.2s;
  color: #aaa;
}

.skill-thinking-block.expanded .skill-thinking-toggle {
  transform: rotate(90deg);
}

/* 默认折叠：body高度0不可见 */
.skill-thinking-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  font-size: 12px;
  color: #666;
  padding: 0 10px;
  line-height: 1.6;
}

/* 展开：显示最多 3 行高度，超出滚动 */
.skill-thinking-block.expanded .skill-thinking-body {
  max-height: 72px;   /* 约3行（12px * 1.6 * 3 ≈ 58px，留余量）*/
  overflow-y: auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(110, 99, 255, 0.1);
}

/* 执行过程中：自动展开以显示实时内容 */
.skill-thinking-block.running .skill-thinking-body {
  max-height: 72px;
  overflow-y: auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(110, 99, 255, 0.1);
}

.skill-thinking-block.running .skill-thinking-toggle {
  transform: rotate(90deg);
}

/* ===== Skill 结论气泡 ===== */
.tool-call-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(110, 99, 255, 0.08);
  border: 1px solid rgba(110, 99, 255, 0.25);
  border-radius: 6px;
  padding: 4px 10px;
  margin: 4px 0;
  font-size: 12px;
  color: #6c63ff;
  animation: toolCallSlideIn 0.2s ease;
}

.tool-call-status.done {
  background: rgba(82, 196, 26, 0.08);
  border-color: rgba(82, 196, 26, 0.3);
  color: #389e0d;
}

.tool-call-icon {
  font-size: 13px;
}

.tool-call-name {
  font-weight: 500;
}

.tool-call-spinner {
  color: #aaa;
  font-size: 12px;
  animation: dotBlink 1s infinite;
}

.tool-call-status.done .tool-call-spinner {
  animation: none;
  color: #52c41a;
  font-weight: bold;
}

@keyframes toolCallSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== Skill 意图识别确认条 ===== */
.skill-intent-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-size: 12px;
  color: #1e40af;
  animation: skill-bar-in 0.3s ease-out;
}
.skill-intent-bar .skill-intent-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.skill-intent-bar .skill-intent-text {
  flex: 1;
  line-height: 1.4;
}
.skill-intent-bar .skill-intent-text strong {
  color: #1d4ed8;
}
.skill-intent-bar .skill-intent-run {
  padding: 4px 14px;
  border: none;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.skill-intent-bar .skill-intent-run:hover {
  background: #1d4ed8;
}
.skill-intent-bar .skill-intent-skip {
  padding: 4px 10px;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  background: transparent;
  color: #3b82f6;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.skill-intent-bar .skill-intent-skip:hover {
  background: #dbeafe;
}
@keyframes skill-bar-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 页面上下文确认条 */
.page-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
  border: 1px solid #fde68a;
  border-radius: 10px;
  font-size: 12px;
  color: #92400e;
  animation: skill-bar-in 0.3s ease-out;
}
.page-context-bar .page-context-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.page-context-bar .page-context-text {
  flex: 1;
  line-height: 1.4;
}
.page-context-bar .page-context-text strong {
  color: #b45309;
}
.page-context-bar .page-context-yes {
  padding: 4px 14px;
  border: none;
  border-radius: 6px;
  background: #d97706;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.page-context-bar .page-context-yes:hover {
  background: #b45309;
}
.page-context-bar .page-context-no {
  padding: 4px 10px;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  background: transparent;
  color: #d97706;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.page-context-bar .page-context-no:hover {
  background: #fef3c7;
}
