page

import React, { useState } from 'react';
import { Card, CardContent } from '@/components/ui/card';
import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from '@/components/ui/carousel';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';

// Resource Stats Section
const ResourceStats = () => {
  const stats = [
    { icon: '🔷', value: '10/200', label: '芯片/元素' },
    { icon: '📊', value: '10000', label: '热负荷' },
    { icon: '📋', value: '2000', label: '基础用例' },
    { icon: '💾', value: '300', label: 'DTS问题单' }
  ];

  return (
    <div className="bg-white border-b border-gray-100">
      <div className="max-w-[1200px] mx-auto px-8 py-10">
        <div className="grid grid-cols-4 gap-8">
          {stats.map((stat, index) => (
            <Card key={index} className="hover:shadow-md transition-all duration-300 border-gray-100">
              <CardContent className="p-8 flex items-center gap-5">
                <div className="text-5xl flex-shrink-0">{stat.icon}</div>
                <div className="flex-1">
                  <div className="text-3xl font-bold text-gray-900 mb-1">{stat.value}</div>
                  <div className="text-sm text-gray-500">{stat.label}</div>
                </div>
              </CardContent>
            </Card>
          ))}
        </div>
      </div>
    </div>
  );
};

// Projects Carousel Section
const ProjectsCarousel = () => {
  const projects = [
    { 
      year: '2025', 
      subtitle: '芯片系统上市 已形成文档',
      image: '🎨',
      title: '已发布Changsha、Xian、Atherton',
      description: '2025年度重要发布'
    },
    { 
      year: '2024', 
      subtitle: '系统验证 CFRO架构',
      image: '🎯',
      title: '已发布HBtv、CFRO',
      description: '2024年度核心项目'
    },
    { 
      year: '2023', 
      subtitle: '云端测试 测试框架',
      image: '☁️',
      title: '已发布C2T',
      description: '2023年度突破性进展'
    }
  ];

  return (
    <div className="max-w-[1200px] mx-auto px-8 py-20">
      <div className="grid grid-cols-3 gap-8">
        {projects.map((project, index) => (
          <Card key={index} className="hover:shadow-xl transition-all duration-300 hover:-translate-y-2 border-gray-100">
            <CardContent className="p-0">
              <div className="p-8 pb-6 text-center">
                <div className="text-5xl font-bold text-gray-900 mb-2">{project.year}</div>
                <div className="text-sm text-gray-500">{project.subtitle}</div>
              </div>
              
              <div className="bg-gradient-to-br from-blue-50 via-cyan-50 to-blue-50 h-56 flex items-center justify-center text-7xl mx-8 mb-6 rounded-xl shadow-inner">
                {project.image}
              </div>
              
              <div className="px-8 pb-8 text-center">
                <div className="text-lg font-semibold text-gray-900 mb-2">{project.title}</div>
                <div className="text-sm text-gray-500">{project.description}</div>
              </div>
            </CardContent>
          </Card>
        ))}
      </div>
    </div>
  );
};

// Digital Lab Section
const DigitalLab = () => {
  const [activeTab, setActiveTab] = useState('device');

  const labStats = [
    { icon: '⛔', value: '20', label: '单元' },
    { icon: '🔵', value: '1000', label: '数量' },
    { icon: '🏢', value: '619', label: '工作站' },
    { icon: '🟣', value: '80%', label: '覆盖率' }
  ];

  const tabData = {
    device: [
      { label: '在线设备', value: '400台', icon: '💻' },
      { label: '离线设备', value: '100台', icon: '💻' },
      { label: 'CPU利用率', value: '78%', icon: '💻' },
      { label: '运维模式', value: '24/7', icon: '💻' }
    ],
    test: [
      { label: '累计测试', value: '100台', icon: '🧪' },
      { label: '测试中', value: '50台', icon: '🧪' },
      { label: '成功率', value: '95%', icon: '🧪' },
      { label: '测试时长', value: '24h', icon: '🧪' }
    ],
    system: [
      { label: '系统数量', value: '200个', icon: '⚙️' },
      { label: '运行中', value: '180个', icon: '⚙️' },
      { label: '维护中', value: '20个', icon: '⚙️' },
      { label: '可用率', value: '90%', icon: '⚙️' }
    ]
  };

  return (
    <div className="bg-gradient-to-b from-gray-50 to-white py-20">
      <div className="max-w-[1200px] mx-auto px-8">
        <h2 className="text-4xl font-bold text-gray-900 mb-12 text-center">数字化实验室</h2>
        
        <div className="grid grid-cols-4 gap-8 mb-12">
          {labStats.map((stat, index) => (
            <Card key={index} className="hover:shadow-md transition-all duration-300 bg-white border-gray-100">
              <CardContent className="p-8 text-center">
                <div className="text-6xl mb-5">{stat.icon}</div>
                <div className="text-4xl font-bold text-gray-900 mb-2">{stat.value}</div>
                <div className="text-sm text-gray-500">{stat.label}</div>
              </CardContent>
            </Card>
          ))}
        </div>

        <div className="flex justify-center mb-8">
          <Tabs value={activeTab} onValueChange={setActiveTab} className="w-auto">
            <TabsList className="bg-white shadow-sm border border-gray-200 p-1">
              <TabsTrigger value="device" className="px-8 py-3 data-[state=active]:bg-blue-50 data-[state=active]:text-blue-600">
                在线设备
              </TabsTrigger>
              <TabsTrigger value="test" className="px-8 py-3 data-[state=active]:bg-blue-50 data-[state=active]:text-blue-600">
                累计测试
              </TabsTrigger>
              <TabsTrigger value="system" className="px-8 py-3 data-[state=active]:bg-blue-50 data-[state=active]:text-blue-600">
                系统运维
              </TabsTrigger>
            </TabsList>
          </Tabs>
        </div>

        <Card className="bg-white border-gray-100 shadow-sm">
          <CardContent className="p-10">
            <div className="grid grid-cols-4 gap-10 text-center">
              {tabData[activeTab].map((stat, index) => (
                <div key={index} className="space-y-3">
                  <div className="text-5xl">{stat.icon}</div>
                  <div className="text-sm text-gray-500 font-medium">{stat.label}</div>
                  <div className="text-3xl font-bold text-gray-900">{stat.value}</div>
                </div>
              ))}
            </div>
          </CardContent>
        </Card>
      </div>
    </div>
  );
};

