<template>
  <div class="home">
    <!-- 主横幅区域 -->
    <section class="hero-banner">
      <img :src="bannerImage" :alt="bannerAlt" class="banner-image" />
    </section>

    <!-- 数据统计区域 -->
    <section class="stats-section">
      <div class="stats-grid">
          <div class="stat-item">
            <div class="stat-icon">
              <img src="/top/顶部icon1.png" alt="学习视频" />
            </div>
            <div class="stat-content">
              <div class="stat-number">1000 +</div>
              <div class="stat-label">{{ t('home.stats.learningVideos') }}</div>
            </div>
          </div>
          <div class="stat-item">
            <div class="stat-icon">
              <img src="/top/顶部icon2.png" alt="名师专家" />
            </div>
            <div class="stat-content">
              <div class="stat-number">109 +</div>
              <div class="stat-label">{{ t('home.stats.expertTeachers') }}</div>
            </div>
          </div>
          <div class="stat-item">
            <div class="stat-icon">
              <img src="/top/顶部icon3.png" alt="培训教材" />
            </div>
            <div class="stat-content">
              <div class="stat-number">3549 +</div>
              <div class="stat-label">{{ t('home.stats.trainingMaterials') }}</div>
            </div>
          </div>
          <div class="stat-item">
            <div class="stat-icon">
              <img src="/top/顶部icon4.png" alt="资源素材" />
            </div>
            <div class="stat-content">
              <div class="stat-number">6532 +</div>
              <div class="stat-label">{{ t('home.stats.resourceMaterials') }}</div>
            </div>
          </div>
          <div class="stat-item">
            <div class="stat-icon">
              <img src="/top/顶部icon5.png" alt="在线实验" />
            </div>
            <div class="stat-content">
              <div class="stat-number">2652 +</div>
              <div class="stat-label">{{ t('home.stats.onlineExperiments') }}</div>
            </div>
          </div>
        </div>
    </section>

    <!-- 热门课程 -->
    <section class="popular-courses">
      <div class="container">
        <div class="section-header">
          <div class="section-title-group">
            <img src="/images/热门好课.png" alt="热门好课" class="section-title-image" />
            <div class="section-subtitle">{{ t('home.popularCourses.subtitle') }}</div>
          </div>
          <n-button text type="primary" class="view-all-btn" @click="$router.push('/courses')">
            {{ t('home.popularCourses.viewAll') }} >
          </n-button>
        </div>
        <div class="courses-grid">
          <div class="course-card" v-for="course in popularCourses" :key="course.id">
            <div class="course-image">
              <img :src="course.thumbnail" :alt="course.title" />
            </div>
            <div class="course-info">
              <h3 class="course-title">{{ course.title }}</h3>
              <div class="course-meta">
                <span class="course-students">{{ course.studentsCount }}{{ t('home.popularCourses.studentsEnrolled') }}</span>
                <button class="enroll-btn" @click="handleEnrollCourse(course.id)">{{ t('home.popularCourses.enroll') }}</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 专题训练 -->
    <section class="special-training">
      <div class="container">
        <div class="section-header">
          <div class="section-title-group">
            <img src="/images/专题训练.png" alt="专题训练" class="section-title-image" />
            <div class="section-subtitle">{{ t('home.specialTraining.subtitle') }}</div>
          </div>
          <n-button text type="primary" class="view-all-btn" @click="$router.push('/training')">
            {{ t('home.specialTraining.viewAll') }} >
          </n-button>
        </div>
        <div class="training-grid">
          <div class="training-card" v-for="training in specialTrainings" :key="training.id">
            <div class="training-image">
              <img :src="training.thumbnail" :alt="training.title" />
            </div>
            <div class="training-info">
              <div class="training-title-row">
                <h3 class="training-title">{{ training.title }}</h3>
                <span class="training-tag">{{ training.tag }}</span>
              </div>
              <div class="training-meta">
                <span class="training-students">{{ training.studentsCount }}{{ t('home.specialTraining.studentsCheckedIn') }}</span>
                <button class="join-btn">{{ t('home.specialTraining.join') }}</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 学习路径 -->
    <section class="learning-paths">
      <div class="container">
        <div class="section-header">
          <div class="section-title-group">
            <img src="/images/学习路径.png" alt="学习路径" class="section-title-image" />
            <div class="section-subtitle">{{ t('home.learningPaths.subtitle') }}</div>
          </div>
          <n-button text type="primary" class="view-all-btn" @click="$router.push('/learning-paths')">
            {{ t('home.learningPaths.viewAll') }} >
          </n-button>
        </div>
        <div class="paths-grid">
          <div class="path-card" v-for="path in learningPaths" :key="path.id" :class="`path-card-${path.id}`">
            <div class="path-content">
              <div class="path-image-container">
                <img :src="path.image" :alt="path.title" class="path-image" />
              </div>

              <div class="path-body">
                <div class="path-free-label">{{ t('home.learningPaths.freeLabel') }}</div>
                <div class="path-description">
                  {{ t('home.learningPaths.description') }}
                  <span class="detail-link">{{ t('home.learningPaths.viewDetails') }}</span>
                </div>

                <div class="path-details">
                  <div class="path-detail-item">
                    <span class="detail-label">{{ t('home.learningPaths.targetAudience') }}</span>
                    <span class="detail-value">{{ path.targetAudience }}</span>
                  </div>
                  <div class="path-detail-item">
                    <span class="detail-label">{{ t('home.learningPaths.learningGoal') }}</span>
                    <span class="detail-value">{{ path.learningGoal }}</span>
                  </div>
                  <div class="path-detail-item path-resources-item">
                    <span class="detail-label">{{ t('home.learningPaths.supportingResources') }}</span>
                    <div class="resources-tags">
                      <span class="resource-tag tag-1">{{ t('home.learningPaths.fullLearningMaterials') }}</span>
                      <span class="resource-tag tag-2">{{ t('home.learningPaths.oneOnOneTutoring') }}</span>
                    </div>
                  </div>
                </div>

                <div class="path-warning">
                  <i class="warning-icon">⚠</i>
                  {{ t('home.learningPaths.warmTip') }}
                </div>

                <button class="path-learn-btn">{{ t('home.learningPaths.startLearning') }}</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 精选评论 -->
    <section class="featured-reviews">
      <div class="container">
        <div class="section-header">
          <div class="section-title-group">
            <img src="/images/精选评论.png" alt="精选评论" class="section-title-image" />
            <div class="section-subtitle">{{ t('home.featuredReviews.subtitle') }}</div>
          </div>
        </div>
        <div class="reviews-grid">
          <div class="review-card" v-for="review in featuredReviews" :key="review.id">
            <!-- 上层：头像 + 姓名职位 -->
            <div class="review-header">
              <div class="review-avatar">
                <img :src="review.avatar" :alt="review.name" />
              </div>
              <div class="reviewer-info">
                <h3 class="reviewer-name">{{ review.name }}</h3>
                <p class="reviewer-title">{{ review.title }}</p>
              </div>
            </div>
            <!-- 下层：评论内容 -->
            <div class="review-content-wrapper">
              <p class="review-content">{{ review.content }}</p>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 登录模态框 -->
    <LoginModal
      v-model:show="loginModalVisible"
      @success="handleAuthSuccess"
    />

    <!-- 注册模态框 -->
    <RegisterModal
      v-model:show="registerModalVisible"
      @success="handleAuthSuccess"
    />
  </div>
