<template>
  <div class="skill-node" :class="{ selected: data.selected }">
    <Handle type="target" :position="Position.Left" id="input" />
    <div class="node-header">
      <ThunderboltOutlined class="node-icon" />
      <span class="node-title">{{ data.label }}</span>
    </div>
    <div class="node-body">
      <div v-if="data.action" class="node-detail">
        <span class="detail-label">动作:</span>
        <span class="detail-value">{{ data.action }}</span>
      </div>
      <div v-if="data.timeout_seconds" class="node-detail">
        <span class="detail-label">超时:</span>
        <span class="detail-value">{{ data.timeout_seconds }}s</span>
      </div>
    </div>
    <Handle type="source" :position="Position.Right" id="output" />
  </div>
</template>

<script setup lang="ts">
import { Handle, Position } from '@vue-flow/core'
import { ThunderboltOutlined } from '@ant-design/icons-vue'
import type { WorkflowNodeData } from '@/utils/workflowSerializer'

defineProps<{
  data: WorkflowNodeData
}>()
</script>

<style scoped>
.skill-node {
  background: #fff;
  border: 2px solid #1890ff;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 160px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s;
}

.skill-node:hover {
  box-shadow: 0 4px 12px rgba(24, 144, 255, 0.25);
}

.skill-node.selected {
  border-color: #096dd9;
  box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.2);
}

.node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.node-icon {
  color: #1890ff;
  font-size: 14px;
}

.node-title {
  font-weight: 600;
  color: #333;
  font-size: 13px;
}

.node-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.node-detail {
  display: flex;
  gap: 4px;
  color: #666;
  font-size: 11px;
}

.detail-label {
  color: #999;
}

.detail-value {
  color: #666;
}
</style>
