<script setup>
import { computed } from 'vue';

const props = defineProps({
  content: {
    type: Object,
    required: true,
  },
});

// 解析内容
const endData = computed(() => {
  if (typeof props.content === 'string') {
    try {
      return JSON.parse(props.content);
    } catch {
      return {};
    }
  }
  return props.content;
});
</script>

<template>
  <div class="end-consultation-card">
    <!-- 卡片头部 -->
    <div class="card-header">
      <div class="header-icon">
        <i class="fas fa-check-circle"></i>
      </div>
      <div class="header-title">本次问诊已结束</div>
    </div>

    <!-- 卡片内容 -->
    <div class="card-body">
      <!-- 结束原因 -->
      <div v-if="endData.end_reason" class="info-row">
        <div class="info-icon">
          <i class="fas fa-comment-alt"></i>
        </div>
        <div class="info-content">
          <div class="info-label">结束原因</div>
          <div class="info-value">{{ endData.end_reason }}</div>
        </div>
      </div>

      <!-- 结束时间 -->
      <div v-if="endData.end_time" class="info-row">
        <div class="info-icon">
          <i class="fas fa-clock"></i>
        </div>
        <div class="info-content">
          <div class="info-label">结束时间</div>
          <div class="info-value">{{ endData.end_time }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.end-consultation-card {
  width: 100%;
  min-width: 350px;
  max-width: 450px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all 0.3s ease;
}

.end-consultation-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* 卡片头部 */
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  color: white;
}

.header-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* 卡片内容 */
.card-body {
  padding: 20px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: white;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-row:hover {
  border-color: #64748b;
  background: #f8fafc;
}

.info-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 14px;
  flex-shrink: 0;
}

.info-content {
  flex: 1;
  min-width: 0;
}

.info-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
  font-weight: 500;
}

.info-value {
  font-size: 14px;
  color: #1e293b;
  line-height: 1.6;
  word-break: break-word;
}

/* 暗黑模式适配 */
.dark .end-consultation-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-color: #334155;
}

.dark .card-header {
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
}

.dark .info-row {
  background: #1e293b;
  border-color: #334155;
}

.dark .info-row:hover {
  background: #334155;
}

.dark .info-value {
  color: #e2e8f0;
}

.dark .info-icon {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: #94a3b8;
}
</style>