</template>

<script setup lang="ts">
import { onMounted, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { useCourseStore } from '@/stores/course'
import { useAuth } from '@/composables/useAuth'
import LoginModal from '@/components/auth/LoginModal.vue'
import RegisterModal from '@/components/auth/RegisterModal.vue'

const { t, locale } = useI18n()
const router = useRouter()
const courseStore = useCourseStore()
const { loginModalVisible, registerModalVisible, handleAuthSuccess } = useAuth()

// 轮播图根据语言动态切换
const bannerImage = computed(() => {
  return locale.value === 'zh' ? '/banners/banner1.png' : '/banners/banner1-en.png'
})

const bannerAlt = computed(() => {
  return t('home.banner.alt')
})

// 热门课程数据
const popularCourses = computed(() => [
  {
    id: 1,
    title: t('home.courses.pythonBasics'),
    thumbnail: '/images/courses/course1.png',
    category: '基础课程',
    studentsCount: 324,
    rating: 4.8,
    price: 299,
    originalPrice: 399
  },
  {
    id: 2,
    title: t('home.courses.newEnergyMaterials'),
    thumbnail: '/images/courses/course2.png',
    category: '专业课程',
    studentsCount: 324,
    rating: 4.7,
    price: 199,
    originalPrice: 299
  },
  {
    id: 3,
    title: t('home.courses.pptDesign'),
    thumbnail: '/images/courses/course3.png',
    category: '实用技能',
    studentsCount: 324,
    rating: 4.9,
    price: 399,
    originalPrice: 499
  },
  {
    id: 4,
    title: t('home.courses.newEnergyVehicle'),
    thumbnail: '/images/courses/course4.png',
    category: '前沿技术',
    studentsCount: 324,
    rating: 4.6,
    price: 499,
    originalPrice: 699
  },
  {
    id: 5,
    title: t('home.courses.artificialIntelligence'),
    thumbnail: '/images/courses/course5.png',
    category: 'AI技术',
    studentsCount: 324,
    rating: 4.8,
    price: 359,
    originalPrice: 459
  }
])

// 专题训练数据
const specialTrainings = computed(() => [
  {
    id: 1,
    title: t('home.trainings.chineseCulture'),
    thumbnail: '/images/traings/traing1.png',
    studentsCount: 324,
    tag: t('home.tags.weeklyPractice')
  },
  {
    id: 2,
    title: t('home.trainings.chinesePhonetics'),
    thumbnail: '/images/traings/traing2.png',
    studentsCount: 324,
    tag: t('home.tags.beginner')
  },
  {
    id: 3,
    title: t('home.trainings.dataStatistics'),
    thumbnail: '/images/traings/traing3.png',
    studentsCount: 324,
    tag: t('home.tags.practical')
  },
  {
    id: 4,
    title: t('home.trainings.foreignChinese'),
    thumbnail: '/images/traings/traing4.png',
    studentsCount: 324,
    tag: t('home.tags.competition')
  }
])

// 学习路径数据
const learningPaths = computed(() => [
  {
    id: 1,
    title: t('home.learningPathsData.beginnerToEntry.title'),
    targetAudience: t('home.learningPathsData.beginnerToEntry.targetAudience'),
    learningGoal: t('home.learningPathsData.beginnerToEntry.learningGoal'),
    image: '/images/studys/study1.png'
  },
  {
    id: 2,
    title: t('home.learningPathsData.entryToMastery.title'),
    targetAudience: t('home.learningPathsData.entryToMastery.targetAudience'),
    learningGoal: t('home.learningPathsData.entryToMastery.learningGoal'),
    image: '/images/studys/study2.png'
  },
  {
    id: 3,
    title: t('home.learningPathsData.expertAdvanced.title'),
    targetAudience: t('home.learningPathsData.expertAdvanced.targetAudience'),
    learningGoal: t('home.learningPathsData.expertAdvanced.learningGoal'),
    image: '/images/studys/study3.png'
  }
])

// 精选评论数据
const featuredReviews = computed(() => [
  {
    id: 1,
    name: t('home.reviewsData.reviewer1.name'),
    title: t('home.reviewsData.reviewer1.title'),
    avatar: '/opinion/opioion1.png',
    content: t('home.reviewsData.reviewer1.content')
  },
  {
    id: 2,
    name: t('home.reviewsData.reviewer2.name'),
    title: t('home.reviewsData.reviewer2.title'),
    avatar: '/opinion/opioion2.png',
    content: t('home.reviewsData.reviewer2.content')
  },
  {
    id: 3,
    name: t('home.reviewsData.reviewer3.name'),
    title: t('home.reviewsData.reviewer3.title'),
    avatar: '/opinion/opioion3.png',
    content: t('home.reviewsData.reviewer3.content')
  }
])

// 处理课程报名 - 跳转到课程详情页面
const handleEnrollCourse = (courseId: number) => {
  // 跳转到课程详情页面，在那里进行登录状态判断和报名
  router.push(`/course/${courseId}`)
}

onMounted(async () => {
  await courseStore.fetchCourses()
})
</script>

<style scoped>
.home {
  width: 100%;
  background: #f8f9fa;
}

/* 主横幅区域 */
.hero-banner {
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.banner-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}





.cta-button {
  padding: 12px 32px;
  font-size: 16px;
  border-radius: 25px;
  background: #ff6b35;
  border: none;
}

.banner-right {
  display: flex;
  justify-content: center;
  align-items: center;
}

.instructor-avatars {
  position: relative;
}

.avatar-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.instructor-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.instructor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 占位符样式 */
.avatar-placeholder,
.image-placeholder,
.icon-placeholder {
  width: 100%;
  height: 100%;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
}

.course-image .image-placeholder {
  height: 120px;
}



.path-icon .icon-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: #e6f7ff;
}

