<template>
  <div class="dashboard-page">
    <h2 class="page-title">{{ $t('supplier.dashboard') }}</h2>
    <el-row :gutter="16">
      <el-col :span="8">
        <div class="stat-card">
          <div class="stat-icon pending"><el-icon><Clock /></el-icon></div>
          <div class="stat-info">
            <p class="stat-value">{{ stats.pending }}</p>
            <p class="stat-label">待处理订单</p>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="stat-card">
          <div class="stat-icon total"><el-icon><List /></el-icon></div>
          <div class="stat-info">
            <p class="stat-value">{{ stats.total }}</p>
            <p class="stat-label">总订单数</p>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="stat-card">
          <div class="stat-icon products"><el-icon><Goods /></el-icon></div>
          <div class="stat-info">
            <p class="stat-value">{{ stats.products }}</p>
            <p class="stat-label">商品数量</p>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { Clock, List, Goods } from '@element-plus/icons-vue'
import { supplierApi } from '../../api'

const stats = ref({ pending: '--', total: '--', products: '--' })

onMounted(async () => {
  try {
    const res: any = await supplierApi.getOrders()
    const orders = res.data || []
    stats.value.pending = orders.filter((o: any) => o.status === 'pending_confirm').length
    stats.value.total = orders.length
  } catch {}
})
</script>

<style scoped lang="scss">
.dashboard-page { padding: 0; }
.page-title { font-size: 24px; font-weight: 600; color: #fff; margin-bottom: 24px; }
.stat-card {
  background: #2d2d44;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.stat-icon.pending { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.stat-icon.total { background: rgba(78, 110, 242, 0.15); color: #4e6ef2; }
.stat-icon.products { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 700; color: #fff; }
.stat-label { font-size: 14px; color: rgba(255, 255, 255, 0.5); margin-top: 4px; }
</style>
