'use client';

import { motion } from 'framer-motion';
import { useInView } from 'framer-motion';
import { useRef } from 'react';
import { StaticLink } from '@/components/ui/static-link';
import { Button } from '@/components/ui/button';
import { ArrowRight, Lightbulb, Cpu, Users } from 'lucide-react';
import { InkGlowCard } from '@/components/ui/ink-glow-card';

const SOLUTIONS_OVERVIEW = [
  {
    icon: Lightbulb,
    title: '参谋伙伴',
    subtitle: '数字化转型咨询',
    description: '帮您看清前路，迈对第一步。用行业智慧洞察趋势，用理性分析避开陷阱。',
    points: ['行业趋势洞察报告', '成熟度评估', '实施路径规划'],
  },
  {
    icon: Cpu,
    title: '技术伙伴',
    subtitle: '信息技术解决方案',
    description: '让技术真正为业务服务。不追逐"最火"的技术，只选择"最对"的技术。',
    points: ['业务场景调研', '技术方案定制', '敏捷交付迭代'],
  },
  {
    icon: Users,
    title: '同行伙伴',
    subtitle: '长期陪跑服务',
    description: '从需求理解到产品落地，陪伴才是常态。当产品真正为您所用那天，才是我们成为伙伴的开始。',
    points: ['专属客户成功经理', '季度业务复盘', '7×24小时响应'],
  },
];

const solutionAccents: { rgb: string; glowStart: string; glowEnd: string }[] = [
  { rgb: '196, 30, 58', glowStart: '#C41E3A', glowEnd: '#D97706' },
  { rgb: '37, 99, 235', glowStart: '#2563EB', glowEnd: '#7C3AED' },
  { rgb: '22, 163, 74', glowStart: '#16A34A', glowEnd: '#0891B2' },
];

export function HomeSolutionsSection() {
  const ref = useRef(null);
  const isInView = useInView(ref, { once: true, margin: '-100px' });

  return (
    <section id="solutions" role="region" aria-labelledby="solutions-heading" className="py-20 md:py-28 bg-white" ref={ref}>
      <div className="container-wide">
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={isInView ? { opacity: 1, y: 0 } : {}}
          transition={{ duration: 0.5, ease: [0.16, 1, 0.3, 1] }}
          className="text-center max-w-3xl mx-auto mb-14"
        >
          <h2 id="solutions-heading" className="text-3xl sm:text-4xl font-semibold text-[#1C1C1C] mb-4">
            三种角色，一种<span className="text-[#C41E3A] font-calligraphy">身份</span>
          </h2>
          <p className="text-base text-[#595959]">
            您的数字化转型成长伙伴——从战略咨询到技术落地，再到长期陪跑
          </p>
        </motion.div>

        <div className="grid grid-cols-1 md:grid-cols-3 gap-6 md:gap-8">
          {SOLUTIONS_OVERVIEW.map((item, idx) => {
            const Icon = item.icon;
            const accent = solutionAccents[idx % solutionAccents.length]!;
            return (
              <InkGlowCard
                key={item.title}
                index={idx}
                accentColorRgb={accent.rgb}
                glowStart={accent.glowStart}
                glowEnd={accent.glowEnd}
              >
                <div className="p-6 md:p-8">
                  <div
                    className="w-11 h-11 rounded-xl flex items-center justify-center mb-5"
                    style={{ backgroundColor: `rgba(${accent.rgb}, 0.06)` }}
                  >
                    <Icon className="w-5 h-5" style={{ color: accent.glowStart }} strokeWidth={1.8} />
                  </div>
                  <h3 className="text-lg font-semibold text-[#1C1C1C] mb-1">{item.title}</h3>
                  <p className="text-xs text-[#C41E3A] font-medium mb-3">{item.subtitle}</p>
                  <p className="text-sm text-[#595959] leading-relaxed mb-5">{item.description}</p>
                  <ul className="space-y-2">
                    {item.points.map((point, i) => (
                      <li key={i} className="flex items-start gap-2 text-sm text-[#595959]">
                        <div className="w-1.5 h-1.5 bg-[#C41E3A] rounded-full mt-1.5 shrink-0" />
                        {point}
                      </li>
                    ))}
                  </ul>
                </div>
              </InkGlowCard>
            );
          })}
        </div>

        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={isInView ? { opacity: 1, y: 0 } : {}}
          transition={{ duration: 0.5, delay: 0.3, ease: [0.16, 1, 0.3, 1] }}
          className="mt-12 text-center"
        >
          <Button size="lg" asChild>
            <StaticLink href="/solutions">
              了解完整解决方案
              <ArrowRight className="ml-2 w-4 h-4" />
            </StaticLink>
          </Button>
        </motion.div>
      </div>
    </section>
  );
}