/* 数据统计区域 */
.stats-section {
  width: 1920px;
  height: 187px;
  background: #F2FBFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.stats-grid {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 auto;
  padding: 0 247px;
}

.stat-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 25px;
  border-right: 1px solid #f0f0f0;
}

.stat-item:last-child {
  border-right: none;
}

.stat-item:last-child {
  border-right: none;
}

.stat-icon {
  flex-shrink: 0;
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  display: block;
}



.stat-content {
  text-align: left;
  flex: 1;
}

.stat-number {
  font-size: 22px;
  font-weight: 700;
  color: #292C2E;
  margin-bottom: 6px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 14px;
  color: #5A5C5E;
  line-height: 1.3;
  font-weight: 400;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.special-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.special-icon {
  margin-bottom: 6px;
}

.special-number {
  font-size: 20px;
  font-weight: bold;
  color: white;
  line-height: 1.2;
}

.special-text {
  font-size: 11px;
  color: white;
  opacity: 0.9;
  line-height: 1;
}

/* 通用样式 */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  padding: 0;
}

.section-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.section-title {
  font-size: 28px;
  font-weight: 600;
  color: #333;
  margin: 0;
  margin-bottom: 4px;
  line-height: 1.2;
}

.section-title-image {
  height: 32px;
  width: auto;
  object-fit: contain;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 24px;
  color: #C0C0C0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
  font-weight: 400;
  font-family: 'Source Han Sans', 'Source Han Sans Regular', sans-serif;
}

