Spaces:
Running

File size: 37,378 Bytes
4681a40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeonTasks | Futuristic Productivity</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/lucide@latest"></script>
    <script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700&family=Exo+2:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --neon-blue: #08f7fe;
            --neon-pink: #fe53bb;
            --neon-green: #09fbd3;
            --neon-purple: #9467fe;
            --dark-bg: #0f0e17;
            --card-bg: rgba(15, 14, 23, 0.7);
        }
        
        body {
            font-family: 'Exo 2', sans-serif;
            background-color: var(--dark-bg);
            color: white;
            min-height: 100vh;
            overflow-x: hidden;
        }
        
        .font-futuristic {
            font-family: 'Orbitron', sans-serif;
        }
        
        .neon-text-blue {
            text-shadow: 0 0 5px var(--neon-blue), 0 0 10px var(--neon-blue);
            color: var(--neon-blue);
        }
        
        .neon-text-pink {
            text-shadow: 0 0 5px var(--neon-pink), 0 0 10px var(--neon-pink);
            color: var(--neon-pink);
        }
        
        .neon-text-green {
            text-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green);
            color: var(--neon-green);
        }
        
        .neon-border-blue {
            box-shadow: 0 0 10px var(--neon-blue), inset 0 0 10px var(--neon-blue);
            border: 1px solid var(--neon-blue);
        }
        
        .neon-border-pink {
            box-shadow: 0 0 10px var(--neon-pink), inset 0 0 10px var(--neon-pink);
            border: 1px solid var(--neon-pink);
        }
        
        .neon-border-green {
            box-shadow: 0 0 10px var(--neon-green), inset 0 0 10px var(--neon-green);
            border: 1px solid var(--neon-green);
        }
        
        .glass-card {
            background: rgba(15, 14, 23, 0.7);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-radius: 16px;
        }
        
        .glow-hover:hover {
            filter: drop-shadow(0 0 8px currentColor);
        }
        
        .task-completed {
            position: relative;
            opacity: 0.6;
        }
        
        .task-completed::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 2px;
            background: var(--neon-green);
            transform: scaleX(0);
            transform-origin: left;
            animation: strike 0.3s ease-out forwards;
        }
        
        @keyframes strike {
            to { transform: scaleX(1); }
        }
        
        .progress-bar {
            position: relative;
            overflow: hidden;
        }
        
        .progress-bar::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: var(--progress);
            background: linear-gradient(90deg, var(--neon-pink), var(--neon-blue));
            transition: width 0.5s ease;
        }
        
        .streak-fire {
            animation: pulse 1.5s infinite alternate;
        }
        
        @keyframes pulse {
            from { filter: drop-shadow(0 0 5px #ff6b00); }
            to { filter: drop-shadow(0 0 15px #ff9500); }
        }
        
        .confetti {
            position: fixed;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            pointer-events: none;
            z-index: 1000;
        }
        
        .task-enter {
            animation: slideIn 0.3s ease-out forwards;
        }
        
        @keyframes slideIn {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }
        
        .category-tab.active {
            border-bottom: 2px solid var(--neon-blue);
            color: var(--neon-blue);
        }
        
        .timeline-item::before {
            content: "";
            position: absolute;
            left: 20px;
            top: 30px;
            bottom: -30px;
            width: 2px;
            background: rgba(255, 255, 255, 0.2);
        }
        
        .timeline-item:last-child::before {
            display: none;
        }
    </style>
</head>
<body class="min-h-screen flex flex-col">
    <!-- Confetti container (hidden by default) -->
    <div id="confetti" class="confetti hidden"></div>
    
    <!-- Header -->
    <header class="py-4 px-6 flex justify-between items-center border-b border-gray-800">
        <h1 class="text-2xl font-futuristic neon-text-blue">NeonTasks</h1>
        <button id="installBtn" class="flex items-center gap-2 px-4 py-2 rounded-full glass-card neon-border-blue hover:bg-blue-900/20 transition-all group">
            <i data-lucide="download" class="w-5 h-5 glow-hover"></i>
            <span class="hidden md:inline text-sm">Download App</span>
            <div class="absolute top-full mt-2 right-0 bg-gray-800 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity">
                Install for full-screen experience
            </div>
        </button>
    </header>
    
    <!-- Motivational Quote -->
    <div class="px-6 py-3 text-center bg-gray-900/50 border-b border-gray-800">
        <p id="motivationalQuote" class="text-sm italic">"Productivity is never an accident. It is always the result of a commitment to excellence, intelligent planning, and focused effort."</p>
    </div>
    
    <!-- Main Content -->
    <main class="flex-1 container mx-auto px-4 py-6 max-w-3xl">
        <!-- XP Progress Bar -->
        <div class="mb-6">
            <div class="flex justify-between items-center mb-1">
                <span class="text-xs">Level <span id="currentLevel">1</span></span>
                <span class="text-xs"><span id="currentXP">0</span>/<span id="nextLevelXP">100</span> XP</span>
            </div>
            <div class="progress-bar h-2 rounded-full bg-gray-800" style="--progress: 0%"></div>
        </div>
        
        <!-- Streak Info -->
        <div class="flex items-center gap-2 mb-6">
            <div class="flex items-center gap-1 px-3 py-1 rounded-full bg-gray-800/50">
                <i data-lucide="flame" class="w-4 h-4 text-orange-400 streak-fire"></i>
                <span class="text-xs"><span id="streakCount">3</span> day streak</span>
            </div>
            <div class="flex items-center gap-1 px-3 py-1 rounded-full bg-gray-800/50">
                <i data-lucide="trophy" class="w-4 h-4 text-yellow-400"></i>
                <span class="text-xs">Level <span id="displayLevel">1</span></span>
            </div>
        </div>
        
        <!-- Add Task Form -->
        <div class="glass-card p-4 mb-6 neon-border-blue">
            <div class="flex gap-2">
                <input id="taskInput" type="text" placeholder="What needs to be done?" class="flex-1 bg-gray-900/50 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:border-blue-500">
                <button id="addTaskBtn" class="px-4 py-2 rounded-lg bg-blue-600 hover:bg-blue-700 transition-colors flex items-center gap-1">
                    <i data-lucide="plus" class="w-4 h-4"></i>
                    <span>Add</span>
                </button>
            </div>
            <div class="mt-3 grid grid-cols-1 md:grid-cols-3 gap-2">
                <select id="taskCategory" class="bg-gray-900/50 border border-gray-700 rounded-lg px-3 py-1 text-sm focus:outline-none">
                    <option value="general">General</option>
                    <option value="work">Work</option>
                    <option value="personal">Personal</option>
                    <option value="urgent">Urgent</option>
                </select>
                <input id="taskTime" type="time" class="bg-gray-900/50 border border-gray-700 rounded-lg px-3 py-1 text-sm focus:outline-none">
                <button id="showAdvancedBtn" class="text-xs text-gray-400 hover:text-white transition-colors flex items-center gap-1">
                    <i data-lucide="chevron-down" class="w-3 h-3"></i>
                    <span>Advanced</span>
                </button>
            </div>
            <div id="advancedFields" class="mt-3 hidden">
                <textarea id="taskDescription" placeholder="Description (optional)" class="w-full bg-gray-900/50 border border-gray-700 rounded-lg px-3 py-2 text-sm focus:outline-none resize-none" rows="2"></textarea>
            </div>
        </div>
        
        <!-- Category Tabs -->
        <div class="flex border-b border-gray-800 mb-4">
            <button data-category="all" class="category-tab active px-4 py-2 text-sm">All</button>
            <button data-category="work" class="category-tab px-4 py-2 text-sm">Work</button>
            <button data-category="personal" class="category-tab px-4 py-2 text-sm">Personal</button>
            <button data-category="urgent" class="category-tab px-4 py-2 text-sm">Urgent</button>
        </div>
        
        <!-- View Toggle -->
        <div class="flex justify-end mb-4">
            <div class="flex bg-gray-800 rounded-lg p-1">
                <button id="listViewBtn" class="px-3 py-1 rounded-md bg-blue-600 text-white">
                    <i data-lucide="list" class="w-4 h-4"></i>
                </button>
                <button id="timelineViewBtn" class="px-3 py-1 rounded-md text-gray-400 hover:text-white">
                    <i data-lucide="align-justify" class="w-4 h-4"></i>
                </button>
            </div>
        </div>
        
        <!-- Tasks List (Default View) -->
        <div id="tasksList" class="space-y-3">
            <!-- Tasks will be added here dynamically -->
        </div>
        
        <!-- Timeline View (Hidden by default) -->
        <div id="timelineView" class="hidden space-y-6">
            <!-- Timeline items will be added here dynamically -->
        </div>
        
        <!-- Empty State -->
        <div id="emptyState" class="text-center py-12 text-gray-500">
            <i data-lucide="list-checks" class="w-12 h-12 mx-auto mb-4"></i>
            <h3 class="text-lg font-medium">No tasks yet</h3>
            <p class="text-sm">Add your first task to get started</p>
        </div>
    </main>
    
    <!-- Footer -->
    <footer class="py-4 px-6 border-t border-gray-800">
        <div class="flex justify-between items-center">
            <div class="text-sm text-gray-500">
                <span id="taskCount">0</span> tasks remaining
            </div>
            <button id="clearCompletedBtn" class="px-4 py-2 rounded-lg bg-gray-800 hover:bg-gray-700 transition-colors flex items-center gap-1 neon-border-pink">
                <i data-lucide="trash-2" class="w-4 h-4"></i>
                <span>Clear Completed</span>
            </button>
        </div>
    </footer>
    
    <script>
        // Initialize Lucide icons
        lucide.createIcons();
        
        // App state
        let state = {
            tasks: [],
            xp: 0,
            level: 1,
            streak: 0,
            lastCheckinDate: null,
            viewMode: 'list',
            currentCategory: 'all'
        };
        
        // DOM elements
        const elements = {
            taskInput: document.getElementById('taskInput'),
            addTaskBtn: document.getElementById('addTaskBtn'),
            tasksList: document.getElementById('tasksList'),
            timelineView: document.getElementById('timelineView'),
            emptyState: document.getElementById('emptyState'),
            clearCompletedBtn: document.getElementById('clearCompletedBtn'),
            taskCount: document.getElementById('taskCount'),
            currentXP: document.getElementById('currentXP'),
            nextLevelXP: document.getElementById('nextLevelXP'),
            currentLevel: document.getElementById('currentLevel'),
            displayLevel: document.getElementById('displayLevel'),
            streakCount: document.getElementById('streakCount'),
            motivationalQuote: document.getElementById('motivationalQuote'),
            confetti: document.getElementById('confetti'),
            taskCategory: document.getElementById('taskCategory'),
            taskTime: document.getElementById('taskTime'),
            taskDescription: document.getElementById('taskDescription'),
            showAdvancedBtn: document.getElementById('showAdvancedBtn'),
            advancedFields: document.getElementById('advancedFields'),
            listViewBtn: document.getElementById('listViewBtn'),
            timelineViewBtn: document.getElementById('timelineViewBtn'),
            installBtn: document.getElementById('installBtn'),
            categoryTabs: document.querySelectorAll('.category-tab')
        };
        
        // Motivational quotes
        const quotes = [
            "Productivity is never an accident. It is always the result of a commitment to excellence, intelligent planning, and focused effort.",
            "The secret of getting ahead is getting started.",
            "You don't have to be great to start, but you have to start to be great.",
            "The way to get started is to quit talking and begin doing.",
            "Your time is limited, don't waste it living someone else's life.",
            "The future depends on what you do today.",
            "Do the hard jobs first. The easy jobs will take care of themselves.",
            "Success is the sum of small efforts, repeated day in and day out.",
            "The only limit to our realization of tomorrow is our doubts of today.",
            "You are never too old to set another goal or to dream a new dream."
        ];
        
        // Initialize the app
        function init() {
            loadState();
            updateMotivationalQuote();
            renderTasks();
            setupEventListeners();
            checkStreak();
            
            // Check for PWA install prompt
            let deferredPrompt;
            window.addEventListener('beforeinstallprompt', (e) => {
                e.preventDefault();
                deferredPrompt = e;
                elements.installBtn.style.display = 'flex';
            });
            
            elements.installBtn.addEventListener('click', async () => {
                if (deferredPrompt) {
                    deferredPrompt.prompt();
                    const { outcome } = await deferredPrompt.userChoice;
                    if (outcome === 'accepted') {
                        elements.installBtn.style.display = 'none';
                    }
                    deferredPrompt = null;
                }
            });
        }
        
        // Set up event listeners
        function setupEventListeners() {
            elements.addTaskBtn.addEventListener('click', addTask);
            elements.taskInput.addEventListener('keypress', (e) => {
                if (e.key === 'Enter') addTask();
            });
            elements.clearCompletedBtn.addEventListener('click', clearCompletedTasks);
            elements.showAdvancedBtn.addEventListener('click', toggleAdvancedFields);
            elements.listViewBtn.addEventListener('click', () => switchView('list'));
            elements.timelineViewBtn.addEventListener('click', () => switchView('timeline'));
            
            elements.categoryTabs.forEach(tab => {
                tab.addEventListener('click', () => {
                    elements.categoryTabs.forEach(t => t.classList.remove('active'));
                    tab.classList.add('active');
                    state.currentCategory = tab.dataset.category;
                    renderTasks();
                });
            });
        }
        
        // Toggle advanced fields
        function toggleAdvancedFields() {
            elements.advancedFields.classList.toggle('hidden');
            const icon = elements.showAdvancedBtn.querySelector('i');
            if (elements.advancedFields.classList.contains('hidden')) {
                icon.setAttribute('data-lucide', 'chevron-down');
            } else {
                icon.setAttribute('data-lucide', 'chevron-up');
            }
            lucide.createIcons();
        }
        
        // Switch between list and timeline view
        function switchView(view) {
            state.viewMode = view;
            if (view === 'list') {
                elements.tasksList.classList.remove('hidden');
                elements.timelineView.classList.add('hidden');
                elements.listViewBtn.classList.add('bg-blue-600', 'text-white');
                elements.listViewBtn.classList.remove('text-gray-400');
                elements.timelineViewBtn.classList.add('text-gray-400');
                elements.timelineViewBtn.classList.remove('bg-blue-600', 'text-white');
            } else {
                elements.tasksList.classList.add('hidden');
                elements.timelineView.classList.remove('hidden');
                elements.timelineViewBtn.classList.add('bg-blue-600', 'text-white');
                elements.timelineViewBtn.classList.remove('text-gray-400');
                elements.listViewBtn.classList.add('text-gray-400');
                elements.listViewBtn.classList.remove('bg-blue-600', 'text-white');
            }
            renderTasks();
        }
        
        // Add a new task
        function addTask() {
            const title = elements.taskInput.value.trim();
            if (!title) return;
            
            const newTask = {
                id: Date.now().toString(),
                title,
                description: elements.taskDescription.value.trim(),
                category: elements.taskCategory.value,
                time: elements.taskTime.value,
                completed: false,
                createdAt: new Date().toISOString()
            };
            
            state.tasks.unshift(newTask);
            saveState();
            renderTasks();
            
            // Reset form
            elements.taskInput.value = '';
            elements.taskDescription.value = '';
            elements.taskTime.value = '';
            if (!elements.advancedFields.classList.contains('hidden')) {
                toggleAdvancedFields();
            }
            elements.taskInput.focus();
            
            // Animation for new task
            const taskElement = document.getElementById(`task-${newTask.id}`);
            if (taskElement) {
                taskElement.classList.add('task-enter');
            }
        }
        
        // Toggle task completion
        function toggleTaskCompletion(taskId) {
            const task = state.tasks.find(t => t.id === taskId);
            if (!task) return;
            
            task.completed = !task.completed;
            task.updatedAt = new Date().toISOString();
            
            if (task.completed) {
                // Add XP for completing a task
                addXP(10);
                
                // Check for achievement (every 5 completed tasks)
                const completedCount = state.tasks.filter(t => t.completed).length;
                if (completedCount % 5 === 0) {
                    showConfetti();
                }
            } else {
                // Remove XP if unchecking
                addXP(-10);
            }
            
            saveState();
            renderTasks();
        }
        
        // Delete a task
        function deleteTask(taskId) {
            state.tasks = state.tasks.filter(task => task.id !== taskId);
            saveState();
            renderTasks();
        }
        
        // Clear completed tasks
        function clearCompletedTasks() {
            state.tasks = state.tasks.filter(task => !task.completed);
            saveState();
            renderTasks();
            
            // Animation
            elements.clearCompletedBtn.classList.add('animate-pulse');
            setTimeout(() => {
                elements.clearCompletedBtn.classList.remove('animate-pulse');
            }, 1000);
        }
        
        // Add XP and level up
        function addXP(amount) {
            state.xp += amount;
            
            // Calculate XP needed for next level (simple progression)
            const xpNeeded = state.level * 100;
            
            if (state.xp >= xpNeeded) {
                state.level++;
                state.xp = state.xp - xpNeeded;
                elements.displayLevel.textContent = state.level;
                elements.currentLevel.textContent = state.level;
                showConfetti();
            } else if (state.xp < 0) {
                state.xp = 0;
            }
            
            // Update UI
            updateXPDisplay();
            saveState();
        }
        
        // Update XP display
        function updateXPDisplay() {
            elements.currentXP.textContent = state.xp;
            elements.nextLevelXP.textContent = state.level * 100;
            
            // Update progress bar
            const progress = (state.xp / (state.level * 100)) * 100;
            document.querySelector('.progress-bar').style.setProperty('--progress', `${progress}%`);
        }
        
        // Check and update streak
        function checkStreak() {
            const today = new Date().toDateString();
            
            if (!state.lastCheckinDate) {
                // First time using the app
                state.lastCheckinDate = today;
                state.streak = 1;
            } else if (state.lastCheckinDate === today) {
                // Already checked in today
                return;
            } else {
                const lastDate = new Date(state.lastCheckinDate);
                const currentDate = new Date();
                const dayDiff = (currentDate - lastDate) / (1000 * 60 * 60 * 24);
                
                if (dayDiff <= 1) {
                    // Checked in consecutive days
                    state.streak++;
                } else if (dayDiff > 1) {
                    // Broken streak
                    state.streak = 1;
                }
                
                state.lastCheckinDate = today;
            }
            
            elements.streakCount.textContent = state.streak;
            saveState();
        }
        
        // Update motivational quote
        function updateMotivationalQuote() {
            const randomQuote = quotes[Math.floor(Math.random() * quotes.length)];
            elements.motivationalQuote.textContent = randomQuote;
            
            // Change quote every 12 hours
            setTimeout(updateMotivationalQuote, 12 * 60 * 60 * 1000);
        }
        
        // Show confetti animation
        function showConfetti() {
            elements.confetti.classList.remove('hidden');
            
            // Create confetti elements
            for (let i = 0; i < 100; i++) {
                const confetti = document.createElement('div');
                confetti.style.position = 'absolute';
                confetti.style.width = `${Math.random() * 10 + 5}px`;
                confetti.style.height = `${Math.random() * 10 + 5}px`;
                confetti.style.backgroundColor = getRandomColor();
                confetti.style.left = `${Math.random() * 100}%`;
                confetti.style.top = '-10px';
                confetti.style.opacity = '0.8';
                confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
                
                // Animation
                const animation = confetti.animate([
                    { top: '-10px', opacity: 0.8 },
                    { top: '100%', opacity: 0 }
                ], {
                    duration: Math.random() * 3000 + 2000,
                    easing: 'cubic-bezier(0.1, 0.8, 0.9, 1)'
                });
                
                elements.confetti.appendChild(confetti);
                
                // Remove after animation
                animation.onfinish = () => {
                    confetti.remove();
                    if (elements.confetti.children.length === 0) {
                        elements.confetti.classList.add('hidden');
                    }
                };
            }
        }
        
        // Get random neon color
        function getRandomColor() {
            const colors = ['#08f7fe', '#fe53bb', '#09fbd3', '#9467fe', '#f5d300'];
            return colors[Math.floor(Math.random() * colors.length)];
        }
        
        // Render tasks based on current view and category
        function renderTasks() {
            // Filter tasks by category
            let filteredTasks = [...state.tasks];
            if (state.currentCategory !== 'all') {
                filteredTasks = filteredTasks.filter(task => task.category === state.currentCategory);
            }
            
            // Update task count
            const activeTasks = filteredTasks.filter(task => !task.completed).length;
            elements.taskCount.textContent = activeTasks;
            
            // Show empty state if no tasks
            if (filteredTasks.length === 0) {
                elements.emptyState.classList.remove('hidden');
                elements.tasksList.classList.add('hidden');
                elements.timelineView.classList.add('hidden');
                return;
            } else {
                elements.emptyState.classList.add('hidden');
            }
            
            if (state.viewMode === 'list') {
                renderListTasks(filteredTasks);
            } else {
                renderTimelineTasks(filteredTasks);
            }
        }
        
        // Render tasks in list view
        function renderListTasks(tasks) {
            elements.tasksList.innerHTML = '';
            elements.tasksList.classList.remove('hidden');
            
            tasks.forEach(task => {
                const taskElement = document.createElement('div');
                taskElement.id = `task-${task.id}`;
                taskElement.className = `glass-card p-4 flex items-start gap-3 transition-all ${task.completed ? 'task-completed' : ''}`;
                
                // Add category-specific border
                if (task.category === 'work') {
                    taskElement.classList.add('neon-border-blue');
                } else if (task.category === 'personal') {
                    taskElement.classList.add('neon-border-green');
                } else if (task.category === 'urgent') {
                    taskElement.classList.add('neon-border-pink');
                } else {
                    taskElement.classList.add('border-gray-700');
                }
                
                // Checkbox
                const checkbox = document.createElement('div');
                checkbox.className = 'flex items-center mt-1';
                checkbox.innerHTML = `
                    <input type="checkbox" id="check-${task.id}" ${task.completed ? 'checked' : ''} 
                        class="w-5 h-5 rounded bg-gray-800 border-2 border-gray-700 focus:ring-0 focus:ring-offset-0">
                `;
                checkbox.querySelector('input').addEventListener('change', () => toggleTaskCompletion(task.id));
                
                // Task content
                const content = document.createElement('div');
                content.className = 'flex-1';
                
                const title = document.createElement('div');
                title.className = `font-medium ${task.completed ? 'line-through text-gray-400' : ''}`;
                title.textContent = task.title;
                
                const meta = document.createElement('div');
                meta.className = 'flex flex-wrap gap-2 mt-1 text-xs text-gray-400';
                
                if (task.category && task.category !== 'general') {
                    const category = document.createElement('span');
                    category.className = 'px-2 py-0.5 rounded-full bg-gray-800/50';
                    category.textContent = task.category.charAt(0).toUpperCase() + task.category.slice(1);
                    meta.appendChild(category);
                }
                
                if (task.time) {
                    const time = document.createElement('span');
                    time.className = 'flex items-center gap-1';
                    time.innerHTML = `<i data-lucide="clock" class="w-3 h-3"></i> ${task.time}`;
                    meta.appendChild(time);
                }
                
                if (task.description) {
                    const desc = document.createElement('div');
                    desc.className = 'mt-2 text-sm text-gray-300';
                    desc.textContent = task.description;
                    content.appendChild(desc);
                }
                
                content.appendChild(title);
                content.appendChild(meta);
                
                // Delete button
                const deleteBtn = document.createElement('button');
                deleteBtn.className = 'p-1 text-gray-500 hover:text-red-400 transition-colors';
                deleteBtn.innerHTML = '<i data-lucide="trash-2" class="w-4 h-4"></i>';
                deleteBtn.addEventListener('click', (e) => {
                    e.stopPropagation();
                    deleteTask(task.id);
                });
                
                taskElement.appendChild(checkbox);
                taskElement.appendChild(content);
                taskElement.appendChild(deleteBtn);
                
                elements.tasksList.appendChild(taskElement);
            });
            
            // Recreate Lucide icons for new elements
            lucide.createIcons();
        }
        
        // Render tasks in timeline view
        function renderTimelineTasks(tasks) {
            elements.timelineView.innerHTML = '';
            elements.timelineView.classList.remove('hidden');
            
            // Sort tasks by time (if available) or creation date
            const sortedTasks = [...tasks].sort((a, b) => {
                if (a.time && b.time) return a.time.localeCompare(b.time);
                return new Date(a.createdAt) - new Date(b.createdAt);
            });
            
            sortedTasks.forEach(task => {
                const taskElement = document.createElement('div');
                taskElement.className = `timeline-item relative pl-12 ${task.completed ? 'opacity-60' : ''}`;
                
                // Time indicator
                const timeIndicator = document.createElement('div');
                timeIndicator.className = 'absolute left-0 top-0 w-8 h-8 rounded-full flex items-center justify-center bg-gray-800 border-2 border-gray-700';
                
                if (task.time) {
                    timeIndicator.innerHTML = `<span class="text-xs">${task.time.split(':').slice(0, 2).join(':')}</span>`;
                } else {
                    timeIndicator.innerHTML = '<i data-lucide="calendar" class="w-4 h-4"></i>';
                }
                
                // Task card
                const card = document.createElement('div');
                card.className = `glass-card p-4 mb-6 ${task.completed ? 'task-completed' : ''}`;
                
                // Add category-specific border
                if (task.category === 'work') {
                    card.classList.add('neon-border-blue');
                } else if (task.category === 'personal') {
                    card.classList.add('neon-border-green');
                } else if (task.category === 'urgent') {
                    card.classList.add('neon-border-pink');
                } else {
                    card.classList.add('border-gray-700');
                }
                
                // Task title and checkbox
                const header = document.createElement('div');
                header.className = 'flex items-center justify-between';
                
                const title = document.createElement('div');
                title.className = `font-medium ${task.completed ? 'line-through text-gray-400' : ''}`;
                title.textContent = task.title;
                
                const checkbox = document.createElement('div');
                checkbox.className = 'flex items-center';
                checkbox.innerHTML = `
                    <input type="checkbox" id="check-${task.id}" ${task.completed ? 'checked' : ''} 
                        class="w-5 h-5 rounded bg-gray-800 border-2 border-gray-700 focus:ring-0 focus:ring-offset-0">
                `;
                checkbox.querySelector('input').addEventListener('change', () => toggleTaskCompletion(task.id));
                
                header.appendChild(title);
                header.appendChild(checkbox);
                
                // Task description
                const description = document.createElement('div');
                description.className = 'mt-2 text-sm text-gray-300';
                description.textContent = task.description;
                
                // Task meta (category)
                const meta = document.createElement('div');
                meta.className = 'mt-2 flex justify-end';
                
                if (task.category && task.category !== 'general') {
                    const category = document.createElement('span');
                    category.className = 'px-2 py-0.5 rounded-full text-xs bg-gray-800/50';
                    category.textContent = task.category.charAt(0).toUpperCase() + task.category.slice(1);
                    meta.appendChild(category);
                }
                
                card.appendChild(header);
                if (task.description) card.appendChild(description);
                card.appendChild(meta);
                
                taskElement.appendChild(timeIndicator);
                taskElement.appendChild(card);
                
                elements.timelineView.appendChild(taskElement);
            });
            
            // Recreate Lucide icons for new elements
            lucide.createIcons();
        }
        
        // Save state to localStorage
        function saveState() {
            localStorage.setItem('neonTasksState', JSON.stringify(state));
        }
        
        // Load state from localStorage
        function loadState() {
            const savedState = localStorage.getItem('neonTasksState');
            if (savedState) {
                state = JSON.parse(savedState);
                
                // Update UI from loaded state
                elements.currentXP.textContent = state.xp;
                elements.nextLevelXP.textContent = state.level * 100;
                elements.currentLevel.textContent = state.level;
                elements.displayLevel.textContent = state.level;
                elements.streakCount.textContent = state.streak;
                
                updateXPDisplay();
            }
        }
        
        // Clean up old completed tasks at midnight
        function cleanUpCompletedTasks() {
            const now = new Date();
            const midnight = new Date();
            midnight.setHours(24, 0, 0, 0);
            
            // Check if it's midnight
            if (now.getHours() === 0 && now.getMinutes() === 0) {
                state.tasks = state.tasks.filter(task => !task.completed);
                saveState();
                renderTasks();
            }
            
            // Schedule next check in 1 minute
            setTimeout(cleanUpCompletedTasks, 60000);
        }
        
        // Initialize the app when DOM is loaded
        document.addEventListener('DOMContentLoaded', init);
        
        // Start the midnight cleanup check
        setTimeout(cleanUpCompletedTasks, 1000);
    </script>
<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=krish95/simple-todo-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>