/* isdp/web/src/pages/Workflow/Workflow.css */

/* ========== 页面容器 ========== */
.workflow-page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--bg-base);
  padding: 0;
}

/* 页面头部 */
.workflow-page-header {
  padding: 20px 24px;
  background: var(--bg-container);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.workflow-page-title {
  margin: 0 !important;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.workflow-page-subtitle {
  margin: 4px 0 0 0;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ========== 团队列表容器 ========== */
.workflow-teams-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========== 团队卡片 ========== */
.workflow-team-card {
  background: var(--bg-container);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: all 0.2s ease;
}

.workflow-team-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* 团队头部 */
.workflow-team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-sidebar);
}

.workflow-team-title-wrapper {
  display: flex;
  align-items: center;
}

.workflow-team-name {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.workflow-team-name.editable {
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.workflow-team-name.editable:hover {
  background: var(--color-primary-opacity-10);
}

.workflow-team-name-editor {
  display: flex;
  align-items: center;
}

/* Agent 列表 */
.workflow-team-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px;
  align-items: flex-start;
}

/* Agent 头像容器 */
.workflow-agent-avatar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  /* 固定宽度确保间隔一致 */
  width: 70px;
}

/* Agent 头像 */
.workflow-agent-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: visible;
  /* 确保 Badge 图标叠加不被裁剪 */
  flex-shrink: 0;
}

/* Agent 类型 - 使用主题主色 */
.workflow-agent-avatar.agent {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}

.workflow-agent-avatar.agent:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px var(--color-primary-opacity-30);
}

/* Human 类型 - 使用主题协调色 */
.workflow-agent-avatar.human {
  background: linear-gradient(135deg, var(--human-color) 0%, var(--human-color-hover) 100%);
}

.workflow-agent-avatar.human:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px var(--human-color-shadow);
}

.workflow-agent-icon {
  font-size: 24px;
  color: #fff;
}

.workflow-agent-name {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-agent-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.workflow-agent-avatar-wrapper:hover .workflow-agent-remove {
  opacity: 1;
}

/* 添加 Agent 按钮 */
.workflow-agent-add {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  font-size: 20px;
}

.workflow-agent-add:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ========== 添加 Agent 弹出层 ========== */
.workflow-add-agent-popover {
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
}

.workflow-add-agent-title {
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.workflow-add-agent-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.workflow-add-agent-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.workflow-add-agent-item:hover {
  background: var(--color-primary-light);
}

/* ========== A2A Enhancement: 可路由团队配置 ========== */
.workflow-routable-teams {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-base);
}

.workflow-routable-teams-popover {
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
}

/* ========== 加载状态 ========== */
.workflow-loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* ========== 深色主题 ========== */
[data-theme='dark'] .workflow-team-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme='dark'] .workflow-team-header {
  background: #0f172a;
  border-bottom-color: #334155;
}

[data-theme='dark'] .workflow-agent-add {
  border-color: #475569;
}

[data-theme='dark'] .workflow-agent-add:hover {
  background: #064e3b;
}

/* AgentTypeIcon Badge 样式 - 确保在圆形容器内正确显示 */
.workflow-agent-avatar .ant-badge {
  display: flex;
  align-items: center;
  justify-content: center;
}

.workflow-agent-avatar .ant-badge-count {
  /* 确保 Badge 叠加不被裁剪 */
  z-index: 10;
}

/* 深色模式下 Badge 白色背景需要保留 */
[data-theme='dark'] .workflow-agent-avatar .ant-badge-count > div {
  background-color: #fff !important;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
  .workflow-page-header {
    padding: 16px;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .workflow-teams-container {
    padding: 16px;
  }

  .workflow-team-agents {
    padding: 16px;
    gap: 12px;
  }

  .workflow-agent-avatar {
    width: 48px;
    height: 48px;
  }

  .workflow-agent-add {
    width: 48px;
    height: 48px;
  }
}

/* ========== 拖拽手柄 ========== */
.workflow-agent-drag-handle {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s;
}

.workflow-agent-avatar-wrapper:hover .workflow-agent-drag-handle {
  opacity: 1;
}

.workflow-agent-drag-handle:hover {
  color: var(--color-primary);
}

/* ========== 拖拽状态 ========== */
.workflow-agent-avatar-wrapper.dragging {
  opacity: 0.5;
  background: var(--bg-container-hover);
}

.workflow-agent-avatar-wrapper.drag-over {
  border: 2px dashed var(--color-primary);
  background: var(--bg-container-hover);
}

/* ========== 视图切换按钮 ========== */
.workflow-team-header-actions {
  display: flex;
  gap: 8px;
}

/* ========== 关系图容器 ========== */
.workflow-relation-graph {
  height: 200px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  background: var(--bg-container);
}

.workflow-relation-graph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
}