import packageJson from "@/package.json";

export default function AppLayout({ children }: { children: React.ReactNode }) {
  const version = packageJson.version;
  const buildDate =
    process.env.NEXT_PUBLIC_BUILD_DATE ||
    new Date().toLocaleDateString("de-DE", {
      day: "2-digit",
      month: "2-digit",
      year: "numeric",
    });

  return (
    <div className="min-h-screen py-8 px-4">
      <div className="max-w-316 mx-auto border-2 border-black rounded-xl bg-gray-200 p-6">
        <h1 className="text-4xl font-bold text-center mb-6 tracking-tight">
          Auto-Charger Log
        </h1>

        <div className="max-w-6xl mx-auto">
          <main className="border-2 border-black rounded-lg p-6 bg-[#FFFFDD]">
            {children}
          </main>

          <footer className="mt-8 flex justify-between items-center text-sm text-gray-600 px-4">
            <a href="mailto:rxf@gmx.de" className="hover:underline">
              mailto:rxf@gmx.de
            </a>
            <div>
              Version {version} - {buildDate}
            </div>
          </footer>
        </div>
      </div>
    </div>
  );
}
