/* ========================= 智能体管理页样式 ========================= */

.agent-container {
  padding: 20px;
  height: calc(100% - 60px);
  overflow-y: auto;
}

.agent-panel {
  display: none;
  animation: agentFadeIn 0.25s ease;
}

.agent-panel.active {
  display: block;
}

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

/* ========================= 侧边栏 ========================= */

.sidebar > .search-box {
  flex: 0 0 auto;
  padding: 12px 16px;
}

#agentList {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#agentList .chat-item {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 0;
}

#agentList .chat-item-content {
  flex: 1;
  min-width: 0;
  text-align: left;
}

#agentList .chat-item-title {
  text-align: left;
}

#agentList .chat-item-delete {
  margin-left: auto;
}

.agent-list-avatar {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ========================= Tab 栏 ========================= */

.agent-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========================= 欢迎空态 ========================= */

.agent-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.agent-empty-state svg {
  opacity: 0.35;
}

.agent-empty-state p {
  font-size: 0.9rem;
  max-width: 240px;
  line-height: 1.6;
}

/* ========================= 头像选择器 ========================= */

.agent-avatar-display {
  font-size: 2.2rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.agent-avatar-display:hover {
  border-color: var(--accent-color);
}

.agent-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.agent-avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 400px;
  margin-top: 10px;
}

.agent-avatar-option {
  font-size: 1.4rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.agent-avatar-option:hover {
  background: var(--bg-tertiary);
}

.agent-avatar-option.selected {
  border-color: var(--accent-color);
  background: rgba(37, 99, 235, 0.1);
}

/* ========================= 提示词变量提示 ========================= */

.variable-group-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  margin-bottom: 4px;
}

.variable-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.variable-tag {
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--accent-color);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.variable-tag:hover {
  background: var(--bg-secondary);
}

/* ========================= 自定义变量 ========================= */

.custom-var-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.custom-var-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.custom-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-var-key {
  width: 150px;
  flex-shrink: 0;
  font-family: monospace;
  font-size: 0.85rem;
}

/* 覆盖全局 .form-group input[type="text"] { width:100% } */
.form-group .custom-var-row input.custom-var-key {
  width: 150px;
  flex-shrink: 0;
  padding: 6px 10px;
}

.form-group .custom-var-row input.custom-var-value {
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 6px 10px;
}

.custom-var-sep {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.custom-var-value {
  flex: 1;
  min-width: 0;
}

.custom-var-remove {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
}

.custom-var-remove:hover {
  color: #ef4444;
}

.custom-var-format-info {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  line-height: 1.6;
}

.custom-var-format-info ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.custom-var-format-info li {
  margin-bottom: 4px;
}

.custom-var-format-info code {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
  font-size: 0.78rem;
}

/* ========================= 工具配置 ========================= */

.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}

.tool-card-header label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
}

.tool-card-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.tool-card-body .form-group {
  margin-bottom: 10px;
}

.tool-card-body .form-group:last-child {
  margin-bottom: 0;
}

/* 知识库多选 */
.kb-multi-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 6px 0;
}

.kb-multi-select label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
  font-weight: normal;
}

/* MCP 工具分组选择 */
.mcp-tool-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.mcp-server-group {
  margin-bottom: 10px;
}

.mcp-server-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border-color);
}

.mcp-tool-list label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  cursor: pointer;
  padding: 3px 0 3px 4px;
  font-weight: normal;
  font-size: 0.88rem;
}

.mcp-tool-name {
  font-family: monospace;
  font-size: 0.85rem;
}

.mcp-tool-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* HTTP 工具列表 */
.http-tool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.http-tool-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
}

.http-tool-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.http-tool-item-name {
  font-weight: 500;
  font-size: 0.9rem;
  flex: 1;
}

.http-tool-item-url {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================= 测试对话区 ========================= */

.agent-test-area {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - 280px);
  min-height: 300px;
}

.agent-test-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px 10px 0 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-test-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
}

.agent-test-msg.user {
  background: var(--message-user-bg);
  color: var(--message-user-text);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.agent-test-msg.assistant {
  background: var(--message-assistant-bg);
  color: var(--message-assistant-text);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.agent-test-msg.system-hint {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 4px 8px;
  max-width: 100%;
  text-align: center;
}

.agent-test-input-row {
  display: flex;
  gap: 8px;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 10px;
  background: var(--bg-primary);
}

.agent-test-input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  min-height: 40px;
  max-height: 100px;
}

.agent-test-input-row textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* ========================= 统计信息 ========================= */

.agent-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 12px;
  white-space: nowrap;
}

/* ========================= 底部操作栏 ========================= */

.panel-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-footer-right {
  display: flex;
  gap: 8px;
}

/* ========================= HTTP 工具编辑弹窗 ========================= */

.modal-medium {
  max-width: 560px;
  width: 90%;
}

.http-method-select {
  width: 100%;
}

/* ========================= HTTP 工具测试区 ========================= */

.http-test-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.http-test-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  user-select: none;
  transition: background 0.15s;
}

.http-test-section-header:hover {
  background: var(--hover-bg, var(--bg-secondary));
  filter: brightness(0.95);
}

.http-test-toggle-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.http-test-section-body {
  padding: 14px;
  border-top: 1px solid var(--border-color);
}

.http-test-url-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 6px 10px;
  margin-top: 6px;
  word-break: break-all;
  font-family: monospace;
  min-height: 28px;
}

.http-test-result {
  margin-top: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.http-test-result-status {
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.http-test-result-status.success { color: #22c55e; }
.http-test-result-status.error   { color: #ef4444; }
.http-test-result-status.pending { color: var(--text-muted); }

.http-test-result-body {
  margin: 0;
  padding: 12px;
  font-size: 0.78rem;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ========================= 响应式 ========================= */

@media (max-width: 768px) {
  .agent-tabs {
    flex-wrap: wrap;
  }

  .agent-avatar-picker {
    max-width: 100%;
  }

  .agent-test-area {
    height: calc(100vh - 320px);
  }
}
