<?php
session_start();
include '../controler/database.php';

include '../controler/actionModif.php';
?>

<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <title>Profil</title>
    <link rel="stylesheet" href="../css/profil.css">
</head>
<header>
 <div class="grand-titre">
                <h1>MON PROFIL</h1>
                <p>Vos informations personnelles</p>
</div>
</header>
<body>
<?php include '../controler/menu-profil.php';?>


<div class="but2">
    <a href="../controler/logout.php">Se déconnecter</a>
</div>

<!-- PROFIL -->


<?php if ($message): ?>
    <div class="message-alert <?php echo strpos($message, 'succès') !== false ? 'success' : 'error'; ?>">
        <?php echo $message; ?>
    </div>
<?php endif; ?>


<div class="profil-section">
    <!-- PROFIL (à gauche) -->
    <div class="profile">
        <div class="profile-header">
            <div class="logo"></div>
            <div class="nom">
                <h2><?php echo $prenom;?> <?php echo $nom;?></h2>
                <p class="pseudo">@<?php echo $pseudo;?></p>
            </div>
        </div>

        <div class="profile-info">
            <div class="section">
                <h3>Informations personnelles</h3>
                
                <div class="info">
                    <label>Nom :</label>
                    <p><?php echo $nom;?></p>
                </div>
                
                <div class="info">
                    <label>Prénom :</label>
                    <p><?php echo $prenom;?></p>
                </div>
                
                <div class="info">
                    <label>Nom d'utilisateur :</label>
                    <p><?php echo $pseudo;?></p>
                </div>
                
                <div class="info">
                    <label>Email :</label>
                    <p><?php echo $email;?></p>
                </div>
                
                <div class="info">
                    <label>Âge :</label>
                    <p><?php echo $age;?></p>
                </div>
            </div>

            <div class="section">
                <h3>Statistiques</h3>
                
                <div class="info">
                    <label>Événements rejoints :</label>
                    <p><?php echo $nombre_evenements;?></p>
                </div>
                
                <div class="info">
                    <label>Membre depuis :</label>
                    <p><?php echo $date;?></p>
                </div>
            </div>
        </div>
    </div>


    <div class="profile">
        <div class="profile-info">
            <div class="section">
                <h3>Modifier mes informations</h3>
                
                <form method="POST">
                    <div class="section">
                        <h3>Informations personnelles</h3>
                        
                        <div class="form-group">
                            <label>Nom :</label>
                            <input type="text" name="nom" value="<?php echo htmlspecialchars($nom);?>" required>
                        </div>
                        
                        <div class="form-group">
                            <label>Prénom :</label>
                            <input type="text" name="prenom" value="<?php echo htmlspecialchars($prenom);?>" required>
                        </div>
                        
                        <div class="form-group">
                            <label>Email :</label>
                            <input type="email" name="email" value="<?php echo htmlspecialchars($email);?>" required>
                        </div>
                        
                        <div class="form-group">
                            <label>Âge :</label>
                            <input type="number" name="age" value="<?php echo $age;?>" min="1" max="120">
                        </div>
                    </div>

                    <div class="section">
                        <h3>Changer le mot de passe</h3>
                        
                        <div class="form-group">
                            <label>Nouveau mot de passe :</label>
                            <input type="password" name="nouveau_mdp" placeholder="Laisser vide pour ne pas changer">
                        </div>
                        
                        <div class="form-group">
                            <label>Confirmer le nouveau mot de passe :</label>
                            <input type="password" name="confirmer_mdp" placeholder="Confirmer le mot de passe">
                        </div>
                    </div>

                    <button type="submit" class="btn-modifier">Sauvegarder les modifications</button>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>