.view-all-btn {
  font-size: 24px;
  color: #999;
  padding: 0;
  height: auto;
  line-height: 34px;
  font-weight: 400;
}

.view-all-btn:hover {
  color: #1890ff;
}

/* 热门课程 */
.popular-courses {
  padding: 70px 0;
  background: #FFFFFF;
  width: 100%;
  min-height: 542px;
  height: auto;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  width: 100%;
}

.course-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  height: auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.course-image {
  position: relative;
  width: 268px;
  height: 160px;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  flex-shrink: 0;
}

.course-image img {
  width: 268px;
  height: 160px;
  object-fit: cover;
}



.course-info {
  padding: 12px 14px 16px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.course-title {
  font-size: 16px;
  font-weight: 500;
  color: #333333;
  margin-bottom: 12px;
  line-height: 1.5;
  height: auto;
  min-height: 24px;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.course-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #666;
  margin-top: auto;
  padding-top: 8px;
}

.course-students {
  color: #999999;
  font-size: 14px;
  line-height: 17px;
  white-space: nowrap;
}

.enroll-btn {
  background: #1890ff;
  color: #FFFFFF;
  border: none;
  min-width: 59px;
  height: 25px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 400;
  line-height: 17px;
  font-family: 'PingFang SC', '苹方-简', 'PingFang SC Regular', sans-serif;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.enroll-btn:hover {
  background: #40a9ff;
}

.join-btn {
  background: #FFFFFF;
  color: #1890ff;
  border: 1px solid #1890ff;
  width: 59px;
  height: 25px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 400;
  line-height: 17px;
  font-family: 'PingFang SC', '苹方-简', 'PingFang SC Regular', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

.join-btn:hover {
  background: #f0f8ff;
  border-color: #40a9ff;
  color: #40a9ff;
}

/* 专题训练 */
.special-training {
  padding: 80px 0;
  background: #F2FBFF;
  width: 100%;
  min-height: 578px;
  height: auto;
}

.training-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.training-card {
  background: white;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
  cursor: pointer;
}

.training-card:hover {
  transform: translateY(-2px);
}

.training-image {
  position: relative;
  width: 334px;
  height: 212px;
  overflow: hidden;
}

.training-image img {
  width: 334px;
  height: 212px;
  object-fit: cover;
}

.training-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* 改为flex-start，让内容从顶部开始排列 */
  height: 100px; /* 使用固定高度而不是最小高度，确保所有卡片高度一致 */
}

.training-title-row {
  display: flex;
  align-items: flex-start; /* 让标题和标签顶部对齐 */
  gap: 8px;
  justify-content: flex-start; /* 改为flex-start，让标签紧跟在标题后面 */
  width: 100%;
  flex-wrap: nowrap; /* 防止换行，保持在同一行 */
  min-height: 28px; /* 增加最小高度以适应标签高度 */
}

.training-title {
  font-size: 20px;
  font-weight: 500;
  color: #333333;
  line-height: 24px; /* 固定行高为24px，确保所有标题高度一致 */
  margin: 0;
  flex: none; /* 让标题宽度根据内容自适应 */
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  display: inline-block; /* inline-block让宽度根据内容自适应 */
  padding-top: 2px; /* 添加2px的顶部padding，让标题与标签对齐 */
  max-width: calc(100% - 120px); /* 增加预留空间，适应英文标签可能更长的情况 */
  vertical-align: top; /* 确保与标签顶部对齐 */
}

.training-tag {
  background: #1890ff;
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  padding: 0 12px; /* 左右内边距，让文字有呼吸空间 */
  border-radius: 5px;
  white-space: nowrap;
  font-family: 'PingFang SC', '苹方-简', 'PingFang SC Regular', sans-serif;
  height: 20px;
  flex-shrink: 0; /* 防止标签被压缩 */
  display: inline-flex; /* 改为inline-flex，与标题的inline-block更好配合 */
  align-items: center;
  justify-content: center;
  width: auto; /* 自适应宽度 */
  margin-top: 2px; /* 与标题的padding-top保持一致 */
  vertical-align: top; /* 确保与标题顶部对齐 */
}

.training-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #666;
  margin-top: auto; /* 保持margin-top: auto，让meta区域始终在底部 */
  padding-top: 8px;
  height: 25px; /* 固定高度确保所有meta区域高度一致 */
}

.training-students {
  color: #999999;
  font-size: 14px;
  line-height: 17px;
  white-space: nowrap;
  display: flex;
  align-items: center; /* 确保文本垂直居中对齐 */
  height: 25px; /* 与meta区域高度一致 */
}

/* 学习路径 */
.learning-paths {
  padding: 80px 0;
  background: white;
  width: 100%;
  min-height: 859px;
  height: auto;
}

.paths-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 100%;
}

