'use client';

import { useScrollReveal } from '@/hooks/useScrollReveal';
import SectionTitle from "../Common/SectionTitle";

/**
 * Framework Section - Digital Growth Framework
 * Displays 6-layer framework with animated flow
 */

const frameworks = [
  {
    id: 1,
    icon: 'i-ai',
    label: '01 · NỀN TẢNG',
    title: 'AI',
    description: 'Trí tuệ nhân tạo là lớp tư duy trung tâm, hỗ trợ phân tích, phản hồi và ra quyết định xuyên suốt hệ thống.',
  },
  {
    id: 2,
    icon: 'i-website',
    label: '02 · GIAO DIỆN',
    title: 'Website',
    description: 'Điểm chạm đầu tiên với khách hàng — nơi thu thập nhu cầu và chuyển hoá thành dữ liệu có giá trị.',
  },
  {
    id: 3,
    icon: 'i-crm',
    label: '03 · QUAN HỆ',
    title: 'CRM',
    description: 'Tập trung toàn bộ dữ liệu khách hàng vào một nơi duy nhất, loại bỏ thất thoát thông tin giữa các phòng ban.',
  },
  {
    id: 4,
    icon: 'i-automation',
    label: '04 · VẬN HÀNH',
    title: 'Automation',
    description: 'Tự động hoá các quy trình lặp lại, kết nối công cụ rời rạc thành một dòng chảy công việc thống nhất.',
  },
  {
    id: 5,
    icon: 'i-data',
    label: '05 · TÀI SẢN',
    title: 'Data',
    description: 'Dữ liệu được chuẩn hoá và lưu trữ có cấu trúc — trở thành tài sản để phân tích và ra quyết định.',
  },
  {
    id: 6,
    icon: 'i-dashboard',
    label: '06 · QUYẾT ĐỊNH',
    title: 'Dashboard',
    description: 'Trực quan hoá toàn bộ hoạt động kinh doanh theo thời gian thực, hỗ trợ lãnh đạo ra quyết định nhanh và chính xác.',
  },
];

export const FrameworkSection = () => {
  const headRef = useScrollReveal();
  const flowRef = useScrollReveal();

  return (
    <section id="framework" className="pt-16 md:pt-20 lg:pt-28">
      <div className="container">
        <SectionTitle
          title="80% doanh nghiệp đầu tư sai vào công nghệ"
          paragraph="Một hệ thống 6 lớp, vận hành liền mạch từ trí tuệ nhân tạo đến bảng điều khiển ra quyết định — mỗi lớp là nền móng cho lớp tiếp theo."
          center mb="44px"
        />
      </div>

        <div ref={flowRef} className="reveal relative max-w-[640px] mx-auto">
          {/* Flow track with pulse animation */}
          <div className="absolute left-[31px] top-2 bottom-2 w-0.5 bg-[var(--line)]">
            <div
              className="absolute left-[-5px] top-0 w-3 h-3 rounded-full bg-[var(--cyan)]"
              style={{
                boxShadow: '0 0 16px 4px var(--cyan), 0 0 40px 8px var(--cyan-dim)',
                animation: 'flow-run 6s cubic-bezier(0.6,0,0.4,1) infinite',
              }}
            />
          </div>

          {/* Flow nodes */}
          {frameworks.map((framework) => (
            <div
              key={framework.id}
              className="reveal relative z-10 grid grid-cols-[64px_1fr] gap-6 pb-13 last:pb-0"
            >
              {/* Icon circle */}
              <div className="w-16 h-16 rounded-full bg-[var(--panel)] border border-[var(--line)] flex items-center justify-center text-[var(--cyan)]">
                <svg className="w-6 h-6 stroke-current fill-none stroke-1.5 stroke-linecap-round stroke-linejoin-round">
                  <use href={`#${framework.icon}`} />
                </svg>
              </div>

              {/* Content */}
              <div>
                <span className="block font-mono text-xs text-[var(--muted-2)] tracking-widest mb-1">
                  {framework.label}
                </span>
                <h3 className="text-[22px] font-semibold mb-1.5 text-[var(--text)]">
                  {framework.title}
                </h3>
                <p className="text-sm text-[var(--muted)] max-w-[420px]">
                  {framework.description}
                </p>
              </div>
            </div>
          ))}
        </div>
    </section>
  );
};
