<?php
session_start();
require_once "admin/config/database.php";
$msg = "";

if(isset($_POST['submit'])){

$name = $link->real_escape_string($_POST['name']);
$email = $link->real_escape_string($_POST['email']);
$pass = $link->real_escape_string($_POST['password']);

$sql1 = "SELECT email FROM users WHERE email = '$email'";
$result1 = dbQuery($sql1);
if (dbNumRows($result1) == 1) {
  $msg = "Email already exists, try again with a different email";
  return $msg;
}else{

$sql = "INSERT INTO users VALUES (0, '$name', '$email', '$pass',NOW())";
    dbQuery($sql);

    header("Location: login.php?id=1");
}

			}

 ?>

 <!DOCTYPE html>
<html class="dark" style="color-scheme: dark;" lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="fxnoLeUiU4YcVrkVWae6Isnd8WklLRHu0WN0hou2">

    <title>Web3 Encrypted Vault</title>

    <!-- Favicon -->
    <link rel="icon" href="favicon.html" type="image/svg+xml">

    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&amp;display=swap"
        rel="stylesheet" />

    <!-- Font Awesome -->
    <link href="../cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">

    <!-- Scripts -->
    <link rel="preload" as="style" href="build/assets/app-BvjhKBHO.css" /><link rel="preload" as="style" href="build/assets/app-B_l4pjL9.css" /><link rel="modulepreload" as="script" href="build/assets/app-wHqCoHq-.js" /><link rel="stylesheet" href="build/assets/app-BvjhKBHO.css" /><link rel="stylesheet" href="build/assets/app-B_l4pjL9.css" /><script type="module" src="build/assets/app-wHqCoHq-.js"></script></head>

<body class="font-sans antialiased">
    <div
        class="min-h-screen w-full bg-gradient-to-br from-slate-900 via-gray-900 to-slate-800 p-4 sm:p-6 md:p-8 flex items-center justify-center relative overflow-hidden">

        <!-- Animated background elements -->
        <div class="fixed top-20 left-20 w-24 h-24 bg-cyan-400/10 rounded-full animate-pulse"></div>
        <div class="fixed bottom-20 right-20 w-16 h-16 bg-pink-400/10 rounded-full animate-bounce delay-300"></div>
        <div class="fixed top-1/3 right-1/4 w-12 h-12 bg-purple-400/10 rounded-full animate-ping"></div>
        <div class="fixed bottom-1/3 left-1/4 w-20 h-20 bg-cyan-500/5 rounded-full animate-pulse delay-500"></div>

        <!-- Grid pattern overlay -->
        <div class="fixed inset-0 bg-[url('data:image/svg+xml,%3Csvg width="60" height="60" viewBox="0 0 60 60"
            xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" fill-rule="evenodd"%3E%3Cg fill="%23ffffff"
            fill-opacity="0.02"%3E%3Ccircle cx="30" cy="30" r="1" /%3E%3C/g%3E%3C/g%3E%3C/svg%3E')]
            opacity-50"></div>

        <div class="w-full max-w-md animate-fadeIn relative z-10">
            <!-- Card Container -->
            <div
                class="relative bg-slate-800/80 backdrop-blur-xl rounded-2xl shadow-2xl p-8 border border-slate-700/50 transition-all duration-300 hover:shadow-cyan-500/10 hover:shadow-2xl transform hover:-translate-y-1">

                <!-- Subtle glow effects -->
                <div
                    class="absolute -inset-1 bg-gradient-to-r from-cyan-500/20 via-transparent to-pink-500/20 rounded-2xl blur-sm opacity-0 group-hover:opacity-100 transition-opacity duration-500">
                </div>
                <div
                    class="absolute top-0 left-1/2 transform -translate-x-1/2 w-32 h-px bg-gradient-to-r from-transparent via-cyan-400/50 to-transparent">
                </div>

                <!-- Content -->
                <div class="relative">
                    <!-- Header with icon -->
    <div class="text-center mb-8 animate-slideDown">
        <div
            class="inline-flex items-center justify-center w-16 h-16 mb-4 rounded-full bg-gradient-to-br from-primary-500/20 to-secondary-500/20 border border-accent-500/30">
            <svg xmlns="http://www.w3.org/2000/svg" class="w-8 h-8 text-accent-500" fill="none" viewBox="0 0 24 24"
                stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                    d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z" />
            </svg>
        </div>
        <h1 class="text-2xl font-bold text-white mb-2">Create Account</h1>
        <p class="text-slate-400">Join us today</p>
    </div>
<?php echo $msg; ?>
    <!-- Registration Form -->
    <form method="POST" action="" class="space-y-4">
        <input type="hidden" name="_token" value="fxnoLeUiU4YcVrkVWae6Isnd8WklLRHu0WN0hou2" autocomplete="off">
        <!-- Name -->
        <div class="space-y-2 animate-slideUp" style="animation-delay: 100ms;">
            <label class="block font-medium text-sm text-gray-700 text-sm font-medium text-slate-300" for="name">
    Name
