<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Connexion - Plateforme d'Inscription</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <!-- Google Fonts - Montserrat -->
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary-blue: #00c0ed;
            --primary-green: #b7d22b;
            --primary-white: #ffffff;
            --primary-black: #000000;
            --light-blue: #f0f9ff;
            --light-green: #f8fce6;
            --gray-light: #f8f9fa;
            --gray-medium: #6c757d;
            --gray-dark: #343a40;
        }

        body {
            font-family: 'Montserrat', sans-serif;
            background-color: var(--light-blue);
            min-height: 100vh;
            display: flex;
            align-items: center;
            padding: 20px;
            margin: 0;
        }

        .container-custom {
            max-width: 400px;
            width: 100%;
            margin: 0 auto;
        }

        .main-card {
            background: var(--primary-white);
            border-radius: 12px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
            overflow: hidden;
            border: none;
            padding: 30px;
        }

        .logo {
            text-align: center;
            margin-bottom: 25px;
        }

        .logo-icon {
            width: 70px;
            height: 70px;
            background-color: var(--primary-blue);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 15px;
            color: var(--primary-white);
            font-size: 28px;
        }

        .logo h1 {
            color: var(--primary-black);
            font-weight: 700;
            font-size: 22px;
            margin-bottom: 5px;
        }

        .logo p {
            color: var(--gray-medium);
            font-size: 14px;
            line-height: 1.4;
        }

        .form-label {
            color: var(--gray-dark);
            font-weight: 500;
            font-size: 14px;
            margin-bottom: 6px;
        }

        .form-control {
            border: 1px solid #ced4da;
            border-radius: 6px;
            padding: 10px 12px;
            font-size: 14px;
            transition: all 0.2s ease;
            font-family: 'Montserrat', sans-serif;
        }

        .form-control:focus {
            border-color: var(--primary-blue);
            box-shadow: 0 0 0 3px rgba(0, 192, 237, 0.15);
        }

        .form-control::placeholder {
            color: var(--gray-medium);
        }

        .form-control.is-invalid {
            border-color: #dc3545;
        }

        .input-with-icon {
            position: relative;
        }

        .input-with-icon i {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--primary-blue);
            font-size: 16px;
        }

        .input-with-icon input {
            padding-left: 40px;
        }

        .btn-custom-primary {
            background-color: var(--primary-green);
            border: none;
            color: var(--primary-white);
            padding: 12px 30px;
            border-radius: 6px;
            font-weight: 600;
            font-size: 15px;
            transition: all 0.2s ease;
            width: 100%;
            font-family: 'Montserrat', sans-serif;
        }

        .btn-custom-primary:hover {
            background-color: var(--primary-blue);
            color: var(--primary-white);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 192, 237, 0.2);
        }

        .btn-custom-primary:disabled {
            opacity: 0.7;
            cursor: not-allowed;
        }

        .btn-custom-secondary {
            background-color: var(--primary-white);
            border: 2px solid var(--primary-blue);
            color: var(--primary-blue);
            padding: 12px 30px;
            border-radius: 6px;
            font-weight: 600;
            font-size: 15px;
            transition: all 0.2s ease;
            width: 100%;
            font-family: 'Montserrat', sans-serif;
        }

        .btn-custom-secondary:hover {
            background-color: var(--light-blue);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 192, 237, 0.1);
        }

        .separator {
            text-align: center;
            margin: 25px 0;
            position: relative;
        }

        .separator::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            width: 100%;
            height: 1px;
            background: #e9ecef;
        }

        .separator span {
            background: var(--primary-white);
            padding: 0 15px;
            color: var(--gray-medium);
            font-size: 13px;
            position: relative;
        }

        .forgot-password {
            text-align: center;
            margin-top: 15px;
            margin-bottom: 20px;
        }

        .forgot-password a {
            color: var(--primary-blue);
            text-decoration: none;
            font-size: 13px;
            font-weight: 500;
            transition: all 0.2s ease;
            cursor: pointer;
        }

        .forgot-password a:hover {
            color: var(--primary-green);
            text-decoration: underline;
        }

        .admin-link {
            text-align: center;
            margin-top: 25px;
            padding-top: 20px;
            border-top: 1px solid #e9ecef;
        }

        .admin-link a {
            color: var(--gray-medium);
            text-decoration: none;
            font-size: 13px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s ease;
        }

        .admin-link a:hover {
            color: var(--primary-blue);
        }

        .error-message {
            color: #dc3545;
            font-size: 12px;
            margin-top: 4px;
            display: none;
        }

        .error-message.show {
            display: block;
        }

        /* Alert styling */
        .alert-custom {
            border-radius: 6px;
            padding: 12px 15px;
            margin-bottom: 20px;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .alert-custom i {
            font-size: 18px;
        }

        .alert-custom.alert-error {
            background-color: #f8d7da;
            border: 1px solid #f5c6cb;
            color: #721c24;
        }

        .alert-custom.alert-success {
            background-color: #d4edda;
            border: 1px solid #c3e6cb;
            color: #155724;
        }

        .alert-custom.alert-warning {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            color: #856404;
        }

        /* Responsive adjustments */
        @media (max-width: 576px) {
            .main-card {
                padding: 20px;
            }

            .logo-icon {
                width: 60px;
                height: 60px;
                font-size: 24px;
            }

            .logo h1 {
                font-size: 20px;
            }

            body {
                padding: 15px;
            }
        }

        @media (max-width: 400px) {
            .container-custom {
                padding: 0 10px;
            }

            .main-card {
                padding: 15px;
            }
        }
    </style>
</head>
<body>
<div class="container-custom">
    <div class="card main-card">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-graduation-cap"></i>
            </div>
            <h1>Plateforme d'Inscription</h1>
            <p>Concours d'Entrée - Cycle d'Ingénieur</p>
        </div>



        <form id="loginForm" method="POST" action="">

            <div class="mb-3">
                <label class="form-label">CIN</label>
                <div class="input-with-icon">
                    <i class="fas fa-user"></i>
                    <input type="text" class="form-control" id="email-cin" name="email-cin" placeholder="Entrez votre CIN" required value="<?= htmlspecialchars($_POST['email-cin'] ?? '') ?>">
                </div>
                <div class="error-message" id="email-error">Veuillez entrer votre CIN</div>
            </div>

            <div class="mb-3">
                <label class="form-label">Mot de passe</label>
                <div class="input-with-icon">
                    <i class="fas fa-lock"></i>
                    <input type="password" class="form-control" id="password" name="password" placeholder="Entrez votre mot de passe" required>
                </div>
                <div class="error-message" id="password-error">Veuillez entrer votre mot de passe</div>
            </div>

            <div class="forgot-password">
                <a href="#" onclick="forgotPassword()">Mot de passe oublié ?</a>
            </div>

            <button type="submit" class="btn btn-custom-primary d-flex align-items-center justify-content-center gap-2 mb-3" id="loginBtn">
                <i class="fas fa-sign-in-alt"></i> Se Connecter
            </button>

            <div class="separator">
                <span>Nouveau candidat ?</span>
            </div>

            <button type="button" class="btn btn-custom-secondary d-flex align-items-center justify-content-center gap-2 mb-3" onclick="window.location.href='step1-personal-info.php'">
                <i class="fas fa-user-plus"></i> Créer un compte
            </button>

            <div class="admin-link">
                <a href="admin-login.php">
                    <i class="fas fa-cog"></i> Accès Administration
                </a>
            </div>
        </form>
    </div>
</div>

<script src="main.js"></script>

<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>

<script>
    // Validation function
    function validateForm() {
        const emailCin = document.getElementById('email-cin');
        const password = document.getElementById('password');
        let isValid = true;

        // Reset error states
        emailCin.classList.remove('is-invalid');
        password.classList.remove('is-invalid');
        document.getElementById('email-error').classList.remove('show');
        document.getElementById('password-error').classList.remove('show');

        // Validate fields
        if (!emailCin.value.trim()) {
            emailCin.classList.add('is-invalid');
            document.getElementById('email-error').classList.add('show');
            isValid = false;
        }

        if (!password.value.trim()) {
            password.classList.add('is-invalid');
            document.getElementById('password-error').classList.add('show');
            isValid = false;
        }

        return isValid;
    }

    // Real-time validation
    document.querySelectorAll('input[required]').forEach(input => {
        input.addEventListener('blur', function() {
            if (!this.value.trim()) {
                this.classList.add('is-invalid');
                const errorId = this.id + '-error';
                const errorEl = document.getElementById(errorId);
                if (errorEl) errorEl.classList.add('show');
            } else {
                this.classList.remove('is-invalid');
                const errorId = this.id + '-error';
                const errorEl = document.getElementById(errorId);
                if (errorEl) errorEl.classList.remove('show');
            }
        });
    });

    // Forgot password function
    function forgotPassword() {
        const emailCin = document.getElementById('email-cin').value;

        if (!emailCin) {
            alert('Veuillez entrer votre email ou CIN pour réinitialiser votre mot de passe.');
            document.getElementById('email-cin').focus();
            return;
        }

        // In a real app, you would send a reset link
        alert('📧 Un email de réinitialisation a été envoyé à l\'adresse associée à ' + emailCin + '.\n\nDans une application réelle, vous recevriez un lien pour réinitialiser votre mot de passe.');
    }

    // Focus on first input on page load
    document.addEventListener('DOMContentLoaded', function() {
        document.getElementById('email-cin').focus();
    });
</script>
</body>
</html>
