File size: 61,179 Bytes
55da947
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PerseverAI - Compagnon Pédagogique</title>
    
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>

        :root {

            --primary: #2563eb;

            --primary-dark: #1d4ed8;

            --secondary: #475569;

            --success: #16a34a;

            --warning: #d97706;

            --danger: #dc2626;

            --info: #0891b2;

            --purple: #7c3aed;

            --gray-50: #f8fafc;

            --gray-100: #f1f5f9;

            --gray-200: #e2e8f0;

            --gray-600: #475569;

            --gray-800: #1e293b;

            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);

            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

        }

        

        * { margin: 0; padding: 0; box-sizing: border-box; }

        

        body {

            font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

            background: var(--gray-50);

            color: var(--gray-800);

            line-height: 1.5;

        }

        

        .container { max-width: 1400px; margin: 0 auto; padding: 24px; }

        

        .header {

            background: white;

            border-radius: 12px;

            padding: 24px 32px;

            margin-bottom: 24px;

            box-shadow: var(--shadow-sm);

            border: 1px solid var(--gray-200);

        }

        

        .header h1 { font-size: 1.75rem; font-weight: 600; color: var(--gray-800); margin-bottom: 8px; }

        .header p { color: var(--gray-600); font-size: 0.9rem; }

        .badge { display: inline-block; background: var(--gray-100); padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; color: var(--gray-600); margin-top: 12px; }

        

        .nav-tabs {

            display: flex;

            background: white;

            border-radius: 12px;

            border: 1px solid var(--gray-200);

            overflow-x: auto;

            margin-bottom: 24px;

        }

        

        .nav-tab {

            padding: 14px 20px;

            background: transparent;

            border: none;

            font-size: 0.9rem;

            font-weight: 500;

            color: var(--gray-600);

            cursor: pointer;

            transition: all 0.2s;

            white-space: nowrap;

            border-bottom: 2px solid transparent;

        }

        

        .nav-tab:hover { color: var(--primary); background: var(--gray-50); }

        .nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

        

        .card {

            background: white;

            border-radius: 12px;

            border: 1px solid var(--gray-200);

            padding: 24px;

            margin-bottom: 24px;

        }

        

        .card-header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            margin-bottom: 20px;

            padding-bottom: 16px;

            border-bottom: 1px solid var(--gray-200);

            flex-wrap: wrap;

            gap: 12px;

        }

        

        .card-header h3 { font-size: 1.25rem; font-weight: 600; color: var(--gray-800); }

        

        .form-group { margin-bottom: 20px; }

        .form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--gray-600); margin-bottom: 8px; }

        .form-control {

            width: 100%;

            padding: 10px 14px;

            border: 1px solid var(--gray-200);

            border-radius: 8px;

            font-size: 0.9rem;

            transition: all 0.2s;

        }

        .form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

        .form-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }

        .form-col { flex: 1; min-width: 200px; }

        

        .btn {

            padding: 10px 18px;

            border-radius: 8px;

            font-size: 0.85rem;

            font-weight: 500;

            cursor: pointer;

            transition: all 0.2s;

            border: none;

        }

        .btn-primary { background: var(--primary); color: white; }

        .btn-primary:hover { background: var(--primary-dark); }

        .btn-secondary { background: white; border: 1px solid var(--gray-200); color: var(--gray-600); }

        .btn-secondary:hover { background: var(--gray-50); }

        .btn-large { padding: 12px 24px; font-size: 0.9rem; }

        

        /* Planning Stats Cards */

        .planning-stats {

            display: grid;

            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));

            gap: 16px;

            margin-bottom: 28px;

            background: var(--gray-50);

            border-radius: 16px;

            padding: 20px;

        }

        .planning-stat-item {

            text-align: center;

            background: white;

            padding: 16px;

            border-radius: 12px;

            border: 1px solid var(--gray-200);

        }

        .planning-stat-number {

            font-size: 2rem;

            font-weight: 700;

            color: var(--primary);

        }

        .planning-stat-label {

            font-size: 0.75rem;

            color: var(--gray-600);

            margin-top: 4px;

        }

        

        /* Planning Table */

        .planning-sessions-table {

            width: 100%;

            border-collapse: collapse;

            margin-top: 20px;

        }

        .planning-sessions-table th {

            text-align: left;

            padding: 14px 12px;

            background: var(--gray-50);

            border-bottom: 2px solid var(--gray-200);

            font-weight: 600;

            font-size: 0.8rem;

            color: var(--gray-600);

        }

        .planning-sessions-table td {

            padding: 16px 12px;

            border-bottom: 1px solid var(--gray-200);

            vertical-align: top;

        }

        .session-type-badge {

            display: inline-block;

            padding: 4px 10px;

            border-radius: 20px;

            font-size: 0.7rem;

            font-weight: 500;

        }

        .type-apprentissage { background: #dbeafe; color: #1e40af; }

        .type-consolidation { background: #dcfce7; color: #166534; }

        .type-maintien { background: #fef3c7; color: #92400e; }

        

        .retention-slider {

            width: 100%;

            margin: 15px 0;

        }

        .retention-slider input {

            width: 100%;

            cursor: pointer;

            accent-color: var(--primary);

        }

        .retention-labels {

            display: flex;

            justify-content: space-between;

            font-size: 0.7rem;

            color: var(--gray-600);

            margin-top: 5px;

        }

        

        .time-slots-group {

            display: flex;

            flex-wrap: wrap;

            gap: 12px;

            margin-top: 8px;

        }

        .time-slot-checkbox {

            display: flex;

            align-items: center;

            gap: 6px;

            background: var(--gray-50);

            padding: 6px 12px;

            border-radius: 20px;

            border: 1px solid var(--gray-200);

            cursor: pointer;

        }

        .radio-group {

            display: flex;

            gap: 20px;

            margin-top: 8px;

        }

        .radio-option {

            display: flex;

            align-items: center;

            gap: 8px;

            cursor: pointer;

        }

        

        .notifications-table {

            width: 100%;

            border-collapse: collapse;

            font-size: 0.85rem;

        }

        .notifications-table th {

            text-align: left;

            padding: 12px 8px;

            background: var(--gray-50);

            border-bottom: 2px solid var(--gray-200);

            font-weight: 600;

        }

        .notifications-table td {

            padding: 12px 8px;

            border-bottom: 1px solid var(--gray-200);

        }

        

        .priority-high { color: var(--danger); font-weight: 600; }

        .priority-medium { color: var(--warning); font-weight: 600; }

        .priority-low { color: var(--success); font-weight: 600; }

        

        .status-badge {

            display: inline-block;

            padding: 4px 10px;

            border-radius: 20px;

            font-size: 0.7rem;

            font-weight: 500;

        }

        .status-pending { background: #fef3c7; color: #92400e; }

        .status-accepted { background: #dcfce7; color: #166534; }

        

        .action-cell {

            display: flex;

            flex-wrap: wrap;

            gap: 6px;

        }

        .action-icon-btn {

            background: transparent;

            border: none;

            cursor: pointer;

            padding: 6px 10px;

            border-radius: 20px;

            font-size: 0.7rem;

            font-weight: 500;

            transition: all 0.2s;

        }

        .action-accept { background: #dcfce7; color: #166534; }

        .action-reject { background: #fee2e2; color: #991b1b; }

        .action-hold { background: #e0f2fe; color: #075985; }

        .action-help { background: #fed7aa; color: #9a3412; }

        

        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

        .stat-card { background: white; border: 1px solid var(--gray-200); border-radius: 8px; padding: 16px; text-align: center; }

        .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }

        

        .chart-container { height: 300px; margin-top: 20px; }

        .tab-content { display: none; }

        .tab-content.active { display: block; }

        

        /* Spaced Repetition Curve */

        .spaced-repetition-container {

            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);

            border-radius: 16px;

            padding: 20px;

            margin-top: 20px;

        }

        .curve-legend {

            display: flex;

            justify-content: center;

            gap: 24px;

            margin-bottom: 16px;

            font-size: 0.75rem;

        }

        .legend-item {

            display: flex;

            align-items: center;

            gap: 8px;

        }

        .legend-color {

            width: 20px;

            height: 3px;

            border-radius: 2px;

        }

        .legend-color.square {

            width: 12px;

            height: 12px;

            border-radius: 50%;

        }

        

        @media (max-width: 768px) {

            .container { padding: 16px; }

            .planning-sessions-table { font-size: 0.7rem; }

            .planning-sessions-table td, .planning-sessions-table th { padding: 8px 6px; }

        }

        

        .session-detail-line { font-size: 0.75rem; color: var(--gray-600); margin: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

        .export-btn { background: white; border: 1px solid var(--gray-200); padding: 8px 16px; border-radius: 8px; cursor: pointer; }

        .export-btn:hover { background: var(--gray-50); }

        

        /* Profile specific styles */

        .profile-progress {

            background: var(--gray-100);

            border-radius: 12px;

            padding: 16px;

            margin-bottom: 24px;

        }

        .progress-bar-container {

            background: var(--gray-200);

            border-radius: 20px;

            height: 10px;

            margin: 12px 0;

            overflow: hidden;

        }

        .progress-bar-fill {

            background: var(--primary);

            width: 0%;

            height: 100%;

            border-radius: 20px;

            transition: width 0.3s ease;

        }

        .big5-rating {

            display: flex;

            gap: 8px;

            margin-top: 8px;

            flex-wrap: wrap;

        }

        .rating-btn {

            width: 40px;

            height: 40px;

            border-radius: 40px;

            border: 1px solid var(--gray-200);

            background: white;

            cursor: pointer;

            font-weight: 600;

            transition: all 0.2s;

        }

        .rating-btn:hover { background: var(--gray-100); }

        .rating-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

        .motivation-rating {

            display: flex;

            gap: 8px;

            margin-top: 8px;

            flex-wrap: wrap;

        }

        .profile-recommendations {

            background: #fefce8;

            border-left: 4px solid var(--warning);

            padding: 16px;

            border-radius: 12px;

            margin-top: 20px;

        }

        .profile-summary-cards {

            display: grid;

            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));

            gap: 16px;

            margin-bottom: 24px;

        }

        .profile-mini-card {

            background: var(--gray-50);

            border-radius: 12px;

            padding: 16px;

            text-align: center;

        }

        .profile-mini-card h4 { font-size: 0.75rem; color: var(--gray-600); margin-bottom: 8px; }

        .profile-mini-card .value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }

        .flex-between { display: flex; justify-content: space-between; align-items: center; }



        /* NOUVEAUX STYLES DASHBOARD - HEATMAP & INDICATEURS */

        .heatmap-container {

            background: white;

            border-radius: 16px;

            padding: 20px;

            margin-bottom: 24px;

            border: 1px solid var(--gray-200);

        }

        .heatmap-grid {

            display: grid;

            grid-template-columns: repeat(7, 1fr);

            gap: 10px;

            margin: 20px 0;

        }

        .heatmap-day {

            text-align: center;

            font-size: 0.7rem;

            font-weight: 500;

            color: var(--gray-600);

            margin-bottom: 8px;

        }

        .heatmap-cell {

            aspect-ratio: 1 / 1;

            border-radius: 8px;

            transition: transform 0.2s;

            cursor: pointer;

        }

        .heatmap-cell:hover { transform: scale(1.05); }

        .level-0 { background-color: #edf2f7; }

        .level-1 { background-color: #c6f6d5; }

        .level-2 { background-color: #9ae6b4; }

        .level-3 { background-color: #48bb78; }

        .level-4 { background-color: #276749; }

        .legend-heatmap {

            display: flex;

            justify-content: center;

            gap: 20px;

            margin-top: 16px;

            flex-wrap: wrap;

        }

        .legend-heatmap-item {

            display: flex;

            align-items: center;

            gap: 6px;

            font-size: 0.7rem;

        }

        .legend-color-box {

            width: 20px;

            height: 20px;

            border-radius: 4px;

        }

        .indicator-card {

            background: var(--gray-50);

            border-radius: 12px;

            padding: 20px;

            text-align: center;

            border: 1px solid var(--gray-200);

        }

        .indicator-value {

            font-size: 2.2rem;

            font-weight: 800;

            color: var(--primary);

        }

        .effort-badge {

            display: inline-block;

            background: #e0e7ff;

            padding: 8px 16px;

            border-radius: 40px;

            font-size: 0.8rem;

            font-weight: 600;

            color: #3730a3;

        }

        .dashboard-view-toggle {

            display: flex;

            gap: 12px;

            margin-bottom: 24px;

        }

        .view-btn {

            padding: 8px 18px;

            border-radius: 40px;

            background: white;

            border: 1px solid var(--gray-200);

            cursor: pointer;

            font-weight: 500;

        }

        .view-btn.active {

            background: var(--primary);

            color: white;

            border-color: var(--primary);

        }

    </style>
</head>
<body>
<div class="container">
    <header class="header">
        <h1>PerseverAI</h1>
        <p>Compagnon d'apprentissage autorégulé - Notifications IA & Actions</p>
        <div class="badge">AI · Aid · Perseverance · Tableau des événements</div>
    </header>
    
    <nav class="nav-tabs">
        <button class="nav-tab" onclick="showTab('profile')">Profil</button>
        <button class="nav-tab" onclick="showTab('objectif')">Objectif</button>
        <button class="nav-tab" onclick="showTab('planner')">Planning</button>
        <button class="nav-tab" onclick="showTab('dashboard')">Mon Dashboard</button>
        <button class="nav-tab" onclick="showTab('journal')">Mon Journal</button>
        <button class="nav-tab" onclick="showTab('notifications')">Notifications IA</button>
    </nav>
    
    <!-- PROFIL -->
    <section id="profile" class="tab-content">
        <div class="card">
            <div class="card-header">
                <h3>Profil d'Apprentissage Personnalisé</h3>
                <div>
                    <button class="btn btn-secondary" onclick="autoFillProfile()">Remplir automatiquement</button>
                    <button class="btn btn-secondary" onclick="saveProfileData()">Sauvegarder</button>
                </div>
            </div>
            
            <div class="profile-progress">
                <div class="flex-between">
                    <span><strong>Complétion du Profil</strong></span>
                    <span id="profileCompletionPercent">40%</span>
                </div>
                <div class="progress-bar-container">
                    <div class="progress-bar-fill" id="profileProgressFill" style="width: 40%;"></div>
                </div>
                <div class="flex-between" style="margin-top: 8px;">
                    <span>Questionnaires complétés: <span id="completedCount">2</span>/5</span>
                    <span>Profil personnalisé: <span id="profileLevel">Intermédiaire</span></span>
                </div>
            </div>
            
            <div class="card" style="margin-bottom: 20px; padding: 20px;">
                <h4 style="margin-bottom: 16px;">Profil de Personnalité (Big Five Traits)</h4>
                <p style="font-size: 0.8rem; color: var(--gray-600); margin-bottom: 20px;">Évaluez vos traits de personnalité sur une échelle de 1 à 5</p>
                
                <div class="form-group">
                    <label class="form-label">Je suis quelqu'un de sociable, extraverti, énergique</label>
                    <div class="big5-rating" data-trait="extraversion">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">Je fais preuve de curiosité intellectuelle, j'aime les nouvelles expériences</label>
                    <div class="big5-rating" data-trait="openness">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">Je suis organisé, fiable, je respecte mes engagements</label>
                    <div class="big5-rating" data-trait="conscientiousness">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">Je suis coopératif, serviable, empathique</label>
                    <div class="big5-rating" data-trait="agreeableness">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">Je ressens facilement de l'anxiété, du stress, de la nervosité</label>
                    <div class="big5-rating" data-trait="neuroticism">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div style="margin-top: 16px; font-size: 0.8rem; color: var(--gray-600); background: var(--gray-50); padding: 12px; border-radius: 8px;">
                    Section complétée - Score neuroticisme: <span id="neuroticismScore">4.0</span> (qualité du sommeil importante)
                </div>
            </div>
            
            <div class="card" style="margin-bottom: 20px; padding: 20px;">
                <h4 style="margin-bottom: 16px;">Profil Motivationnel</h4>
                <p style="font-size: 0.8rem; color: var(--gray-600); margin-bottom: 20px;">Pourquoi étudiez-vous ? Sélectionnez vos principales motivations</p>
                
                <div class="form-group">
                    <label class="form-label">J'étudie parce que j'aime apprendre, je trouve cela intéressant et plaisant</label>
                    <div class="motivation-rating" data-motivation="intrinsic">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="form-label">J'étudie pour obtenir de bonnes notes et faire plaisir à mes parents/professeurs</label>
                    <div class="motivation-rating" data-motivation="introjected">
                        <button type="button" class="rating-btn" data-value="1">1</button>
                        <button type="button" class="rating-btn" data-value="2">2</button>
                        <button type="button" class="rating-btn" data-value="3">3</button>
                        <button type="button" class="rating-btn" data-value="4">4</button>
                        <button type="button" class="rating-btn" data-value="5">5</button>
                    </div>
                </div>
                
                <div style="margin-top: 16px; font-size: 0.8rem; color: var(--gray-600); background: var(--gray-50); padding: 12px; border-radius: 8px;">
                    Section complétée - Motivation introjectée: <span id="introjectedScore">4.0</span> (pression interne modérée)
                </div>
            </div>
            
            <div class="profile-summary-cards">
                <div class="profile-mini-card"><h4>Big Five Traits</h4><div class="value" id="summaryExtraversion">3.0</div><div>Extraversion</div></div>
                <div class="profile-mini-card"><div class="value" id="summaryOpenness">3.0</div><div>Ouverture</div></div>
                <div class="profile-mini-card"><div class="value" id="summaryConscientiousness">4.0</div><div>Conscience</div></div>
                <div class="profile-mini-card"><h4>Motivation</h4><div class="value" id="summaryIntrinsic">3.0</div><div>Intrinsèque</div></div>
                <div class="profile-mini-card"><div class="value" id="summaryIntrojected">4.0</div><div>Introjectée</div></div>
            </div>
            
            <div class="profile-recommendations" style="background: transparent; border-left: none; padding: 0;">
                <h4 style="margin-bottom: 12px;">Recommandations Personnalisées Basées sur Votre Profil</h4>
                <div id="recommendationsContainer">
                    <p> Qualité du sommeil: Maintenez 7-8 heures de sommeil de qualité.</p>
                    <p> Planification: Renforcez votre organisation avec des rappels.</p>
                </div>
            </div>
            
            <button class="btn btn-primary btn-large" onclick="finalizeProfile()" style="width:100%; margin-top: 20px;">
                <i class="fas fa-check-circle"></i> Finaliser et Générer le Profil Personnalisé
            </button>
        </div>
    </section>
    
    <!-- OBJECTIF -->
    <section id="objectif" class="tab-content">
        <div class="card">
            <div class="card-header"><h3>Définir mon Objectif d'Apprentissage</h3></div>
            <div class="form-row">
                <div class="form-col"><label class="form-label">Compétence Cible</label><select id="competence" class="form-control"></select></div>
                <div class="form-col"><label class="form-label">Niveau Actuel</label><select id="level" class="form-control"><option value="0">Débutant</option><option value="1" selected>Intermédiaire</option><option value="2">Avancé</option></select></div>
            </div>
            <div class="form-row">
                <div class="form-col"><label class="form-label">Date de Début</label><input type="date" id="start" class="form-control" value="2024-01-15"></div>
                <div class="form-col"><label class="form-label">Date de Fin</label><input type="date" id="end" class="form-control" value="2024-12-31"></div>
            </div>
            <div class="form-row">
                <div class="form-col"><label class="form-label">Durée par Session (minutes)</label><select id="sessionDuration" class="form-control"><option value="20" selected>20 minutes (Optimal)</option><option value="30">30 minutes</option><option value="45">45 minutes</option></select></div>
                <div class="form-col"><label class="form-label">Méthode Productivité</label><div class="radio-group"><label class="radio-option"><input type="radio" name="productivityMethod" value="pomodoro" checked> Pomodoro</label><label class="radio-option"><input type="radio" name="productivityMethod" value="deepwork"> Deep Work</label></div></div>
            </div>
            <div class="form-row">
                <div class="form-col"><label class="form-label">Type d'Énergie</label><div class="radio-group"><label class="radio-option"><input type="radio" name="energyType" value="morning" checked> Matinale</label><label class="radio-option"><input type="radio" name="energyType" value="evening"> Vespérale</label></div></div>
                <div class="form-col"><label class="form-label">Créneaux Disponibles</label><div class="time-slots-group" id="timeSlotsGroup"><label class="time-slot-checkbox"><input type="checkbox" value="08:00-10:00"> 08:00-10:00</label><label class="time-slot-checkbox"><input type="checkbox" value="10:00-12:00"> 10:00-12:00</label><label class="time-slot-checkbox"><input type="checkbox" value="14:00-16:00"> 14:00-16:00</label></div></div>
            </div>
            <div class="form-group"><label class="form-label">Qualité Estimée de Rétention</label><div class="retention-slider"><input type="range" id="retentionQuality" min="0" max="3" step="1" value="2"><div class="retention-labels"><span>0 - Faible</span><span>1 - Moyenne</span><span>2 - Bonne</span><span>3 - Excellente</span></div></div><div class="retention-value" id="retentionValueDisplay">Bon - Consolidation progressive</div></div>
            <button class="btn btn-primary btn-large" onclick="generatePlanner()" style="width:100%;"><i class="fas fa-magic"></i> Générer le Planner Personnalisé</button>
        </div>
    </section>
    
    <!-- PLANNING -->
    <section id="planner" class="tab-content">
        <div class="card">
            <div class="card-header"><h3><i class="fas fa-calendar-alt"></i> Planner Personnalisé</h3><button class="export-btn" onclick="exportPlanning()"><i class="fas fa-download"></i> Exporter</button></div>
            <div class="planning-stats" id="planningStats"><div class="planning-stat-item"><div class="planning-stat-number" id="statSessions">6</div><div class="planning-stat-label">Sessions Planifiées</div></div><div class="planning-stat-item"><div class="planning-stat-number" id="statTotalDays">270</div><div class="planning-stat-label">Jours Totaux</div></div><div class="planning-stat-item"><div class="planning-stat-number" id="statQuality">3/4</div><div class="planning-stat-label">Niveau de Qualité</div></div><div class="planning-stat-item"><div class="planning-stat-number" id="statDuration">20min</div><div class="planning-stat-label">Durée/Session</div></div></div>
            <div style="overflow-x: auto;"><table class="planning-sessions-table" id="sessionsTable"><thead><tr><th>Date</th><th>Session</th><th>Compétence</th><th>Durée</th><th>Intervalle</th><th>Type</th><th>Stratégie</th><th>Productivité</th><th>Heure Optimale</th></tr></thead><tbody id="sessionsTableBody"></tbody></table></div>
            <div class="spaced-repetition-container"><h4 style="margin-bottom: 16px;"><i class="fas fa-chart-line"></i> Courbe de Répétition Espacée (SM-2 Algorithm)</h4><div class="curve-legend"><div class="legend-item"><div class="legend-color" style="background: #2563eb; width: 30px; height: 3px;"></div><span>Seuil de rétention (Forgetting Curve)</span></div><div class="legend-item"><div class="legend-color square" style="background: #ef4444;"></div><span>Sessions de révision</span></div><div class="legend-item"><div class="legend-color" style="background: #10b981; width: 30px; height: 3px;"></div><span>Intervalle optimal SM-2</span></div></div><div style="position: relative;"><canvas id="spacedRepetitionCurve" width="100%" height="220" style="max-height: 220px; width: 100%;"></canvas></div><div style="display: flex; justify-content: space-between; margin-top: 12px; font-size: 0.7rem; color: var(--gray-600);" id="intervalDatesCurve"></div><p style="font-size: 0.7rem; color: var(--gray-500); margin-top: 16px; text-align: center; font-style: italic;"><i class="fas fa-lightbulb"></i> La courbe montre l'évolution théorique de la rétention. Chaque révision au moment optimal (juste avant l'oubli) renforce la mémoire et augmente l'intervalle suivant.</p></div>
        </div>
    </section>
    
    <!-- NOUVEAU DASHBOARD AVEC HEATMAP & INDICATEURS -->
    <section id="dashboard" class="tab-content">
        <div class="card">
            <div class="card-header">
                <h3><i class="fas fa-fire"></i> Heatmap d'activité - Analyse de la persistance et du management de l'effort (persévérance)</h3>
                <div class="dashboard-view-toggle">
                    <button class="view-btn active" data-view="combined" onclick="setDashboardView('combined')">🎯 Vue combinée</button>
                </div>
            </div>
            
            <!-- Heatmap Hebdomadaire -->
            <div class="heatmap-container">
                <h4 style="margin-bottom: 12px;"><i class="fas fa-calendar-week"></i> Niveaux d'activité</h4>
                <div class="heatmap-grid" id="heatmapGrid"></div>
                <div class="legend-heatmap">
                    <div class="legend-heatmap-item"><div class="legend-color-box level-0"></div><span>Aucune</span></div>
                    <div class="legend-heatmap-item"><div class="legend-color-box level-1"></div><span>Faible</span></div>
                    <div class="legend-heatmap-item"><div class="legend-color-box level-2"></div><span>Moyenne</span></div>
                    <div class="legend-heatmap-item"><div class="legend-color-box level-3"></div><span>Élevée</span></div>
                    <div class="legend-heatmap-item"><div class="legend-color-box level-4"></div><span>Intense</span></div>
                </div>
            </div>
            
            <!-- Indicateurs de gestion du temps -->
            <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 24px;">
                <div class="indicator-card">
                    <div style="font-size: 0.8rem; color: var(--gray-600);">🕖 Régularité du travail</div>
                    <div class="indicator-value" id="regularityScore">90%</div>
                    <div style="font-size: 0.7rem;">La constance de l'activité de l'apprenant dans le temps.</div>
                </div>
                <div class="indicator-card">
                    <div style="font-size: 0.8rem; color: var(--gray-600);">⏰ Gestion des échéances</div>
                    <div class="indicator-value" id="deadlineScore">88%</div>
                    <div style="font-size: 0.7rem;">La capacité de l'apprenant à respecter les délais.</div>
                </div>
                <div class="indicator-card">
                    <div style="font-size: 0.8rem; color: var(--gray-600);">⚡ Schéma d'effort</div>
                    <div class="effort-badge" id="effortPattern">Effort concentré (Pic d'activité jeudi/vendredi)</div>
                    <div style="font-size: 0.7rem; margin-top: 6px;">La dynamique temporelle de l'effort.</div>
                </div>
                <div class="indicator-card">
                    <div style="font-size: 0.8rem; color: var(--gray-600);">💪 Persistance et gestion des efforts</div>
                    <div class="indicator-value" id="persistenceScore">Très élevée</div>
                    <div style="font-size: 0.7rem;">Indice de persévérance globale</div>
                </div>
            </div>
            
            <div class="chart-container">
                <canvas id="progressChart"></canvas>
            </div>
        </div>
    </section>
    
    <!-- JOURNAL -->
    <section id="journal" class="tab-content">
        <div class="card"><div class="card-header"><h3>Mon journal d'apprentissage</h3><button class="btn btn-secondary" onclick="saveJournal()">Sauvegarder</button></div>
        <div class="form-group"><label class="form-label">Accompli aujourd'hui</label><textarea id="done" class="form-control" rows="2"></textarea></div>
        <div class="form-group"><label class="form-label">Stratégie utilisée</label><textarea id="metacognition" class="form-control" rows="2"></textarea></div>
        <div id="journalEntriesList"></div></div>
    </section>
    
    <!-- NOTIFICATIONS -->
    <section id="notifications" class="tab-content">
        <div class="card">
            <div class="card-header"><h3><i class="fas fa-bell"></i> Notifications IA - Tableau des événements</h3><button class="btn btn-primary" onclick="generateRandomEvent()"><i class="fas fa-plus"></i> Générer un événement</button></div>
            <div class="stats-grid"><div class="stat-card"><div class="stat-value" id="totalEvents">0</div><div class="stat-label">Total</div></div><div class="stat-card"><div class="stat-value" id="pendingEvents">0</div><div class="stat-label">En attente</div></div><div class="stat-card"><div class="stat-value" id="acceptedEvents">0</div><div class="stat-label">Acceptés</div></div></div>
            <div style="overflow-x:auto;"><table class="notifications-table"><thead><tr><th>Date</th><th>Type</th><th>Titre</th><th>Message</th><th>Priorité</th><th>Statut</th><th>Actions</th></tr></thead><tbody id="notificationsTableBody"></tbody></table></div>
            <div class="chart-container"><canvas id="notificationEfficiencyChart"></canvas></div>
        </div>
    </section>
</div>

<script>

    // Données compétences

    const competencesData = [

        { "id": "D-MCONJ", "label": "Marques de la conjugaison", "category": "Discours" },

        { "id": "D-PDV", "label": "Points de vue adoptés", "category": "Discours" },

        { "id": "D-SSENT", "label": "Compréhension des mots", "category": "Discours" },

        { "id": "M-CHOI", "label": "Choix des mots et des expressions", "category": "Maîtrise" },

        { "id": "M-COMP", "label": "Construction des phrases", "category": "Maîtrise" },

        { "id": "M-DEV", "label": "Développement du vocabulaire", "category": "Maîtrise" }

    ];

    

    let eventsList = [];

    let currentSessions = [];

    let spacedChart = null;

    let dashChart = null;

    

    let profileData = {

        extraversion: 3, openness: 3, conscientiousness: 4, agreeableness: 3, neuroticism: 3,

        intrinsic: 3, introjected: 4

    };

    

    const eventTemplates = [

        { type: "Rappel d'étude", title: "Session de révision", message: "Votre session est prévue aujourd'hui.", priority: "high" },

        { type: "Conseil IA", title: "Optimisation", message: "Révisez les conjugaisons.", priority: "medium" },

        { type: "Encouragement", title: "Progression", message: "80% des objectifs atteints.", priority: "low" }

    ];

    

    // SIMULATION DONNÉES HEATMAP & INDICATEURS

    function generateHeatmapData() {

        const days = ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim'];

        const weeks = 4;

        let matrix = [];

        for(let w = 0; w < weeks; w++) {

            let week = [];

            for(let d = 0; d < 7; d++) {

                let base = (w * 7 + d) % 10;

                let level = 0;

                if(base < 3) level = 1;

                else if(base < 6) level = 2;

                else if(base < 8) level = 3;

                else level = 4;

                if(d === 3 || d === 4) level = Math.min(4, level+1);

                week.push(level);

            }

            matrix.push(week);

        }

        return { days, weeks: matrix };

    }

    

    function renderHeatmap() {

        const container = document.getElementById('heatmapGrid');

        if(!container) return;

        const { days, weeks } = generateHeatmapData();

        container.innerHTML = '';

        for(let i = 0; i < days.length; i++) {

            let dayDiv = document.createElement('div');

            dayDiv.className = 'heatmap-day';

            dayDiv.innerText = days[i];

            container.appendChild(dayDiv);

        }

        for(let w = 0; w < weeks.length; w++) {

            for(let d = 0; d < weeks[w].length; d++) {

                let cell = document.createElement('div');

                cell.className = `heatmap-cell level-${weeks[w][d]}`;

                cell.title = `${days[d]} Semaine ${w+1} : Niveau ${weeks[w][d]}`;

                container.appendChild(cell);

            }

        }

    }

    

    function updateIndicators() {

        document.getElementById('regularityScore').innerText = "90%";

        document.getElementById('deadlineScore').innerText = "88%";

        document.getElementById('effortPattern').innerText = "Effort concentré (Pic d'activité jeudi/vendredi)";

        document.getElementById('persistenceScore').innerText = "Très élevée";

    }

    

    function setDashboardView(view) {

        document.querySelectorAll('.view-btn').forEach(btn => btn.classList.remove('active'));

        document.querySelector(`.view-btn[data-view="${view}"]`).classList.add('active');

        if(view === 'combined') {

            renderHeatmap();

            updateIndicators();

        }

    }

    

    // FONCTIONS EXISTANTES (inchangées)

    function initCompetencesSelect() {

        const select = document.getElementById('competence');

        if(select) select.innerHTML = '<option value="comprendre_mots">Comprendre les mots</option>' + competencesData.map(c => `<option value="${c.id}">${c.label}</option>`).join('');

    }

    

    function setupRatingListeners() {

        document.querySelectorAll('.big5-rating .rating-btn').forEach(btn => {

            btn.addEventListener('click', function() {

                const container = this.closest('.big5-rating');

                const trait = container.dataset.trait;

                const value = parseInt(this.dataset.value);

                profileData[trait] = value;

                updateRatingUI(container, value);

                updateProfileUI();

                saveProfileToStorage();

            });

        });

        document.querySelectorAll('.motivation-rating .rating-btn').forEach(btn => {

            btn.addEventListener('click', function() {

                const container = this.closest('.motivation-rating');

                const motivation = container.dataset.motivation;

                const value = parseInt(this.dataset.value);

                profileData[motivation] = value;

                updateRatingUI(container, value);

                updateProfileUI();

                saveProfileToStorage();

            });

        });

    }

    

    function updateRatingUI(container, value) {

        container.querySelectorAll('.rating-btn').forEach(btn => {

            btn.classList.remove('active');

            if(parseInt(btn.dataset.value) === value) btn.classList.add('active');

        });

    }

    

    function updateProfileUI() {

        document.getElementById('summaryExtraversion').innerText = profileData.extraversion;

        document.getElementById('summaryOpenness').innerText = profileData.openness;

        document.getElementById('summaryConscientiousness').innerText = profileData.conscientiousness;

        document.getElementById('summaryIntrinsic').innerText = profileData.intrinsic;

        document.getElementById('summaryIntrojected').innerText = profileData.introjected;

        document.getElementById('neuroticismScore').innerText = profileData.neuroticism;

        document.getElementById('introjectedScore').innerText = profileData.introjected;

        let completed = Object.values(profileData).filter(v => v).length;

        const percent = Math.round((completed / 7) * 100);

        document.getElementById('profileCompletionPercent').innerText = percent + '%';

        document.getElementById('profileProgressFill').style.width = percent + '%';

        document.getElementById('completedCount').innerText = Math.min(completed, 5);

        let level = "Débutant";

        if(profileData.conscientiousness >= 4 && profileData.intrinsic >= 4) level = "Avancé";

        else if(profileData.conscientiousness >= 3) level = "Intermédiaire";

        document.getElementById('profileLevel').innerText = level;

        const recos = [];

        recos.push("◼ Qualité du sommeil: Maintenez 7-8 heures de sommeil de qualité.");

        recos.push("◼ Planification: Renforcez votre organisation avec des rappels.");

        document.getElementById('recommendationsContainer').innerHTML = recos.map(r => `<p>${r}</p>`).join('');

    }

    

    function autoFillProfile() {

        profileData = { extraversion: 4, openness: 4, conscientiousness: 5, agreeableness: 4, neuroticism: 2, intrinsic: 5, introjected: 3 };

        document.querySelectorAll('.big5-rating').forEach(container => { if(profileData[container.dataset.trait]) updateRatingUI(container, profileData[container.dataset.trait]); });

        document.querySelectorAll('.motivation-rating').forEach(container => { if(profileData[container.dataset.motivation]) updateRatingUI(container, profileData[container.dataset.motivation]); });

        updateProfileUI();

        saveProfileToStorage();

        showToast("Profil automatiquement rempli !");

    }

    

    function saveProfileData() { saveProfileToStorage(); showToast("Profil sauvegardé !"); }

    function finalizeProfile() { saveProfileToStorage(); showToast("Profil finalisé !"); }

    function saveProfileToStorage() { localStorage.setItem('perseverAI_profile', JSON.stringify(profileData)); }

    function loadProfileFromStorage() { const saved = localStorage.getItem('perseverAI_profile'); if(saved) Object.assign(profileData, JSON.parse(saved)); updateProfileUI(); }

    

    function retentionRate(days, strength = 0.5) { return Math.exp(-days / (strength * 30)) * 100; }

    

    function drawSpacedRepetitionCurve(sessions) {

        const canvas = document.getElementById('spacedRepetitionCurve');

        if(!canvas || sessions.length === 0) return;

        const ctx = canvas.getContext('2d');

        const container = canvas.parentElement;

        const width = container.clientWidth - 40;

        const height = 200;

        canvas.width = width;

        canvas.height = height;

        ctx.clearRect(0, 0, width, height);

        const startDate = sessions[0].date.getTime();

        const endDate = sessions[sessions.length-1].date.getTime();

        const totalDays = (endDate - startDate) / (1000 * 60 * 60 * 24);

        ctx.beginPath();

        ctx.strokeStyle = '#2563eb';

        ctx.lineWidth = 2.5;

        ctx.setLineDash([]);

        let firstPoint = true;

        for(let x = 0; x <= width; x++) {

            const dayProgression = (x / width) * totalDays;

            const retention = retentionRate(dayProgression, 0.4);

            const y = height - (retention / 100) * height;

            if(firstPoint) { ctx.moveTo(x, y); firstPoint = false; }

            else { ctx.lineTo(x, y); }

        }

        ctx.stroke();

        ctx.fillStyle = 'rgba(37, 99, 235, 0.05)';

        ctx.fill();

        ctx.beginPath();

        ctx.strokeStyle = '#10b981';

        ctx.lineWidth = 1.5;

        ctx.setLineDash([8, 6]);

        for(let i = 0; i < sessions.length; i++) {

            const x = ((sessions[i].date.getTime() - startDate) / (endDate - startDate)) * width;

            if(x >= 0 && x <= width) { ctx.beginPath(); ctx.moveTo(x, 0); ctx.lineTo(x, height); ctx.stroke(); }

        }

        ctx.setLineDash([]);

        for(let i = 0; i < sessions.length; i++) {

            const x = ((sessions[i].date.getTime() - startDate) / (endDate - startDate)) * width;

            const dayProgression = ((sessions[i].date.getTime() - startDate) / (1000 * 60 * 60 * 24));

            const retentionAtSession = retentionRate(dayProgression, 0.4);

            const y = height - (retentionAtSession / 100) * height;

            ctx.beginPath(); ctx.fillStyle = '#ef4444'; ctx.arc(x, y, 6, 0, 2 * Math.PI); ctx.fill();

            ctx.fillStyle = 'white'; ctx.beginPath(); ctx.arc(x, y, 3, 0, 2 * Math.PI); ctx.fill();

            ctx.fillStyle = '#1e293b'; ctx.font = 'bold 9px Inter'; ctx.fillText(`R${i+1}`, x-5, y-8);

        }

        const datesDiv = document.getElementById('intervalDatesCurve');

        if(datesDiv) datesDiv.innerHTML = sessions.map(s => `<span>${s.dateStr}</span>`).join('');

    }

    

    function generatePlanner() {

        const competence = document.getElementById('competence')?.value || "comprendre_mots";

        const competenceLabel = competencesData.find(c=>c.id===competence)?.label || "Comprendre les mots";

        const startDate = new Date(document.getElementById('start')?.value || "2024-01-15");

        const sessionDur = document.getElementById('sessionDuration')?.value || "20";

        const method = document.querySelector('input[name="productivityMethod"]:checked')?.value || "pomodoro";

        const timeSlot = document.querySelector('#timeSlotsGroup input:checked')?.value || "08:00-10:00";

        const retention = document.getElementById('retentionQuality')?.value || "2";

        const intervals = [1, 7, 16, 35, 70, 140];

        const sessions = [];

        for(let i = 0; i < intervals.length; i++) {

            let currentDate = new Date(startDate);

            if(i > 0) currentDate.setDate(startDate.getDate() + intervals[i-1]);

            else currentDate = new Date(startDate);

            const sessionTypes = ["Apprentissage", "Consolidation", "Consolidation", "Maintien", "Maintien", "Maintien"];

            const strategies = ["Focus intense", "Révision active", "Révision active", "Révision active", "Révision active", "Révision active"];

            sessions.push({ id: i+1, date: new Date(currentDate), dateStr: currentDate.toLocaleDateString('fr-FR'), dayName: currentDate.toLocaleDateString('fr-FR', { weekday: 'long' }), competence: competenceLabel, duration: sessionDur + " minutes", interval: intervals[i] + " jours", type: sessionTypes[i], strategy: strategies[i], productivity: method === 'pomodoro' ? 'Pomodoro' : 'Deep Work', optimalTime: timeSlot });

        }

        currentSessions = sessions;

        renderPlanningTable(sessions);

        updatePlanningStats(sessions, retention, sessionDur);

        drawSpacedRepetitionCurve(sessions);

        showToast("Planning personnalisé généré !");

        showTab('planner');

    }

    

    function generateDefaultPlanning() {

        const startDate = new Date("2024-01-17");

        const intervals = [1, 7, 16, 35, 70, 140];

        const sessions = [];

        for(let i = 0; i < intervals.length; i++) {

            let currentDate = new Date(startDate);

            if(i > 0) currentDate.setDate(startDate.getDate() + (i===1?1: intervals[i-1]));

            else currentDate = new Date(startDate);

            const sessionTypes = ["Apprentissage", "Consolidation", "Consolidation", "Maintien", "Maintien", "Maintien"];

            const strategies = ["Focus intense", "Révision active", "Révision active", "Révision active", "Révision active", "Révision active"];

            sessions.push({ id: i+1, date: new Date(currentDate), dateStr: currentDate.toLocaleDateString('fr-FR'), dayName: currentDate.toLocaleDateString('fr-FR', { weekday: 'long' }), competence: "comprendre_mots", duration: "20 minutes", interval: intervals[i] + " jours", type: sessionTypes[i], strategy: strategies[i], productivity: "Pomodoro", optimalTime: "08:00-10:00" });

        }

        currentSessions = sessions;

        renderPlanningTable(sessions);

        updatePlanningStats(sessions, "2", "20");

        drawSpacedRepetitionCurve(sessions);

    }

    

    function renderPlanningTable(sessions) {

        const tbody = document.getElementById('sessionsTableBody');

        if(!tbody) return;

        tbody.innerHTML = sessions.map(s => `<tr><td><strong>${s.dateStr}</strong><br><span style="font-size:0.7rem;">${s.dayName}</span></td><td><strong>R${s.id}</strong></td><td>${s.competence}</td><td>${s.duration}</td><td>${s.interval}</td><td><span class="session-type-badge ${s.type === 'Apprentissage' ? 'type-apprentissage' : (s.type === 'Consolidation' ? 'type-consolidation' : 'type-maintien')}">${s.type}</span></td><td>${s.strategy}</td><td>${s.productivity}</td><td>${s.optimalTime}</td></tr>`).join('');

    }

    

    function updatePlanningStats(sessions, quality, duration) {

        document.getElementById('statSessions').innerText = sessions.length;

        if(sessions.length > 0) { const lastDate = sessions[sessions.length-1].date; const firstDate = sessions[0].date; const totalDays = Math.ceil((lastDate - firstDate) / (1000 * 60 * 60 * 24)); document.getElementById('statTotalDays').innerText = totalDays; }

        const qualityMap = {'0':'1/4','1':'2/4','2':'3/4','3':'4/4'};

        document.getElementById('statQuality').innerText = qualityMap[quality] || "3/4";

        document.getElementById('statDuration').innerText = duration + "min";

    }

    

    function exportPlanning() {

        let csv = "Date,Session,Compétence,Durée,Intervalle,Type,Stratégie,Productivité,Heure Optimale\n";

        currentSessions.forEach(s => { csv += `"${s.dateStr}","R${s.id}","${s.competence}","${s.duration}","${s.interval}","${s.type}","${s.strategy}","${s.productivity}","${s.optimalTime}"\n`; });

        const blob = new Blob([csv], {type: 'text/csv'});

        const link = document.createElement('a');

        link.href = URL.createObjectURL(blob);

        link.download = 'planning_perseverai.csv';

        link.click();

        showToast("Planning exporté en CSV");

    }

    

    function generateRandomEvent() {

        const template = eventTemplates[Math.floor(Math.random() * eventTemplates.length)];

        const newEvent = { id: Date.now() + Math.random(), date: new Date().toLocaleString(), type: template.type, title: template.title, message: template.message, priority: template.priority, status: 'pending' };

        eventsList.unshift(newEvent);

        saveEvents();

        renderEventsTable();

        updateEventStats();

        showToast(`Nouvel événement: ${template.title}`);

    }

    

    function executeAction(eventId, actionType, actionLabel) {

        const eventIndex = eventsList.findIndex(e => e.id == eventId);

        if(eventIndex === -1) return;

        eventsList[eventIndex].status = actionType === 'ACCEPT' ? 'accepted' : (actionType === 'REJECT' ? 'rejected' : 'hold');

        renderEventsTable();

        updateEventStats();

        saveEvents();

        showToast(`${actionLabel}`);

    }

    

    function renderEventsTable() {

        const tbody = document.getElementById('notificationsTableBody');

        if(!tbody) return;

        if(eventsList.length === 0) { tbody.innerHTML = '<tr><td colspan="7" style="text-align:center;">Aucun événement</td></tr>'; return; }

        tbody.innerHTML = eventsList.map(event => `<tr><td>${event.date}</td><td>${event.type}</td><td><strong>${event.title}</strong></td><td>${event.message}</td><td><span class="priority-${event.priority}">${event.priority}</span></td><td><span class="status-badge ${event.status === 'accepted' ? 'status-accepted' : 'status-pending'}">${event.status === 'accepted' ? 'Accepté' : 'En attente'}</span></td><td class="action-cell"><button class="action-icon-btn action-accept" onclick="executeAction(${event.id}, 'ACCEPT', 'Accepté')">✓ Accepter</button><button class="action-icon-btn action-reject" onclick="executeAction(${event.id}, 'REJECT', 'Rejeté')">✗ Rejeter</button><button class="action-icon-btn action-hold" onclick="executeAction(${event.id}, 'HOLD', 'En attente')">⏸ Attente</button><button class="action-icon-btn action-help" onclick="executeAction(${event.id}, 'HELP', 'Aide demandée')">🆘 Aide</button></td></tr>`).join('');

    }

    

    function updateEventStats() {

        document.getElementById('totalEvents').innerText = eventsList.length;

        document.getElementById('pendingEvents').innerText = eventsList.filter(e => e.status === 'pending').length;

        document.getElementById('acceptedEvents').innerText = eventsList.filter(e => e.status === 'accepted').length;

        if(efficiencyChart) efficiencyChart.data.datasets[0].data = [eventsList.filter(e=>e.status==='accepted').length, eventsList.filter(e=>e.status==='rejected').length, eventsList.filter(e=>e.status==='pending').length];

        efficiencyChart?.update();

    }

    

    let efficiencyChart = null;

    function createChart() {

        const ctx = document.getElementById('notificationEfficiencyChart')?.getContext('2d');

        if(ctx) efficiencyChart = new Chart(ctx, { type: 'bar', data: { labels: ['Acceptés', 'Rejetés', 'En attente'], datasets: [{ label: 'Actions', data: [0,0,0], backgroundColor: ['#16a34a','#dc2626','#d97706'] }] }, options: { responsive: true } });

    }

    

    function saveJournal() { if(document.getElementById('done')?.value) { let journal = JSON.parse(localStorage.getItem('journal') || '[]'); journal.unshift({ date: new Date().toLocaleString(), done: document.getElementById('done').value }); localStorage.setItem('journal', JSON.stringify(journal)); showToast("Journal sauvegardé"); document.getElementById('done').value = ''; } }

    function saveEvents() { localStorage.setItem('eventsList', JSON.stringify(eventsList)); }

    function loadSavedData() { const saved = localStorage.getItem('eventsList'); if(saved) eventsList = JSON.parse(saved); }

    

    function showTab(tabId) {

        document.querySelectorAll('.tab-content').forEach(t => t.classList.remove('active'));

        document.getElementById(tabId).classList.add('active');

        document.querySelectorAll('.nav-tab').forEach(t => t.classList.remove('active'));

        if(window.event?.target) window.event.target.classList.add('active');

        if(tabId === 'dashboard') {

            renderHeatmap();

            updateIndicators();

            const ctx = document.getElementById('progressChart')?.getContext('2d');

            if(ctx && !dashChart) dashChart = new Chart(ctx, { type:'line', data:{ labels:['Sem1','Sem2','Sem3','Sem4'], datasets:[{ label:'Progression', data:[30,45,60,75], borderColor:'#2563eb' }] } });

            else if(dashChart) dashChart.update();

        }

        if(tabId === 'planner') { if(currentSessions.length === 0) generateDefaultPlanning(); else drawSpacedRepetitionCurve(currentSessions); }

        if(tabId === 'notifications') { renderEventsTable(); updateEventStats(); }

        if(tabId === 'profile') { loadProfileFromStorage(); updateProfileUI(); }

    }

    

    function showToast(msg) { let div = document.createElement('div'); div.style.cssText = `position:fixed; bottom:20px; right:20px; background:#1e293b; color:white; padding:12px 20px; border-radius:8px; z-index:1000;`; div.innerHTML = msg; document.body.appendChild(div); setTimeout(()=>div.remove(), 2500); }

    

    document.addEventListener('DOMContentLoaded', () => {

        initCompetencesSelect();

        loadSavedData();

        renderEventsTable();

        updateEventStats();

        createChart();

        initProfileModule();

        const retentionSlider = document.getElementById('retentionQuality');

        if(retentionSlider) retentionSlider.addEventListener('input', function() {

            const val = parseInt(this.value);

            const messages = {0: "0 - Faible", 1: "1 - Moyenne", 2: "2 - Bon - Consolidation progressive", 3: "3 - Excellente"};

            document.getElementById('retentionValueDisplay').innerText = messages[val];

        });

        generateDefaultPlanning();

        loadProfileFromStorage();

        setupRatingListeners();

        updateProfileUI();

    });

    

    function initProfileModule() { loadProfileFromStorage(); setupRatingListeners(); updateProfileUI(); }

    window.addEventListener('resize', () => { if(document.getElementById('planner').classList.contains('active') && currentSessions.length > 0) drawSpacedRepetitionCurve(currentSessions); });

</script>
</body>
</html>