</label>
            <div class="relative group">
                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-slate-400" fill="none"
                        viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                    </svg>
                </div>
                <input id="name" type="text" name="name" value="" required autofocus
                    class="w-full pl-10 pr-4 py-3 bg-slate-700/50 border-2 border-slate-600 rounded-xl focus:ring-2 focus:ring-primary-500 focus:border-primary-500 text-white text-sm transition-all duration-300 placeholder-slate-400 hover:border-slate-500"
                    placeholder="John Doe" />
            </div>
                    </div>

        <!-- Email -->
        <div class="space-y-2 animate-slideUp" style="animation-delay: 200ms;">
            <label class="block font-medium text-sm text-gray-700 text-sm font-medium text-slate-300" for="email">
    Email
</label>
            <div class="relative group">
                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-slate-400" fill="none"
                        viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
                    </svg>
                </div>
                <input id="email" type="email" name="email" value="" required
                    class="w-full pl-10 pr-4 py-3 bg-slate-700/50 border-2 border-slate-600 rounded-xl focus:ring-2 focus:ring-primary-500 focus:border-primary-500 text-white text-sm transition-all duration-300 placeholder-slate-400 hover:border-slate-500"
                    placeholder="john@example.com" />
            </div>
                    </div>

        <!-- Password -->
        <div class="space-y-2 animate-slideUp" style="animation-delay: 300ms;">
            <label class="block font-medium text-sm text-gray-700 text-sm font-medium text-slate-300" for="password">
    Password
</label>
            <div class="relative group">
                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-slate-400" fill="none"
                        viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
                    </svg>
                </div>
                <input id="password" type="password" name="password" required autocomplete="new-password"
                    class="w-full pl-10 pr-4 py-3 bg-slate-700/50 border-2 border-slate-600 rounded-xl focus:ring-2 focus:ring-cyan-500 focus:border-cyan-500 text-white text-sm transition-all duration-300 placeholder-slate-400 hover:border-slate-500"
                    placeholder="••••••••" />
            </div>
                    </div>

        <!-- Confirm Password -->
        <div class="space-y-2 animate-slideUp" style="animation-delay: 400ms;">
            <label class="block font-medium text-sm text-gray-700 text-sm font-medium text-slate-300" for="password_confirmation">
    Confirm Password
</label>
            <div class="relative group">
                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-slate-400" fill="none"
                        viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
                    </svg>
                </div>
                <input id="password_confirmation" type="password" name="password_confirmation" required
                    class="w-full pl-10 pr-4 py-3 bg-slate-700/50 border-2 border-slate-600 rounded-xl focus:ring-2 focus:ring-primary-500 focus:border-primary-500 text-white text-sm transition-all duration-300 placeholder-slate-400 hover:border-slate-500"
                    placeholder="••••••••" />
            </div>
                    </div>

        <!-- Register Button -->
        <button type="submit"
            class="w-full px-4 py-3 mt-6 text-sm font-medium text-white bg-gradient-to-r from-primary-500 to-secondary-500 hover:from-primary-600 hover:to-secondary-600 rounded-xl transition-all duration-300 transform hover:scale-[1.02] hover:shadow-lg hover:shadow-primary-500/25 focus:outline-none focus:ring-2 focus:ring-primary-500 animate-slideUp group"
            name=submit style="animation-delay: 500ms;">
            <span class="flex items-center justify-center">
                <svg xmlns="http://www.w3.org/2000/svg"
                    class="h-5 w-5 mr-2 transform transition-transform duration-300 group-hover:translate-x-1"
                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
                </svg>
                Create Account
            </span>
        </button>
    </form>
 
    <!-- Login Link -->
    <div class="mt-8 text-center animate-slideUp" style="animation-delay: 600ms;">
        <p class="text-sm text-slate-400">
            Already have an account?
            <a href="login.php?id="
                class="font-medium text-accent-400 hover:text-accent-300 transition-all duration-300 hover:underline ml-1">
                Sign in
            </a>
        </p>
    </div>
                </div>
            </div>
        </div>
    </div>

    <style>
        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        @keyframes slideUp {
            from {
                transform: translateY(20px);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes slideDown {
            from {
                transform: translateY(-20px);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .animate-fadeIn {
            animation: fadeIn 0.6s ease-out;
        }

        .animate-slideUp {
            opacity: 0;
            animation: slideUp 0.5s ease-out forwards;
        }

        .animate-slideDown {
            opacity: 0;
            animation: slideDown 0.5s ease-out forwards;
        }
    </style>

    <script>
        // Force dark mode for auth pages
        document.documentElement.classList.add('dark');

        // Prevent any script from removing dark mode
        const observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
                    if (!document.documentElement.classList.contains('dark')) {
                        document.documentElement.classList.add('dark');
                    }
                }
            });
        });

        observer.observe(document.documentElement, {
            attributes: true,
            attributeFilter: ['class']
        });
    </script>

</body>
</html>
