"use client";

import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import ReactLenis from "lenis/react";
import { useState } from "react";
import ContactSplitForm from '@/components/sections/contact/ContactSplitForm';
import FaqBase from '@/components/sections/faq/FaqBase';
import FeatureCardMedia from '@/components/sections/feature/FeatureCardMedia';
import FooterLogoReveal from '@/components/sections/footer/FooterLogoReveal';
import HeroBillboardScroll from '@/components/sections/hero/HeroBillboardScroll';
import MediaAbout from '@/components/sections/about/MediaAbout';
import MetricCardFourteen from '@/components/sections/metrics/MetricCardFourteen';
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import ProductCardFour from '@/components/sections/product/ProductCardFour';
import TestimonialCardSixteen from '@/components/sections/testimonial/TestimonialCardSixteen';

const i18n = {
  RU: {
    nav: [{ name: "Главная", id: "hero" }, { name: "О нас", id: "about" }, { name: "Услуги", id: "services" }, { name: "Контакты", id: "contact" }],
    hero: { title: "ФАРУС: Ваш надежный партнер в переводах", desc: "Профессиональный перевод с персидского, русского и английского языков. Гарантия точности и качества для бизнеса и частных лиц." },
    about: { title: "О нашем бюро", desc: "Мы специализируемся на высокоточных переводах, понимая культурные и лингвистические особенности каждого языка. Наша команда состоит из экспертов, работающих с документами любой сложности." },
    features: { title: "Наши преимущества", desc: "Почему выбирают ФАРУС для лингвистических задач.", items: [{ id: "f1", title: "Мультиязычность", desc: "Профессионально работаем с персидским, русским и английским языками.", tag: "Языки" }, { id: "f2", title: "Точность", desc: "Проверка терминологии и соблюдение стандартов качества на каждом этапе.", tag: "Качество" }, { id: "f3", title: "Скорость", desc: "Соблюдение установленных сроков вне зависимости от объема.", tag: "Сроки" }] },
    services: { title: "Наши услуги", desc: "Полный спектр переводческих услуг для ваших нужд.", items: [{ id: "p1", name: "Юридический перевод", price: "от 500₽" }, { id: "p2", name: "Технический перевод", price: "от 700₽" }, { id: "p3", name: "Перевод документов", price: "от 300₽" }] },
    metrics: { title: "ФАРУС в цифрах", tag: "Статистика", m: [{ id: "m1", val: "1000+", desc: "Успешных проектов" }, { id: "m2", val: "15+", desc: "Лет опыта" }, { id: "m3", val: "500+", desc: "Довольных клиентов" }] },
    testimonials: { title: "Отзывы клиентов", desc: "Нам доверяют лидеры индустрии.", items: [{ id: "t1", name: "Алексей Иванов", role: "Директор", comp: "ТехГрупп" }, { id: "t2", name: "Мария Сергеева", role: "Юрист", comp: "Правовед" }, { id: "t3", name: "Дмитрий Петров", role: "Инженер", comp: "ПромТех" }], kpi: [{v: "4.9", l: "Рейтинг"}, {v: "98%", l: "Точность"}, {v: "100%", l: "Своевременность"}] },
    faq: { title: "Часто задаваемые вопросы", desc: "Мы всегда готовы ответить на ваши вопросы.", items: [{ id: "q1", title: "Как заказать перевод?", cont: "Просто оставьте заявку через форму, и мы свяжемся с вами." }, { id: "q2", title: "Сколько стоит перевод?", cont: "Стоимость зависит от сложности, языка и объема материала." }, { id: "q3", title: "Работаете ли вы с нотариальным заверением?", cont: "Да, мы предоставляем услуги нотариального заверения переведенных документов." }] },
    contact: { title: "Свяжитесь с нами", desc: "Оставьте заявку, и мы бесплатно проконсультируем вас.", ph: "Ваше имя", phEmail: "Ваш email", phMsg: "Ваш запрос", btn: "Отправить" },
    footer: { logo: "ФАРУС", l: "Политика конфиденциальности", r: "Все права защищены © 2024" }
  },
  EN: {
    nav: [{ name: "Home", id: "hero" }, { name: "About", id: "about" }, { name: "Services", id: "services" }, { name: "Contact", id: "contact" }],
    hero: { title: "FARUS: Your Trusted Translation Partner", desc: "Professional translation services in Persian, Russian, and English. Guaranteed quality and accuracy for business and private clients." },
    about: { title: "About Our Bureau", desc: "We specialize in high-precision translations, understanding the cultural and linguistic nuances of each language. Our team consists of experts working with complex documents." },
    features: { title: "Our Advantages", desc: "Why choose FARUS for your linguistic needs.", items: [{ id: "f1", title: "Multilingualism", desc: "Professional translation in Persian, Russian, and English.", tag: "Languages" }, { id: "f2", title: "Accuracy", desc: "Strict terminology check and quality standards at every stage.", tag: "Quality" }, { id: "f3", title: "Speed", desc: "Meeting established deadlines regardless of volume.", tag: "Timelines" }] },
    services: { title: "Our Services", desc: "Full range of translation services for your needs.", items: [{ id: "p1", name: "Legal Translation", price: "from $10" }, { id: "p2", name: "Technical Translation", price: "from $15" }, { id: "p3", name: "Document Translation", price: "from $5" }] },
    metrics: { title: "FARUS in Numbers", tag: "Statistics", m: [{ id: "m1", val: "1000+", desc: "Successful Projects" }, { id: "m2", val: "15+", desc: "Years of Experience" }, { id: "m3", val: "500+", desc: "Happy Clients" }] },
    testimonials: { title: "Client Testimonials", desc: "Trusted by industry leaders.", items: [{ id: "t1", name: "Alexey Ivanov", role: "Director", comp: "TechGroup" }, { id: "t2", name: "Maria Sergeyeva", role: "Lawyer", comp: "LawExpert" }, { id: "t3", name: "Dmitry Petrov", role: "Engineer", comp: "PromTech" }], kpi: [{v: "4.9", l: "Rating"}, {v: "98%", l: "Accuracy"}, {v: "100%", l: "Timeliness"}] },
    faq: { title: "Frequently Asked Questions", desc: "We are always ready to answer your questions.", items: [{ id: "q1", title: "How to order translation?", cont: "Leave an application through the form and we will contact you." }, { id: "q2", title: "How much does it cost?", cont: "The cost depends on complexity, language, and volume of material." }, { id: "q3", title: "Do you provide notary services?", cont: "Yes, we provide notary certification services for translated documents." }] },
    contact: { title: "Contact Us", desc: "Submit an application for a free consultation.", ph: "Your Name", phEmail: "Your Email", phMsg: "Your Request", btn: "Submit" },
    footer: { logo: "FARUS", l: "Privacy Policy", r: "All Rights Reserved © 2024" }
  },
  FA: {
    nav: [{ name: "خانه", id: "hero" }, { name: "درباره ما", id: "about" }, { name: "خدمات", id: "services" }, { name: "تماس", id: "contact" }],
    hero: { title: "فاروس: شریک قابل اعتماد شما در ترجمه", desc: "ترجمه حرفه‌ای به زبان‌های فارسی، روسی و انگلیسی. تضمین دقت و کیفیت برای کسب‌وکارها و اشخاص حقیقی." },
    about: { title: "درباره دفتر ما", desc: "ما در ترجمه‌های با دقت بالا تخصص داریم و تفاوت‌های فرهنگی و زبانی هر زبان را درک می‌کنیم. تیم ما از متخصصانی تشکیل شده است که با اسناد پیچیده کار می‌کنند." },
    features: { title: "مزایای ما", desc: "چرا فاروس را برای نیازهای زبانی خود انتخاب کنید.", items: [{ id: "f1", title: "چندزبانی", desc: "کار حرفه‌ای با زبان‌های فارسی، روسی و انگلیسی.", tag: "زبان‌ها" }, { id: "f2", title: "دقت", desc: "بررسی اصطلاحات و رعایت استانداردهای کیفیت در هر مرحله.", tag: "کیفیت" }, { id: "f3", title: "سرعت", desc: "پایبندی به مهلت‌های تعیین‌شده صرف نظر از حجم.", tag: "زمان" }] },
    services: { title: "خدمات ما", desc: "طیف کامل خدمات ترجمه برای نیازهای شما.", items: [{ id: "p1", name: "ترجمه حقوقی", price: "از ۵۰۰ روبل" }, { id: "p2", name: "ترجمه فنی", price: "از ۷۰۰ روبل" }, { id: "p3", name: "ترجمه اسناد", price: "از ۳۰۰ روبل" }] },
    metrics: { title: "فاروس به اعداد", tag: "آمار", m: [{ id: "m1", val: "۱۰۰۰+", desc: "پروژه موفق" }, { id: "m2", val: "۱۵+", desc: "سال تجربه" }, { id: "m3", val: "۵۰۰+", desc: "مشتری راضی" }] },
    testimonials: { title: "نظرات مشتریان", desc: "رهبران صنعت به ما اعتماد دارند.", items: [{ id: "t1", name: "الکسی ایوانف", role: "مدیر", comp: "تک‌گروپ" }, { id: "t2", name: "ماریا سرگوا", role: "وکیل", comp: "حقوق‌دان" }, { id: "t3", name: "دیمیتری پتروف", role: "مهندس", comp: "پروم‌تک" }], kpi: [{v: "۴.۹", l: "امتیاز"}, {v: "۹۸٪", l: "دقت"}, {v: "۱۰۰٪", l: "به‌موقع"}] },
    faq: { title: "سوالات متداول", desc: "ما همیشه آماده پاسخگویی به سوالات شما هستیم.", items: [{ id: "q1", title: "چگونه سفارش دهیم؟", cont: "فقط از طریق فرم درخواست بگذارید و ما با شما تماس خواهیم گرفت." }, { id: "q2", title: "هزینه چقدر است؟", cont: "هزینه بستگی به پیچیدگی، زبان و حجم مواد دارد." }, { id: "q3", title: "آیا تاییدیه محضری می‌دهید؟", cont: "بله، ما خدمات تایید محضری اسناد ترجمه‌شده را ارائه می‌دهیم." }] },
    contact: { title: "تماس با ما", desc: "درخواست خود را برای مشاوره رایگان ثبت کنید.", ph: "نام شما", phEmail: "ایمیل شما", phMsg: "درخواست شما", btn: "ارسال" },
    footer: { logo: "فاروس", l: "سیاست حریم خصوصی", r: "تمامی حقوق محفوظ است © ۲۰۲۴" }
  }
};