.path-card {
  background: white;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: auto;
  min-height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.path-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.path-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.path-image-container {
  width: 100%;
  height: 195px;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  margin-bottom: 20px;
}

.path-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 0 24px 24px 24px;
}





.path-free-label {
  font-size: 22px;
  color: #333;
  font-weight: bold;
  margin-bottom: 12px;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.path-description {
  font-size: 16px;
  color: #666;
  line-height: 1.6;
  margin-bottom: 16px;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.detail-link {
  color: #1890ff;
  cursor: pointer;
  margin-left: 5px;
  font-size: 14px;
}

.detail-link:hover {
  text-decoration: underline;
}

.path-details {
  margin-bottom: 16px;
  background-color: #F7F8FA;
  padding: 16px;
  border-radius: 8px;
  flex: 1;
}

.path-detail-item {
  display: flex;
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.5;
  align-items: flex-start;
}

.detail-label {
  color: #666;
  min-width: 80px;
  flex-shrink: 0;
  margin-right: 8px;
  word-wrap: break-word;
  word-break: break-word;
}

.detail-value {
  color: #333;
  flex: 1;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.4;
}

.resources-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.resource-tag {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: normal;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.3;
  text-align: center;
}

/* 第一个卡片的配套资源样式 */
.path-card-1 .resource-tag.tag-1 {
  color: #0C6ED9;
  background-color: #E6F3FF;
}

.path-card-1 .resource-tag.tag-2 {
  color: #0C6ED9;
  background-color: #E6F3FF;
}

/* 第二个卡片的配套资源样式 */
.path-card-2 .resource-tag.tag-1 {
  color: #3DA015;
  background-color: #F6FFEC;
}

.path-card-2 .resource-tag.tag-2 {
  color: #3DA015;
  background-color: #F6FFEC;
}

/* 第三个卡片的配套资源样式 */
.path-card-3 .resource-tag.tag-1 {
  color: #551DAB;
  background-color: #F9F0FF;
}

.path-card-3 .resource-tag.tag-2 {
  color: #551DAB;
  background-color: #F9F0FF;
}

.path-warning {
  background: #FFEBE5;
  border: 1px solid #FFEBE5;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #FF682D;
  margin-bottom: 20px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  gap: 6px;
}

.warning-icon {
  color: #F39C12;
  font-style: normal;
  font-size: 14px;
}

.path-learn-btn {
  background: #1890ff;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  align-self: flex-end;
  margin-top: auto;
  margin-bottom: 5px;
  white-space: nowrap;
}

.path-learn-btn:hover {
  background: #40a9ff;
}

.path-image {
  width: 448px;
  height: 195px;
  border-radius: 8px;
  object-fit: cover;
}

/* 精选评论 */
.featured-reviews {
  padding: 70px 0 76px 0;
  background: #F2FBFF;
  width: 100%;
  height: auto;
}

.reviews-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
  max-width: 100%;
}

.review-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  width: 454px;
  min-height: 245px;
  height: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.review-card:hover {
  transform: translateY(-2px);
}

.review-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.review-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 上层：头像 + 姓名职位的横向布局 */
.review-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  width: 100%;
}

