"use client";

import "./globals.css";
import { usePathname } from "next/navigation";
import Navbar from "./components/Navbar";
import Sidebar from "./components/Sidebar";
import { AuthProvider } from "./context/AuthContext";
import { ThemeProvider } from "./context/ThemeContext";
export default function RootLayout({ children }) {
  const pathname = usePathname();
  const isAuthPage = pathname === '/' || pathname.startsWith('/login');

  return (
    <html lang="en">
      <head>
        <title>Employee Portal</title>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="icon" href="/images/brand/brand-06.svg" /></head>
      <body className={isAuthPage ? "" : "flex h-screen overflow-hidden"}>
        <ThemeProvider>
        <AuthProvider>
          {!isAuthPage ? (
            <>
              <Sidebar />
              <div className="flex flex-col flex-1 overflow-hidden">
                <Navbar />
                <main className="flex-1 overflow-y-auto p-4">{children}</main>
              </div>
            </>
          ) : (
            children
          )}
        </AuthProvider>
        </ThemeProvider>
      </body>
    </html>
  );
}