<template>
  <footer class="footer">
    <!-- 背景图片容器 -->
    <div class="footer-background"></div>

    <div class="footer-content">
      <div class="robot-container">
        <div
          v-for="robot in robots"
          :key="robot.type"
          class="robot-item"
          @click="showTaskDetail(robot.type)"
        >
          <div class="robot-placeholder">
            <img :src="getImageUrl(robot.image)" :alt="robot.name" class="robot-image" />
          </div>
          <div class="robot-label">{{ robot.name }}</div>
        </div>
      </div>
    </div>

    <!-- 任务详情弹窗 -->
    <TaskDetailModal
      :visible="taskDetailVisible"
      :robot-type="currentRobotType"
      @close="taskDetailVisible = false"
    />
  </footer>
</template>

<script setup lang="ts">
import { ref, nextTick } from 'vue'
import TaskDetailModal from './TaskDetailModal.vue'
import { robotConfig } from '../config/robotConfig'

// 弹窗状态
const taskDetailVisible = ref(false)
const currentRobotType = ref('')
const robots = robotConfig

// 显示任务详情
const showTaskDetail = (robotType: string) => {
  currentRobotType.value = robotType
  taskDetailVisible.value = true
}

// 获取图片URL
const getImageUrl = (image: string) => {
  return new URL(`../assets/images/${image}`, import.meta.url).href
}
</script>

<style lang="scss" scoped>
// SCSS变量定义
$footer-height: 218.62px;
$robot-width: 88px;
$robot-height: 94px;
$neon-cyan: #78fee0;
$transition-speed: 0.3s ease;

.footer {
  height: $footer-height;
  position: relative;
  overflow: visible;
  display: flex;
  align-items: flex-end;
  justify-content: center;

  // 背景图片容器
  .footer-background {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 280px;
    background: url('@/assets/images/footer_bg.png');
    background-size: contain;
    background-position: center bottom;
    background-repeat: no-repeat;
    z-index: 1;
  }

  // 内容容器
  .footer-content {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: flex-end;
    justify-content: center;

    // 机器人容器
    .robot-container {
      display: flex;
      gap: 40px;
      align-items: flex-end;
      padding-bottom: 23px;

      // 机器人项
      .robot-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 204px;
        height: 144px;
        cursor: pointer;
        transition: all $transition-speed;

        &:hover {
          transform: translateY(-10px);

          .robot-placeholder::after {
            background: rgba(0, 255, 230, 0.4);
            box-shadow: 0 0 20px rgba(0, 255, 230, 0.5);
          }

          .robot-label {
            color: #fff;
            text-shadow: 0 0 10px rgba(0, 255, 230, 0.8);
          }
        }

        // 机器人占位符
        .robot-placeholder {
          position: relative;
          width: 182px;
          height: 90px;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: all $transition-speed;

          &::after {
            content: '';
            position: absolute;
            bottom: -28px;
            left: 50%;
            transform: translateX(-50%) perspective(200px) rotateX(70deg);
            width: 80%;
            height: 80px;
            border: 2px solid #2dd4bf;
            border-top: none;
            // background: linear-gradient(
            //   to bottom,
            //   rgba(45, 212, 191, 0.1),
            //   rgba(45, 212, 191, 0.3)
            // );
            background: linear-gradient(to top, rgba(45, 212, 191, 0.3), rgba(45, 212, 191, 0.05));
            box-shadow: 0 0 20px rgba(0, 255, 230, 0.3);
          }

          .robot-image {
            width: $robot-width;
            height: $robot-height;
            object-fit: cover;
            border-radius: 7px;
          }
        }

        // 机器人标签
        .robot-label {
          color: $neon-cyan;
          font-size: 24px;
          line-height: 42px;
          text-align: center;
          white-space: nowrap;
          transition: all $transition-speed;
        }
      }
    }
  }
}
</style>
