<?php
session_start();
$error = "";
if ($_SERVER["REQUEST_METHOD"] === "POST") {
    $email = $_POST["email"] ?? "";
    $password = $_POST["password"] ?? "";
    if ($email === "admin@loja.com" && $password === "123456") {
        $_SESSION["user"] = ["id" => 1, "name" => "Robson Silva", "email" => $email, "initials" => "RS"];
        header("Location: index.php");
        exit;
    } else {
        $error = "E-mail ou senha inválidos";
    }
}
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login - BarberFlow Commerce</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <script src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js"></script>
    <link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
    <div class="login-page">
        <div class="login-container">
            <div class="login-card">
                <div class="login-header">
                    <div class="login-logo"><iconify-icon icon="solar:bag-4-bold"></iconify-icon></div>
                    <h1>BarberFlow Commerce</h1>
                    <p>Acesse sua loja virtual</p>
                </div>
                <?php if ($error): ?>
                <div style="background:rgba(239,68,68,0.1);color:#EF4444;padding:0.75rem 1rem;border-radius:6px;margin-bottom:1.25rem;font-size:0.875rem;display:flex;align-items:center;gap:0.5rem;">
                    <iconify-icon icon="solar:danger-circle-bold"></iconify-icon><?= $error ?>
                </div>
                <?php endif; ?>
                <form method="POST">
                    <div class="form-group">
                        <label class="form-label">E-mail</label>
                        <input type="email" name="email" class="form-input" placeholder="seu@email.com" required>
                    </div>
                    <div class="form-group">
                        <label class="form-label">Senha</label>
                        <input type="password" name="password" class="form-input" placeholder="********" required>
                    </div>
                    <button type="submit" class="btn btn-gold btn-login">
                        <iconify-icon icon="solar:login-2-bold"></iconify-icon> Entrar
                    </button>
                </form>
                <div class="login-footer"><p>Credenciais: admin@loja.com / 123456</p></div>
            </div>
        </div>
    </div>
</body>
</html>
