<template>
  <div class="recommend-page">
    <div class="recommend-container">
      <!-- 场景采购区域（独立卡片） -->
      <div class="scene-card">
        <div class="scene-header">
          <div class="scene-title">
            <span class="title-text">场景采购</span>
            <span class="title-desc">为采购人构建了一份取舍的推荐菜单</span>
          </div>
          <span class="view-more" @click="handleViewMore">更多推荐 &gt;</span>
        </div>
        <div class="scene-content">
          <div class="scene-grid">
            <div
              v-for="item in sceneList"
              :key="item.id"
              class="scene-item"
              :style="{ backgroundImage: `url(${item.imageUrl})` }"
            >
              <div class="scene-overlay">
                <div class="scene-info">
                  <h3 class="scene-name">{{ item.name }}</h3>
                  <p class="scene-desc">{{ item.description }}</p>
                </div>
              </div>
              <el-icon class="delete-icon" @click.stop="handleRemoveScene(item.id)">
                <Close />
              </el-icon>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup name="DecorationRecommend" lang="ts">
import { ref } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Close } from '@element-plus/icons-vue';

// 场景列表
const sceneList = ref([
  {
    id: '1',
    name: '茶水间',
    description: '商用净水解决方案',
    imageUrl: '/img/Midea.jpg'
  },
  {
    id: '2',
    name: '办公室',
    description: '商用家电解决方案',
    imageUrl: '/img/格力.jpg'
  },
  {
    id: '3',
    name: '办公健身房',
    description: '健身休闲解决方案',
    imageUrl: '/img/PHILIPS.jpg'
  },
  {
    id: '4',
    name: '会议室',
    description: '智能会议解决方案',
    imageUrl: '/img/MAXHUB.jpg'
  },
  {
    id: '5',
    name: '钢制档案类',
    description: '家具解决方案',
    imageUrl: '/img/联想.jpg'
  }
]);

// 查看更多
const handleViewMore = () => {
  ElMessage.info('更多推荐功能开发中...');
};

// 移除场景
const handleRemoveScene = (id: string) => {
  ElMessageBox.confirm('是否确认移除该场景？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    const index = sceneList.value.findIndex(item => item.id === id);
    if (index !== -1) {
      sceneList.value.splice(index, 1);
      ElMessage.success('移除成功');
    }
  }).catch(() => {});
};
</script>

<style scoped lang="scss">
.recommend-page {
  min-height: 100vh;
  background: #f5f5f5;
  padding: 20px;
}

.recommend-container {
  max-width: 1200px;
  margin: 0 auto;
}

.scene-card {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
}

.scene-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.scene-title {
  .title-text {
    font-size: 20px;
    font-weight: 600;
    color: #303133;
    margin-right: 15px;
  }
  
  .title-desc {
    font-size: 14px;
    color: #909399;
  }
}

.view-more {
  font-size: 14px;
  color: #409eff;
  cursor: pointer;
  
  &:hover {
    color: #66b1ff;
  }
}

.scene-content {
  .scene-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }
}

.scene-item {
  position: relative;
  height: 280px;
  border-radius: 8px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  
  &:hover {
    .scene-overlay {
      background: rgba(0, 0, 0, 0.5);
    }
    
    .delete-icon {
      opacity: 1;
    }
  }
  
  .scene-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
  }
  
  .scene-info {
    text-align: center;
    color: #fff;
    
    .scene-name {
      margin: 0 0 10px 0;
      font-size: 22px;
      font-weight: 600;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    .scene-desc {
      margin: 0;
      font-size: 14px;
      opacity: 0.9;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
  }
  
  .delete-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 18px;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.3s;
    
    &:hover {
      background: rgba(245, 108, 108, 0.8);
    }
  }
}
</style>
