<template>
  <div class="risk-card">
    <div class="risk-card__header">
      <span class="risk-card__icon">!</span>
      <span class="risk-card__title">风险标记</span>
      <span class="risk-card__expert">{{ risk.expert_name || risk.expert }}</span>
    </div>
    <div class="risk-card__meta">
      <span class="risk-card__phase">{{ risk.phase_name }}</span>
    </div>
    <div class="risk-card__description">
      <AssistantText :message="descMessage" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import AssistantText from './AssistantText.vue'
import type { IChatMessage, IRiskFlag } from '@/api/types'

const props = defineProps<{
  risk: IRiskFlag
}>()

const descMessage = computed<IChatMessage>(() => ({
  id: `risk-desc-${props.risk.phase_id}-${props.risk.expert}`,
  role: 'assistant',
  content: props.risk.risk_description,
  timestamp: new Date().toISOString(),
  status: 'completed',
}))
</script>

<style scoped>
.risk-card {
  padding: 10px 14px;
  border-left: 3px solid #fa8c16;
  background: #fff7e6;
  border-radius: 4px;
}

.risk-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.risk-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fa8c16;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.risk-card__title {
  font-weight: 600;
  font-size: 14px;
  color: #fa8c16;
}

.risk-card__expert {
  font-size: 12px;
  color: #666;
  margin-left: auto;
}

.risk-card__meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.risk-card__phase::before {
  content: '阶段: ';
  color: #999;
}

.risk-card__description {
  font-size: 13px;
  color: #333;
}
</style>
