<!doctype html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Détail produit <%= product.nom %></title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="bg-gray-100">
<%- include('../components/navbar'); -%>
<% if(addedPannier) {%>
    <div id="toast-success" class="absolute duration-700 ease-in opacity-100 flex items-center w-full max-w-xs p-4 mt-4 ml-4 text-gray-500 bg-white rounded-lg shadow" role="alert">
        <div class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200">
            <svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"></path></svg>
            <span class="sr-only">Check icon</span>
        </div>
        <div class="ml-3 text-sm font-normal">Produit ajouté avec succès !</div>
    </div>
<% }%>
<div class="container mx-auto px-4 py-8">
    <div class="max-w-xl mx-auto bg-white rounded shadow">
        <div class="p-8">
            <h1 class="text-2xl font-semibold mb-4"><%= product.nom %></h1>
            <div class="mb-4">
                <img src="<%= product.image %>" alt="<%= product.nom %>" class="w-full rounded-lg">
            </div>
            <p class="text-gray-700 mb-4"><%= product.description %></p>
            <p class="text-gray-700 mb-4">Prix: <%= product.prix %> €</p>
            <p class="text-gray-700 mb-4">Couleur: <%= product.couleur %></p>
            <p class="text-gray-700 mb-4">Texture: <%= product.texture %></p>
            <p class="text-gray-700 mb-4">Forme: <%= product.forme %></p>
            <p class="text-gray-700 mb-4">Goût: <%= product.gout %></p>
            <form action="/panier" method="post" class="w-full max-w-lg">
                <div class="flex flex-wrap -mx-3 mb-6">
                    <input type="hidden" name="idBonbon" id="idBonbon" value="<%= product.id %>">
                    <div class="pr-4">
                        <input type="number" value="1" id="quantity" name="quantity" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" required>
                    </div>
                    <button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Ajouter au panier</button>
                </div>
            </form>

        </div>

    </div>
    <div>
        <h2 class="text-2xl font-bold tracking-tight text-gray-900">Produits recommandés en fonction des caractéristiques du bonbon</h2>
        <div class="mt-6 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-4 xl:gap-x-8">
            <% for (let j = 0; j < produitSimilaires.length; j++) { %>
                <div class="group relative">
                    <div class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-md bg-gray-200 lg:aspect-none group-hover:opacity-75 lg:h-80">
                        <img src="<%- produitSimilaires[j].image %>" alt="<%- produitSimilaires[j].nom %>" class="h-full w-full object-cover object-center lg:h-full lg:w-full">
                    </div>
                    <div class="mt-4 flex justify-between">
                        <div>
                            <h3 class="text-sm text-gray-700">
                                <a href="/produit/<%- produitSimilaires[j].id %>">
                                    <span aria-hidden="true" class="absolute inset-0"></span>
                                    <%- produitSimilaires[j].nom %>
                                </a>
                            </h3>
                        </div>
                        <p class="text-sm font-medium text-gray-900"><%- produitSimilaires[j].prix %> €</p>
                    </div>
                </div>
            <% } %>
        </div>
    </div>
</div>
<%- include('../components/footer'); -%>

<script>
    const toast = document.getElementById('toast-success');
    if(toast) {
        setTimeout(() => {
            toast.classList.add('opacity-0');
        }, 2000);
    }
</script>

</body>

</html>