/* 下层：评论内容 */
.review-content-wrapper {
  margin-top: 30px;
  width: 100%;
}

.reviewer-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.reviewer-name {
  font-size: 28px;
  font-weight: 500;
  color: #333333;
  line-height: 1.2;
  margin-bottom: 8px;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.reviewer-title {
  font-size: 22px;
  color: #999999;
  line-height: 1.2;
  margin: 0 0 16px 0;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.review-content {
  font-size: 20px;
  color: #999999;
  line-height: 1.6;
  margin: 0;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  flex: 1;
}

/* 通用文本自适应样式 */
.home-container * {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 确保所有标题和文本都能正确换行 */
h1, h2, h3, h4, h5, h6, p, span, div {
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* 防止长单词破坏布局 */
.section-title, .section-subtitle, .course-title, .training-title,
.reviewer-name, .reviewer-title, .review-content, .detail-value, .stat-label {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* 确保专题训练标题在不同语言下的一致性 */
.training-title {
  /* 字体渲染优化 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* 确保中英文字体一致性 */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* 字符间距优化 */
  letter-spacing: -0.01em;
}

/* 确保标签在不同语言下的一致性 */
.training-tag {
  /* 字体渲染优化 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 专题训练标题响应式优化 */
@media (max-width: 768px) {
  .training-title-row {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    min-height: auto; /* 移动端不需要固定最小高度 */
  }

  .training-title {
    font-size: 18px;
    line-height: 1.3; /* 移动端稍微增加行高提高可读性 */
    flex: none; /* 移动端重置flex */
  }

  .training-tag {
    align-self: flex-start;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .training-title {
    font-size: 18px;
    max-width: calc(100% - 70px);
    line-height: 1.2; /* 保持一致的行高 */
    padding-top: 2px; /* 保持垂直对齐 */
  }

  .training-tag {
    margin-top: 2px; /* 保持垂直对齐 */
  }
}

/* 响应式设计 */

/* 超大屏幕 (≥1400px) */
@media (min-width: 1400px) {
  .banner-content {
    padding: 0 32px;
  }

  .container {
    padding: 0 32px;
    max-width: 1400px;
    margin: 0 auto;
  }

  .courses-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
  }

  .training-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
  }

  .paths-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
  }

  .reviews-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 48px;
  }
}

/* 大屏幕 (1200px-1399px) */
@media (max-width: 1399px) and (min-width: 1200px) {
  .container {
    padding: 0 24px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .courses-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }

  .training-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
  }

  .paths-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }

  .reviews-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
  }
}

