import type { Metadata } from "next";
import "./globals.css";

export const metadata: Metadata = {
  title: "DashCaddy - Self-Hosting Made Beautiful",
  description:
    "Deploy 92+ Docker apps with one click. AI-powered self-hosting with automatic SSL, DNS, reverse proxy, security center, and fleet management.",
  keywords: [
    "self-hosting",
    "docker",
    "dashboard",
    "caddy",
    "reverse proxy",
    "ssl",
    "dns",
    "homelab",
    "AI self-hosting",
  ],
  openGraph: {
    title: "DashCaddy - Self-Hosting Made Beautiful",
    description:
      "Deploy 92+ Docker apps with one click. AI-powered self-hosting with automatic SSL, DNS, and reverse proxy.",
    url: "https://dashcaddy.net",
    siteName: "DashCaddy",
    type: "website",
  },
  twitter: {
    card: "summary_large_image",
    title: "DashCaddy - Self-Hosting Made Beautiful",
    description:
      "Deploy 92+ Docker apps with one click. AI-powered self-hosting.",
  },
};

// Inline script to set theme class BEFORE first paint — prevents FOUC
const themeScript = `
(function() {
  try {
    var stored = localStorage.getItem('theme');
    var prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
    var theme = stored || (prefersDark ? 'dark' : 'light');
    if (theme === 'dark') document.documentElement.classList.add('dark');
  } catch(e) {}
})();
`;

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" className="h-full antialiased" suppressHydrationWarning>
      <head>
        <script dangerouslySetInnerHTML={{ __html: themeScript }} />
      </head>
      <body className="min-h-full flex flex-col bg-surface-950 text-surface-100" style={{ fontFamily: "'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif" }}>
        {children}
      </body>
    </html>
  );
}
