File size: 5,291 Bytes
5463318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React, { useEffect, useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Link } from 'react-router-dom';
import { BrainCircuit, Moon, Sun } from 'lucide-react';
import { useAuthToggle } from './AuthToggleContext';
import { LoginForm } from './LoginForm';
import { SignupForm } from './SignupForm';
import { GradientPanel } from './GradientPanel';
import { useTheme } from '../../context/ThemeContext';

export const AuthContainer = () => {
    const { mode } = useAuthToggle();
    const isLogin = mode === 'login';
    const { theme, toggleTheme } = useTheme();

    const [isMobile, setIsMobile] = useState(false);

    useEffect(() => {
        const checkMobile = () => setIsMobile(window.innerWidth < 1024);
        checkMobile();
        window.addEventListener('resize', checkMobile);
        return () => window.removeEventListener('resize', checkMobile);
    }, []);

    return (
        <div className="h-screen w-full overflow-hidden bg-slate-50 dark:bg-[#0F172A] flex font-sans transition-colors duration-300">

            {/* Top Navbar overlapping (Pointer events mixed for overlay) */}
            <nav className="absolute top-0 left-0 right-0 z-50 flex items-center justify-between px-8 py-6 pointer-events-none">
                <Link to="/" className="flex items-center gap-2 pointer-events-auto group">
                    <div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[#4F7CFF] to-[#8B5CF6] flex items-center justify-center shadow-lg shadow-blue-500/20 group-hover:scale-105 transition-transform duration-300">
                        <BrainCircuit className="h-6 w-6 text-white" />
                    </div>
                    <span className="text-2xl font-bold tracking-tight text-white transition-colors duration-300">
                        ExamCraft<span className="text-[#4F7CFF]">.AI</span>
                    </span>
                </Link>
                <div className="pointer-events-auto">
                    <button
                        onClick={toggleTheme}
                        className="p-2.5 rounded-full bg-white/5 dark:bg-black/20 backdrop-blur-md border border-white/10 dark:border-white/10 hover:bg-white/20 dark:hover:bg-white/10 transition-all duration-300 text-white dark:text-slate-300 hover:text-white shadow-sm"
                        aria-label="Toggle theme"
                    >
                        {theme === "dark" ? <Sun size={20} /> : <Moon size={20} />}
                    </button>
                </div>
            </nav>

            <div className="flex w-full h-full relative z-10 font-sans">
                {/* Left Section: Branding (Hidden on lg < 1024px) */}
                <div className="hidden lg:block lg:w-1/2 h-full relative overflow-hidden bg-[#0F172A]">
                    <GradientPanel />
                </div>

                {/* Right Section: Auth Forms */}
                <div className="w-full lg:w-1/2 h-full flex flex-col items-center justify-center p-6 sm:p-12 lg:p-16 relative overflow-hidden bg-white dark:bg-[#0F172A] transition-colors duration-300">

                    {/* Subtle ambient light in right section for dark mode */}
                    <div className="absolute top-0 right-0 -m-32 w-96 h-96 bg-[#4F7CFF]/10 rounded-full blur-[100px] pointer-events-none dark:block hidden" />
                    <div className="absolute bottom-0 left-0 -m-32 w-96 h-96 bg-[#8B5CF6]/10 rounded-full blur-[100px] pointer-events-none dark:block hidden" />

                    <div className="w-full max-w-md relative z-10 glass-card sm:p-10 p-6 rounded-2xl sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] dark:sm:shadow-[0_8px_30px_rgba(0,0,0,0.4)] dark:bg-[#111827]/80 bg-white border border-transparent dark:border-white/5 h-full sm:h-auto flex flex-col justify-center sm:block">
                        <AnimatePresence mode="wait">
                            {isLogin ? (
                                <motion.div
                                    key="login"
                                    initial={{ opacity: 0, x: -20 }}
                                    animate={{ opacity: 1, x: 0 }}
                                    exit={{ opacity: 0, x: 20 }}
                                    transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
                                    className="w-full flex"
                                >
                                    <LoginForm />
                                </motion.div>
                            ) : (
                                <motion.div
                                    key="signup"
                                    initial={{ opacity: 0, x: 20 }}
                                    animate={{ opacity: 1, x: 0 }}
                                    exit={{ opacity: 0, x: -20 }}
                                    transition={{ duration: 0.4, ease: [0.4, 0, 0.2, 1] }}
                                    className="w-full flex"
                                >
                                    <SignupForm />
                                </motion.div>
                            )}
                        </AnimatePresence>
                    </div>
                </div>
            </div>
        </div>
    );
};