<template>
  <div class="status-cards">
    <div class="info-title">
      待处理
    </div>
    <!--  <div class="custom-line"></div> -->
    <div class="pending-items">
      <div class="pending-item" v-for="(item, index) in statusList" :key="index" @click="handleClick(item)">
        <div class="icon-wrapper">
         <el-icon :size="40" class="card-icon" :style="{ color: item.color }">
              <component :is="item.icon" />
            </el-icon>
        </div>
        <div class="item-content">
          <span class="number" data-target="37">{{ item.value }}</span>
          <span class="label">{{ item.label }}</span>
        </div>
      </div>

      <!-- <div class="pending-item" data-animate="fadeInUp" data-delay="100">
        <div class="icon-wrapper orange">
          <i class="fas fa-exclamation-circle"></i>
        </div>
        <div class="item-content">
          <span class="number" data-target="2">0</span>
          <span class="label">已逾期</span>
        </div>
      </div>

      <div class="pending-item" data-animate="fadeInUp" data-delay="200">
        <div class="icon-wrapper green">
          <i class="fas fa-cog"></i>
        </div>
        <div class="item-content">
          <span class="number" data-target="0">0</span>
          <span class="label">维护中</span>
        </div>
      </div>

      <div class="pending-item" data-animate="fadeInUp" data-delay="300">
        <div class="icon-wrapper red">
          <i class="fas fa-times-circle"></i>
        </div>
        <div class="item-content">
          <span class="number" data-target="40">0</span>
          <span class="label">已关闭</span>
        </div>
      </div> -->
    </div>
    <!-- <div class="card-grid">

      <el-row :gutter="15">
        <el-col v-for="(item, index) in statusList" :key="index" :xs="24" :sm="12" :md="12" :lg="12">
          <div 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>
        </el-col>
      </el-row>
    </div> -->
  </div>
</template>

<script setup lang="ts" name="StatusCards">
import {
  DocumentChecked, Timer, Tools, Warning
} from '@element-plus/icons-vue'
import { defineProps, computed } from 'vue'
import { useRouter } from 'vue-router'

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



const statusList = computed(() => [
 { label: '已借出', value: props.statusData.pending_return, icon: Timer, color: '#E6A23C' },
  { label: '待审批', value: props.statusData.pending_approval, icon: DocumentChecked, color: '#409EFF' },
 
  { label: '待维修', value: props.statusData.pending_maintenance, icon: Tools, color: '#67C23A' },
  { label: '已逾期', value: props.statusData.pending_overdue, icon: Warning, color: '#F56C6C' },
])

const router = useRouter()
function handleClick(item: any) {
  console.log('点击状态卡片:', item.label);
  switch (item.label) {
    case '待审批':
      router.push('/borrow/approval')
      break
    case '已借出':
      router.push('/borrow/list?status=5')
      break
    case '待维修':
      router.push('/devicemaintenance')
      break
    case '已逾期':
      router.push('/borrow/list?status=8')
      break
    default:
      console.warn('未知状态:', item.label)
  }
}
</script>

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

.info-title {
  /* padding-left: 10%; */
  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;
}

.status-cards {
  background: #fff;
  padding: 20px;
  min-height: 330px;
  height: auto;
  border-radius: 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;
}

.card {
  align-items: center;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  border: none !important;
  margin-bottom: 10px;
}

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

.card-value {
  font-size: 20px;
  font-weight: bold;
}

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

/* 待处理项目样式 */
.pending-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 30px;
    min-height: 200px;
    height: auto;
    
    @media (max-width: 768px) {
      gap: 20px;
      min-height: 180px;
    }
    
    @media (max-width: 576px) {
      gap: 15px;
      min-height: 160px;
    }
    
    @media (max-width: 480px) {
      grid-template-columns: 1fr;
      grid-template-rows: repeat(4, auto);
      gap: 12px;
      min-height: auto;
    }
}
.pending-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
    transform: translateY(30px);
    height: 100%;
    min-height: 90px;
}

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

.icon-wrapper {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.icon-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    opacity: 0.1;
}

.icon-wrapper i {
    font-size: 16px;
    color: #fff;
    z-index: 1;
}

.blue { background: linear-gradient(135deg, #667eea, #764ba2); }
.orange { background: linear-gradient(135deg, #f093fb, #f5576c); }
.green { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.red { background: linear-gradient(135deg, #fa709a, #fee140); }

.item-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.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;
    }
}

.label {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    
    @media (max-width: 576px) {
      font-size: 11px;
    }
}

</style>