<template>
  <div class="bill-card">
    <div class="card-content">
      <input
        type="checkbox"
        :checked="bill.selected"
        class="checkbox"
        @change="emit('toggleSelect', bill.id)"
      />
      <div class="card-main">
        <h4 class="text-title-3-bold text-primary-80-clor">{{ bill.title }}</h4>
        <div class="fields-grid">
          <div
            v-for="field in billFields"
            :key="field.key"
            class="field-item"
          >
            <span class="field-label text-tip-2 text-primary-50-clor">{{ field.label }}</span>
            <template v-if="field.key === 'areas'">
              <div class="area-tags">
               
                <AreaTag  v-for="area in bill.areas"
                  :key="area" :tagName="area" />
              </div>
            </template>
            <template v-else-if="field.key === 'passDays'">
              <span class="text-tip-2 main-color">{{ bill.passDays }}天</span>
            </template>
            <template v-else>
              <span class="text-tip-2">{{ bill[field.key as keyof typeof bill] }}</span>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { BillInfo } from '../api'
  import AreaTag from '@/components/base/AreaTag/index.vue'
defineProps<{
  bill: BillInfo
}>()

const emit = defineEmits<{
  toggleSelect: [id: string]
}>()

const billFields = [
  { key: 'proposalDate', label: '提案时间：' },
  { key: 'areas', label: '涉及领域：' },
  { key: 'electionPhase', label: '选举周期阶段：' },
  { key: 'proposer', label: '提案人：' },
  { key: 'coProposers', label: '共同提案人：' },
  { key: 'proposerPosition', label: '提案人职务：' },
  { key: 'governmentType', label: '政府结构类型：' },
  { key: 'budgetScale', label: '法案预算规模：' },
  { key: 'passDays', label: '通过耗时：' }
]
</script>

<style scoped>
.bill-card {
  border: 1px solid var(--bg-black-10);
  border-radius: var(--radius-10);
  padding: 16px;
}

.card-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.checkbox {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-primary-100);
}

.card-main {
  flex: 1;
}

.card-main h4 {
  margin: 0 0 16px 0;
  line-height: 20px;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 24px;
}

.field-item {
  display: flex;
  align-items: center;
}

.field-label {
  width: 100px;
  flex-shrink: 0;
}

.area-tags {
  display: flex;
  gap: 8px;
}

.area-tag {
  padding: 2px 8px;
  font-size: 12px;
  color: var(--color-primary-100);
  background-color: var(--color-primary-10);
  border: 1px solid var(--color-primary-10);
  border-radius: var(--radius-4);
}
</style>
