<div class="modal fade" id="visualiserFicheModal<?= $fiche['id'] ?>" tabindex="-1">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">

      <div class="modal-header bg-info text-white">
        <h5 class="modal-title">
          Fiche technique – <?= htmlspecialchars($fiche['produit']) ?>
        </h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>

      <div class="modal-body">

        <p>
          <strong>Produit fini :</strong>
          <?= htmlspecialchars($fiche['produit']) ?>
        </p>

        <table class="table table-bordered table-sm">
          <thead class="table-dark">
            <tr>
              <th>Matière première</th>
              <th>Quantité</th>
              <th>Unité</th>
            </tr>
          </thead>
          <tbody>
            <?php if (empty($details)): ?>
              <tr>
                <td colspan="3" class="text-center text-muted">
                  Aucune matière première enregistrée
                </td>
              </tr>
            <?php else: ?>
              <?php foreach ($details as $d): ?>
                <tr>
                  <td><?= htmlspecialchars($d['nom']) ?></td>
                  <td class="text-end">
                    <?= number_format($d['quantite'], 3, ',', ' ') ?>
                  </td>
                  <td><?= htmlspecialchars($d['unite']) ?></td>
                </tr>
              <?php endforeach; ?>
            <?php endif; ?>
          </tbody>
        </table>

      </div>

      <div class="modal-footer">
        <button class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
      </div>

    </div>
  </div>
</div>
