<template>
  <div class="info-cards">
    <div class="info-title">
      数据简报
    </div>
    <!-- <div class="custom-line"></div> -->
    <div class="stats-grid">
      <div v-for="(item, index) in infoList" :key="index" @click="handleClick(item)" :class="item.class" class="stat-card"
        data-animate="slideInRight">
        <div class="stat-icon">
          <!-- <el-icon :size="40" class="card-icon" :style="{ color: item.color }">
            <component :is="item.icon" />
          </el-icon> -->
           <i class="fas" :class="item.iconFont"></i>
        </div>
        <div class="stat-content">
          <span class="stat-number" data-target="423">{{ item.value }}</span>
          <span class="stat-label">{{ item.label }}</span>
        </div>
      </div>

      <!--  <div class="stat-card red" data-animate="slideInRight" data-delay="100">
                    <div class="stat-icon">
                        <i class="fas fa-calendar-alt"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="63">0</span>
                        <span class="stat-label">在线数</span>
                    </div>
                </div>

                <div class="stat-card green" data-animate="slideInRight" data-delay="200">
                    <div class="stat-icon">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="325">0</span>
                        <span class="stat-label">在线数</span>
                    </div>
                </div>

                <div class="stat-card yellow" data-animate="slideInRight" data-delay="300">
                    <div class="stat-icon">
                        <i class="fas fa-clock"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="0">0</span>
                        <span class="stat-label">今日新增</span>
                    </div>
                </div>

                <div class="stat-card gray" data-animate="slideInRight" data-delay="400">
                    <div class="stat-icon">
                        <i class="fas fa-sync-alt"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="0">0</span>
                        <span class="stat-label">今日同步</span>
                    </div>
                </div>

                <div class="stat-card purple" data-animate="slideInRight" data-delay="100">
                    <div class="stat-icon">
                        <i class="fas fa-users"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="209">0</span>
                        <span class="stat-label">新增用户人数</span>
                    </div>
                </div>

                <div class="stat-card teal" data-animate="slideInRight" data-delay="200">
                    <div class="stat-icon">
                        <i class="fas fa-chart-bar"></i>
                    </div>
                    <div class="stat-content">
                        <span class="stat-number" data-target="225">0</span>
                        <span class="stat-label">累计使用次数</span>
                    </div>
                </div> -->
    </div>
    <!-- <div class="card-grid">
      
      <div
        v-for="(item, index) in infoList"
        :key="index"
        class="card"
        @click="handleClick(item)"
      >
      <el-icon :size="40" class="card-icon" :style="{ color: item.color }">
        <component :is="item.icon" />
      </el-icon>

        <div class="card-value">{{ item.value }}</div>
        <div class="card-label">{{ item.label }}</div>
      </div>
    </div> -->
  </div>
</template>

<script setup lang="ts" name="InfoCards">
import {
  Goods, Box, Collection, Timer, RefreshRight,
  DataLine, User
} from '@element-plus/icons-vue'
import { defineProps, computed } from 'vue'

const props = defineProps({
  summaryData: {
    type: Object,
    required: true
  }
})

const infoList = computed(() => [//
  { label: '设备总库存数', value: props.summaryData.total_devices, icon: Goods, color: '#409EFF',class:'blue',iconFont:'fa-shopping-bag' },
  { label: '在借数', value: props.summaryData.borrowed_devices, icon: Box, color: '#F56C6C',class:'red',iconFont:'fa-calendar-alt' },
  { label: '在库数', value: props.summaryData.available_devices, icon: Collection, color: '#67C23A',class:'green',iconFont:'fa-chart-line' },
  { label: '今日借出', value: props.summaryData.today_borrowed, icon: Timer, color: '#E6A23C',class:'yellow',iconFont:'fa-clock' },
  { label: '今日归还', value: props.summaryData.today_returned, icon: RefreshRight, color: '#909399',class:'gray',iconFont:'fa-sync-alt' },
  { label: '累计借用人次', value: props.summaryData.total_borrowers, icon: User, color: '#3498DB',class:'purple',iconFont:'fa-users' },
  { label: '累计借用次数', value: props.summaryData.total_borrows, icon: DataLine, color: '#9B59B6',class:'teal',iconFont:'fa-chart-bar' },

]);
function handleClick(item: any) {
  console.log('点击信息卡片:', item.label);
}
</script>

<style scoped>
.custom-line {
  height: 1px;
  background-color: #ccc;
  width: 100%;
  margin: 10px 0;
}

.info-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 18px;
  color: #2c3e50;
  position: relative;
  
  @media (max-width: 768px) {
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  @media (max-width: 576px) {
    font-size: 16px;
    margin-bottom: 12px;
  }
}

.info-title::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 50px;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 2px;
}

.info-cards {
  background: #fff;
  min-height: 330px;
  height: auto;
  border-radius: 20px;
  padding: 20px;
  box-sizing: border-box;
  
  @media (max-width: 768px) {
    padding: 15px;
    min-height: auto;
    border-radius: 15px;
  }
  
  @media (max-width: 576px) {
    padding: 12px;
    border-radius: 12px;
  }
}

.card-grid {
  padding: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.card {
  width: calc(20% - 12px);
  align-items: center;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  border: none !important;
}

.card-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 20px;
  font-weight: bold;
  color: #67C23A;
}

.card-label {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}

/* 统计卡片网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 30px;
  min-height: 200px;
  height: auto;
  align-content: start;
  
  @media (max-width: 1200px) {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
  }
  
  @media (max-width: 768px) {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    min-height: auto;
  }
  
  @media (max-width: 576px) {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  @media (max-width: 480px) {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
 transform: translateY(30px);
  position: relative;
  overflow: hidden;
  min-height: 90px;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-color);
  transition: width 0.3s ease;
}

.stat-card:hover::before {
  width: 100%;
  opacity: 0.1;
}

.stat-card:hover {
  /*    transform: translateY(-5px); */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.stat-card.blue {
  --card-color: #3498db;
}

.stat-card.red {
  --card-color: #e74c3c;
}

.stat-card.green {
  --card-color: #2ecc71;
}

.stat-card.yellow {
  --card-color: #f39c12;
}

.stat-card.gray {
  --card-color: #95a5a6;
}

.stat-card.purple {
  --card-color: #9b59b6;
}

.stat-card.teal {
  --card-color: #1abc9c;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  background: var(--card-color);
  color: #fff;
  font-size: 20px;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1;
  
  @media (max-width: 768px) {
    font-size: 18px;
  }
  
  @media (max-width: 576px) {
    font-size: 16px;
  }
}

.stat-label {
  font-size: 12px;
  color: #7f8c8d;
  margin-top: 5px;
  
  @media (max-width: 576px) {
    font-size: 11px;
    margin-top: 3px;
  }
}
</style>