/* 中等屏幕 (992px-1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
  .banner-content {
    padding: 0 20px;
    gap: 40px;
  }

  .container {
    padding: 0 20px;
    max-width: 992px;
    margin: 0 auto;
  }

  .courses-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .training-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .paths-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .reviews-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }

  .section-title {
    font-size: 26px;
  }

  .banner-title {
    font-size: 3rem;
  }
}

/* 小屏幕 (768px-991px) */
@media (max-width: 991px) and (min-width: 768px) {
  .banner-content {
    padding: 0 16px;
    gap: 32px;
  }

  .container {
    padding: 0 16px;
    max-width: 768px;
    margin: 0 auto;
  }

  .banner-title {
    font-size: 2.5rem;
    line-height: 1.2;
  }

  .section-title {
    font-size: 24px;
  }

  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 50px 0;
  }

  .courses-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .training-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }

  .paths-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .reviews-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .stats-section {
    width: 100%;
  }

  .stats-grid {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }

  .stat-item {
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
    padding: 16px 0;
    justify-content: center;
    text-align: center;
  }

  .stat-item:last-child {
    border-bottom: none;
  }

  .course-image {
    width: 100%;
    height: 140px;
  }

  .course-image img {
    width: 100%;
    height: 140px;
  }

  .training-image {
    width: 100%;
    height: 180px;
  }

  .training-image img {
    width: 100%;
    height: 180px;
  }
}

/* 移动设备 (576px-767px) */
@media (max-width: 767px) and (min-width: 576px) {
  .banner-content {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
    padding: 0 16px;
  }

  .container {
    padding: 0 16px;
    max-width: 576px;
    margin: 0 auto;
  }

  .banner-title {
    font-size: 2rem;
    line-height: 1.3;
  }

  .banner-subtitle {
    font-size: 1.1rem;
  }

  .section-title {
    font-size: 20px;
  }

  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 40px 0;
  }

  .courses-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .training-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .paths-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .reviews-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .stats-section {
    width: 100%;
  }

  .stats-grid {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .stat-item {
    border-right: none;
    border-bottom: 1px solid #e8e8e8;
    padding: 12px 0;
    justify-content: center;
    text-align: center;
  }

  .stat-item:last-child {
    border-bottom: none;
  }

  .course-image {
    width: 100%;
    height: 200px;
  }

  .course-image img {
    width: 100%;
    height: 200px;
  }

  .training-image {
    width: 100%;
    height: 160px;
  }

  .training-image img {
    width: 100%;
    height: 160px;
  }

  .review-card {
    width: 100%;
    min-height: auto;
  }

  .footer-title {
    font-size: 18px;
  }
}

