<template>
  <div class="help-page">
    <div class="help-container">
   
      <div class="help-cards-container">
        <div 
          class="help-card" 
          v-for="item in helpItems" 
          :key="item.id"
          @click="handleCardClick(item)"
        >
          <div class="card-content">
            <div class="icon-section">
              <img :src="item.icon" :alt="item.title" class="help-icon" />
            </div>
            <div class="text-section">
              <h3 class="card-title">{{ item.title }}</h3>
              <p class="card-description">{{ item.description }}</p>
            </div>
            <div class="action-section">
              <el-button 
                class="view-button"
                @click.stop="openDocument(item.link)"
              >
                立即查看
              </el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
// 导入图标
import docIcon from '@/assets/icons/文档.svg'

// 帮助项目数据
const helpItems = ref([
  {
    id: 1,
    title: '1818AI使用官方文档',
    description: '快速了解1818AI平台功能，轻松上手各种创作工具和服务流程',
    icon: docIcon,
    link: 'https://lcnezxfyaf18.feishu.cn/wiki/QK5Fwmkv1iHezLkNwnScNxkbnWf?from=from_copylink' // 替换为实际的飞书文档链接
  },
  
    {
    id: 2, // 修正重复的 id
    title: '抖音小帮手官方使用文档',
    description: '常见问题解答与插件使用教程，全面的开发指南',
    icon: docIcon,
    link: 'https://lcnezxfyaf18.feishu.cn/wiki/UtELwMeYdicSnbkVEjecXmsgnYf' // 替换为实际的飞书文档链接
  },
  
])

// 处理卡片点击
const handleCardClick = (item) => {
  console.log('点击卡片:', item.title)
}

// 打开飞书文档
const openDocument = (link) => {
  if (link) {
    window.open(link, '_blank')
  } else {
    ElMessage.warning('文档链接暂未配置')
  }
}
</script>

<style scoped>
.help-page {
  width: 100%;
  min-height: 800px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.help-container {
  width: 100%;
  box-sizing: border-box;
}

.section-title {
  width: 100%;
  max-width: 312px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 0;
  margin-bottom: 30px;
  text-align: left;
}

.title-bar {
  width: 4px;
  height: 24px;
  background: #333;
  border-radius: 2px;
}

.title-text {
  font-family: Arial, sans-serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 28px;
  letter-spacing: 0px;
  color: #333;
  margin: 0;
  text-align: left;
  align-self: flex-start;
  flex: 1;
  text-align-last: left;
  -webkit-text-align-last: left;
  display: inline-block;
}

.help-cards-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-start;
  width: 100%;
}

.help-card {
  width: 1063px;
  height: 139px;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.help-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);

}

.card-content {
  display: flex;
  align-items: center;
  margin-top: 10px;
  height: 100%;
  padding: 0 32px;
  text-align: left;
}

.icon-section {
  flex-shrink: 0;
  margin-right: 24px;
}

.help-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.text-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-right: 24px;
  text-align: left;
}

.card-title {
  font-family: 'Arial';
  font-size: 28px;
  font-weight: 500;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  text-align: left;
}

.card-description {
  margin: 0;
  font-family: 'Arial';
  font-size: 18px;
  font-weight: 400;
  color: #666666;
  line-height: 1.5;
  text-align: left;
}

.action-section {
  flex-shrink: 0;
}

.view-button {
  width: 120px;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  background: #ffffff !important;
  color: #333333 !important;
  border: 1px solid #333333 !important;
  box-shadow: none !important;
}

.view-button:hover {
  transform: translateY(-1px);
  background: #f5f5f5 !important;
  color: #333333 !important;
  border-color: #333333 !important;
  box-shadow: 0 2px 6px rgba(51, 51, 51, 0.15) !important;
}

.view-button:focus {
  background: #ffffff !important;
  color: #333333 !important;
  border-color: #333333 !important;
  box-shadow: 0 0 0 2px rgba(51, 51, 51, 0.1) !important;
}

.view-button:active {
  background: #f0f0f0 !important;
  color: #333333 !important;
  border-color: #333333 !important;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .help-card {
    width: 100%;
    max-width: 1063px;
  }
  
  .help-cards-container {
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .help-page {
    padding: 0;
  }
  
  .help-container {
    padding: 0;
  }
  
  .help-cards-container {
    align-items: flex-start;
  }
  
  .help-card {
    height: auto;
    min-height: 139px;
    width: 100%;
  }
  
  .card-content {
    padding: 20px;
    flex-direction: column;
    text-align: left;
    align-items: flex-start;
  }
  
  .icon-section {
    margin-right: 0;
    margin-bottom: 16px;
    align-self: flex-start;
  }
  
  .text-section {
    margin-right: 0;
    margin-bottom: 20px;
    text-align: left;
    width: 100%;
  }
  
  .card-title {
    text-align: left;
  }
  
  .card-description {
    text-align: left;
  }
  
  .action-section {
    align-self: flex-start;
  }
  
  .section-title {
    margin-bottom: 20px;
  }
  
  .title-text {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .section-title {
    width: 100%;
  }
  
  .title-text {
    font-size: 18px;
  }
  
  .help-cards-container {
    align-items: flex-start;
  }
  
  .help-card {
    min-height: 120px;
    width: 100%;
  }
  
  .card-content {
    padding: 16px;
    align-items: flex-start;
  }
  
  .card-title {
    font-size: 18px;
    text-align: left;
  }
  
  .card-description {
    font-size: 13px;
    text-align: left;
  }
  
  .view-button {
    width: 100px;
    height: 36px;
    font-size: 13px;
  }
  
  .action-section {
    align-self: flex-start;
  }
}
</style>