import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { redirect } from "next/navigation";
import { ResponsiveIframe } from "@/app/components/responsive-iframe";

export default async function Page() {
  const session = await getServerSession(authOptions);

  if (!session) {
    redirect("/signin");
  }

  const mailUrl = process.env.NEXT_PUBLIC_IFRAME_MAIL_URL;
  if (!mailUrl) {
    console.warn("NEXT_PUBLIC_IFRAME_MAIL_URL is not defined in environment variables");
  }

  return (
    <main className="w-full h-screen bg-black">
      <div className="w-full h-full px-4 pt-12 pb-4">
        <ResponsiveIframe 
          src={mailUrl || 'https://mail.slm-lab.net'}
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
          style={{
            marginTop: '-64px',
            marginLeft: '-180px',
            width: 'calc(100% + 360px)',
            right: '-90px',
            height: 'calc(100% + 64px)'
          }}
        />
      </div>
    </main>
  );
} 