<!-- Import des bibliothèques nécessaires -->
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@fullcalendar/icalendar@6.1.8/index.global.min.js"></script>

<div id="calendar-final" style="height: 700px; background: white; padding: 10px; border: 1px solid #ddd;"></div>

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar-final');
    var calendar = new FullCalendar.Calendar(calendarEl, {
      initialView: 'dayGridMonth',
      locale: 'fr',
      headerToolbar: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,listMonth'
      },
      events: {
        url: 'https://www.nuage.ooo/wp-content/uploads/agenda.ics',
        format: 'ics'
      },
      eventClick: function(info) {
        alert('Événement : ' + info.event.title + '\nDescription : ' + (info.event.extendedProps.description || 'Pas de détails'));
      },
      eventSourceFailure: function(error) {
        console.error("Erreur de chargement de l'ICS:", error);
        alert("Le calendrier n'a pas pu charger les événements. Vérifiez la console (F12).");
      }
    });
    calendar.render();
  });
</script>