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
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Serene Tasks | Modern To-Do List</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
    <style>
        @keyframes strike {
            0% { width: 0; }
            100% { width: 100%; }
        }
        .strike-animation::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            width: 0;
            height: 1px;
            background: #666;
            animation: strike 0.3s ease-out forwards;
        }
        .fade-in {
            animation: fadeIn 0.3s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .progress-bar {
            transition: width 0.6s ease;
        }
        .calendar-day {
            width: 30px;
            height: 30px;
        }
        .calendar-day.has-tasks::after {
            content: "";
            position: absolute;
            bottom: 2px;
            left: 50%;
            transform: translateX(-50%);
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: #8B5CF6;
        }
    </style>
</head>
<body class="bg-[#FAFAFA] min-h-screen font-['Poppins'] text-[#1E1E1E]">
    <div class="container mx-auto px-4 py-8 max-w-3xl">
        <!-- Header -->
        <header class="flex justify-between items-center mb-8">
            <h1 class="text-3xl font-semibold text-[#1E1E1E]">Serene Tasks</h1>
            <button id="installBtn" class="hidden bg-[#E3DFF0] hover:bg-[#D4D0E8] text-[#5E4B9E] px-4 py-2 rounded-2xl text-sm transition-colors duration-200 flex items-center">
                <span class="mr-2">📥</span> Install App
            </button>
        </header>

        <!-- Progress Bar -->
        <div class="mb-6">
            <div class="flex justify-between text-sm text-[#666] mb-1">
                <span id="progressText">0 tasks completed</span>
                <span id="totalTasks">0 tasks</span>
            </div>
            <div class="w-full bg-gray-200 rounded-full h-1.5">
                <div id="progressBar" class="progress-bar h-1.5 rounded-full bg-[#8B5CF6]" style="width: 0%"></div>
            </div>
        </div>

        <!-- Task Input -->
        <div class="bg-white rounded-2xl shadow-sm p-4 mb-6 border border-[#EAEAEA]">
            <div class="flex mb-2">
                <input id="taskInput" type="text" placeholder="What needs to be done?" class="flex-grow px-4 py-2 border border-[#EAEAEA] rounded-2xl focus:outline-none focus:ring-1 focus:ring-[#D4E4ED]">
                <button id="addTaskBtn" class="ml-2 bg-[#D4E4ED] hover:bg-[#C5D9E6] text-[#1E1E1E] px-4 py-2 rounded-2xl transition-colors duration-200">Add</button>
            </div>
            <div id="extraFields" class="hidden mt-3">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-3">
                    <input id="taskDesc" type="text" placeholder="Description (optional)" class="px-4 py-2 border border-[#EAEAEA] rounded-2xl focus:outline-none focus:ring-1 focus:ring-[#D4E4ED]">
                    <input id="taskDue" type="datetime-local" class="px-4 py-2 border border-[#EAEAEA] rounded-2xl focus:outline-none focus:ring-1 focus:ring-[#D4E4ED]">
                </div>
                <div class="mt-3 flex flex-wrap gap-2">
                    <span class="text-sm text-[#666] mr-2">Tags:</span>
                    <button data-tag="work" class="tag-btn px-3 py-1 text-xs rounded-full bg-[#D4E4ED] border border-[#D4E4ED] hover:border-[#A3C4D9]">Work</button>
                    <button data-tag="personal" class="tag-btn px-3 py-1 text-xs rounded-full bg-[#F4E1E6] border border-[#F4E1E6] hover:border-[#E8C6CD]">Personal</button>
                    <button data-tag="urgent" class="tag-btn px-3 py-1 text-xs rounded-full bg-[#CFE3DC] border border-[#CFE3DC] hover:border-[#B2D3C9]">Urgent</button>
                </div>
            </div>
            <button id="toggleExtraBtn" class="mt-2 text-sm text-[#666] hover:text-[#1E1E1E] transition-colors duration-200">+ More options</button>
        </div>

        <!-- Filters -->
        <div class="flex overflow-x-auto pb-2 mb-4 scrollbar-hide">
            <button data-filter="all" class="filter-btn active-filter px-4 py-2 mr-2 text-sm rounded-2xl border border-[#EAEAEA] bg-white">All</button>
            <button data-filter="pending" class="filter-btn px-4 py-2 mr-2 text-sm rounded-2xl border border-[#EAEAEA] bg-white">Pending</button>
            <button data-filter="completed" class="filter-btn px-4 py-2 mr-2 text-sm rounded-2xl border border-[#EAEAEA] bg-white">Completed</button>
            <button data-filter="work" class="filter-btn px-4 py-2 mr-2 text-sm rounded-2xl border border-[#D4E4ED] bg-white">Work</button>
            <button data-filter="personal" class="filter-btn px-4 py-2 mr-2 text-sm rounded-2xl border border-[#F4E1E6] bg-white">Personal</button>
            <button data-filter="urgent" class="filter-btn px-4 py-2 text-sm rounded-2xl border border-[#CFE3DC] bg-white">Urgent</button>
        </div>

        <!-- Task List -->
        <div id="taskList" class="space-y-3 mb-6">
            <!-- Tasks will be added here dynamically -->
        </div>

        <!-- Calendar Button -->
        <div class="flex justify-center mb-6">
            <button id="calendarBtn" class="flex items-center text-[#666] hover:text-[#1E1E1E] transition-colors duration-200">
                <span class="mr-2">📅</span> View Week
            </button>
        </div>

        <!-- Clear Completed -->
        <div class="flex justify-center">
            <button id="clearCompletedBtn" class="px-4 py-2 text-sm rounded-2xl border border-[#EAEAEA] bg-white hover:bg-[#FAFAFA] transition-colors duration-200">Clear Completed Tasks</button>
        </div>

        <!-- Calendar Modal -->
        <div id="calendarModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
            <div class="bg-white rounded-2xl p-6 w-full max-w-sm">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-medium">This Week</h3>
                    <button id="closeCalendarBtn" class="text-[#666] hover:text-[#1E1E1E]">✕</button>
                </div>
                <div id="calendarWeek" class="grid grid-cols-7 gap-1 text-center">
                    <!-- Calendar days will be added here dynamically -->
                </div>
            </div>
        </div>
    </div>

    <script>
        // DOM Elements
        const taskInput = document.getElementById('taskInput');
        const addTaskBtn = document.getElementById('addTaskBtn');
        const taskList = document.getElementById('taskList');
        const clearCompletedBtn = document.getElementById('clearCompletedBtn');
        const toggleExtraBtn = document.getElementById('toggleExtraBtn');
        const extraFields = document.getElementById('extraFields');
        const taskDesc = document.getElementById('taskDesc');
        const taskDue = document.getElementById('taskDue');
        const filterBtns = document.querySelectorAll('.filter-btn');
        const tagBtns = document.querySelectorAll('.tag-btn');
        const progressBar = document.getElementById('progressBar');
        const progressText = document.getElementById('progressText');
        const totalTasks = document.getElementById('totalTasks');
        const calendarBtn = document.getElementById('calendarBtn');
        const calendarModal = document.getElementById('calendarModal');
        const closeCalendarBtn = document.getElementById('closeCalendarBtn');
        const calendarWeek = document.getElementById('calendarWeek');
        const installBtn = document.getElementById('installBtn');

        // State
        let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
        let currentFilter = 'all';
        let selectedTag = null;
        let deferredPrompt;

        // Initialize
        document.addEventListener('DOMContentLoaded', () => {
            renderTasks();
            updateProgress();
            setupCalendar();
            checkMidnight();
            
            // Set up PWA installation prompt
            window.addEventListener('beforeinstallprompt', (e) => {
                e.preventDefault();
                deferredPrompt = e;
                installBtn.classList.remove('hidden');
            });
        });

        // Event Listeners
        addTaskBtn.addEventListener('click', addTask);
        taskInput.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') addTask();
        });
        clearCompletedBtn.addEventListener('click', clearCompletedTasks);
        toggleExtraBtn.addEventListener('click', toggleExtraFields);
        filterBtns.forEach(btn => btn.addEventListener('click', applyFilter));
        tagBtns.forEach(btn => btn.addEventListener('click', selectTag));
        calendarBtn.addEventListener('click', () => calendarModal.classList.remove('hidden'));
        closeCalendarBtn.addEventListener('click', () => calendarModal.classList.add('hidden'));
        installBtn.addEventListener('click', installPWA);

        // Functions
        function addTask() {
            const title = taskInput.value.trim();
            if (!title) return;

            const description = taskDesc.value.trim();
            const dueDate = taskDue.value;
            const tag = selectedTag;

            const newTask = {
                id: Date.now(),
                title,
                description,
                dueDate,
                tag,
                completed: false,
                createdAt: new Date().toISOString()
            };

            tasks.push(newTask);
            saveTasks();
            renderTasks();
            updateProgress();
            
            // Reset form
            taskInput.value = '';
            taskDesc.value = '';
            taskDue.value = '';
            selectedTag = null;
            tagBtns.forEach(btn => btn.classList.remove('border-[#1E1E1E]'));
            extraFields.classList.add('hidden');
            toggleExtraBtn.textContent = '+ More options';
        }

        function renderTasks() {
            taskList.innerHTML = '';
            
            let filteredTasks = [...tasks];
            
            // Apply filter
            if (currentFilter === 'pending') {
                filteredTasks = filteredTasks.filter(task => !task.completed);
            } else if (currentFilter === 'completed') {
                filteredTasks = filteredTasks.filter(task => task.completed);
            } else if (['work', 'personal', 'urgent'].includes(currentFilter)) {
                filteredTasks = filteredTasks.filter(task => task.tag === currentFilter);
            }
            
            if (filteredTasks.length === 0) {
                taskList.innerHTML = '<p class="text-center text-[#666] py-4">No tasks found</p>';
                return;
            }
            
            filteredTasks.forEach(task => {
                const taskElement = document.createElement('div');
                taskElement.className = `bg-white rounded-2xl shadow-sm p-4 border border-[#EAEAEA] fade-in ${task.completed ? 'opacity-80' : ''}`;
                taskElement.dataset.id = task.id;
                
                // Tag color mapping
                const tagColors = {
                    work: ['bg-[#D4E4ED]', 'text-[#1E1E1E]'],
                    personal: ['bg-[#F4E1E6]', 'text-[#1E1E1E]'],
                    urgent: ['bg-[#CFE3DC]', 'text-[#1E1E1E]']
                };
                
                const tagClass = task.tag ? tagColors[task.tag][0] : 'hidden';
                const tagTextClass = task.tag ? tagColors[task.tag][1] : 'hidden';
                
                taskElement.innerHTML = `
                    <div class="flex items-start">
                        <button class="complete-btn mr-3 mt-1 flex-shrink-0 w-5 h-5 rounded-full border border-[#EAEAEA] flex items-center justify-center ${task.completed ? 'bg-[#8B5CF6] border-[#8B5CF6]' : ''}">
                            ${task.completed ? '✓' : ''}
                        </button>
                        <div class="flex-grow">
                            <div class="flex items-center">
                                <h3 class="${task.completed ? 'strike-animation relative' : ''}">${task.title}</h3>
                                ${task.tag ? `<span class="text-xs px-2 py-1 rounded-full ml-2 ${tagClass} ${tagTextClass}">${task.tag.charAt(0).toUpperCase() + task.tag.slice(1)}</span>` : ''}
                            </div>
                            ${task.description ? `<p class="text-sm text-[#666] mt-1">${task.description}</p>` : ''}
                            ${task.dueDate ? `<p class="text-xs text-[#666] mt-1">⏰ ${formatDueDate(task.dueDate)}</p>` : ''}
                        </div>
                        <button class="delete-btn ml-2 text-[#666] hover:text-[#1E1E1E] transition-colors duration-200">🗑</button>
                    </div>
                `;
                
                taskList.appendChild(taskElement);
            });
            
            // Add event listeners to new elements
            document.querySelectorAll('.complete-btn').forEach(btn => {
                btn.addEventListener('click', toggleTaskComplete);
            });
            
            document.querySelectorAll('.delete-btn').forEach(btn => {
                btn.addEventListener('click', deleteTask);
            });
        }

        function toggleTaskComplete(e) {
            const taskId = parseInt(e.target.closest('[data-id]').dataset.id);
            const taskIndex = tasks.findIndex(task => task.id === taskId);
            
            if (taskIndex !== -1) {
                tasks[taskIndex].completed = !tasks[taskIndex].completed;
                saveTasks();
                renderTasks();
                updateProgress();
            }
        }

        function deleteTask(e) {
            const taskId = parseInt(e.target.closest('[data-id]').dataset.id);
            tasks = tasks.filter(task => task.id !== taskId);
            saveTasks();
            renderTasks();
            updateProgress();
        }

        function clearCompletedTasks() {
            tasks = tasks.filter(task => !task.completed);
            saveTasks();
            renderTasks();
            updateProgress();
        }

        function saveTasks() {
            localStorage.setItem('tasks', JSON.stringify(tasks));
        }

        function toggleExtraFields() {
            if (extraFields.classList.contains('hidden')) {
                extraFields.classList.remove('hidden');
                toggleExtraBtn.textContent = '- Fewer options';
            } else {
                extraFields.classList.add('hidden');
                toggleExtraBtn.textContent = '+ More options';
            }
        }

        function applyFilter(e) {
            currentFilter = e.target.dataset.filter;
            
            // Update active filter button
            filterBtns.forEach(btn => {
                btn.classList.remove('active-filter', 'border-[#8B5CF6]', 'text-[#8B5CF6]');
            });
            e.target.classList.add('active-filter');
            
            // Add color to the active filter
            if (currentFilter === 'work') {
                e.target.classList.add('border-[#D4E4ED]', 'text-[#5E7A8C]');
            } else if (currentFilter === 'personal') {
                e.target.classList.add('border-[#F4E1E6]', 'text-[#9E6D7B]');
            } else if (currentFilter === 'urgent') {
                e.target.classList.add('border-[#CFE3DC]', 'text-[#5E8C7D]');
            } else {
                e.target.classList.add('border-[#8B5CF6]', 'text-[#8B5CF6]');
            }
            
            renderTasks();
        }

        function selectTag(e) {
            selectedTag = e.target.dataset.tag;
            tagBtns.forEach(btn => btn.classList.remove('border-[#1E1E1E]'));
            e.target.classList.add('border-[#1E1E1E]');
        }

        function updateProgress() {
            const total = tasks.length;
            const completed = tasks.filter(task => task.completed).length;
            const percentage = total > 0 ? Math.round((completed / total) * 100) : 0;
            
            progressBar.style.width = `${percentage}%`;
            progressText.textContent = `${completed} ${completed === 1 ? 'task' : 'tasks'} completed`;
            totalTasks.textContent = `${total} ${total === 1 ? 'task' : 'tasks'}`;
        }

        function formatDueDate(dateString) {
            const date = new Date(dateString);
            return date.toLocaleString([], {
                month: 'short',
                day: 'numeric',
                hour: '2-digit',
                minute: '2-digit'
            });
        }

        function setupCalendar() {
            calendarWeek.innerHTML = '';
            const today = new Date();
            const currentDay = today.getDay(); // 0 (Sunday) to 6 (Saturday)
            
            // Start from Sunday
            const startDate = new Date(today);
            startDate.setDate(today.getDate() - currentDay);
            
            for (let i = 0; i < 7; i++) {
                const dayDate = new Date(startDate);
                dayDate.setDate(startDate.getDate() + i);
                
                const dayElement = document.createElement('div');
                dayElement.className = 'calendar-day relative flex flex-col items-center';
                
                const dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][i];
                const dayNum = dayDate.getDate();
                
                // Check if there are tasks for this day
                const hasTasks = tasks.some(task => {
                    if (task.completed) return false;
                    const taskDate = new Date(task.dueDate || task.createdAt);
                    return taskDate.toDateString() === dayDate.toDateString();
                });
                
                dayElement.innerHTML = `
                    <span class="text-xs text-[#666]">${dayName}</span>
                    <span class="${dayDate.toDateString() === today.toDateString() ? 'bg-[#8B5CF6] text-white rounded-full w-6 h-6 flex items-center justify-center' : ''}">${dayNum}</span>
                `;
                
                if (hasTasks) {
                    dayElement.classList.add('has-tasks');
                }
                
                calendarWeek.appendChild(dayElement);
            }
        }

        function checkMidnight() {
            const now = new Date();
            const midnight = new Date();
            midnight.setHours(24, 0, 0, 0);
            
            const timeUntilMidnight = midnight - now;
            
            setTimeout(() => {
                // Remove completed tasks
                tasks = tasks.filter(task => !task.completed);
                saveTasks();
                renderTasks();
                updateProgress();
                
                // Check again in 24 hours
                checkMidnight();
            }, timeUntilMidnight);
        }

        function installPWA() {
            if (deferredPrompt) {
                deferredPrompt.prompt();
                deferredPrompt.userChoice.then((choiceResult) => {
                    if (choiceResult.outcome === 'accepted') {
                        console.log('User accepted the install prompt');
                    } else {
                        console.log('User dismissed the install prompt');
                    }
                    deferredPrompt = null;
                });
            }
        }
    </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/silktasks" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>