<!DOCTYPE html>
<html lang="fr"  th:replace="~{modele-page :: layout('Accueil - ENI-Enchères',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="assets/bootstrap-icons/bootstrap-icons.min.css" rel="stylesheet">
</head>
<body>
<div id="container-main">
    <div class="container mt-4">
        <div class="row mb-4">
            <div class="col-12">
                <!-- Formulaire de recherche avec sélection de catégorie -->
                <form th:action="@{/accueil}" method="post" class="mb-3">
                    <!-- Barre de recherche -->
                    <div class="mb-3">
                        <input type="text" class="form-control" th:attr="placeholder=#{accueil.search.title}" name="searchTitle">
                    </div>
                    <div class="mb-3">
                        <select class="form-control" name="searchCategory">
                            <option value="">Toutes les catégories</option>
                            <option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-primary">Recherche</button>
                </form>
            </div>
        </div>
        <div class="row">
            <div th:each="article : ${articles}" class="col-md-6 mb-4">
                <div class="card shadow-sm h-100">
                    <div class="row g-0">
                        <div class="col-md-4 d-flex align-items-center justify-content-center p-3">
                            <img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded">
                        </div>
                        <div class="col-md-8">
                            <div class="card-body d-flex flex-column">
                                <h5 class="card-title" th:text="${article.nom}">Nom de l'article</h5>
                                <p class="card-text mb-auto" th:text="${article.desc}">Description</p>
                                <div class="d-flex justify-content-between align-items-center">
                                    <div>
                                        <h6>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>

                                        <h6>Vendeur: <span th:text="${article.utilisateur.getPseudo()}"></span> </h6>
                                    </div>
                                </div>
                                </br>
                                <h6 class="text-muted">Fin de l'enchere: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="js/bootstrap/bootstrap.min.js"></script>
</body>
</html>