<template>
  <section class="section-reviews relative overflow-hidden py-28" ref="sectionRef">
    <!-- 背景 -->
    <div class="absolute inset-0" style="background: linear-gradient(180deg, #f8f5ff 0%, #ffffff 40%, #f0f9ff 100%);"></div>
    <div class="absolute inset-0 pointer-events-none overflow-hidden">
      <div class="review-bg-orb review-bg-orb-1"></div>
      <div class="review-bg-orb review-bg-orb-2"></div>
    </div>

    <div class="relative z-10 max-w-7xl mx-auto px-6">
      <!-- 标题 -->
      <div class="text-center mb-16 reveal-up" :class="{ 'is-visible': isVisible }">
        <span class="inline-flex items-center gap-2 bg-amber-50 border border-amber-200 text-amber-600 text-xs font-bold px-4 py-1.5 rounded-full mb-6 uppercase tracking-widest">
          <span class="w-1.5 h-1.5 bg-amber-500 rounded-full animate-pulse"></span>
          用户评价
        </span>
        <h2 class="text-5xl lg:text-6xl font-black text-gray-900 mb-5 leading-tight">
          真实用户，<span class="reviews-gradient-text">真实反馈</span>
        </h2>
        <p class="text-gray-500 text-lg max-w-xl mx-auto">来自全球 50,000+ 用户的真实评价，见证暴米AI如何改变工作方式</p>
      </div>

      <!-- 综合评分横幅 -->
      <div class="reviews-score-banner reveal-up" :class="{ 'is-visible': isVisible }" style="transition-delay: 0.15s;">
        <div class="text-center">
          <div class="text-7xl font-black text-gray-900 mb-2 leading-none">4.9</div>
          <div class="flex justify-center gap-0.5 mb-2">
            <span v-for="i in 5" :key="i" class="text-amber-400 text-2xl">★</span>
          </div>
          <div class="text-gray-500 text-sm font-medium">综合评分</div>
        </div>
        <div class="w-px h-20 bg-gray-200 hidden md:block"></div>
        <div class="flex flex-col gap-2.5 min-w-48">
          <div v-for="item in ratingBreakdown" :key="item.stars" class="flex items-center gap-3">
            <span class="text-gray-400 text-xs w-8 text-right font-medium">{{ item.stars }}星</span>
            <div class="flex-1 h-2 bg-gray-100 rounded-full overflow-hidden">
              <div class="h-full bg-gradient-to-r from-amber-400 to-yellow-300 rounded-full transition-all duration-1000"
                :style="{ width: isVisible ? `${item.percent}%` : '0%' }"></div>
            </div>
            <span class="text-gray-400 text-xs w-8 font-medium">{{ item.percent }}%</span>
          </div>
        </div>
        <div class="w-px h-20 bg-gray-200 hidden md:block"></div>
        <div class="flex gap-10">
          <div v-for="stat in ratingStats" :key="stat.label" class="text-center">
            <div class="text-3xl font-black text-gray-900 mb-1">{{ stat.value }}</div>
            <div class="text-gray-500 text-xs">{{ stat.label }}</div>
          </div>
        </div>
      </div>

      <!-- 精选评价 - 交错布局 -->
      <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6 reveal-up" :class="{ 'is-visible': isVisible }" style="transition-delay: 0.3s;">
        <!-- 大卡片（左侧，占2列） -->
        <div class="lg:col-span-2 review-card-dark group">
          <div class="review-bg-glow"></div>
          <div class="text-violet-400/20 text-9xl font-serif leading-none mb-4 select-none">"</div>
          <blockquote class="text-white text-xl lg:text-2xl font-medium leading-relaxed mb-6">
            暴米AI 彻底改变了我们的内容生产流程。以前需要 3 个人花一天时间完成的工作，现在一个工作流 20 分钟就搞定了，效率提升了
            <span class="text-violet-300 font-black">10 倍以上</span>。
          </blockquote>
          <div class="flex items-center gap-4">
            <img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=60&h=60&fit=crop" alt="用户"
              class="w-12 h-12 rounded-full object-cover ring-2 ring-violet-500/40"/>
            <div>
              <div class="text-white font-bold">张明远</div>
              <div class="text-white/40 text-sm">某电商平台 · 内容总监</div>
            </div>
            <div class="ml-auto flex gap-0.5">
              <span v-for="i in 5" :key="i" class="text-amber-400 text-sm">★</span>
            </div>
          </div>
          <div class="mt-5 flex flex-wrap gap-2">
            <span class="review-tag-violet">效率提升 10x</span>
            <span class="review-tag-green">节省 80% 人力</span>
            <span class="review-tag-blue">使用 n8n + Coze</span>
          </div>
        </div>

        <!-- 右侧两个小卡片 -->
        <div class="flex flex-col gap-6">
          <div v-for="review in sideReviews" :key="review.name"
            class="review-card-light group">
            <div class="text-blue-200 text-5xl font-serif leading-none mb-3 select-none">"</div>
            <blockquote class="text-gray-700 text-sm leading-relaxed mb-4">{{ review.quote }}</blockquote>
            <div class="flex items-center gap-3">
              <img :src="review.avatar" :alt="review.name" class="w-9 h-9 rounded-full object-cover ring-2 ring-gray-100"/>
              <div>
                <div class="text-gray-800 font-bold text-sm">{{ review.name }}</div>
                <div class="text-gray-400 text-xs">{{ review.role }}</div>
              </div>
              <div class="ml-auto text-amber-400 text-xs font-bold">★ {{ review.rating }}</div>
            </div>
            <div class="mt-3 flex flex-wrap gap-1.5">
              <span v-for="tag in review.tags" :key="tag"
                class="text-xs bg-gray-50 text-gray-500 border border-gray-100 px-2 py-0.5 rounded-full hover:bg-violet-50 hover:text-violet-600 hover:border-violet-100 transition-colors duration-200 cursor-default">{{ tag }}</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 第二行：3个等宽卡片 -->
      <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-14 reveal-up" :class="{ 'is-visible': isVisible }" style="transition-delay: 0.45s;">
        <div v-for="(review, idx) in midReviews" :key="review.name"
          class="review-card-light group"
          :style="{ transitionDelay: `${0.45 + idx * 0.08}s` }">
          <div class="absolute top-0 right-0 w-28 h-28 rounded-full opacity-10 pointer-events-none"
            :style="`background: radial-gradient(circle, ${review.accent}, transparent); transform: translate(30%, -30%);`"></div>
          <div class="text-4xl font-serif leading-none mb-3 select-none text-blue-200">"</div>
          <blockquote class="text-gray-600 text-sm leading-relaxed mb-4">{{ review.quote }}</blockquote>
          <div class="flex items-center gap-3">
            <img :src="review.avatar" :alt="review.name" class="w-9 h-9 rounded-full object-cover ring-2 ring-gray-100"/>
            <div>
              <div class="font-bold text-sm text-gray-900">{{ review.name }}</div>
              <div class="text-xs text-gray-400">{{ review.role }}</div>
            </div>
            <div class="ml-auto text-amber-400 text-xs font-bold">★ {{ review.rating }}</div>
          </div>
          <div class="mt-3 inline-flex items-center gap-1.5 text-xs font-medium px-3 py-1.5 rounded-full" :class="review.tagClass">
            {{ review.result }}
          </div>
        </div>
      </div>

      <!-- 品牌墙 -->
      <div class="pt-8 border-t border-gray-100 reveal-up" :class="{ 'is-visible': isVisible }" style="transition-delay: 0.6s;">
        <div class="text-center text-gray-400 text-sm mb-8 font-medium tracking-wide uppercase">来自各行各业的用户信任</div>
        <div class="overflow-hidden">
          <div class="flex gap-4 brand-scroll">
            <div v-for="(brand, i) in [...brands, ...brands]" :key="i"
              class="flex-shrink-0 flex items-center gap-2.5 bg-white border border-gray-100 rounded-2xl px-5 py-3 hover:border-violet-200 hover:bg-violet-50 hover:shadow-md transition-all duration-300 cursor-pointer group">
              <span class="text-xl group-hover:scale-110 transition-transform duration-200">{{ brand.icon }}</span>
              <span class="text-gray-600 text-sm font-semibold whitespace-nowrap group-hover:text-violet-600 transition-colors duration-200">{{ brand.name }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const isVisible = ref(false)
const sectionRef = ref(null)

onMounted(() => {
  const observer = new IntersectionObserver(
    (entries) => { entries.forEach(e => { if (e.isIntersecting) { isVisible.value = true; observer.unobserve(e.target) } }) },
    { threshold: 0.1 }
  )
  if (sectionRef.value) observer.observe(sectionRef.value)
})

const ratingBreakdown = [
  { stars: 5, percent: 87 },
  { stars: 4, percent: 10 },
  { stars: 3, percent: 2 },
  { stars: 2, percent: 1 },
  { stars: 1, percent: 0 },
]

const ratingStats = [
  { value: '50,000+', label: '总评价数' },
  { value: '98%', label: '推荐率' },
  { value: '4.9/5', label: '平均评分' },
]

const sideReviews = [
  {
    name: '李晓雨', role: '自媒体创作者',
    avatar: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=40&h=40&fit=crop',
    quote: '用 Coze 搭建了一个自动生成小红书内容的工作流，每天自动发布 5 篇，粉丝涨了 3 倍！',
    rating: '5.0', tags: ['Coze', '内容创作', '小红书']
  },
  {
    name: '王建国', role: '企业 IT 负责人',
    avatar: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=40&h=40&fit=crop',
    quote: 'FastGPT 知识库让我们的客服机器人准确率从 60% 提升到 95%，客户满意度大幅提升。',
    rating: '4.9', tags: ['FastGPT', '客服', '企业']
  }
]

const midReviews = [
  {
    name: '陈思远', role: '数据分析师',
    avatar: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=40&h=40&fit=crop',
    quote: 'n8n 的可视化工作流让我把每周的数据报表完全自动化，节省了 8 小时/周，现在可以专注更有价值的分析工作。',
    rating: '5.0', accent: '#8b5cf6', result: '节省 8h/周', tagClass: 'bg-violet-50 text-violet-600'
  },
  {
    name: '刘美华', role: '电商运营总监',
    avatar: 'https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=40&h=40&fit=crop',
    quote: '暴米AI 的课程体系非常系统，从入门到实战，让我们团队 5 个人都快速掌握了 AI 工作流，ROI 非常高。',
    rating: '4.9', accent: '#3b82f6', result: '团队全员上手', tagClass: 'bg-blue-50 text-blue-600'
  },
  {
    name: '赵志强', role: 'SaaS 创业者',
    avatar: 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=40&h=40&fit=crop',
    quote: '用 Dify 搭建了产品的 AI 功能，原本需要 2 个月开发的功能，用工作流 3 天就上线了，太震撼了。',
    rating: '5.0', accent: '#10b981', result: '3天上线AI功能', tagClass: 'bg-emerald-50 text-emerald-600'
  }
]

const brands = [
  { icon: '🏢', name: '字节跳动' },
  { icon: '🛒', name: '某电商平台' },
  { icon: '📱', name: '移动互联网公司' },
  { icon: '🏦', name: '金融科技企业' },
  { icon: '🎓', name: '在线教育机构' },
  { icon: '🏥', name: '医疗健康平台' },
  { icon: '🚗', name: '汽车科技公司' },
  { icon: '🎮', name: '游戏公司' },
]
</script>

<style scoped>
/* 背景光晕 */
.review-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
}
.review-bg-orb-1 {
  width: 500px; height: 500px;
  top: -100px; right: -100px;
  background: radial-gradient(circle, rgba(245,158,11,0.08) 0%, transparent 70%);
  animation: reviewOrbFloat 14s ease-in-out infinite;
}
.review-bg-orb-2 {
  width: 400px; height: 400px;
  bottom: -80px; left: -80px;
  background: radial-gradient(circle, rgba(59,130,246,0.08) 0%, transparent 70%);
  animation: reviewOrbFloat 18s ease-in-out infinite reverse;
}
@keyframes reviewOrbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(20px, -25px); }
}

