import type { Metadata } from "next";

import "./globals.css";

export const metadata: Metadata = {
  title: "TeaTea 康护智慧养老系统",
  description: "AI赋能智慧养老系统后台管理端初步框架",
};

type RootLayoutProps = {
  children: React.ReactNode;
};

export default function RootLayout({ children }: RootLayoutProps): React.ReactElement {
  return (
    <html lang="zh-CN" suppressHydrationWarning>
      <head>
        <script
          dangerouslySetInnerHTML={{
            __html: `
try {
  var theme = localStorage.getItem("teatea-theme") || "system";
  var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
  var isDark = theme === "dark" || (theme === "system" && prefersDark);
  document.documentElement.classList.toggle("dark", isDark);
  document.documentElement.style.colorScheme = isDark ? "dark" : "light";
} catch (_) {}
`,
          }}
        />
      </head>
      <body>{children}</body>
    </html>
  );
}
