<?php session_start(); require_once 'includes/header.php'; ?>
<div class="row align-items-center mb-5">
    <div class="col-md-6">
        <h1 class="display-4">Bienvenue chez <span class="text-primary">CIBER</span></h1>
        <p class="lead">Votre partenaire de confiance pour le contrôle qualité dans le BTP.</p>
    </div>
    <div class="col-md-6">
        <img src="assets/images/chantier.jpg" class="img-fluid rounded shadow" alt="Chantier BTP">
    </div>
</div>
<div class="row g-4">
    <div class="col-md-6">
        <div class="card h-100 border-primary">
            <div class="card-header bg-primary text-white text-center py-3">
                <h3><i class="fas fa-hard-hat me-2"></i> Personnel</h3>
            </div>
            <div class="card-body">
                <form action="login.php" method="post">
                    <div class="mb-3">
                        <label for="username_pers" class="form-label">Nom d'utilisateur</label>
                        <input type="text" class="form-control" id="username_pers" name="username" required>
                    </div>
                    <div class="mb-3">
                        <label for="password_pers" class="form-label">Mot de passe</label>
                        <div class="input-group">
                            <input type="password" class="form-control" id="password_pers" name="password" required>
                            <button class="btn btn-outline-secondary" type="button" onclick="togglePassword('password_pers', this)"><i class="fas fa-eye"></i></button>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary w-100">Connexion</button>
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="card h-100 border-danger">
            <div class="card-header bg-danger text-white text-center py-3">
                <h3><i class="fas fa-crown me-2"></i> Administration</h3>
            </div>
            <div class="card-body">
                 <p class="text-muted">Accès réservé aux administrateurs.</p>
                <form action="login.php" method="post">
                    <div class="mb-3">
                        <label for="username_admin" class="form-label">Nom d'utilisateur</label>
                        <input type="text" class="form-control" id="username_admin" name="username" required>
                    </div>
                    <div class="mb-3">
                        <label for="password_admin" class="form-label">Mot de passe</label>
                        <div class="input-group">
                            <input type="password" class="form-control" id="password_admin" name="password" required>
                            <button class="btn btn-outline-secondary" type="button" onclick="togglePassword('password_admin', this)"><i class="fas fa-eye"></i></button>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-danger w-100">Connexion</button>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
function togglePassword(fieldId, btn) {
    const field = document.getElementById(fieldId);
    if (field.type === 'password') {
        field.type = 'text';
        btn.innerHTML = '<i class="fas fa-eye-slash"></i>';
    } else {
        field.type = 'password';
        btn.innerHTML = '<i class="fas fa-eye"></i>';
    }
}
</script>
<?php
if (isset($_SESSION['error'])) { echo '<div class="alert alert-danger mt-3">' . $_SESSION['error'] . '</div>'; unset($_SESSION['error']); }
if (isset($_SESSION['success'])) { echo '<div class="alert alert-success mt-3">' . $_SESSION['success'] . '</div>'; unset($_SESSION['success']); }
require_once 'includes/footer.php';
?>