<?php
/**
 * Agentic Square - Premium Login Interface
 * CodeCanyon Distribution Standard
 */

require_once __DIR__ . '/config/config.php';

if (isset($_SESSION['user_id'])) {
    header('Location: ' . app_url('index.php'));
    exit;
}

require_once __DIR__ . '/sections/header.php';
?>

<div class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 relative bg-nftDark">
    <!-- Atmospheric Visual Ambient Glow Elements[cite: 1] -->
    <div class="absolute top-1/4 left-1/4 w-72 h-72 bg-nftAccentPurple/10 rounded-full blur-[100px] pointer-events-none"></div>
    <div class="absolute bottom-1/4 right-1/4 w-72 h-72 bg-nftAccentCyan/10 rounded-full blur-[100px] pointer-events-none"></div>

    <div class="max-w-md w-full space-y-8 relative z-10">
        <div class="text-center">
            <div class="mx-auto w-12 h-12 bg-gradient-to-tr from-nftAccentCyan to-nftAccentPurple rounded-xl flex items-center justify-center font-bold text-2xl tracking-wider shadow-lg shadow-cyan-500/20 cursor-pointer" onclick="window.location.href='<?php echo htmlspecialchars(app_url('index.php'), ENT_QUOTES, 'UTF-8'); ?>'">
                A
            </div>
            <h2 class="mt-6 text-3xl font-extrabold tracking-tight text-white">Sign in to your portal</h2>
            <p class="mt-2 text-sm text-nftTextGray">
                Access your items, orders, and dashboard infrastructure.
            </p>
        </div>
<!-- System Alert Messages Execution Wrapper -->
<?php if (isset($_SESSION['login_error'])): ?>
    <div class="bg-rose-500/10 border border-rose-500/20 text-rose-400 p-4 rounded-xl text-sm flex items-center space-x-2">
        <i class="fa-solid fa-circle-exclamation"></i>
        <span><?php echo $_SESSION['login_error']; unset($_SESSION['login_error']); ?></span>
    </div>
<?php endif; ?>
        <!-- Form Layout Module Block[cite: 2] -->
        <form class="glass-card mt-8 space-y-5 p-6 sm:p-8 rounded-3xl border border-slate-800/80" action="<?php echo htmlspecialchars(app_url('login-process.php'), ENT_QUOTES, 'UTF-8'); ?>" method="POST">
            
            <div class="space-y-1.5">
                <label for="email" class="text-xs font-semibold text-slate-300 uppercase tracking-wider">Email Address</label>
                <div class="relative">
                    <input id="email" name="email" type="email" required placeholder="john@example.com" class="w-full bg-slate-950/60 border border-slate-800/80 rounded-xl pl-10 pr-4 py-3 text-sm focus:outline-none focus:border-nftAccentCyan text-slate-200 transition-all">
                    <i class="fa-solid fa-envelope absolute left-3.5 top-3.5 text-xs text-nftTextGray"></i>
                </div>
            </div>

            <div class="space-y-1.5">
                <div class="flex items-center justify-between">
                    <label for="password" class="text-xs font-semibold text-slate-300 uppercase tracking-wider">Account Password</label>
                    <a href="#" class="text-[11px] text-nftAccentPurple hover:text-nftAccentCyan transition-colors">Forgot credentials?</a>
                </div>
                <div class="relative">
                    <input id="password" name="password" type="password" required placeholder="••••••••" class="w-full bg-slate-950/60 border border-slate-800/80 rounded-xl pl-10 pr-4 py-3 text-sm focus:outline-none focus:border-nftAccentCyan text-slate-200 transition-all">
                    <i class="fa-solid fa-lock absolute left-3.5 top-3.5 text-xs text-nftTextGray"></i>
                </div>
            </div>

            <button type="submit" class="w-full btn-gradient py-3.5 rounded-xl font-bold text-sm tracking-wide shadow-xl transition-all[cite: 2]">
                Access Dashboard Systems <i class="fa-solid fa-arrow-right-to-bracket ml-2 text-xs"></i>
            </button>

            <div class="text-center text-xs text-nftTextGray pt-2">
                New to the platform? <a href="<?php echo htmlspecialchars(app_url('register.php'), ENT_QUOTES, 'UTF-8'); ?>" class="text-nftAccentCyan hover:underline font-semibold">Create account</a>
            </div>
        </form>
    </div>
</div>

</body>
</html>
