<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>نظام إدارة المبيعات - تسجيل الدخول</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            overflow: hidden;
            direction: rtl;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #4169E1, #87CEEB);
            position: relative;
        }

        .background {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #4169E1, #2ECC71, #F1C40F, #E74C3C);
            z-index: -1;
            animation: gradientShift 15s ease infinite;
            background-size: 400% 400%;
        }

        @keyframes gradientShift {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .particles {
            position: absolute;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        .login-container {
            position: relative;
            z-index: 1;
            max-width: 450px;
            margin: 0 auto;
            padding: 40px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 25px;
            box-shadow: 0 10px 30px rgba(65, 105, 225, 0.4);
            top: 50%;
            transform: translateY(-50%);
            animation: fadeIn 1s ease-in-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-60px); }
            to { opacity: 1; transform: translateY(-50%); }
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .login-header img {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            margin-bottom: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            animation: float 3s ease-in-out infinite;
        }

        @keyframes float {
            0% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0); }
        }

        .login-header h1 {
            color: #4169E1;
            font-size: 2.5rem;
            font-weight: bold;
            text-shadow: 0 0 5px rgba(65, 105, 225, 0.5);
        }

        .form-control {
            border-radius: 25px;
            padding: 12px 20px;
            border: 2px solid #4169E1;
            background: rgba(255, 255, 255, 0.8);
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: #2ECC71;
            box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
            background: #fff;
        }

        .btn-login {
            background: linear-gradient(45deg, #4169E1, #2ECC71);
            border: none;
            padding: 12px 30px;
            font-size: 1.2rem;
            font-weight: bold;
            border-radius: 25px;
            color: #fff;
            width: 100%;
            transition: all 0.4s ease;
            position: relative;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .btn-login::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            background: rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            transition: width 0.6s ease, height 0.6s ease;
        }

        .btn-login:hover::before {
            width: 300px;
            height: 300px;
        }

        .btn-login:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(46, 204, 113, 0.5);
        }

        .btn-login span {
            position: relative;
            z-index: 1;
            margin-right: 10px; /* مسافة بين النص والأيقونة */
        }

        .btn-login i {
            position: relative;
            z-index: 1;
            font-size: 1.2rem;
        }

        .btn-login:disabled {
            background: #cccccc;
            cursor: not-allowed;
        }

        .btn-login:disabled::before {
            display: none;
        }
    </style>
</head>
<body>
    <div class="background"></div>
    <div class="particles" id="particles-js"></div>
    
    <div class="login-container">
        <div class="login-header">
            <img src="uploads/logo.png" alt="Astra Logo">
            <h1>Astra</h1>
        </div>
        <?php if (isset($_GET['error'])): ?>
            <div class="alert alert-danger text-center" role="alert">
                <?php echo htmlspecialchars(urldecode($_GET['error'])); ?>
            </div>
        <?php endif; ?>
        <form id="login-form" action="login_process.php" method="POST">
            <div class="mb-4">
                <input type="text" class="form-control" name="username" placeholder="اسم المستخدم" required>
            </div>
            <div class="mb-4">
                <input type="password" class="form-control" name="password" placeholder="كلمة المرور" required>
            </div>
            <button type="submit" class="btn btn-login" id="login-btn">
                <span>تسجيل الدخول</span>
                <i class="fas fa-sign-in-alt"></i>
            </button>
        </form>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>
    <script>
        particlesJS("particles-js", {
            "particles": {
                "number": { "value": 100, "density": { "enable": true, "value_area": 800 } },
                "color": { "value": "#ffffff" },
                "shape": { "type": "circle" },
                "opacity": { "value": 0.5, "random": true },
                "size": { "value": 4, "random": true },
                "line_linked": {
                    "enable": true,
                    "distance": 150,
                    "color": "#2ECC71",
                    "opacity": 0.4,
                    "width": 1
                },
                "move": { "enable": true, "speed": 3, "direction": "none", "random": true }
            },
            "interactivity": {
                "detect_on": "canvas",
                "events": {
                    "onhover": { "enable": true, "mode": "repulse" },
                    "onclick": { "enable": true, "mode": "push" }
                }
            },
            "retina_detect": true
        });

        // إضافة رسالة تحميل أثناء معالجة تسجيل الدخول
        document.getElementById('login-form').addEventListener('submit', function(e) {
            const loginBtn = document.getElementById('login-btn');
            loginBtn.disabled = true;
            loginBtn.innerHTML = '<span>جاري تسجيل الدخول...</span><i class="fas fa-spinner fa-spin"></i>';
        });
    </script>
</body>
</html>