// Development Timeline Section
const DevelopmentTimeline = () => {
  const milestones = [
    { year: '2008', items: ['黑盒测试', '系统功能验证'], position: 'low' },
    { year: '2016', items: ['自动化测试工厂', '测试赋能'], position: 'high' },
    { year: '2018', items: ['测试能力量化', 'C2C测试'], position: 'low' },
    { year: '2020', items: ['覆盖测试', '失效测试', '虚拟自动化'], position: 'high' },
    { year: '2025', items: ['AI测试应用', '更快化验证', '测试工具链'], position: 'low' }
  ];

  return (
    <div className="bg-white py-20">
      <div className="max-w-[1200px] mx-auto px-8">
        <h2 className="text-4xl font-bold text-gray-900 mb-20 text-center">发展路标</h2>
        
        <div className="relative" style={{ height: '320px' }}>
          {/* SVG Path Line with gradient */}
          <svg className="absolute inset-0 w-full h-full" style={{ zIndex: 0 }}>
            <defs>
              <linearGradient id="lineGradient" x1="0%" y1="0%" x2="100%" y2="0%">
                <stop offset="0%" stopColor="#06b6d4" stopOpacity="0.8" />
                <stop offset="25%" stopColor="#3b82f6" stopOpacity="0.9" />
                <stop offset="50%" stopColor="#8b5cf6" stopOpacity="0.9" />
                <stop offset="75%" stopColor="#3b82f6" stopOpacity="0.9" />
                <stop offset="100%" stopColor="#06b6d4" stopOpacity="0.8" />
              </linearGradient>
              <filter id="glow">
                <feGaussianBlur stdDeviation="2" result="coloredBlur"/>
                <feMerge>
                  <feMergeNode in="coloredBlur"/>
                  <feMergeNode in="SourceGraphic"/>
                </feMerge>
              </filter>
            </defs>
            <path
              d="M 60 200 Q 150 160, 240 120 T 420 120 T 600 120 T 780 120 T 960 200"
              stroke="url(#lineGradient)"
              strokeWidth="4"
              fill="none"
              filter="url(#glow)"
            />
          </svg>

          {/* Milestones */}
          <div className="relative flex justify-between items-start h-full" style={{ zIndex: 1 }}>
            {milestones.map((milestone, index) => (
              <div 
                key={index} 
                className="flex flex-col items-center w-1/5"
                style={{ 
                  marginTop: milestone.position === 'high' ? '10px' : '160px'
                }}
              >
                {/* Content above */}
                <div className="text-center mb-6 space-y-1">
                  {milestone.items.map((item, idx) => (
                    <div key={idx} className="text-sm text-gray-600 font-medium">
                      • {item}
                    </div>
                  ))}
                </div>
                
                {/* Year */}
                <div className="text-3xl font-bold text-gray-900 mb-5 tracking-tight">{milestone.year}</div>
                
                {/* Node with pulse effect */}
                <div className="relative">
                  <div className="w-5 h-5 bg-gradient-to-br from-cyan-400 to-blue-500 rounded-full shadow-lg shadow-cyan-500/50 relative z-10">
                  </div>
                  <div className="absolute inset-0 w-5 h-5 bg-cyan-400 rounded-full animate-ping opacity-40"></div>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
};

// Footer Section
const Footer = () => {
  const footerSections = [
    { title: '帮助文档', links: ['平台介绍', '新手指南'] },
    { title: '服务与认证', links: ['服务认证'] },
    { title: '外部站点', links: ['CIDA', 'DBCX', 'HiAPM', 'HiDesk', 'DTS', 'HiALM'] }
  ];

  return (
    <footer className="bg-gradient-to-b from-white to-gray-50 border-t border-gray-100">
      <div className="max-w-[1200px] mx-auto px-8 py-16">
        <div className="grid grid-cols-4 gap-12 mb-12">
          {/* Kirin Logo Section */}
          <div>
            <div className="flex items-center gap-3 mb-2">
              <div className="w-10 h-10 bg-gradient-to-br from-red-500 to-pink-600 rounded-lg shadow-md"></div>
              <span className="text-xl font-bold text-gray-900">Kirin</span>
            </div>
            <div className="text-sm text-gray-600 ml-13">先进测试中心</div>
          </div>

          {/* Footer Links */}
          {footerSections.map((section, index) => (
            <div key={index}>
              <h3 className="font-semibold mb-4 text-gray-900 text-base">{section.title}</h3>
              <ul className="space-y-2.5">
                {section.links.map((link, idx) => (
                  <li key={idx}>
                    <a href="#" className="text-gray-600 hover:text-blue-600 transition-colors text-sm">
                      {link}
                    </a>
                  </li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        <div className="border-t border-gray-200 pt-8 text-center text-sm text-gray-500">
          Copyright © Huawei Technologies Co., Ltd. 2025. All rights reserved.
        </div>
      </div>
    </footer>
  );
};

// Main Page Component
export default function Page() {
  return (
    <div className="min-h-screen bg-white">
      <ResourceStats />
      <ProjectsCarousel />
      <DigitalLab />
      <DevelopmentTimeline />
      <Footer />
    </div>
  );
}