File size: 25,209 Bytes
03084ff
 
 
 
 
c870f81
c721805
 
 
2ae3cf3
 
c721805
c870f81
51e6ea5
 
 
 
 
 
 
 
 
 
2ae3cf3
 
 
51e6ea5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03084ff
51e6ea5
c870f81
 
 
 
 
7b917ee
 
 
 
 
 
 
 
 
 
c870f81
03084ff
c870f81
 
 
7b917ee
c870f81
 
7b917ee
c870f81
7b917ee
c870f81
e6f372c
c870f81
 
1c9d3b3
7b917ee
c870f81
7b917ee
c870f81
 
7b917ee
 
e6f372c
 
7b917ee
 
 
 
 
 
 
c870f81
 
 
 
03084ff
7b917ee
c870f81
 
7b917ee
 
 
 
 
 
2ae3cf3
7b917ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c870f81
 
1c9d3b3
 
7b917ee
c870f81
 
7b917ee
51e6ea5
7b917ee
 
 
 
 
 
 
 
c870f81
1c9d3b3
7b917ee
 
 
 
 
 
 
 
c870f81
 
6f7cdb6
2a72442
7b917ee
2a72442
c870f81
 
1c9d3b3
7b917ee
 
 
2a72442
 
7b917ee
 
 
c870f81
51e6ea5
 
 
 
 
 
 
 
 
c870f81
a01391a
03084ff
 
 
2ae3cf3
7b917ee
2ae3cf3
021083f
 
 
 
 
 
 
 
 
2ae3cf3
 
021083f
 
 
 
 
 
 
 
 
 
 
03084ff
2a72442
 
021083f
 
 
 
 
 
 
7b917ee
021083f
 
1c71f62
021083f
 
 
 
8484853
 
021083f
 
 
 
 
 
 
 
a01391a
7b917ee
021083f
7b917ee
021083f
 
03084ff
1c71f62
7b917ee
03084ff
021083f
 
 
 
 
 
 
 
 
 
 
 
 
c870f81
 
021083f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b917ee
c870f81
2a72442
021083f
 
7b917ee
021083f
51e6ea5
021083f
7b917ee
021083f
2ae3cf3
969f0b5
 
2ae3cf3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969f0b5
 
021083f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a72442
 
021083f
51e6ea5
 
 
 
021083f
 
 
51e6ea5
021083f
 
 
 
51e6ea5
021083f
 
 
 
 
 
 
 
 
 
03084ff
021083f
51e6ea5
 
 
 
 
 
 
 
 
2ae3cf3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51e6ea5
 
 
 
 
 
 
 
 
 
 
 
 
2ae3cf3
 
51e6ea5
2ae3cf3
 
51e6ea5
2ae3cf3
 
51e6ea5
 
 
2ae3cf3
 
 
 
 
 
51e6ea5
 
 
2ae3cf3
 
 
 
 
 
51e6ea5
 
 
 
 
 
 
6f7cdb6
2a72442
6f7cdb6
 
 
 
2a72442
 
 
6f7cdb6
2a72442
 
021083f
6f7cdb6
 
 
 
 
 
 
 
 
 
021083f
6f7cdb6
 
 
021083f
6f7cdb6
 
 
 
 
 
 
021083f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b917ee
021083f
 
03084ff
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mariam AI - Assistant Philosophique</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.3/sweetalert2.all.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.3.0/marked.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/locale/fr.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert2/11.7.3/sweetalert2.min.css" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        .collapsible {
            cursor: pointer;
            padding: 18px;
            width: 100%;
            border: none;
            text-align: left;
            outline: none;
            font-size: 15px;
            background-color: #f1f1f1;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .active, .collapsible:hover {
            background-color: #ddd;
        }

        .content {
            padding: 0 18px;
            display: none;
            overflow: hidden;
            background-color: white;
        }
        .animate-fadeIn {
            animation: fadeIn 0.5s ease-out forwards;
        }
        .animate-slideUp {
            animation: slideUp 0.5s ease-out forwards;
        }
        .animate-shake {
            animation: shake 0.5s ease-in-out;
        }
         @keyframes fadeIn {
                from { opacity: 0; transform: translateY(10px); }
                to { opacity: 1; transform: translateY(0); }
            }
            @keyframes slideUp {
                from { opacity: 0; transform: translateY(20px); }
                to { opacity: 1; transform: translateY(0); }
            }
            @keyframes shake {
                0%, 100% { transform: translateX(0); }
                25% { transform: translateX(-5px); }
                75% { transform: translateX(5px); }
            }
    </style>