/* 渐变文字 */
.reviews-gradient-text {
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 评分横幅 */
.reviews-score-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-bottom: 48px;
  padding: 32px 40px;
  background: linear-gradient(135deg, rgba(245,158,11,0.06) 0%, rgba(59,130,246,0.04) 100%);
  border: 1px solid rgba(245,158,11,0.15);
  border-radius: 28px;
}

/* 深色评价卡片 */
.review-card-dark {
  position: relative;
  background: linear-gradient(135deg, #1a1040, #0d1b3e);
  border-radius: 24px;
  padding: 32px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(139,92,246,0.2);
}
.review-card-dark:hover {
  transform: translateY(-6px);
  box-shadow: 0 30px 70px rgba(0,0,0,0.25), 0 0 0 1px rgba(139,92,246,0.3);
}
.review-bg-glow {
  position: absolute;
  top: 0; right: 0;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.15), transparent);
  transform: translate(30%, -30%);
  pointer-events: none;
}

/* 浅色评价卡片 */
.review-card-light {
  position: relative;
  background: white;
  border: 1px solid #f3f4f6;
  border-radius: 24px;
  padding: 24px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.review-card-light:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.08);
  border-color: rgba(196,181,253,0.5);
}

/* 标签 */
.review-tag-violet {
  font-size: 12px;
  background: rgba(139,92,246,0.15);
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,0.25);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}
.review-tag-green {
  font-size: 12px;
  background: rgba(16,185,129,0.15);
  color: #34d399;
  border: 1px solid rgba(16,185,129,0.25);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}
