File size: 78,378 Bytes
e636ecd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87b1086
 
e636ecd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
<!DOCTYPE html>
<html lang="fr" class="h-full">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TaskMaster - Gestionnaire de tâches</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        urgent: '#dc2626',
                        high: '#ea580c',
                        normal: '#2563eb',
                        low: '#6b7280',
                        work: '#2563eb',
                        personal: '#16a34a',
                        property: '#7c3aed',
                        admin: '#db2777',
                    }
                }
            }
        }
    </script>
    <style>
        .task-card:hover .task-actions {
            opacity: 1;
        }
        .priority-column {
            min-height: calc(100vh - 200px);
        }
        .drawer {
            transition: transform 0.3s ease-in-out;
        }
        .drawer-closed {
            transform: translateX(100%);
        }
        .drawer-open {
            transform: translateX(0);
        }
        .fade-in {
            animation: fadeIn 0.3s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        .slide-up {
            animation: slideUp 0.2s ease-out;
        }
        @keyframes slideUp {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }
        .checkbox-container {
            position: relative;
            padding-left: 35px;
            cursor: pointer;
        }
        .checkbox-container input {
            position: absolute;
            opacity: 0;
            cursor: pointer;
            height: 0;
            width: 0;
        }
        .checkmark {
            position: absolute;
            top: 0;
            left: 0;
            height: 24px;
            width: 24px;
            border: 2px solid #d1d5db;
            border-radius: 6px;
            transition: all 0.2s;
        }
        .checkbox-container:hover .checkmark {
            border-color: #9ca3af;
        }
        .checkbox-container input:checked ~ .checkmark {
            background-color: #2563eb;
            border-color: #2563eb;
        }
        .checkmark:after {
            content: "";
            position: absolute;
            display: none;
        }
        .checkbox-container input:checked ~ .checkmark:after {
            display: block;
        }
        .checkbox-container .checkmark:after {
            left: 7px;
            top: 3px;
            width: 6px;
            height: 12px;
            border: solid white;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
        }
        .dark .checkbox-container input:checked ~ .checkmark {
            background-color: #3b82f6;
            border-color: #3b82f6;
        }
        .dark .checkmark {
            border-color: #4b5563;
        }
        .dark .checkbox-container:hover .checkmark {
            border-color: #6b7280;
        }
    </style>
</head>
<body class="h-full bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 transition-colors duration-200">
    <!-- Auth Modal -->
    <div id="auth-modal" class="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 hidden">
        <div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md p-6 mx-4 fade-in">
            <div class="flex justify-between items-center mb-6">
                <h2 class="text-2xl font-bold" id="auth-modal-title">Connexion</h2>
                <button onclick="toggleAuthModal()" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div id="auth-tabs" class="flex border-b border-gray-200 dark:border-gray-700 mb-6">
                <button onclick="switchAuthTab('login')" class="px-4 py-2 font-medium border-b-2 border-transparent hover:text-blue-600 dark:hover:text-blue-400" id="login-tab">Connexion</button>
                <button onclick="switchAuthTab('register')" class="px-4 py-2 font-medium border-b-2 border-transparent hover:text-blue-600 dark:hover:text-blue-400" id="register-tab">Inscription</button>
            </div>
            
            <form id="login-form" class="space-y-4">
                <div>
                    <label for="login-email" class="block text-sm font-medium mb-1">Email</label>
                    <input type="email" id="login-email" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                <div>
                    <label for="login-password" class="block text-sm font-medium mb-1">Mot de passe</label>
                    <input type="password" id="login-password" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                <button type="button" onclick="login()" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md transition duration-200">
                    Se connecter
                </button>
            </form>
            
            <form id="register-form" class="space-y-4 hidden">
                <div>
                    <label for="register-email" class="block text-sm font-medium mb-1">Email</label>
                    <input type="email" id="register-email" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                <div>
                    <label for="register-password" class="block text-sm font-medium mb-1">Mot de passe</label>
                    <input type="password" id="register-password" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                <div>
                    <label for="register-confirm-password" class="block text-sm font-medium mb-1">Confirmer le mot de passe</label>
                    <input type="password" id="register-confirm-password" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                <button type="button" onclick="register()" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md transition duration-200">
                    S'inscrire
                </button>
            </form>
        </div>
    </div>

    <!-- Notification -->
    <div id="notification" class="fixed top-4 right-4 z-50 px-4 py-3 rounded-md shadow-lg hidden slide-up" style="max-width: 350px;">
        <div class="flex items-center">
            <div id="notification-icon" class="mr-3"></div>
            <div>
                <h4 id="notification-title" class="font-medium"></h4>
                <p id="notification-message" class="text-sm"></p>
            </div>
            <button onclick="hideNotification()" class="ml-auto text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                <i class="fas fa-times"></i>
            </button>
        </div>
    </div>

    <!-- Overdue Banner -->
    <div id="overdue-banner" class="bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-100 px-4 py-3 mb-4 rounded-md hidden">
        <div class="flex items-center">
            <i class="fas fa-exclamation-circle mr-2"></i>
            <span>Vous avez <span id="overdue-count">0</span> tâche(s) en retard</span>
            <button onclick="hideOverdueBanner()" class="ml-auto text-red-500 hover:text-red-700 dark:hover:text-red-300">
                <i class="fas fa-times"></i>
            </button>
        </div>
    </div>

    <!-- Task Detail Drawer -->
    <div id="task-drawer" class="drawer drawer-closed fixed inset-y-0 right-0 z-40 w-full max-w-md bg-white dark:bg-gray-800 shadow-xl overflow-y-auto">
        <div class="p-6">
            <div class="flex justify-between items-center mb-6">
                <h3 class="text-xl font-bold" id="task-drawer-title">Détails de la tâche</h3>
                <button onclick="closeTaskDrawer()" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="space-y-6">
                <div>
                    <label class="block text-sm font-medium mb-1">Titre</label>
                    <input type="text" id="task-title" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                </div>
                
                <div>
                    <label class="block text-sm font-medium mb-1">Description</label>
                    <textarea id="task-description" rows="3" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700"></textarea>
                </div>
                
                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium mb-1">Date d'échéance</label>
                        <input type="datetime-local" id="task-due" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                    </div>
                    
                    <div>
                        <label class="block text-sm font-medium mb-1">Priorité</label>
                        <select id="task-priority" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                            <option value="low">Basse</option>
                            <option value="normal">Normale</option>
                            <option value="high">Haute</option>
                            <option value="urgent">Urgente</option>
                        </select>
                    </div>
                </div>
                
                <div>
                    <label class="block text-sm font-medium mb-1">Catégorie</label>
                    <select id="task-category" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                        <option value="">Aucune catégorie</option>
                    </select>
                </div>
                
                <div>
                    <label class="block text-sm font-medium mb-1">Statut</label>
                    <select id="task-status" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                        <option value="todo">À faire</option>
                        <option value="in_progress">En cours</option>
                        <option value="done">Terminée</option>
                        <option value="archived">Archivée</option>
                    </select>
                </div>
                
                <div>
                    <div class="flex justify-between items-center mb-2">
                        <label class="block text-sm font-medium">Rappels</label>
                        <button onclick="addReminder()" class="text-sm text-blue-600 dark:text-blue-400 hover:underline">Ajouter un rappel</button>
                    </div>
                    <div id="task-reminders" class="space-y-2">
                        <!-- Reminders will be added here -->
                    </div>
                </div>
            </div>
            
            <div class="mt-8 flex justify-between">
                <button onclick="deleteTask()" class="px-4 py-2 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900 rounded-md transition duration-200">
                    Supprimer
                </button>
                <div class="space-x-2">
                    <button onclick="saveTask()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md transition duration-200">
                        Enregistrer
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- Main App Layout -->
    <div class="flex flex-col h-full">
        <!-- Header -->
        <header class="bg-white dark:bg-gray-800 shadow-sm">
            <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">
                        <i class="fas fa-tasks text-blue-600 dark:text-blue-400 mr-2 text-xl"></i>
                        <h1 class="text-xl font-bold">TaskMaster</h1>
                    </div>
                    <div class="flex items-center space-x-4">
                        <button onclick="toggleDarkMode()" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700">
                            <i id="dark-mode-icon" class="fas fa-moon"></i>
                        </button>
                        <div class="relative">
                            <button onclick="toggleUserMenu()" class="flex items-center space-x-2 focus:outline-none">
                                <div class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white">
                                    <span id="user-initial">U</span>
                                </div>
                            </button>
                            <div id="user-menu" class="hidden absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-md shadow-lg py-1 z-50">
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Profil</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Paramètres</a>
                                <a href="#" onclick="logout()" class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700">Déconnexion</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <main class="flex-1 overflow-hidden">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-full">
                <div class="flex h-full">
                    <!-- Sidebar -->
                    <aside class="hidden md:block w-64 border-r border-gray-200 dark:border-gray-700 pr-4 py-6 overflow-y-auto">
                        <div class="space-y-1">
                            <button onclick="switchView('dashboard')" class="w-full flex items-center px-3 py-2 text-sm font-medium rounded-md bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-200">
                                <i class="fas fa-tachometer-alt mr-3"></i>
                                Tableau de bord
                            </button>
                            <button onclick="switchView('all-tasks')" class="w-full flex items-center px-3 py-2 text-sm font-medium rounded-md hover:bg-gray-200 dark:hover:bg-gray-700">
                                <i class="fas fa-list-ul mr-3"></i>
                                Toutes les tâches
                            </button>
                            <button onclick="switchView('categories')" class="w-full flex items-center px-3 py-2 text-sm font-medium rounded-md hover:bg-gray-200 dark:hover:bg-gray-700">
                                <i class="fas fa-tags mr-3"></i>
                                Catégories
                            </button>
                            <button onclick="switchView('priorities')" class="w-full flex items-center px-3 py-2 text-sm font-medium rounded-md hover:bg-gray-200 dark:hover:bg-gray-700">
                                <i class="fas fa-flag mr-3"></i>
                                Priorités
                            </button>
                            <button onclick="switchView('calendar')" class="w-full flex items-center px-3 py-2 text-sm font-medium rounded-md hover:bg-gray-200 dark:hover:bg-gray-700">
                                <i class="fas fa-calendar-alt mr-3"></i>
                                Calendrier
                            </button>
                        </div>

                        <div class="mt-8">
                            <h3 class="px-3 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
                                Catégories
                            </h3>
                            <div class="mt-1 space-y-1" id="category-list">
                                <!-- Categories will be added here -->
                            </div>
                        </div>
                    </aside>

                    <!-- Main Content Area -->
                    <div class="flex-1 flex flex-col overflow-hidden">
                        <!-- Mobile Navigation -->
                        <div class="md:hidden flex justify-around items-center border-b border-gray-200 dark:border-gray-700 py-2">
                            <button onclick="switchView('dashboard')" class="flex flex-col items-center px-2 py-1 text-xs rounded-md">
                                <i class="fas fa-tachometer-alt mb-1"></i>
                                <span>Dashboard</span>
                            </button>
                            <button onclick="switchView('all-tasks')" class="flex flex-col items-center px-2 py-1 text-xs rounded-md">
                                <i class="fas fa-list-ul mb-1"></i>
                                <span>Toutes</span>
                            </button>
                            <button onclick="switchView('categories')" class="flex flex-col items-center px-2 py-1 text-xs rounded-md">
                                <i class="fas fa-tags mb-1"></i>
                                <span>Catégories</span>
                            </button>
                            <button onclick="switchView('priorities')" class="flex flex-col items-center px-2 py-1 text-xs rounded-md">
                                <i class="fas fa-flag mb-1"></i>
                                <span>Priorités</span>
                            </button>
                        </div>

                        <!-- Content -->
                        <div class="flex-1 overflow-y-auto p-4">
                            <!-- Dashboard View -->
                            <div id="dashboard-view">
                                <div class="mb-6">
                                    <div class="relative">
                                        <input type="text" id="quick-add-input" placeholder="Que devez-vous faire ? #catégorie !priorité" class="w-full px-4 py-3 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                                        <button onclick="quickAddTask()" class="absolute right-3 top-1/2 transform -translate-y-1/2 p-2 text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300">
                                            <i class="fas fa-plus"></i>
                                        </button>
                                    </div>
                                </div>

                                <div id="overdue-banner-container"></div>

                                <div class="space-y-6">
                                    <div>
                                        <h2 class="text-lg font-semibold mb-3 flex items-center">
                                            <span class="w-2 h-2 bg-red-500 rounded-full mr-2"></span>
                                            En retard
                                        </h2>
                                        <div id="overdue-tasks" class="space-y-2">
                                            <!-- Overdue tasks will be added here -->
                                        </div>
                                    </div>

                                    <div>
                                        <h2 class="text-lg font-semibold mb-3 flex items-center">
                                            <span class="w-2 h-2 bg-orange-500 rounded-full mr-2"></span>
                                            Aujourd'hui
                                        </h2>
                                        <div id="today-tasks" class="space-y-2">
                                            <!-- Today's tasks will be added here -->
                                        </div>
                                    </div>

                                    <div>
                                        <h2 class="text-lg font-semibold mb-3 flex items-center">
                                            <span class="w-2 h-2 bg-yellow-500 rounded-full mr-2"></span>
                                            Demain
                                        </h2>
                                        <div id="tomorrow-tasks" class="space-y-2">
                                            <!-- Tomorrow's tasks will be added here -->
                                        </div>
                                    </div>

                                    <div>
                                        <h2 class="text-lg font-semibold mb-3 flex items-center">
                                            <span class="w-2 h-2 bg-blue-500 rounded-full mr-2"></span>
                                            À venir
                                        </h2>
                                        <div id="upcoming-tasks" class="space-y-2">
                                            <!-- Upcoming tasks will be added here -->
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- All Tasks View -->
                            <div id="all-tasks-view" class="hidden">
                                <div class="mb-6 flex flex-col md:flex-row md:items-center md:justify-between space-y-3 md:space-y-0">
                                    <div class="relative w-full md:w-64">
                                        <input type="text" id="task-search" placeholder="Rechercher des tâches..." class="w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                                        <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
                                    </div>
                                    <div class="flex space-x-2">
                                        <select id="task-filter-status" class="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                                            <option value="">Tous les statuts</option>
                                            <option value="todo">À faire</option>
                                            <option value="in_progress">En cours</option>
                                            <option value="done">Terminée</option>
                                            <option value="archived">Archivée</option>
                                        </select>
                                        <select id="task-filter-priority" class="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                                            <option value="">Toutes priorités</option>
                                            <option value="urgent">Urgente</option>
                                            <option value="high">Haute</option>
                                            <option value="normal">Normale</option>
                                            <option value="low">Basse</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="mb-4 flex justify-between items-center">
                                    <h2 class="text-lg font-semibold">Toutes les tâches</h2>
                                    <select id="task-sort" class="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700">
                                        <option value="due_asc">Échéance (proche)</option>
                                        <option value="due_desc">Échéance (lointaine)</option>
                                        <option value="priority">Priorité</option>
                                        <option value="created">Date de création</option>
                                        <option value="updated">Dernière modification</option>
                                    </select>
                                </div>

                                <div id="all-tasks-list" class="space-y-2">
                                    <!-- All tasks will be added here -->
                                </div>
                            </div>

                            <!-- Categories View -->
                            <div id="categories-view" class="hidden">
                                <div class="mb-6 flex justify-between items-center">
                                    <h2 class="text-lg font-semibold">Catégories</h2>
                                    <button onclick="showAddCategoryModal()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md transition duration-200">
                                        <i class="fas fa-plus mr-1"></i> Nouvelle catégorie
                                    </button>
                                </div>

                                <div id="categories-list" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                                    <!-- Categories will be added here -->
                                </div>
                            </div>

                            <!-- Priorities View -->
                            <div id="priorities-view" class="hidden">
                                <div class="mb-6">
                                    <h2 class="text-lg font-semibold">Vue par priorités</h2>
                                </div>

                                <div class="grid grid-cols-1 md:grid-cols-4 gap-4">
                                    <div class="priority-column bg-red-50 dark:bg-red-900/20 p-4 rounded-lg">
                                        <div class="flex items-center mb-4">
                                            <h3 class="font-medium text-red-600 dark:text-red-400">Urgent</h3>
                                            <span class="ml-auto px-2 py-1 text-xs bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200 rounded-full">3</span>
                                        </div>
                                        <div id="urgent-tasks" class="space-y-2">
                                            <!-- Urgent tasks will be added here -->
                                        </div>
                                    </div>

                                    <div class="priority-column bg-orange-50 dark:bg-orange-900/20 p-4 rounded-lg">
                                        <div class="flex items-center mb-4">
                                            <h3 class="font-medium text-orange-600 dark:text-orange-400">Haute</h3>
                                            <span class="ml-auto px-2 py-1 text-xs bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-200 rounded-full">2</span>
                                        </div>
                                        <div id="high-tasks" class="space-y-2">
                                            <!-- High priority tasks will be added here -->
                                        </div>
                                    </div>

                                    <div class="priority-column bg-blue-50 dark:bg-blue-900/20 p-4 rounded-lg">
                                        <div class="flex items-center mb-4">
                                            <h3 class="font-medium text-blue-600 dark:text-blue-400">Normale</h3>
                                            <span class="ml-auto px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 rounded-full">4</span>
                                        </div>
                                        <div id="normal-tasks" class="space-y-2">
                                            <!-- Normal priority tasks will be added here -->
                                        </div>
                                    </div>

                                    <div class="priority-column bg-gray-100 dark:bg-gray-800 p-4 rounded-lg">
                                        <div class="flex items-center mb-4">
                                            <h3 class="font-medium text-gray-600 dark:text-gray-300">Basse</h3>
                                            <span class="ml-auto px-2 py-1 text-xs bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 rounded-full">1</span>
                                        </div>
                                        <div id="low-tasks" class="space-y-2">
                                            <!-- Low priority tasks will be added here -->
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- Calendar View -->
                            <div id="calendar-view" class="hidden">
                                <div class="mb-6 flex justify-between items-center">
                                    <h2 class="text-lg font-semibold">Calendrier</h2>
                                    <div class="flex items-center space-x-2">
                                        <button class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700">
                                            <i class="fas fa-chevron-left"></i>
                                        </button>
                                        <span class="font-medium">Mai 2023</span>
                                        <button class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-gray-700">
                                            <i class="fas fa-chevron-right"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden">
                                    <div class="grid grid-cols-7 gap-px bg-gray-200 dark:bg-gray-700">
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Lun</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Mar</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Mer</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Jeu</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Ven</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Sam</div>
                                        <div class="bg-gray-100 dark:bg-gray-800 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400">Dim</div>
                                    </div>
                                    <div class="grid grid-cols-7 gap-px bg-gray-200 dark:bg-gray-700">
                                        <!-- Calendar days will be added here -->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // State management
        let currentUser = null;
        let tasks = [];
        let categories = [];
        let reminders = [];
        let currentView = 'dashboard';
        let currentTaskId = null;

        // Demo data
        const demoCategories = [
            { id: 1, name: 'Travail', color: 'work', icon: 'briefcase' },
            { id: 2, name: 'Personnel', color: 'personal', icon: 'home' },
            { id: 3, name: 'Immobilier', color: 'property', icon: 'building' },
            { id: 4, name: 'Administration', color: 'admin', icon: 'file-alt' }
        ];

        const demoTasks = [
            { 
                id: 1, 
                title: 'Payer l\'assurance', 
                description: 'Payer l\'assurance voiture avant la date limite', 
                status: 'todo', 
                priority: 'high', 
                category_id: 4, 
                due_at: new Date(Date.now() + 86400000).toISOString(), // Tomorrow
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 2, 
                title: 'Préparer présentation client', 
                description: 'Préparer les slides pour la réunion de mercredi', 
                status: 'in_progress', 
                priority: 'urgent', 
                category_id: 1, 
                due_at: new Date(Date.now() + 172800000).toISOString(), // 2 days
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 3, 
                title: 'Faire les courses', 
                description: 'Acheter fruits, légumes et produits ménagers', 
                status: 'todo', 
                priority: 'normal', 
                category_id: 2, 
                due_at: new Date(Date.now() + 259200000).toISOString(), // 3 days
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 4, 
                title: 'Réparer robinet cuisine', 
                description: 'Le robinet fuit depuis plusieurs jours', 
                status: 'todo', 
                priority: 'low', 
                category_id: 2, 
                due_at: null,
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 5, 
                title: 'Rappel taxe foncière', 
                description: 'Payer la taxe foncière avant le 15 octobre', 
                status: 'todo', 
                priority: 'high', 
                category_id: 3, 
                due_at: new Date('2023-10-15').toISOString(),
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 6, 
                title: 'Réunion équipe', 
                description: 'Préparer le point sur les projets en cours', 
                status: 'done', 
                priority: 'normal', 
                category_id: 1, 
                due_at: new Date(Date.now() - 86400000).toISOString(), // Yesterday
                completed_at: new Date().toISOString(),
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            },
            { 
                id: 7, 
                title: 'Rendez-vous médecin', 
                description: 'Contrôle annuel à 14h30', 
                status: 'todo', 
                priority: 'urgent', 
                category_id: 2, 
                due_at: new Date(Date.now() + 3600000).toISOString(), // In 1 hour
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            }
        ];

        const demoReminders = [
            { id: 1, task_id: 1, remind_at: new Date(Date.now() + 82800000).toISOString(), channel: 'in_app' }, // 1h before
            { id: 2, task_id: 1, remind_at: new Date(Date.now() + 86040000).toISOString(), channel: 'in_app' }, // 10min before
            { id: 3, task_id: 7, remind_at: new Date(Date.now() + 1800000).toISOString(), channel: 'in_app' } // 30min before
        ];

        // Initialize app
        document.addEventListener('DOMContentLoaded', function() {
            // Check if user is logged in
            const storedUser = localStorage.getItem('currentUser');
            if (storedUser) {
                currentUser = JSON.parse(storedUser);
                initApp();
            } else {
                toggleAuthModal();
            }

            // Load demo data if no user data exists
            if (!localStorage.getItem('tasks')) {
                categories = demoCategories;
                tasks = demoTasks;
                reminders = demoReminders;
                saveData();
            } else {
                loadData();
            }

            // Check for overdue tasks
            checkOverdueTasks();
        });

        // Data management
        function saveData() {
            if (currentUser) {
                localStorage.setItem(`tasks_${currentUser.id}`, JSON.stringify(tasks));
                localStorage.setItem(`categories_${currentUser.id}`, JSON.stringify(categories));
                localStorage.setItem(`reminders_${currentUser.id}`, JSON.stringify(reminders));
            }
        }

        function loadData() {
            if (currentUser) {
                const storedTasks = localStorage.getItem(`tasks_${currentUser.id}`);
                const storedCategories = localStorage.getItem(`categories_${currentUser.id}`);
                const storedReminders = localStorage.getItem(`reminders_${currentUser.id}`);

                if (storedTasks) tasks = JSON.parse(storedTasks);
                if (storedCategories) categories = JSON.parse(storedCategories);
                if (storedReminders) reminders = JSON.parse(storedReminders);
            }
        }

        // Auth functions
        function toggleAuthModal() {
            const modal = document.getElementById('auth-modal');
            modal.classList.toggle('hidden');
        }

        function switchAuthTab(tab) {
            const loginForm = document.getElementById('login-form');
            const registerForm = document.getElementById('register-form');
            const loginTab = document.getElementById('login-tab');
            const registerTab = document.getElementById('register-tab');
            const modalTitle = document.getElementById('auth-modal-title');

            if (tab === 'login') {
                loginForm.classList.remove('hidden');
                registerForm.classList.add('hidden');
                loginTab.classList.add('border-blue-500', 'text-blue-600', 'dark:text-blue-400');
                loginTab.classList.remove('border-transparent');
                registerTab.classList.add('border-transparent');
                registerTab.classList.remove('border-blue-500', 'text-blue-600', 'dark:text-blue-400');
                modalTitle.textContent = 'Connexion';
            } else {
                loginForm.classList.add('hidden');
                registerForm.classList.remove('hidden');
                registerTab.classList.add('border-blue-500', 'text-blue-600', 'dark:text-blue-400');
                registerTab.classList.remove('border-transparent');
                loginTab.classList.add('border-transparent');
                loginTab.classList.remove('border-blue-500', 'text-blue-600', 'dark:text-blue-400');
                modalTitle.textContent = 'Inscription';
            }
        }

        function login() {
            const email = document.getElementById('login-email').value;
            const password = document.getElementById('login-password').value;

            // Simple validation
            if (!email || !password) {
                showNotification('error', 'Erreur', 'Veuillez remplir tous les champs');
                return;
            }

            // In a real app, this would be an API call
            currentUser = {
                id: 1,
                email: email,
                name: email.split('@')[0]
            };
            localStorage.setItem('currentUser', JSON.stringify(currentUser));

            toggleAuthModal();
            initApp();
            showNotification('success', 'Connecté', 'Vous êtes maintenant connecté');
        }

        function register() {
            const email = document.getElementById('register-email').value;
            const password = document.getElementById('register-password').value;
            const confirmPassword = document.getElementById('register-confirm-password').value;

            // Simple validation
            if (!email || !password || !confirmPassword) {
                showNotification('error', 'Erreur', 'Veuillez remplir tous les champs');
                return;
            }

            if (password !== confirmPassword) {
                showNotification('error', 'Erreur', 'Les mots de passe ne correspondent pas');
                return;
            }

            // In a real app, this would be an API call
            currentUser = {
                id: 1,
                email: email,
                name: email.split('@')[0]
            };
            localStorage.setItem('currentUser', JSON.stringify(currentUser));

            toggleAuthModal();
            initApp();
            showNotification('success', 'Inscription réussie', 'Votre compte a été créé');
        }

        function logout() {
            currentUser = null;
            localStorage.removeItem('currentUser');
            toggleAuthModal();
            document.getElementById('user-menu').classList.add('hidden');
        }

        function initApp() {
            loadData();
            renderUserInfo();
            renderCategories();
            renderTasks();
            setupEventListeners();
        }

        function renderUserInfo() {
            if (currentUser) {
                document.getElementById('user-initial').textContent = currentUser.name.charAt(0).toUpperCase();
            }
        }

        // UI functions
        function toggleUserMenu() {
            const menu = document.getElementById('user-menu');
            menu.classList.toggle('hidden');
        }

        function toggleDarkMode() {
            document.documentElement.classList.toggle('dark');
            const icon = document.getElementById('dark-mode-icon');
            if (document.documentElement.classList.contains('dark')) {
                icon.classList.remove('fa-moon');
                icon.classList.add('fa-sun');
            } else {
                icon.classList.remove('fa-sun');
                icon.classList.add('fa-moon');
            }
        }

        function showNotification(type, title, message) {
            const notification = document.getElementById('notification');
            const icon = document.getElementById('notification-icon');
            const notificationTitle = document.getElementById('notification-title');
            const notificationMessage = document.getElementById('notification-message');

            // Set notification content
            notificationTitle.textContent = title;
            notificationMessage.textContent = message;

            // Set notification style based on type
            notification.className = `fixed top-4 right-4 z-50 px-4 py-3 rounded-md shadow-lg slide-up ${type === 'error' ? 'bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-100' : 'bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-100'}`;

            // Set icon
            icon.className = `fas ${type === 'error' ? 'fa-exclamation-circle text-red-500 dark:text-red-300' : 'fa-check-circle text-green-500 dark:text-green-300'}`;

            // Show notification
            notification.classList.remove('hidden');

            // Hide after 5 seconds
            setTimeout(hideNotification, 5000);
        }

        function hideNotification() {
            const notification = document.getElementById('notification');
            notification.classList.add('hidden');
        }

        function showOverdueBanner(count) {
            const banner = document.getElementById('overdue-banner');
            const countElement = document.getElementById('overdue-count');
            
            countElement.textContent = count;
            banner.classList.remove('hidden');
            
            // Also add to dashboard view
            const dashboardBanner = document.getElementById('overdue-banner-container');
            dashboardBanner.innerHTML = `
                <div class="bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-100 px-4 py-3 mb-4 rounded-md">
                    <div class="flex items-center">
                        <i class="fas fa-exclamation-circle mr-2"></i>
                        <span>Vous avez ${count} tâche(s) en retard</span>
                        <button onclick="hideOverdueBanner()" class="ml-auto text-red-500 hover:text-red-700 dark:hover:text-red-300">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>
            `;
        }

        function hideOverdueBanner() {
            const banner = document.getElementById('overdue-banner');
            banner.classList.add('hidden');
            document.getElementById('overdue-banner-container').innerHTML = '';
        }

        function checkOverdueTasks() {
            const now = new Date();
            const overdueTasks = tasks.filter(task => 
                task.due_at && 
                new Date(task.due_at) < now && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );

            if (overdueTasks.length > 0) {
                showOverdueBanner(overdueTasks.length);
            }
        }

        // View switching
        function switchView(view) {
            currentView = view;
            
            // Hide all views
            document.getElementById('dashboard-view').classList.add('hidden');
            document.getElementById('all-tasks-view').classList.add('hidden');
            document.getElementById('categories-view').classList.add('hidden');
            document.getElementById('priorities-view').classList.add('hidden');
            document.getElementById('calendar-view').classList.add('hidden');
            
            // Show selected view
            document.getElementById(`${view}-view`).classList.remove('hidden');
            
            // Update sidebar active state
            updateSidebarActiveState();
            
            // Render specific content if needed
            if (view === 'priorities') {
                renderPriorityColumns();
            } else if (view === 'calendar') {
                renderCalendar();
            }
        }

        function updateSidebarActiveState() {
            // Reset all buttons
            const sidebarButtons = document.querySelectorAll('aside button');
            sidebarButtons.forEach(button => {
                button.classList.remove('bg-blue-100', 'dark:bg-blue-900', 'text-blue-700', 'dark:text-blue-200');
                button.classList.add('hover:bg-gray-200', 'dark:hover:bg-gray-700');
            });
            
            // Set active button
            const activeButton = document.querySelector(`aside button[onclick="switchView('${currentView}')"]`);
            if (activeButton) {
                activeButton.classList.add('bg-blue-100', 'dark:bg-blue-900', 'text-blue-700', 'dark:text-blue-200');
                activeButton.classList.remove('hover:bg-gray-200', 'dark:hover:bg-gray-700');
            }
        }

        // Task functions
        function renderTasks() {
            renderDashboardTasks();
            renderAllTasks();
            renderPriorityColumns();
        }

        function renderDashboardTasks() {
            const now = new Date();
            const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
            const tomorrow = new Date(today);
            tomorrow.setDate(tomorrow.getDate() + 1);
            
            // Overdue tasks (due before today and not done)
            const overdueTasks = tasks.filter(task => 
                task.due_at && 
                new Date(task.due_at) < today && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            // Today's tasks (due today)
            const todayTasks = tasks.filter(task => 
                task.due_at && 
                new Date(task.due_at) >= today && 
                new Date(task.due_at) < tomorrow && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            // Tomorrow's tasks (due tomorrow)
            const tomorrowTasks = tasks.filter(task => 
                task.due_at && 
                new Date(task.due_at) >= tomorrow && 
                new Date(task.due_at) < new Date(tomorrow.getTime() + 86400000) && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            // Upcoming tasks (due after tomorrow)
            const upcomingTasks = tasks.filter(task => 
                task.due_at && 
                new Date(task.due_at) >= new Date(tomorrow.getTime() + 86400000) && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            // Render each section
            renderTaskList('overdue-tasks', overdueTasks);
            renderTaskList('today-tasks', todayTasks);
            renderTaskList('tomorrow-tasks', tomorrowTasks);
            renderTaskList('upcoming-tasks', upcomingTasks);
        }

        function renderAllTasks() {
            const filteredTasks = filterAndSortTasks();
            renderTaskList('all-tasks-list', filteredTasks);
        }

        function filterAndSortTasks() {
            const statusFilter = document.getElementById('task-filter-status').value;
            const priorityFilter = document.getElementById('task-filter-priority').value;
            const searchQuery = document.getElementById('task-search').value.toLowerCase();
            const sortOption = document.getElementById('task-sort').value;
            
            let filteredTasks = [...tasks];
            
            // Apply status filter
            if (statusFilter) {
                filteredTasks = filteredTasks.filter(task => task.status === statusFilter);
            }
            
            // Apply priority filter
            if (priorityFilter) {
                filteredTasks = filteredTasks.filter(task => task.priority === priorityFilter);
            }
            
            // Apply search filter
            if (searchQuery) {
                filteredTasks = filteredTasks.filter(task => 
                    task.title.toLowerCase().includes(searchQuery) || 
                    (task.description && task.description.toLowerCase().includes(searchQuery))
                );
            }
            
            // Apply sorting
            switch (sortOption) {
                case 'due_asc':
                    filteredTasks.sort((a, b) => {
                        if (!a.due_at && !b.due_at) return 0;
                        if (!a.due_at) return 1;
                        if (!b.due_at) return -1;
                        return new Date(a.due_at) - new Date(b.due_at);
                    });
                    break;
                case 'due_desc':
                    filteredTasks.sort((a, b) => {
                        if (!a.due_at && !b.due_at) return 0;
                        if (!a.due_at) return 1;
                        if (!b.due_at) return -1;
                        return new Date(b.due_at) - new Date(a.due_at);
                    });
                    break;
                case 'priority':
                    const priorityOrder = { 'urgent': 0, 'high': 1, 'normal': 2, 'low': 3 };
                    filteredTasks.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority]);
                    break;
                case 'created':
                    filteredTasks.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
                    break;
                case 'updated':
                    filteredTasks.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
                    break;
            }
            
            return filteredTasks;
        }

        function renderPriorityColumns() {
            const urgentTasks = tasks.filter(task => 
                task.priority === 'urgent' && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            const highTasks = tasks.filter(task => 
                task.priority === 'high' && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            const normalTasks = tasks.filter(task => 
                task.priority === 'normal' && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            const lowTasks = tasks.filter(task => 
                task.priority === 'low' && 
                task.status !== 'done' && 
                task.status !== 'archived'
            );
            
            // Update counts
            document.querySelector('#priorities-view .priority-column:nth-child(1) span').textContent = urgentTasks.length;
            document.querySelector('#priorities-view .priority-column:nth-child(2) span').textContent = highTasks.length;
            document.querySelector('#priorities-view .priority-column:nth-child(3) span').textContent = normalTasks.length;
            document.querySelector('#priorities-view .priority-column:nth-child(4) span').textContent = lowTasks.length;
            
            // Render tasks
            renderTaskList('urgent-tasks', urgentTasks);
            renderTaskList('high-tasks', highTasks);
            renderTaskList('normal-tasks', normalTasks);
            renderTaskList('low-tasks', lowTasks);
        }

        function renderTaskList(containerId, taskList) {
            const container = document.getElementById(containerId);
            container.innerHTML = '';
            
            if (taskList.length === 0) {
                container.innerHTML = '<p class="text-gray-500 dark:text-gray-400 text-center py-4">Aucune tâche à afficher</p>';
                return;
            }
            
            taskList.forEach(task => {
                const taskElement = createTaskElement(task);
                container.appendChild(taskElement);
            });
        }

        function createTaskElement(task) {
            const category = categories.find(c => c.id === task.category_id);
            const taskReminders = reminders.filter(r => r.task_id === task.id);
            
            const taskElement = document.createElement('div');
            taskElement.className = 'task-card bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 border border-gray-200 dark:border-gray-700 hover:shadow-md transition duration-200';
            taskElement.dataset.taskId = task.id;
            
            // Priority indicator
            let priorityClass = '';
            let priorityText = '';
            switch (task.priority) {
                case 'urgent':
                    priorityClass = 'bg-urgent text-white';
                    priorityText = 'Urgent';
                    break;
                case 'high':
                    priorityClass = 'bg-high text-white';
                    priorityText = 'Haute';
                    break;
                case 'normal':
                    priorityClass = 'bg-normal text-white';
                    priorityText = 'Normale';
                    break;
                case 'low':
                    priorityClass = 'bg-low text-white';
                    priorityText = 'Basse';
                    break;
            }
            
            // Status checkbox
            const isChecked = task.status === 'done';
            
            // Due date display
            let dueDateDisplay = '';
            if (task.due_at) {
                const dueDate = new Date(task.due_at);
                const now = new Date();
                const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
                const tomorrow = new Date(today);
                tomorrow.setDate(tomorrow.getDate() + 1);
                
                if (dueDate < today && task.status !== 'done') {
                    dueDateDisplay = `<span class="text-red-500 dark:text-red-400 text-sm"><i class="fas fa-exclamation-circle mr-1"></i> En retard</span>`;
                } else if (dueDate >= today && dueDate < tomorrow) {
                    dueDateDisplay = `<span class="text-orange-500 dark:text-orange-400 text-sm"><i class="far fa-clock mr-1"></i> Aujourd'hui à ${dueDate.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</span>`;
                } else if (dueDate >= tomorrow && dueDate < new Date(tomorrow.getTime() + 86400000)) {
                    dueDateDisplay = `<span class="text-blue-500 dark:text-blue-400 text-sm"><i class="far fa-clock mr-1"></i> Demain à ${dueDate.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</span>`;
                } else {
                    dueDateDisplay = `<span class="text-gray-500 dark:text-gray-400 text-sm"><i class="far fa-calendar-alt mr-1"></i> ${dueDate.toLocaleDateString()}</span>`;
                }
            }
            
            taskElement.innerHTML = `
                <div class="flex items-start">
                    <label class="checkbox-container">
                        <input type="checkbox" ${isChecked ? 'checked' : ''} onchange="toggleTaskStatus(${task.id})">
                        <span class="checkmark"></span>
                    </label>
                    <div class="flex-1 ml-3">
                        <div class="flex items-center justify-between">
                            <h3 class="font-medium ${isChecked ? 'line-through text-gray-400 dark:text-gray-500' : ''}">${task.title}</h3>
                            <div class="task-actions opacity-0 md:opacity-100 transition-opacity duration-200">
                                <button onclick="event.stopPropagation();openTaskDrawer(${task.id})" class="p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                                    <i class="fas fa-pencil-alt"></i>
                                </button>
                                <button onclick="event.stopPropagation();duplicateTask(${task.id})" class="p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                                    <i class="fas fa-copy"></i>
                                </button>
                                <button onclick="event.stopPropagation();deleteTask(${task.id})" class="p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                                    <i class="fas fa-trash-alt"></i>
                                </button>
                            </div>
                        </div>
                        ${task.description ? `<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">${task.description}</p>` : ''}
                        <div class="mt-2 flex flex-wrap items-center gap-2">
                            ${task.priority !== 'normal' ? `<span class="px-2 py-1 text-xs rounded-full ${priorityClass}">${priorityText}</span>` : ''}
                            ${category ? `<span class="px-2 py-1 text-xs rounded-full bg-${category.color}-100 dark:bg-${category.color}-900/30 text-${category.color}-800 dark:text-${category.color}-200"><i class="fas fa-${category.icon} mr-1"></i> ${category.name}</span>` : ''}
                            ${task.due_at ? dueDateDisplay : ''}
                            ${taskReminders.length > 0 ? `<span class="text-yellow-500 dark:text-yellow-400 text-sm"><i class="fas fa-bell mr-1"></i> ${taskReminders.length} rappel(s)</span>` : ''}
                        </div>
                    </div>
                </div>
            `;
            
            // Add click handler to open task drawer
            taskElement.addEventListener('click', () => openTaskDrawer(task.id));
            
            return taskElement;
        }

        function toggleTaskStatus(taskId) {
            const taskIndex = tasks.findIndex(t => t.id === taskId);
            if (taskIndex === -1) return;
            
            const task = tasks[taskIndex];
            const isChecked = document.querySelector(`.task-card[data-task-id="${taskId}"] input[type="checkbox"]`).checked;
            
            if (isChecked) {
                task.status = 'done';
                task.completed_at = new Date().toISOString();
                
                // Remove future reminders
                reminders = reminders.filter(r => r.task_id !== taskId || new Date(r.remind_at) < new Date());
            } else {
                task.status = 'todo';
                task.completed_at = null;
            }
            
            task.updated_at = new Date().toISOString();
            tasks[taskIndex] = task;
            saveData();
            renderTasks();
            
            showNotification('success', 'Tâche mise à jour', `La tâche a été marquée comme ${isChecked ? 'terminée' : 'à faire'}`);
        }

        function quickAddTask() {
            const input = document.getElementById('quick-add-input');
            const text = input.value.trim();
            if (!text) return;
            
            // Parse quick add syntax (#category !priority)
            let categoryName = null;
            let priority = 'normal';
            
            const categoryMatch = text.match(/#(\w+)/);
            if (categoryMatch) {
                categoryName = categoryMatch[1];
            }
            
            const priorityMatch = text.match(/!(\w+)/);
            if (priorityMatch) {
                const priorityText = priorityMatch[1].toLowerCase();
                if (['urgent', 'high', 'normal', 'low'].includes(priorityText)) {
                    priority = priorityText;
                }
            }
            
            // Clean title (remove tags)
            const title = text.replace(/#\w+/g, '').replace(/!\w+/g, '').trim();
            
            // Find category
            let categoryId = null;
            if (categoryName) {
                const category = categories.find(c => c.name.toLowerCase() === categoryName.toLowerCase());
                if (category) {
                    categoryId = category.id;
                }
            }
            
            // Create task
            const newTask = {
                id: Date.now(),
                title: title,
                description: '',
                status: 'todo',
                priority: priority,
                category_id: categoryId,
                due_at: null,
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            };
            
            tasks.push(newTask);
            saveData();
            renderTasks();
            
            input.value = '';
            showNotification('success', 'Tâche ajoutée', 'La nouvelle tâche a été créée');
        }

        function openTaskDrawer(taskId) {
            currentTaskId = taskId;
            const task = tasks.find(t => t.id === taskId);
            if (!task) return;
            
            // Fill form
            document.getElementById('task-title').value = task.title;
            document.getElementById('task-description').value = task.description || '';
            document.getElementById('task-due').value = task.due_at ? formatDateTimeForInput(task.due_at) : '';
            document.getElementById('task-priority').value = task.priority;
            document.getElementById('task-status').value = task.status;
            
            // Fill category select
            const categorySelect = document.getElementById('task-category');
            categorySelect.innerHTML = '<option value="">Aucune catégorie</option>';
            categories.forEach(category => {
                const option = document.createElement('option');
                option.value = category.id;
                option.textContent = category.name;
                option.selected = task.category_id === category.id;
                categorySelect.appendChild(option);
            });
            
            // Fill reminders
            const remindersContainer = document.getElementById('task-reminders');
            remindersContainer.innerHTML = '';
            
            const taskReminders = reminders.filter(r => r.task_id === taskId);
            taskReminders.forEach(reminder => {
                const reminderElement = document.createElement('div');
                reminderElement.className = 'flex items-center justify-between p-2 bg-gray-100 dark:bg-gray-700 rounded';
                reminderElement.innerHTML = `
                    <span>${formatDateTime(new Date(reminder.remind_at))}</span>
                    <button onclick="removeReminder(${reminder.id})" class="text-red-500 hover:text-red-700 dark:hover:text-red-300">
                        <i class="fas fa-trash-alt"></i>
                    </button>
                `;
                remindersContainer.appendChild(reminderElement);
            });
            
            // Open drawer
            document.getElementById('task-drawer').classList.remove('drawer-closed');
            document.getElementById('task-drawer').classList.add('drawer-open');
        }

        function closeTaskDrawer() {
            document.getElementById('task-drawer').classList.remove('drawer-open');
            document.getElementById('task-drawer').classList.add('drawer-closed');
            currentTaskId = null;
        }

        function saveTask() {
            if (!currentTaskId) return;
            
            const taskIndex = tasks.findIndex(t => t.id === currentTaskId);
            if (taskIndex === -1) return;
            
            const task = tasks[taskIndex];
            
            // Update task
            task.title = document.getElementById('task-title').value;
            task.description = document.getElementById('task-description').value;
            task.due_at = document.getElementById('task-due').value ? new Date(document.getElementById('task-due').value).toISOString() : null;
            task.priority = document.getElementById('task-priority').value;
            task.status = document.getElementById('task-status').value;
            task.category_id = document.getElementById('task-category').value ? parseInt(document.getElementById('task-category').value) : null;
            task.updated_at = new Date().toISOString();
            
            tasks[taskIndex] = task;
            saveData();
            renderTasks();
            closeTaskDrawer();
            
            showNotification('success', 'Tâche sauvegardée', 'Les modifications ont été enregistrées');
        }

        function deleteTask(taskId) {
            if (!taskId) taskId = currentTaskId;
            if (!taskId) return;
            
            if (confirm('Êtes-vous sûr de vouloir supprimer cette tâche ?')) {
                tasks = tasks.filter(t => t.id !== taskId);
                reminders = reminders.filter(r => r.task_id !== taskId);
                saveData();
                renderTasks();
                
                if (taskId === currentTaskId) {
                    closeTaskDrawer();
                }
                
                showNotification('success', 'Tâche supprimée', 'La tâche a été supprimée');
            }
        }

        function duplicateTask(taskId) {
            const task = tasks.find(t => t.id === taskId);
            if (!task) return;
            
            const newTask = {
                ...task,
                id: Date.now(),
                status: 'todo',
                completed_at: null,
                created_at: new Date().toISOString(),
                updated_at: new Date().toISOString()
            };
            
            tasks.push(newTask);
            saveData();
            renderTasks();
            
            showNotification('success', 'Tâche dupliquée', 'La tâche a été dupliquée');
        }

        function addReminder() {
            if (!currentTaskId) return;
            
            // Check if we already have 5 reminders for this task
            const taskReminders = reminders.filter(r => r.task_id === currentTaskId);
            if (taskReminders.length >= 5) {
                showNotification('error', 'Erreur', 'Maximum 5 rappels par tâche');
                return;
            }
            
            // In a real app, we would show a modal to select date/time
            // For demo, we'll just add a reminder for 1 hour before due date
            const task = tasks.find(t => t.id === currentTaskId);
            if (!task.due_at) {
                showNotification('error', 'Erreur', 'Ajoutez d\'abord une date d\'échéance');
                return;
            }
            
            const dueDate = new Date(task.due_at);
            const reminderDate = new Date(dueDate.getTime() - 3600000); // 1 hour before
            
            const newReminder = {
                id: Date.now(),
                task_id: currentTaskId,
                remind_at: reminderDate.toISOString(),
                channel: 'in_app',
                created_at: new Date().toISOString()
            };
            
            reminders.push(newReminder);
            saveData();
            
            // Refresh task drawer
            openTaskDrawer(currentTaskId);
            
            showNotification('success', 'Rappel ajouté', 'Un nouveau rappel a été programmé');
        }

        function removeReminder(reminderId) {
            reminders = reminders.filter(r => r.id !== reminderId);
            saveData();
            
            // Refresh task drawer
            openTaskDrawer(currentTaskId);
        }

        // Category functions
        function renderCategories() {
            // Sidebar categories
            const sidebarCategoryList = document.getElementById('category-list');
            sidebarCategoryList.innerHTML = '';
            
            // Categories view
            const categoriesViewList = document.getElementById('categories-list');
            categoriesViewList.innerHTML = '';
            
            categories.forEach(category => {
                // Count tasks in this category
                const taskCount = tasks.filter(t => t.category_id === category.id && t.status !== 'done' && t.status !== 'archived').length;
                
                // Sidebar item
                const sidebarItem = document.createElement('button');
                sidebarItem.className = 'w-full flex items-center px-3 py-2 text-sm font-medium rounded-md hover:bg-gray-200 dark:hover:bg-gray-700';
                sidebarItem.innerHTML = `
                    <span class="w-3 h-3 rounded-full bg-${category.color}-500 mr-3"></span>
                    <span class="truncate">${category.name}</span>
                    <span class="ml-auto px-2 py-1 text-xs bg-gray-200 dark:bg-gray-700 rounded-full">${taskCount}</span>
                `;
                sidebarItem.onclick = () => filterByCategory(category.id);
                sidebarCategoryList.appendChild(sidebarItem);
                
                // Categories view card
                const categoryCard = document.createElement('div');
                categoryCard.className = 'bg-white dark:bg-gray-800 rounded-lg shadow-sm p-4 border border-gray-200 dark:border-gray-700';
                categoryCard.innerHTML = `
                    <div class="flex items-center mb-3">
                        <span class="w-4 h-4 rounded-full bg-${category.color}-500 mr-3"></span>
                        <h3 class="font-medium flex-1">${category.name}</h3>
                        <div class="flex space-x-2">
                            <button onclick="editCategory(${category.id})" class="p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                                <i class="fas fa-pencil-alt"></i>
                            </button>
                            <button onclick="deleteCategory(${category.id})" class="p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300">
                                <i class="fas fa-trash-alt"></i>
                            </button>
                        </div>
                    </div>
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-500 dark:text-gray-400"><i class="fas fa-${category.icon} mr-1"></i> ${taskCount} tâche(s)</span>
                        <button onclick="filterByCategory(${category.id})" class="text-sm text-blue-600 dark:text-blue-400 hover:underline">
                            Voir les tâches
                        </button>
                    </div>
                `;
                categoriesViewList.appendChild(categoryCard);
            });
        }

        function filterByCategory(categoryId) {
            // Switch to all tasks view
            switchView('all-tasks');
            
            // Set category filter
            document.getElementById('task-filter-status').value = '';
            document.getElementById('task-filter-priority').value = '';
            document.getElementById('task-search').value = '';
            document.getElementById('task-sort').value = 'due_asc';
            
            // Trigger filter
            renderAllTasks();
        }

        function showAddCategoryModal() {
            // In a real app, we would show a modal to add a new category
            // For demo, we'll just add a random category
            const colors = ['work', 'personal', 'property', 'admin'];
            const icons = ['briefcase', 'home', 'building', 'file-alt', 'shopping-cart', 'utensils', 'car', 'heart'];
            
            const newCategory = {
                id: Date.now(),
                name: `Nouvelle catégorie ${categories.length + 1}`,
                color: colors[Math.floor(Math.random() * colors.length)],
                icon: icons[Math.floor(Math.random() * icons.length)],
                created_at: new Date().toISOString()
            };
            
            categories.push(newCategory);
            saveData();
            renderCategories();
            
            showNotification('success', 'Catégorie ajoutée', 'Une nouvelle catégorie a été créée');
        }

        function editCategory(categoryId) {
            // In a real app, we would show a modal to edit the category
            const category = categories.find(c => c.id === categoryId);
            if (!category) return;
            
            // For demo, we'll just add a " (modifié)" to the name
            category.name = `${category.name} (modifié)`;
            saveData();
            renderCategories();
            
            showNotification('success', 'Catégorie modifiée', 'La cat
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=stephaneibens/task-manager" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>