/* 小移动设备 (≤575px) */
@media (max-width: 575px) {
  .banner-content {
    grid-template-columns: 1fr;
    gap: 20px;
    text-align: center;
    padding: 0 12px;
  }

  .container {
    padding: 0 12px;
    max-width: 100%;
    margin: 0 auto;
  }

  .banner-title {
    font-size: 1.6rem;
    line-height: 1.4;
  }

  .banner-subtitle {
    font-size: 1rem;
    line-height: 1.5;
  }

  .section-title {
    font-size: 18px;
  }

  .section-subtitle {
    font-size: 12px;
  }

  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 32px 0;
  }

  .section-header {
    margin-bottom: 20px;
  }

  .courses-grid,
  .training-grid,
  .paths-grid,
  .reviews-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stats-section {
    width: 100%;
    height: auto;
    padding: 20px 0;
  }

  .stats-grid {
    flex-direction: column;
    gap: 8px;
    padding: 8px;
  }

  .stat-item {
    border-right: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 12px 8px;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 8px;
  }

  .stat-item:last-child {
    border-bottom: none;
  }

  .stat-icon {
    width: 48px;
    height: 48px;
  }

  .stat-icon img {
    width: 48px;
    height: 48px;
  }

  .stat-number {
    font-size: 18px;
  }

  .stat-label {
    font-size: 12px;
  }

  .course-image {
    width: 100%;
    height: 180px;
  }

  .course-image img {
    width: 100%;
    height: 180px;
  }

  .training-image {
    width: 100%;
    height: 140px;
  }

  .training-image img {
    width: 100%;
    height: 140px;
  }

  .review-card {
    width: 100%;
    min-height: auto;
    padding: 16px;
  }

  .reviewer-name {
    font-size: 20px;
  }

  .reviewer-title {
    font-size: 16px;
  }

  .review-content {
    font-size: 14px;
  }

  .path-free-label {
    font-size: 18px;
  }

  .path-description {
    font-size: 14px;
  }

  .detail-label,
  .detail-value {
    font-size: 14px;
  }

  .footer-title {
    font-size: 16px;
  }

  .avatar-group {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .instructor-avatar {
    width: 50px;
    height: 50px;
  }
}

/* 超小屏幕 (≤360px) */
@media (max-width: 360px) {
  .container {
    padding: 0 8px;
  }

  .banner-title {
    font-size: 1.4rem;
  }

  .banner-subtitle {
    font-size: 0.9rem;
  }

  .section-title {
    font-size: 16px;
  }

  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 24px 0;
  }

  .stat-item {
    padding: 8px 4px;
  }

  .course-image,
  .training-image {
    height: 120px;
  }

  .course-image img,
  .training-image img {
    height: 120px;
  }

  .review-card {
    padding: 12px;
  }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 20px 0;
  }

  .banner-content {
    gap: 16px;
  }

  .section-header {
    margin-bottom: 16px;
  }

  .stats-section {
    min-height: auto;
    padding: 20px 0;
  }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .section-title-image,
  .footer-logo-img,
  .cert-logo-img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* 打印样式 */
@media print {
  .banner-content,
  .stats-section,
  .footer-container {
    display: none;
  }

  .popular-courses,
  .special-training,
  .learning-paths,
  .featured-reviews {
    padding: 20px 0;
    page-break-inside: avoid;
  }

  .course-card,
  .training-card,
  .path-card,
  .review-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* 全屏模式样式现在在App.vue中统一管理 */

</style>