.review-tag-blue {
  font-size: 12px;
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.25);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}

/* 品牌滚动 */
.brand-scroll {
  animation: brandScroll 25s linear infinite;
}
.brand-scroll:hover {
  animation-play-state: paused;
}
@keyframes brandScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* 滚动动画 */
.reveal-up {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.reveal-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 响应式 ===== */

/* 标题自适应 */
.section-reviews h2 {
  font-size: clamp(2rem, 5vw, 3.75rem);
}

/* 平板（≤1024px）*/
@media (max-width: 1024px) {
  .section-reviews { padding-top: 5rem; padding-bottom: 5rem; }
  .section-reviews .max-w-7xl { padding-left: 1rem; padding-right: 1rem; }
  .reviews-score-banner { gap: 24px; padding: 24px 28px; }
}

/* 手机横屏 / 小平板（≤768px）*/
@media (max-width: 768px) {
  .section-reviews { padding-top: 4rem; padding-bottom: 4rem; }
  /* 评分横幅 */
  .reviews-score-banner { gap: 16px; padding: 20px; flex-direction: column; align-items: flex-start; }
  .reviews-score-banner .text-7xl { font-size: 3.5rem; }
  .reviews-score-banner .text-3xl { font-size: 1.5rem; }
  /* 大卡片内边距 */
  .review-card-dark { padding: 20px; }
  .review-card-dark blockquote { font-size: 1rem; }
  .review-card-dark .text-9xl { font-size: 4rem; margin-bottom: 8px; }
  /* 小卡片 */
  .review-card-light { padding: 16px; }
}

/* 手机竖屏（≤480px）*/
@media (max-width: 480px) {
  .section-reviews { padding-top: 3rem; padding-bottom: 3rem; }
  .reviews-score-banner { padding: 16px; }
  .reviews-score-banner .text-7xl { font-size: 2.75rem; }
  .review-card-dark { padding: 16px; }
  .review-card-dark blockquote { font-size: 0.9rem; }
  .review-card-dark .text-9xl { font-size: 3rem; }
  .review-card-dark .w-12 { width: 2.25rem; height: 2.25rem; }
  .review-card-light { padding: 14px; }
  .review-card-light .text-base { font-size: 0.875rem; }
  .review-tag-violet, .review-tag-green, .review-tag-blue { font-size: 10px; padding: 3px 8px; }
}

/* 极小屏（≤360px）*/
@media (max-width: 360px) {
  .review-card-dark { padding: 12px; }
  .review-card-dark blockquote { font-size: 0.8rem; }
  .review-card-light { padding: 10px; }
}
</style>
