<template>
    <div class="help-center">
      <!-- 顶部蓝色渐变背景区域 -->
      <div class="top-section">
        <!-- <div class="filter-icon">
          <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M3 7H21L15 13V19L9 15V13L3 7Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
          </svg>
        </div> -->
        
        <!-- 搜索框 -->
        <div class="search-container">
          <input 
            v-model="searchQuery"
            type="text" 
            :placeholder="$t('backendSystem.search') || '搜索'" 
            class="search-input"
            @keyup.enter="handleSearch"
          />
        </div>
      </div>
  
      <!-- 主要内容区域 -->
      <div class="main-content">
        <!-- 分类按钮网格 -->
        <div class="category-grid">
          <button 
            v-for="category in categories" 
            :key="category.id"
            class="category-btn"
            @click="handleCategoryClick(category)"
            @keydown.enter="handleCategoryClick(category)"
            tabindex="0"
          >
            {{ $t(category.name )}}
          </button>
        </div>
  
        <!-- 推荐内容区域 -->
        <div class="recommended-section">
          <h3 class="section-title">{{ $t('backendSystem.recommendContent') || '推荐的内容' }}</h3>
          <div class="recommended-items">
            <div 
              v-for="item in recommendedItems" 
              :key="item.id"
              class="recommended-item"
              @click="handleCategoryClick(item)"
            >
              <p class="item-description" >{{ $t(item.description) }}</p>
            </div>
          </div>
        </div>
  
        <!-- 最近活动区域 -->
        <div class="recent-activities">
          <h3 class="section-title">{{ $t('backendSystem.recentActivities') || '最近活动' }}</h3>
          <div class="activities-list">
            <div 
              v-for="activity in activities" 
              :key="activity.id"
              class="activity-item"
              @click="handleActivityClick(activity)"
            >
              <div class="activity-header">
                <span class="activity-badge">{{ handelType(activity.type) }}</span>
              </div>
              <p class="activity-title">{{ activity.title }}</p>
              <div class="activity-meta">
                <span class="activity-author">{{handelTime(activity.createTime) }}</span>
                <!-- <span class="activity-comments">{{ activity.comments }}</span> -->
              </div>
            </div>
          </div>
          
          <!-- 查看更多链接 -->
          <div class="view-more">
            <a href="#" class="view-more-link" @click="handleViewMore">
              {{ $t('backendSystem.viewMore') || '查看更多活动公告' }}
            </a>
          </div>
        </div>
      </div>
  
      <!-- 底部帮助中心链接 -->
      <!-- <div class="bottom-section">
        <div class="help-center-link">
          <span>帮助中心</span>
          <select v-model="selectedLanguage" class="language-select">
            <option value="zh">简体中文</option>
            <option value="en">English</option>
          </select>
        </div>
      </div> -->
    </div>
  </template>
  
  <script>
  /**
   * 帮助中心/知识库页面组件
   * 提供搜索、分类浏览、推荐内容和最近活动功能
   */
  import Index from './index.js'
  export default {
    mixins:[Index],
   
  }
  </script>
  
  <style scoped>
  /**
   * 帮助中心页面样式
   */
  .help-center {
    min-height: 100vh;
    background-color: #f5f5f5;
  }
  
  /* 顶部蓝色渐变背景区域 */
  .top-section {
    position: relative;
    height: 200px;
    background: linear-gradient(135deg, #5721E4 0%, #5721E4 50%, #F4BDD1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  
  /* 过滤器图标 */
  .filter-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.3s ease;
  }
  
  .filter-icon:hover {
    background: rgba(255, 255, 255, 0.2);
  }
  
  /* 搜索框容器 */
  .search-container {
    width: 100%;
    max-width: 400px;
  }
  
  /* 搜索输入框 */
  .search-input {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    outline: none;
    transition: background 0.3s ease;
  }
  
  .search-input:focus {
    background: rgba(255, 255, 255, 1);
  }
  
  .search-input::placeholder {
    color: #999;
  }
  
  /* 主要内容区域 */
  .main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
  }
  
  /* 分类按钮网格 */
  .category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 60px;
  }
  
  /* 分类按钮 */
  .category-btn {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .category-btn:hover {
    border-color: #5721E4;
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(42, 82, 152, 0.1);
  }
  
  .category-btn:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
  }
  
  /* 章节标题 */
  .section-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
  }
  
  /* 推荐内容区域 */
  .recommended-section {
    margin-bottom: 60px;
  }
  
  .recommended-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
   
  }
  
  .recommended-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    cursor: pointer;
  }
  
  .recommended-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  
  .item-description {
    color: #666;
    line-height: 1.6;
    margin: 0;
  }
  
  /* 最近活动区域 */
  .recent-activities {
    margin-bottom: 40px;
  }
  
  .activities-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  
  .activity-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
  }
  
  .activity-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  
  .activity-header {
    margin-bottom: 10px;
  }
  
  .activity-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
  }
  
  .activity-title {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    margin: 0 0 10px 0;
    line-height: 1.4;
  }
  
  .activity-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
  }
  
  .activity-comments {
    color: #999;
  }
  
  /* 查看更多链接 */
  .view-more {
    text-align: center;
    margin-top: 40px;
  }
  
  .view-more-link {
    color: #2a5298;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
  }
  
  .view-more-link:hover {
    color: #1e3c72;
    text-decoration: underline;
  }
  
  /* 底部区域 */
  .bottom-section {
    background: #f8f9fa;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
  }
  
  .help-center-link {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
  }
  
  .language-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #333;
    font-size: 14px;
  }
  
  /* 响应式设计 */
  @media (max-width: 768px) {
    .category-grid {
      grid-template-columns: 1fr;
    }
    
    .recommended-items {
      grid-template-columns: 1fr;
    }
    
    .main-content {
      padding: 20px 15px;
    }
    
    .search-container {
      max-width: 300px;
    }
    
    .help-center-link {
      flex-direction: column;
      gap: 10px;
    }
    
    .activity-meta {
      flex-direction: column;
      align-items: flex-start;
      gap: 5px;
    }
  }
  </style>