</head>

<body class="bg-gradient-to-br from-violet-50 to-indigo-50 min-h-screen">
    <!-- Navbar -->
    <nav class="bg-white/80 backdrop-blur-md border-b border-gray-200 fixed w-full z-50">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between items-center h-16">
                <div class="flex items-center">
                    <div class="text-2xl font-bold bg-gradient-to-r from-violet-600 to-indigo-600 text-transparent bg-clip-text">
                        Mariam AI
                    </div>
                </div>
                <div class="flex items-center space-x-4">
                    <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-violet-100 text-violet-800">
                        <span class="w-2 h-2 bg-violet-400 rounded-full animate-pulse mr-2"></span>
                        Assistant Philosophique
                    </span>
                </div>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <div class="pt-24 pb-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto">
            <!-- Main Card -->
            <div class="bg-white/80 backdrop-blur-md rounded-2xl shadow-xl border border-gray-100 overflow-hidden">
                <!-- Header Section -->
                <div class="bg-gradient-to-r from-violet-600 to-indigo-600 p-6 text-white">
                    <h2 class="text-2xl font-bold">Gen'Dissertation</h2>
                    <p class="mt-2 opacity-90">Créez des dissertations philosophiques pertinentes et structurées</p>
                </div>

                <!-- Content Section -->
                <div class="p-8 space-y-8">
                    <!-- Type Selection -->
                    <div class="space-y-3">
                        <label class="block text-sm font-medium text-gray-700">Type de dissertation</label>
                        <div class="relative">
                            <select id="type-select" class="w-full rounded-xl border-gray-200 shadow-sm focus:border-violet-500 focus:ring-violet-500 appearance-none bg-white py-3 px-4 pr-10">
                                <option value="1">Type 1 -</option>
                                <option value="2">Type 2 -</option>
                            </select>
                            <div class="absolute inset-y-0 right-0 flex items-center px-4 pointer-events-none">
                                <svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </div>
                        <div id="current-type-label" class="inline-flex px-4 py-2 rounded-xl text-sm font-medium bg-gradient-to-r from-violet-50 to-indigo-50 text-violet-700 border border-violet-200">
                            Sujet de type 1
                        </div>
                    </div>

                    <!-- Course Selection -->
                    <div class="space-y-3">
                        <label class="block text-sm font-medium text-gray-700">Sélection du cours</label>
                        <div class="relative">
                            <select id="course-select" class="w-full rounded-xl border-gray-200 shadow-sm focus:border-violet-500 focus:ring-violet-500 appearance-none bg-white py-3 px-4 pr-10">
                                <option value="">Choisir un cours...</option>
                            </select>
                            <div class="absolute inset-y-0 right-0 flex items-center px-4 pointer-events-none">
                                <svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                                    <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-11.414z" clip-rule="evenodd" />
                                </svg>
                            </div>
                        </div>
                        <div class="course-meta hidden">
                            <div class="bg-gradient-to-r from-gray-50 to-white rounded-xl p-4 border border-gray-100">
                                <div class="flex justify-between items-center">
                                    <span id="course-author" class="flex items-center space-x-2">
                                        <svg class="h-5 w-5 text-violet-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                                        </svg>
                                        <span class="text-gray-600"></span>
                                    </span>
                                    <span id="course-date" class="flex items-center space-x-2">
                                        <svg class="h-5 w-5 text-violet-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
                                        </svg>
                                        <span class="text-gray-600"></span>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Question Input -->
                    <div class="space-y-3">
                        <label class="block text-sm font-medium text-gray-700">Sujet de dissertation</label>
                        <div class="relative">
                            <textarea id="question" rows="4"
                                class="w-full rounded-xl border-gray-200 shadow-sm focus:border-violet-500 focus:ring-violet-500 resize-none bg-white py-3 px-4"
                                placeholder="Saisissez votre sujet de dissertation..."></textarea>
                            <div class="absolute bottom-3 right-3 flex items-center space-x-2 text-gray-400">
                                <svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
                                </svg>
                            </div>
                        </div>
                    </div>

                    <!-- Submit Button -->
                    <button id="submit-btn" class="w-full py-4 px-6 rounded-xl bg-gradient-to-r from-violet-600 to-indigo-600 text-white font-medium shadow-lg shadow-violet-200 hover:shadow-xl hover:shadow-violet-300 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:ring-offset-2">
                        <span class="flex items-center justify-center space-x-2">
                            <svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
                            </svg>
                            <span>Générer la dissertation</span>
                        </span>
                    </button>

                    <!-- Response Section -->
                    <div id="response" class="hidden mt-8 prose prose-violet max-w-none">
                        <div class="bg-gradient-to-r from-gray-50 to-white rounded-xl p-6 border border-gray-100">
                            <!-- La réponse sera insérée ici -->
                        </div>
                    </div>

                    <!-- Copy Button -->
                    <button id="copy-btn" class="hidden w-full py-3 px-6 rounded-xl bg-gray-50 text-gray-700 font-medium border border-gray-200 hover:bg-gray-100 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2">
                        <span class="flex items-center justify-center space-x-2">
                            <svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
                            </svg>
                            <span>Copier la dissertation</span>
                        </span>
                    </button>

                      <!-- Saved Dissertations Section -->
                    <div id="saved-dissertations" class="mt-8">
                        <h3 class="text-lg font-medium text-gray-700 mb-4">Dissertations Sauvegardées</h3>
                        <div id="dissertations-list" class="space-y-4">
                            <!-- Les dissertations sauvegardées seront insérées ici -->
                        </div>
                    </div>

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

