import { Navbar } from "@/components/marketing/navbar"
import { Footer } from "@/components/marketing/footer"
import { StructuredData } from "@/components/marketing/structured-data"
import { getSession, isAdminUser } from "@/lib/session"
import { getMaintenanceMode } from "@/lib/settings"
import { MaintenanceScreen } from "@/components/shared/maintenance-screen"

export default async function MarketingLayout({ children }: { children: React.ReactNode }) {
  // Site maintenance mode: show the maintenance screen to everyone except admins.
  const maintenance = await getMaintenanceMode()
  if (maintenance.enabled) {
    const session = await getSession()
    if (!isAdminUser(session?.user)) {
      return <MaintenanceScreen message={maintenance.message} />
    }
  }

  return (
    <div className="min-h-screen bg-[#09090b] text-white">
      <StructuredData />
      <Navbar />
      {children}
      <Footer />
    </div>
  )
}