export default function LandingPage() {
  const [lang, setLang] = useState<'RU' | 'EN' | 'FA'>('RU');
  const t = i18n[lang];

  const toggleLang = () => {
    const langs: ('RU' | 'EN' | 'FA')[] = ['RU', 'EN', 'FA'];
    const nextIndex = (langs.indexOf(lang) + 1) % langs.length;
    setLang(langs[nextIndex]);
  };

  return (
    <ThemeProvider
        defaultButtonVariant="directional-hover"
        defaultTextAnimation="entrance-slide"
        borderRadius="soft"
        contentWidth="medium"
        sizing="medium"
        background="circleGradient"
        cardStyle="glass-elevated"
        primaryButtonStyle="gradient"
        secondaryButtonStyle="glass"
        headingFontWeight="normal"
    >
      <ReactLenis root>
        <div id="nav" data-section="nav">
          <NavbarStyleCentered navItems={t.nav} brandName={t.footer.logo} />
          <div className="fixed top-4 right-4 z-50">
            <button onClick={toggleLang} className="bg-primary-cta text-white px-4 py-2 rounded-full font-semibold shadow-lg hover:scale-105 transition-transform">
              {lang}
            </button>
          </div>
        </div>
        <div id="hero" data-section="hero">
          <HeroBillboardScroll background={{ variant: "gradient-bars" }} title={t.hero.title} description={t.hero.desc} imageSrc="http://img.b2bpic.net/free-photo/call-center-agent-laughing-funny-joke-while-talking-with-customer-office_482257-125812.jpg?_wi=1" />
        </div>
        <div id="about" data-section="about">
          <MediaAbout title={t.about.title} description={t.about.desc} imageSrc="http://img.b2bpic.net/free-photo/three-business-people-with-documente_23-2147626571.jpg?_wi=1" />
        </div>
        <div id="features" data-section="features">
          <FeatureCardMedia animationType="slide-up" textboxLayout="split" title={t.features.title} description={t.features.desc} features={t.features.items.map((i, idx) => ({ ...i, imageSrc: ["http://img.b2bpic.net/free-photo/asian-businesswoman-typing-email-desktop-pc-office_637285-2718.jpg", "http://img.b2bpic.net/free-photo/call-center-agent-laughing-funny-joke-while-talking-with-customer-office_482257-125812.jpg?_wi=2", "http://img.b2bpic.net/free-photo/three-business-people-with-documente_23-2147626571.jpg?_wi=2"][idx] }))} />
        </div>
        <div id="services" data-section="services">
          <ProductCardFour animationType="slide-up" textboxLayout="default" gridVariant="three-columns-all-equal-width" title={t.services.title} description={t.services.desc} products={t.services.items.map((i, idx) => ({ ...i, imageSrc: ["http://img.b2bpic.net/free-photo/minimalist-black-white-office-desk-with-stationery_9975-133066.jpg", "http://img.b2bpic.net/free-photo/corporate-building-with-empty-room_23-2148727503.jpg", "http://img.b2bpic.net/free-photo/medium-shot-girl-with-headphones-laptop-indoors_23-2148389064.jpg"][idx], variant: "Standard" }))} />
        </div>
        <div id="metrics" data-section="metrics">
          <MetricCardFourteen title={t.metrics.title} tag={t.metrics.tag} metrics={t.metrics.m.map(i => ({ id: i.id, value: i.val, description: i.desc }))} metricsAnimation="slide-up" />
        </div>
        <div id="testimonials" data-section="testimonials">
          <TestimonialCardSixteen animationType="slide-up" textboxLayout="default" title={t.testimonials.title} description={t.testimonials.desc} testimonials={t.testimonials.items.map((i, idx) => ({ id: i.id, name: i.name, role: i.role, company: i.comp, rating: 5, imageSrc: ["http://img.b2bpic.net/free-photo/smiling-man-suit-looking-camera_23-2148112202.jpg", "http://img.b2bpic.net/free-photo/middle-aged-hispanic-business-person_23-2151098593.jpg", "http://img.b2bpic.net/free-photo/cheerful-businessman-smiling_74855-1511.jpg"][idx] }))} kpiItems={t.testimonials.kpi.map(i => ({ value: i.v, label: i.l }))} />
        </div>
        <div id="faq" data-section="faq">
          <FaqBase textboxLayout="default" title={t.faq.title} description={t.faq.desc} faqs={t.faq.items.map(i => ({ id: i.id, title: i.title, content: i.cont }))} faqsAnimation="slide-up" />
        </div>
        <div id="contact" data-section="contact">
          <ContactSplitForm title={t.contact.title} description={t.contact.desc} inputs={[{ name: "name", type: "text", placeholder: t.contact.ph, required: true }, { name: "email", type: "email", placeholder: t.contact.phEmail, required: true }]} textarea={{ name: "message", placeholder: t.contact.phMsg, required: true }} buttonText={t.contact.btn} imageSrc="http://img.b2bpic.net/free-photo/young-beautiful-female-support-phone-operator-speaking-consulting-office_176420-957.jpg" />
        </div>
        <div id="footer" data-section="footer">
          <FooterLogoReveal logoText={t.footer.logo} leftLink={{ text: t.footer.l, href: "#" }} rightLink={{ text: t.footer.r, href: "#" }} />
        </div>
      </ReactLenis>
    </ThemeProvider>
  );
}