<template>
  <div class="product-item">
    <div class="product-image">
      <el-image :src="product.image" fit="contain">
        <template #error>
          <div class="image-placeholder">
            <el-icon :size="30" color="#ccc"><Picture /></el-icon>
          </div>
        </template>
      </el-image>
    </div>
    <div class="product-detail">
      <div class="product-name">{{ product.name }}</div>
      <div class="product-spec" v-if="product.spec1">{{ product.spec1 }} {{ product.spec2 }}</div>
      <div class="product-price">¥{{ product.price }}</div>
    </div>
    <div class="product-quantity">x{{ product.quantity }}</div>
  </div>
</template>

<script setup lang="ts">
import { Picture } from '@element-plus/icons-vue'

interface Product {
  image?: string
  name: string
  spec1?: string
  spec2?: string
  price: string | number
  quantity: number
}

defineProps<{ product: Product }>()
</script>

<style scoped lang="scss">
.product-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;

  .product-image {
    width: 80px;
    height: 80px;
    background: #f5f5f5;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    .el-image { width: 100%; height: 100%; }
    .image-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
  }

  .product-detail {
    flex: 1;
    .product-name { font-size: 14px; color: #333; margin-bottom: 5px; line-height: 1.4; }
    .product-spec { font-size: 12px; color: #999; margin-bottom: 5px; }
    .product-price { font-size: 16px; font-weight: bold; color: #e60012; }
  }

  .product-quantity { font-size: 13px; color: #666; }
}
</style>
