import "./globals.css";
import Sidebar from "@/components/Sidebar";

export const metadata = {
  title: "Mr. Drew's Assignment Creator",
  description: "Local, private, high-accuracy assignments, tests, quizzes, worksheets, discussion questions, and case studies.",
};

// Applies the saved (or system-preferred) theme before first paint so dark
// mode doesn't flash white on load.
const THEME_SCRIPT = `try{var t=localStorage.getItem("theme");if(!t)t=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(t==="dark")document.documentElement.dataset.theme="dark";}catch(e){}`;

export default function RootLayout({ children }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <head>
        <script dangerouslySetInnerHTML={{ __html: THEME_SCRIPT }} />
        <link rel="preconnect" href="https://fonts.googleapis.com" />
        <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
      </head>
      <body>
        <div className="app">
          <Sidebar />
          <main className="content">{children}</main>
        </div>
      </body>
    </html>
  );
}
