import { Suspense } from 'react'
import Container from '@/components/frontend/Container'
import FlashSale from '@/components/frontend/home/FlashSale'
import TestimonialsSection from '@/components/frontend/home/TestimonialsSection'
import { HeroModern } from '@/components/frontend/home/blocks/Heroes'
import TrustStrip from '@/components/frontend/home/blocks/TrustStrip'
import CategoryTiles from '@/components/frontend/home/blocks/CategoryTiles'
import ProductTabs from '@/components/frontend/home/blocks/ProductTabs'
import BrandsShowcase from '@/components/frontend/home/blocks/BrandsShowcase'
import BlogTeaser from '@/components/frontend/home/blocks/BlogTeaser'
import { PromoRow, PromoPair, WideBanner } from '@/components/frontend/home/blocks/BannerSections'
import { SectionSkeleton } from '@/components/frontend/skeletons/Skeletons'
import type { HomeBanners } from '@/lib/db/queries/getHeroBanners'

// Design 2 — "Modern": marketplace / bento. Hero slider with side promos,
// trust strip, category tiles, flash sale, tabbed products, brand marquee,
// testimonials, journal. Every section hides itself when it has no data.
// Sections reused from Classic carry their own vertical margins; the wrapper
// strips them so the gap here is the only spacing.
export default function HomeModern({ banners, heading }: { banners: HomeBanners; heading: string }) {
  return (
    <Container className="pt-4 sm:pt-6">
      <h1 className="sr-only">{heading}</h1>
      <div className="flex flex-col gap-14 sm:gap-20 [&>*]:my-0!">
        <div className="flex flex-col gap-4 sm:gap-6">
          <HeroModern slides={banners.hero} side={banners.heroSide} />
          <TrustStrip />
        </div>
        <Suspense fallback={<SectionSkeleton count={6} />}>
          <CategoryTiles />
        </Suspense>
        <PromoRow banners={banners.top} variant="modern" />
        <Suspense fallback={<SectionSkeleton />}>
          <FlashSale />
        </Suspense>
        <Suspense fallback={<SectionSkeleton />}>
          <ProductTabs />
        </Suspense>
        <PromoPair banners={banners.middle} variant="modern" />
        <Suspense fallback={null}>
          <BrandsShowcase variant="modern" />
        </Suspense>
        <Suspense fallback={<SectionSkeleton count={3} />}>
          <TestimonialsSection />
        </Suspense>
        <Suspense fallback={<SectionSkeleton count={3} />}>
          <BlogTeaser variant="modern" />
        </Suspense>
        <WideBanner banners={banners.bottom} variant="modern" />
      </div>
    </Container>
  )
}
