"use client";

import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import HeroCarouselLogo from '@/components/sections/hero/heroCarouselLogo/HeroCarouselLogo';
import ProductCardTwo from '@/components/sections/product/ProductCardTwo';
import FeatureCardTwentyOne from '@/components/sections/feature/FeatureCardTwentyOne';
import MetricCardSeven from '@/components/sections/metrics/MetricCardSeven';
import TestimonialCardSix from '@/components/sections/testimonial/TestimonialCardSix';
import PricingCardFive from '@/components/sections/pricing/PricingCardFive';
import ContactFaq from '@/components/sections/contact/ContactFaq';
import FooterMedia from '@/components/sections/footer/FooterMedia';
import { Zap, Sparkles, Quote, Star, Crown, Phone } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";

type Page = 'home' | 'experience' | 'technology' | 'testimonials' | 'pricing' | 'contact';

export default function LandingPage() {
  const router = useRouter();
  const [currentPage, setCurrentPage] = useState<Page>('home');

  const navigateToPage = (page: Page) => {
    setCurrentPage(page);
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };

  const handleNavigation = (id: string) => {
    const pageMap: { [key: string]: Page } = {
      'experience': 'experience',
      'technology': 'technology',
      'testimonials': 'testimonials',
      'pricing': 'pricing',
      'contact': 'contact',
    };
    if (pageMap[id]) {
      navigateToPage(pageMap[id]);
    }
  };

  return (
    <ThemeProvider
      defaultButtonVariant="directional-hover"
      defaultTextAnimation="reveal-blur"
      borderRadius="rounded"
      contentWidth="mediumLarge"
      sizing="largeSizeMediumTitles"
      background="radialGradient"
      cardStyle="outline"
      primaryButtonStyle="inset-glow"
      secondaryButtonStyle="solid"
      headingFontWeight="extrabold"
    >
      <div id="nav" data-section="nav">
        <NavbarLayoutFloatingInline
          brandName="BASE"
          navItems={[
            { name: "Experience", id: "experience" },
            { name: "Technology", id: "technology" },
            { name: "Testimonials", id: "testimonials" },
            { name: "Pricing", id: "pricing" }
          ]}
          button={{
            text: "Reserve Now",            onClick: () => navigateToPage('contact')
          }}
          className="bg-background/80 backdrop-blur-md border border-accent/20 rounded-full"
          navItemClassName="text-foreground/80 hover:text-accent transition-colors duration-300"
          buttonClassName="bg-primary-cta hover:bg-primary-cta/90 text-white rounded-full"
          buttonTextClassName="font-semibold"
        />
      </div>

      {currentPage === 'home' && (
        <div id="hero" data-section="hero">
          <HeroCarouselLogo
            logoText="BASE"
            description="Experience the future of premium audio with cutting-edge technology that redefines sound."
            buttons={[
              { text: "Explore Now", onClick: () => navigateToPage('experience') },
              { text: "Watch Demo", href: "#" }
            ]}
            slides={[
              {
                imageSrc: "https://img.b2bpic.net/free-photo/photo-metal-texture-pattern_58702-13940.jpg",                imageAlt: "BASE Speaker Premium Design"
              },
              {
                imageSrc: "https://img.b2bpic.net/free-photo/wireless-speaker-amplifier-black_140725-7484.jpg",                imageAlt: "BASE Speaker Technology"
              },
              {
                imageSrc: "https://img.b2bpic.net/free-photo/close-up-military-protection-item_23-2149341299.jpg",                imageAlt: "BASE Speaker Innovation"
              }
            ]}
            autoplayDelay={5000}
            showDimOverlay={true}
            logoLineHeight={1.05}
            ariaLabel="BASE Speaker Hero Section"
            className="relative min-h-screen overflow-hidden"
            logoClassName="text-primary-cta drop-shadow-2xl"
            descriptionClassName="text-foreground/90 font-light tracking-wide"
            buttonClassName="group relative rounded-full overflow-hidden"
            buttonTextClassName="relative z-10 font-semibold"
          />
        </div>
      )}

      {currentPage === 'experience' && (
        <div id="experience" data-section="experience">
          <ProductCardTwo
            title="Immersive Audio Experience"
            description="Discover the revolutionary technology behind BASE speakers with interactive product demonstrations and detailed specifications."
            tag="Product Showcase"
            tagIcon={Zap}
            products={[
              {
                id: "base-pro",                brand: "BASE",                name: "BASE Pro Elite",                price: "$8,999",                rating: 5,
                reviewCount: "2.3k",                imageSrc: "https://img.b2bpic.net/free-photo/photo-metal-texture-pattern_58702-13940.jpg",                imageAlt: "BASE Pro Elite Speaker"
              },
              {
                id: "base-studio",                brand: "BASE",                name: "BASE Studio Master",                price: "$12,499",                rating: 5,
                reviewCount: "1.8k",                imageSrc: "https://img.b2bpic.net/free-photo/wireless-speaker-amplifier-black_140725-7484.jpg",                imageAlt: "BASE Studio Master Speaker"
              },
              {
                id: "base-concert",                brand: "BASE",                name: "BASE Concert Grand",                price: "$15,999",                rating: 5,
                reviewCount: "950",                imageSrc: "https://img.b2bpic.net/free-photo/close-up-military-protection-item_23-2149341299.jpg",                imageAlt: "BASE Concert Grand Speaker"
              },
              {
                id: "base-infinity",                brand: "BASE",                name: "BASE Infinity Limited",                price: "$24,999",                rating: 5,
                reviewCount: "450",                imageSrc: "https://img.b2bpic.net/free-photo/crop-amplifier-black_23-2147781794.jpg",                imageAlt: "BASE Infinity Limited Edition"
              }
            ]}
            gridVariant="two-columns-alternating-heights"
            animationType="scale-rotate"
            textboxLayout="default"
            useInvertedBackground="noInvert"
            buttons={[
              { text: "Back to Home", onClick: () => navigateToPage('home') }
            ]}
            className="py-20"
            cardClassName="group hover:shadow-2xl transition-all duration-500"
            imageClassName="group-hover:scale-105 transition-transform duration-700"
          />
        </div>
      )}

      {currentPage === 'technology' && (
        <div id="technology" data-section="technology">
          <FeatureCardTwentyOne
            title="Next-Generation Audio Technology"
            description="Explore the innovative engineering that powers BASE speakers and delivers unparalleled sound quality."
            tag="Advanced Technology"
            tagIcon={Zap}
            accordionItems={[
              {
                id: "1",                title: "Quantum Acoustic Processor",                content: "Our proprietary Quantum Acoustic Processor uses AI-driven algorithms to analyze and optimize sound in real-time, delivering perfectly balanced audio regardless of your room's acoustics. Each frequency is processed independently through our 48-core parallel processing system."
              },
              {
                id: "2",                title: "Crystalline Driver Array",                content: "Hand-crafted crystalline drivers with molecular alignment create unprecedented clarity. Each driver is individually tuned to vibrate at precise frequencies, producing pure, untainted sound with zero distortion even at maximum volume."
              },
              {
                id: "3",                title: "Magnetic Flux Waveguide",                content: "The proprietary Magnetic Flux Waveguide technology uses advanced electromagnetic fields to guide sound waves with surgical precision. This innovation eliminates phase distortion and creates an immersive 360-degree acoustic experience."
              },
              {
                id: "4",                title: "Neural Listening Intelligence",                content: "Our Neural Listening system learns your preferences and automatically adapts the speaker's output over time. Machine learning algorithms continuously optimize bass response, midrange clarity, and treble extension based on your listening habits."
              },
              {
                id: "5",                title: "Zero-Latency Connectivity",                content: "Quantum-encrypted wireless transmission with zero latency ensures your music is never delayed. Support for all major audio codecs including exclusive BASE-Lossless format for studio-quality streaming."
              }
            ]}
            imageSrc="https://img.b2bpic.net/free-photo/managing-smart-speakers-concept_23-2150170101.jpg"
            imageAlt="BASE Audio Technology"
            useInvertedBackground="invertDefault"
            mediaPosition="right"
            buttons={[
              { text: "Back to Home", onClick: () => navigateToPage('home') }
            ]}
            className="py-24"
            titleClassName="text-4xl md:text-5xl font-extrabold text-foreground"
            descriptionClassName="text-lg text-foreground/70 mt-4"
            accordionClassName="border-b border-accent/20 last:border-b-0"
            accordionTitleClassName="font-semibold text-foreground hover:text-accent transition-colors"
          />
        </div>
      )}

      {currentPage === 'testimonials' && (
        <div id="testimonials" data-section="testimonials">
          <TestimonialCardSix
            title="Trusted by Audio Professionals"
            description="Hear what industry leaders and audiophiles say about BASE speakers."
            tag="Testimonials"
            tagIcon={Quote}
            testimonials={[
              {
                id: "1",                name: "Marcus Sterling",                handle: "@marcussterling_pro",                testimonial: "BASE has completely transformed my studio experience. The clarity and precision are unmatched. Every detail in my mixes comes through with perfect accuracy.",                imageSrc: "https://img.b2bpic.net/free-photo/confident-middle-aged-businesswoman_1262-20882.jpg",                imageAlt: "Marcus Sterling"
              },
              {
                id: "2",                name: "Elena Rodriguez",                handle: "@elenaudio",                testimonial: "The Quantum Acoustic Processor is a game-changer. I've never heard my music sound so alive. BASE delivers what other speakers promise but never achieve.",                imageSrc: "https://img.b2bpic.net/free-photo/close-up-portrait-young-handsome-successful-man_1163-5475.jpg",                imageAlt: "Elena Rodriguez"
              },
              {
                id: "3",                name: "James Mitchell",                handle: "@jamesmusictech",                testimonial: "After 30 years in professional audio, I'm blown away by BASE. The innovation is stunning and the sound quality is beyond exceptional. This is the future of audio.",                imageSrc: "https://img.b2bpic.net/free-photo/close-up-positive-businesswoman_1098-3531.jpg",                imageAlt: "James Mitchell"
              },
              {
                id: "4",                name: "Sophie Chen",                handle: "@sophieaudioart",                testimonial: "BASE speakers have become my gold standard. The attention to detail is incredible. Every frequency is rendered with absolute precision and musicality.",                imageSrc: "https://img.b2bpic.net/free-photo/confident-businessman-smiling_107420-84734.jpg",                imageAlt: "Sophie Chen"
              },
              {
                id: "5",                name: "David Leblanc",                handle: "@davidlblanc",                testimonial: "The Neural Listening Intelligence adapts perfectly to my preferences. It's like having a personal sound engineer optimizing my experience every time I listen.",                imageSrc: "https://img.b2bpic.net/free-photo/medium-shot-man-wearing-suit_23-2149396254.jpg",                imageAlt: "David Leblanc"
              },
              {
                id: "6",                name: "Priya Kapoor",                handle: "@priyakapoor_audio",                testimonial: "Worth every penny. BASE delivers an immersive experience that makes you forget about everything else. Pure audio bliss.",                imageSrc: "https://img.b2bpic.net/free-photo/cheerful-young-businesswoman-smiling-camera_74855-4022.jpg",                imageAlt: "Priya Kapoor"
              }
            ]}
            animationType="slide-up"
            textboxLayout="default"
            useInvertedBackground="invertDefault"
            speed={50}
            topMarqueeDirection="left"
            className="py-20"
            cardClassName="bg-card rounded-xl border border-accent/10 p-6 hover:border-accent/40 transition-colors"
            testimonialClassName="text-foreground/90 leading-relaxed line-clamp-2"
            buttons={[
              { text: "Back to Home", onClick: () => navigateToPage('home') }
            ]}
          />
        </div>
      )}

      {currentPage === 'pricing' && (
        <div id="pricing" data-section="pricing">
          <PricingCardFive
            title="Investment in Sonic Perfection"
            description="Choose the BASE model that matches your needs and budget. All systems include lifetime technical support and warranty."
            tag="Pricing"
            tagIcon={Sparkles}
            textboxLayout="default"
            useInvertedBackground="noInvert"
            animationType="slide-up"
            plans={[
              {
                id: "pro",                tag: "Pro Elite",                tagIcon: Star,
                price: "$8,999",                period: "one-time",                description: "Perfect for audiophile enthusiasts and high-quality home listening.",                button: {
                  text: "Choose Pro Elite",                  onClick: () => navigateToPage('contact')
                },
                featuresTitle: "What's Included:",                features: [
                  "Quantum Acoustic Processor",                  "Crystalline Driver Array",                  "Zero-Latency Connectivity",                  "Neural Listening Intelligence",                  "Lifetime Technical Support",                  "Premium Build Materials"
                ]
              },
              {
                id: "studio",                tag: "Studio Master",                tagIcon: Zap,
                price: "$12,499",                period: "one-time",                description: "Professional-grade system for studios and serious collectors.",                button: {
                  text: "Choose Studio Master",                  onClick: () => navigateToPage('contact')
                },
                featuresTitle: "What's Included:",                features: [
                  "Everything in Pro Elite",                  "Advanced Magnetic Flux Waveguide",                  "48-Core Processing Power",                  "Studio Calibration Service",                  "Custom Acoustic Tuning",                  "Priority Support Hotline"
                ]
              },
              {
                id: "concert",                tag: "Concert Grand",                tagIcon: Crown,
                price: "$15,999",                period: "one-time",                description: "Ultimate reference system for the most demanding audiophiles.",                button: {
                  text: "Choose Concert Grand",                  onClick: () => navigateToPage('contact')
                },
                featuresTitle: "What's Included:",                features: [
                  "Everything in Studio Master",                  "Hand-Tuned Components",                  "Concert Hall Acoustics Package",                  "Dedicated Account Manager",                  "Exclusive Firmware Updates",                  "Lifetime Replacement Guarantee"
                ]
              },
              {
                id: "infinity",                tag: "Infinity Limited",                tagIcon: Zap,
                price: "$24,999",                period: "one-time",                description: "The absolute pinnacle of audio engineering. Extremely limited production.",                button: {
                  text: "Reserve Infinity",                  onClick: () => navigateToPage('contact')
                },
                featuresTitle: "What's Included:",                features: [
                  "Everything in Concert Grand",                  "Custom Artisan Craftsmanship",                  "Bespoke Installation Service",                  "Personal Audio Consulting",                  "Legacy Ownership Program",                  "VIP Community Access"
                ]
              }
            ]}
            className="py-24"
            cardClassName="rounded-2xl border border-accent/20 hover:border-accent/60 transition-all duration-300"
            planPriceClassName="text-5xl font-extrabold text-accent"
            buttons={[
              { text: "Back to Home", onClick: () => navigateToPage('home') }
            ]}
          />
        </div>
      )}

      {currentPage === 'contact' && (
        <>
          <div id="contact" data-section="contact">
            <ContactFaq
              ctaTitle="Ready to Experience BASE?"
              ctaDescription="Join the elite community of audiophiles who demand the very best in sound quality."
              ctaButton={{
                text: "Start Your Journey",                href: "#"
              }}
              ctaIcon={Zap}
              faqs={[
                {
                  id: "1",                  title: "What makes BASE different from other premium speakers?",                  content: "BASE combines cutting-edge AI technology with traditional audio engineering. Our Quantum Acoustic Processor and Neural Listening Intelligence systems create an adaptive listening experience that improves over time, something no other speaker offers."
                },
                {
                  id: "2",                  title: "How long does shipping and installation take?",                  content: "Standard shipping takes 7-14 business days. For orders over $12,000, we include white-glove installation service that typically takes 2-3 days after delivery. We handle all setup and acoustic calibration."
                },
                {
                  id: "3",                  title: "What warranty coverage is included?",                  content: "All BASE speakers include a 10-year comprehensive warranty covering all components and labor. The Infinity Limited edition includes lifetime coverage. Technical support is available 24/7 for all models."
                },
                {
                  id: "4",                  title: "Can I try BASE speakers before purchasing?",                  content: "Yes! We offer 30-day home trials for qualified buyers. If you're not completely satisfied, we'll arrange a full refund with prepaid return shipping. Our confidence in the product is absolute."
                },
                {
                  id: "5",                  title: "Do BASE speakers work with all audio sources?",                  content: "BASE speakers support all major audio formats and codecs including our exclusive BASE-Lossless format. They feature Bluetooth, USB, optical, and analog inputs, making them compatible with virtually any audio device."
                },
                {
                  id: "6",                  title: "What is the Neural Listening Intelligence feature?",                  content: "This proprietary AI system learns your listening preferences and automatically optimizes the speaker's output over time. It continuously adjusts frequency response, dynamics, and spatial imaging for a personalized experience unique to you."
                }
              ]}
              useInvertedBackground="invertDefault"
              animationType="slide-up"
              accordionAnimationType="smooth"
              showCard={true}
              className="py-24"
              ctaTitleClassName="text-3xl md:text-4xl font-extrabold text-foreground"
              ctaDescriptionClassName="text-lg text-foreground/70 mt-2"
              accordionTitleClassName="font-semibold text-foreground"
            />
          </div>

          <div id="footer" data-section="footer">
            <FooterMedia
              imageSrc="https://img.b2bpic.net/free-vector/modern-data-background-template-with-bokeh_1361-2213.jpg"
              imageAlt="BASE Audio Innovation"
              logoText="BASE"
              copyrightText="© 2025 BASE Audio. Redefining the future of sound."
              columns={[
                {
                  title: "Products",                  items: [
                    { label: "Pro Elite", href: "#" },
                    { label: "Studio Master", href: "#" },
                    { label: "Concert Grand", href: "#" },
                    { label: "Infinity Limited", href: "#" }
                  ]
                },
                {
                  title: "Company",                  items: [
                    { label: "About BASE", href: "#" },
                    { label: "Technology", href: "#" },
                    { label: "Careers", href: "#" },
                    { label: "Press", href: "#" }
                  ]
                },
                {
                  title: "Support",                  items: [
                    { label: "Documentation", href: "#" },
                    { label: "Contact Support", href: "#" },
                    { label: "Warranty", href: "#" },
                    { label: "Returns", href: "#" }
                  ]
                }
              ]}
              className="relative"
              mediaWrapperClassName="absolute inset-0 opacity-30"
              logoTextClassName="text-2xl font-extrabold text-foreground"
              columnTitleClassName="text-foreground font-semibold mb-4"
              columnItemClassName="text-foreground/70 hover:text-accent transition-colors"
            />
            <div className="text-center py-4 border-t border-accent/20">
              <button
                onClick={() => navigateToPage('home')}
                className="text-foreground/70 hover:text-accent transition-colors text-sm"
              >
                Back to Home
              </button>
            </div>
          </div>
        </>
      )}
    </ThemeProvider>
  );
}
