import Header from "../components/Header.server";
import Script from "next/script";
import {
  getHeroTranslations,
  getAboutTranslations,
  getProjectsTranslations,
  getContactTranslations,
  getFooterTranslations,
} from "@/lib/translations-loader";
import {
  HeroClient,
  AboutClient,
  ProjectsClient,
  ContactClient,
  FooterClient,
} from "../components/ClientWrappers";

interface HomePageServerProps {
  locale: string;
}

export default async function HomePageServer({ locale }: HomePageServerProps) {
  // Parallel laden aller Translations
  const [heroT, aboutT, projectsT, contactT, footerT] = await Promise.all([
    getHeroTranslations(locale),
    getAboutTranslations(locale),
    getProjectsTranslations(locale),
    getContactTranslations(locale),
    getFooterTranslations(locale),
  ]);

  return (
    <div className="min-h-screen">
      <Script
        id={"structured-data"}
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify({
            "@context": "https://schema.org",
            "@type": "Person",
            name: "Dennis Konkol",
            url: "https://dk0.dev",
            jobTitle: "Software Engineer",
            address: {
              "@type": "PostalAddress",
              addressLocality: "Osnabrück",
              addressCountry: "Germany",
            },
            sameAs: [
              "https://github.com/Denshooter",
              "https://linkedin.com/in/dkonkol",
            ],
          }),
        }}
      />
      <Header locale={locale} />
      {/* Spacer to prevent navbar overlap */}
      <div className="h-24 md:h-32" aria-hidden="true"></div>
      <main className="relative">
        <HeroClient locale={locale} translations={heroT} />

        {/* Wavy Separator 1 - Hero to About */}
        <div className="relative h-24 overflow-hidden">
          <svg
            className="absolute inset-0 w-full h-full"
            viewBox="0 0 1440 120"
            preserveAspectRatio="none"
          >
            <path
              d="M0,64 C240,96 480,32 720,64 C960,96 1200,32 1440,64 L1440,120 L0,120 Z"
              fill="url(#gradient1)"
            />
            <defs>
              <linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="0%">
                <stop offset="0%" stopColor="#BAE6FD" stopOpacity="0.4" />
                <stop offset="50%" stopColor="#DDD6FE" stopOpacity="0.4" />
                <stop offset="100%" stopColor="#FBCFE8" stopOpacity="0.4" />
              </linearGradient>
            </defs>
          </svg>
        </div>

        <AboutClient locale={locale} translations={aboutT} />

        {/* Wavy Separator 2 - About to Projects */}
        <div className="relative h-24 overflow-hidden">
          <svg
            className="absolute inset-0 w-full h-full"
            viewBox="0 0 1440 120"
            preserveAspectRatio="none"
          >
            <path
              d="M0,64 C360,96 720,32 1080,64 C1200,96 1320,32 1440,64 L1440,0 L0,0 Z"
              fill="url(#gradient2)"
            />
            <defs>
              <linearGradient id="gradient2" x1="0%" y1="0%" x2="100%" y2="0%">
                <stop offset="0%" stopColor="#A7F3D0" stopOpacity="0.3" />
                <stop offset="50%" stopColor="#BFDBFE" stopOpacity="0.3" />
                <stop offset="100%" stopColor="#DDD6FE" stopOpacity="0.3" />
              </linearGradient>
            </defs>
          </svg>
        </div>

        <ProjectsClient locale={locale} translations={projectsT} />

        {/* Wavy Separator 3 - Projects to Contact */}
        <div className="relative h-24 overflow-hidden">
          <svg
            className="absolute inset-0 w-full h-full"
            viewBox="0 0 1440 120"
            preserveAspectRatio="none"
          >
            <path
              d="M0,32 C240,64 480,0 720,32 C960,64 1200,0 1440,32 L1440,120 L0,120 Z"
              fill="url(#gradient3)"
            />
            <defs>
              <linearGradient id="gradient3" x1="0%" y1="0%" x2="100%" y2="0%">
                <stop offset="0%" stopColor="#FDE68A" stopOpacity="0.3" />
                <stop offset="50%" stopColor="#FCA5A5" stopOpacity="0.3" />
                <stop offset="100%" stopColor="#C4B5FD" stopOpacity="0.3" />
              </linearGradient>
            </defs>
          </svg>
        </div>

        <ContactClient locale={locale} translations={contactT} />
      </main>
      <FooterClient locale={locale} translations={footerT} />
    </div>
  );
}