<script>
    $(document).ready(function() {
        // Configuration de marked
        marked.setOptions({
            breaks: true,
            gfm: true,
            headerIds: true,
            langPrefix: 'language-',
            smartLists: true,
            smartypants: true
        });

        moment.locale('fr'); // Configuration de moment.js en français

        // Configuration des notifications
        const Toast = Swal.mixin({
            toast: true,
            position: 'top-end',
            showConfirmButton: false,
            timer: 3000,
            timerProgressBar: true,
            customClass: {
                popup: 'rounded-lg shadow-xl border border-gray-100'
            }
        });



        // Animation des boutons
        function addButtonAnimation(buttonId) {
            $(`#${buttonId}`).on('mousedown', function() {
                $(this).addClass('scale-95');
            }).on('mouseup mouseleave', function() {
                $(this).removeClass('scale-95');
            });
        }
        addButtonAnimation('submit-btn');
        addButtonAnimation('copy-btn');

        // Gestion du changement de type
        $('#type-select').change(function() {
            const type = $(this).val();
            const labels = {
                '1': 'Type1',
                '2': 'Type2'
            };
            $('#current-type-label').text(`Type ${type} - ${labels[type]}`);
        });

        // Chargement des cours avec animation
        function loadCourses() {
            return $.ajax({
                url: '/api/philosophy/courses',
                method: 'GET',
                beforeSend: function() {
                    $('#course-select').addClass('animate-pulse');
                },
                complete: function() {
                    $('#course-select').removeClass('animate-pulse');
                }
            });
        }

        loadCourses()
            .done(function(courses) {
                const select = $('#course-select');
                courses.forEach(course => {
                    select.append(`<option value="${course.id}">${course.title}</option>`);
                });
            })
            .fail(function() {
                Toast.fire({
                    icon: 'error',
                    title: 'Erreur de chargement des cours',
                    text: 'Veuillez réessayer ultérieurement'
                });
            });

        // Gestion du changement de cours avec animations
        $('#course-select').change(function() {
            const courseId = $(this).val();
            if (courseId) {
                $.ajax({
                    url: `/api/philosophy/courses/${courseId}`,
                    method: 'GET',
                    beforeSend: function() {
                        $('.course-meta').addClass('animate-pulse');
                    },
                    success: function(course) {
                        $('.course-meta').removeClass('hidden animate-pulse')
                            .addClass('animate-fadeIn');
                        $('#course-author span').text(`Pr. ${course.author}`);
                        $('#course-date span').text(new Date(course.updated_at).toLocaleDateString('fr-FR', {
                            day: 'numeric',
                            month: 'long',
                            year: 'numeric' }));

                        // Afficher une notification de succès
                        Toast.fire({
                            icon: 'success',
                            title: 'Cours chargé avec succès'
                        });
                    },
                    error: function() {
                        Toast.fire({
                            icon: 'error',
                            title: 'Erreur',
                            text: 'Impossible de charger les détails du cours'
                        });
                    }
                });
            } else {
                $('.course-meta').addClass('animate-fadeOut').on('animationend', function() {
                    $(this).addClass('hidden').removeClass('animate-fadeOut');
                });
            }
        });

        // Gestion de la soumission avec conversion en Markdown et sauvegarde
        $('#submit-btn').click(function() {
            const question = $('#question').val().trim();

            if (!question) {
                // Gestion de l'erreur si la question est vide (inchangée)
                return;
            }

            // Animation de chargement sophistiquée
                Swal.fire({
                    title: 'Génération en cours',
                    html: `
                        <div class="space-y-4">
                            <div class="flex justify-center">
                                <div class="w-16 h-16 relative">
                                    <div class="absolute inset-0 rounded-full border-4 border-violet-200 animate-ping"></div>
                                    <div class="absolute inset-0 rounded-full border-4 border-violet-500 animate-pulse"></div>
                                </div>
                            </div>
                            <div class="text-gray-600">
                                <p class="animate-pulse">Analyse philosophique en cours...</p>
                                <p class="text-sm mt-2 text-gray-500">Veuillez patienter quelques instants</p>
                            </div>
                        </div>
                    `,
                    allowOutsideClick: false,
                    showConfirmButton: false,
                    customClass: {
                        popup: 'rounded-2xl'
                    }
                });

            const data = {
                question: question,
                type: $('#type-select').val(),
                courseId: $('#course-select').val() || null
            };

            $.ajax({
                url: '/submit_philo',
                method: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(data),
                success: function(data) {
                    Swal.close();

                    const htmlContent = marked.parse(data.response);
                    // Afficher la dissertation
                    $('#response > div').html(htmlContent);
                    $('#response').removeClass('hidden').addClass('animate-fadeIn');
                    $('#copy-btn').removeClass('hidden').addClass('animate-slideUp');

                    // Sauvegarder la dissertation
                    saveDissertation(question, data.response);

                    Toast.fire({
                        icon: 'success',
                        title: 'Dissertation générée et sauvegardée avec succès',
                        timer: 2000
                    });
                },
                error: function() {
                     Swal.fire({
                        icon: 'error',
                        title: 'Erreur de génération',
                        text: 'Une erreur est survenue lors de la génération de votre dissertation.',
                        customClass: {
                            popup: 'rounded-2xl',
                            confirmButton: 'bg-violet-600 hover:bg-violet-700 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200'
                        }
                    });
                }
            });
        });

        // Fonction pour sauvegarder la dissertation (localStorage ou autre)
       function saveDissertation(title, content) {
            let savedDissertations = JSON.parse(localStorage.getItem('dissertations')) || [];
            savedDissertations.push({ title, content, timestamp: Date.now() });
            localStorage.setItem('dissertations', JSON.stringify(savedDissertations));
           updateSavedDissertationsList();

        }



          // Fonction pour supprimer une dissertation sauvegardée
        function deleteDissertation(index) {
             let savedDissertations = JSON.parse(localStorage.getItem('dissertations')) || [];
            savedDissertations.splice(index, 1);
            localStorage.setItem('dissertations', JSON.stringify(savedDissertations));
            updateSavedDissertationsList();
            Toast.fire({
                icon: 'success',
                title: 'Dissertation supprimée avec succès'
            });

        }

        // Fonction pour afficher les dissertations sauvegardées (avec sections repliables et suppression)
        function updateSavedDissertationsList() {
            const dissertationsList = $('#dissertations-list');
            dissertationsList.empty(); // Vider la liste actuelle

            let savedDissertations = JSON.parse(localStorage.getItem('dissertations')) || [];

           if (savedDissertations.length === 0) {
                dissertationsList.append('<p class="text-gray-500">Aucune dissertation sauvegardée.</p>');
                return;
            }



            savedDissertations.forEach((diss, index) => {
                 const date = moment(diss.timestamp).format('LLL');

                const collapsible = $(`<button class="collapsible rounded-xl border border-gray-100 flex justify-between w-full"><span>${diss.title}</span><span class="text-gray-500 text-sm">${date}</span></button>`);
                const deleteButton = $('<button class="text-red-500 hover:text-red-700 ml-2">Supprimer</button>');
                const content = $('<div class="content prose prose-violet max-w-none p-4"></div>').html(marked.parse(diss.content)); // Convertir en HTML

                collapsible.append(deleteButton); // Ajouter le bouton supprimer
                dissertationsList.append(collapsible, content);

                 // Gestionnaire d'événement pour chaque section repliable
                collapsible.click(function(event) {
                    // Empêcher la propagation de l'événement click sur le bouton "Supprimer"
                   if (event.target === deleteButton[0]) {
                       return;
                    }

                    content.slideToggle("fast");
                    collapsible.toggleClass("active");
                });

                deleteButton.click(function() {
                    // Supprimer la dissertation correspondante
                    deleteDissertation(index);

                });
            });
        }

        // Appeler la fonction pour afficher les dissertations au chargement de la page
        updateSavedDissertationsList();

// Gestion de la copie avec retour visuel amélioré
        $('#copy-btn').click(function() {
            const response = $('#response').text();

            $(this).addClass('scale-95 bg-violet-100');
            navigator.clipboard.writeText(response)
                .then(() => {
                    $(this).removeClass('scale-95 bg-violet-100')
                        .addClass('bg-green-50 text-green-700');

                    setTimeout(() => {
                        $(this).removeClass('bg-green-50 text-green-700');
                    }, 1000);

                    Toast.fire({
                        icon: 'success',
                        title: 'Copié avec succès',
                        text: 'Le contenu a été copié dans votre presse-papiers',
                        timer: 2000
                    });
                })
                .catch(() => {
                    $(this).removeClass('scale-95 bg-violet-100')
                        .addClass('bg-red-50 text-red-700');

                    setTimeout(() => {
                        $(this).removeClass('bg-red-50 text-red-700');
                    }, 1000);

                    Toast.fire({
                        icon: 'error',
                        title: 'Erreur de copie',
                        text: 'Impossible de copier le contenu',
                        timer: 3000
                    });
                });
        });

        // Ajout des styles d'animation personnalisés
        const style = document.createElement('style');
        style.textContent = `
            @keyframes fadeIn {
                from { opacity: 0; transform: translateY(10px); }
                to { opacity: 1; transform: translateY(0); }
            }
            @keyframes slideUp {
                from { opacity: 0; transform: translateY(20px); }
                to { opacity: 1; transform: translateY(0); }
            }
            @keyframes shake {
                0%, 100% { transform: translateX(0); }
                25% { transform: translateX(-5px); }
                75% { transform: translateX(5px); }
            }
            .animate-fadeIn {
                animation: fadeIn 0.5s ease-out forwards;
            }
            .animate-slideUp {
                animation: slideUp 0.5s ease-out forwards;
            }
            .animate-shake {
                animation: shake 0.5s ease-in-out;
            }
        `;
        document.head.appendChild(style);
    });
                      </script>

</body>
</html>