<script setup>
import dapengzhongmiaoguanli from '@/static/svg/dapengzhongmiaoguanli.svg'
import dixing from '@/static/svg/dixing.svg'
import nongshi from '@/static/svg/nongshi.svg'
import shuguo from '@/static/svg/shuguo.svg'

const itemDict = {
  plantingArea: {
    svg: 'nongshi',
    icon: nongshi,
    text: '种植面积（亩）',
    value: 250,
    color: '#4CAF50',
  },
  terrain: {
    svg: 'dixing',
    icon: dixing,
    text: '地形',
    value: '丘陵山地',
    color: '#FF9800',
  },
  variety: {
    svg: 'dapengzhongmiaoguanli',
    icon: dapengzhongmiaoguanli,
    text: '主要品种',
    value: '桂味',
    color: '#E91E63',
  },
  plantingNum: {
    svg: 'shuguo',
    icon: shuguo,
    text: '种植荔枝（棵）',
    value: 8500,
    color: '#2196F3',
  },
}
</script>

<template>
  <!-- 果园基本信息卡片 -->
  <view class="info-section">
    <wd-card :shadow="false" class="basic-card">
      <!-- 基本信息网格 -->
      <wd-row :gutter="12">
        <wd-col
          v-for="(item, key) in itemDict"
          :key="key"
          :span="12"
        >
          <view class="info-item-wrapper">
            <view class="info-item">
              <view
                class="info-icon-container" :style="{
                  'backgroundColor': `${item.color}15`,
                  'borderColor': `${item.color}30`,
                  'boxShadow': `0 2px 8px ${item.color}20`,
                  '--hover-color': item.color,
                }"
              >
                <!-- 使用统一的方式设置图标颜色 -->
                <image
                  :src="item.icon" mode="aspectFit" class="info-icon" :style="{
                    // H5平台使用filter，小程序和APP使用tintColor
                    filter: item.color ? `drop-shadow(0 0 0 ${item.color})` : 'none',
                    tintColor: item.color,
                  }"
                />
              </view>
              <view class="info-content">
                <text class="info-label">{{ item.text }}</text>
                <text class="info-value">{{ item.value }}</text>
              </view>
            </view>
          </view>
        </wd-col>
      </wd-row>
    </wd-card>
  </view>
</template>

<style scoped lang="scss">
@import '../variables.scss';

// 果园信息部分
.info-section {
  margin-bottom: 24px;
}

// 信息项包装器
.info-item-wrapper {
  height: 100%;
}

// 基本信息卡片样式
.basic-card {
  border-radius: $border-radius;
  box-shadow: $box-shadow;
  overflow: hidden;
  background: $card-bg-glass;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  padding: 8px !important;
  // 添加科技感边框
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, $primary-color, $primary-color-dark);
  }
}

// 信息项 - 统一样式
.info-item {
  display: flex;
  align-items: center;
  height: 100%;
  min-height: 100px;
  justify-content: flex-start;
  text-align: left;
  position: relative;
  // 添加微妙的背景装饰
  &::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, rgba(0, 198, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0.6;
  }

  // 图标容器 - 圆形设计
  .info-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid;

    .info-item:hover & {
      transform: translateY(-2px) scale(1.08);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    }

    // 悬浮光效
    &::after {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
      opacity: 0;
      transition: opacity 0.3s ease;
    }

    .info-item:hover &::after {
      opacity: 1;
    }

    // 发光边框效果
    &::before {
      content: '';
      position: absolute;
      inset: -2px;
      border-radius: 50%;
      background: linear-gradient(45deg, transparent, currentColor, transparent);
      opacity: 0;
      transition: opacity 0.3s ease;
      z-index: -1;
    }

    .info-item:hover &::before {
      opacity: 0.5;
      animation: rotate 2s linear infinite;
    }
  }

  // 旋转动画
  @keyframes rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  // 图标样式 - 优化显示
  .info-icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
    // 确保图标清晰可见
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;

    // 图标悬浮效果
    .info-item:hover & {
      transform: scale(1.1);
      // 增强图标视觉效果
      opacity: 1;
    }
  }

  .info-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    gap: 4px;
  }

  .info-label {
    font-size: 12px;
    color: $text-tertiary;
    letter-spacing: 0.2px;
    position: relative;
    z-index: 1;
  }

  .info-value {
    font-size: 16px;
    font-weight: 600;
    color: $primary-color-dark;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
    // 添加数字科技感效果
    &::after {
      content: '';
      position: absolute;
      bottom: -3px;
      left: 0;
      width: 30%;
      height: 1px;
      background: linear-gradient(90deg, $primary-color, transparent);
      opacity: 0.5;
    }
  }
}
</style>
