<template>
  <view class="records-wrapper">
    <view class="records-list" v-if="records && records.length">
      <view v-for="(item, idx) in records" :key="item.id || idx" class="record-item">
        <image class="record-img" :src="item.image" mode="aspectFill" />
        <view class="record-info">
          <view class="record-title">{{ item.title }}</view>
          <view class="record-meta">
            <text class="record-count">x{{ item.count }}</text>
            <!-- <text v-if="item.percent" class="record-percent">{{ item.percent }}%</text> -->
          </view>
        </view>
      </view>
    </view>
    <view class="empty-state-compact" v-else>
      <view class="empty-icon-wrap">
        <text class="empty-icon">🎁</text>
      </view>
      <text class="empty-title">{{ emptyText }}</text>
      <text class="empty-hint">快来参与活动获得奖品吧</text>
    </view>
  </view>
</template>

<script setup>
defineProps({
  records: {
    type: Array,
    default: () => []
  },
  emptyText: {
    type: String,
    default: '暂无购买记录'
  }
})
</script>

<style lang="scss" scoped>
.records-list {
  padding: $spacing-xs 0;
}

.record-item {
  display: flex;
  align-items: center;
  padding: $spacing-sm 0;
  border-bottom: 1rpx solid rgba(0, 0, 0, 0.03);
  
  &:last-child {
    border-bottom: none;
  }
}

.record-img {
  width: 80rpx;
  height: 80rpx;
  border-radius: $radius-md;
  margin-right: $spacing-md;
  background: $bg-secondary;
  flex-shrink: 0;
}

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

.record-title {
  font-size: $font-md;
  font-weight: 600;
  color: $text-main;
  margin-bottom: $spacing-xs;
  @include text-ellipsis(1);
}

.record-meta {
  display: flex;
  align-items: center;
  gap: $spacing-sm;
}

.record-count {
  font-size: $font-sm;
  color: $brand-primary;
  font-weight: 600;
}

.record-percent {
  font-size: $font-xs;
  color: $text-sub;
}

/* 紧凑优雅的空状态 */
.empty-state-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: $spacing-lg $spacing-xl;
  min-height: 200rpx;
}

.empty-icon-wrap {
  width: 80rpx;
  height: 80rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba($brand-primary, 0.1) 0%, rgba($accent-gold, 0.1) 100%);
  border-radius: 50%;
  margin-bottom: $spacing-md;
}

.empty-icon {
  font-size: 40rpx;
}

.empty-title {
  font-size: $font-md;
  color: $text-sub;
  font-weight: 600;
  margin-bottom: 8rpx;
}

.empty-hint {
  font-size: $font-xs;
  color: $text-tertiary;
}
</style>
