<template>
  <section class="overview-stats">
    <div class="section-card">
      <div class="section-header">
        <div class="section-title-group">
          <div class="section-title">{{ summary.title || "风险仪表盘" }}</div>
          <div class="section-subtitle">{{ summary.subtitle || "风险总体数据概览" }}</div>
        </div>
        <div class="section-actions">
          <el-button
            v-for="action in summary.actions || []"
            :key="action.key"
            size="mini"
            :type="action.type || 'primary'"
            :plain="action.plain !== false"
          >
            {{ action.label }}
          </el-button>
        </div>
      </div>

      <div class="stats-grid">
        <div
          v-for="item in summary.stats || []"
          :key="item.key"
          class="stats-card"
        >
          <div class="stats-icon" :class="`stats-icon-${item.tone || 'blue'}`">
            <i :class="item.icon || 'el-icon-data-analysis'" />
          </div>
          <div class="stats-content">
            <div class="stats-label">{{ item.label }}</div>
            <div class="stats-value">{{ item.value }}</div>
          </div>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: "OverviewStats",
  props: {
    summary: {
      type: Object,
      default: () => ({}),
    },
  },
};
</script>

<style lang="scss" scoped>
.overview-stats {
  margin-bottom: 16px;
}

.section-card {
  padding: 20px;
  border-radius: 0;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.section-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.section-actions {
  display: flex;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stats-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border: 1px solid #eef2ff;
  border-radius: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.stats-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 18px;
}

.stats-icon-blue {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.12);
}

.stats-icon-red {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

.stats-icon-amber {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
}

.stats-icon-green {
  color: #10b981;
  background: rgba(16, 185, 129, 0.14);
}

.stats-content {
  min-width: 0;
}

.stats-label {
  font-size: 12px;
  color: #94a3b8;
}

.stats-value {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  color: #0f172a;
}
</style>
