Spaces:
Running

File size: 24,117 Bytes
e323644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>15-Minute Productivity Tracker</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
    
    :root {
      --orange-glow: #ff6b35;
      --orange-dark: #d84315;
      --glass-bg: rgba(255, 255, 255, 0.05);
      --glass-border: rgba(255, 255, 255, 0.1);
    }

    body {
      font-family: 'Inter', sans-serif;
      background: #000;
      min-height: 100vh;
    }

    .glass-effect {
      background: var(--glass-bg);
      backdrop-filter: blur(20px);
      border: 1px solid var(--glass-border);
    }

    .glow-button {
      background: linear-gradient(135deg, var(--orange-glow), var(--orange-dark));
      box-shadow: 0 4px 20px rgba(255, 107, 53, 0.4);
      transition: all 0.3s ease;
    }

    .glow-button:hover {
      box-shadow: 0 6px 30px rgba(255, 107, 53, 0.6);
      transform: translateY(-2px);
    }

    .timer-circle {
      width: 200px;
      height: 200px;
      border-radius: 50%;
      background: conic-gradient(var(--orange-glow) 0deg, var(--orange-glow) var(--progress, 0deg), transparent var(--progress, 0deg));
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
    }

    .timer-circle::before {
      content: '';
      position: absolute;
      inset: 10px;
      background: #000;
      border-radius: 50%;
    }

    .modal-enter {
      animation: modalEnter 0.3s ease-out;
    }

    @keyframes modalEnter {
      from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
      }
      to {
        opacity: 1;
        transform: scale(1) translateY(0);
      }
    }

    .tag-work { background: #10b981; }
    .tag-break { background: #3b82f6; }
    .tag-distraction { background: #ef4444; }
    .tag-exercise { background: #8b5cf6; }
    .tag-other { background: #6b7280; }

    .streak-flame {
      filter: drop-shadow(0 0 10px #ff6b35);
    }

    .fade-in {
      animation: fadeIn 0.5s ease-in;
    }

    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
  </style>
</head>
<body class="text-white">
  <!-- Main App -->
  <div id="app" class="min-h-screen">
    <!-- Navigation -->
    <nav class="glass-effect fixed top-0 w-full z-40 px-4 py-3">
      <div class="max-w-6xl mx-auto flex justify-between items-center">
        <h1 class="text-xl font-bold bg-gradient-to-r from-orange-400 to-orange-600 bg-clip-text text-transparent">
          15-Min Tracker
        </h1>
        <div class="flex gap-4">
          <button onclick="showSection('dashboard')" class="text-gray-300 hover:text-white transition">Dashboard</button>
          <button onclick="showSection('log')" class="text-gray-300 hover:text-white transition">Log</button>
          <button onclick="showSection('analytics')" class="text-gray-300 hover:text-white transition">Analytics</button>
          <button onclick="showSection('settings')" class="text-gray-300 hover:text-white transition">Settings</button>
        </div>
      </div>
    </nav>

    <!-- Dashboard Section -->
    <section id="dashboard-section" class="pt-20 px-4 py-8 max-w-6xl mx-auto">
      <div class="text-center mb-8">
        <h2 class="text-4xl font-bold mb-2">Track Every 15 Minutes</h2>
        <p class="text-gray-400">Own your time, one conscious block at a time</p>
      </div>

      <div class="grid md:grid-cols-2 gap-8">
        <!-- Timer Card -->
        <div class="glass-effect rounded-2xl p-8 text-center">
          <h3 class="text-2xl font-semibold mb-6">Current Timer</h3>
          <div class="flex justify-center mb-6">
            <div class="timer-circle" id="timer-circle">
              <div class="relative z-10">
                <div id="timer-display" class="text-4xl font-bold">15:00</div>
                <div class="text-sm text-gray-400">minutes left</div>
              </div>
            </div>
          </div>
          <div class="flex gap-4 justify-center">
            <button id="pause-btn" onclick="toggleTimer()" class="glow-button px-6 py-2 rounded-lg font-medium">
              Pause
            </button>
            <button onclick="resetTimer()" class="glass-effect px-6 py-2 rounded-lg border border-gray-600 hover:border-gray-400 transition">
              Reset
            </button>
          </div>
        </div>

        <!-- Streak Card -->
        <div class="glass-effect rounded-2xl p-8 text-center">
          <h3 class="text-2xl font-semibold mb-4">Current Streak</h3>
          <div class="flex justify-center items-center gap-4">
            <span id="streak-count" class="text-6xl font-bold text-orange-400">0</span>
            <svg class="w-16 h-16 streak-flame" viewBox="0 0 24 24" fill="currentColor">
              <path d="M12 2c3.2 0 5.8 2.6 5.8 5.8 0 2.4-1.4 4.5-3.5 5.5L12 16l-2.3-2.7c-2.1-1-3.5-3.1-3.5-5.5C6.2 4.6 8.8 2 12 2zm0 18c-4.4 0-8-3.6-8-8 0-3.4 2.1-6.3 5.2-7.5C8.5 5.8 8 7.3 8 8.8 8 12.1 9.9 15 12.5 16L12 16.5V20z"/>
            </svg>
          </div>
          <p class="text-gray-400 mt-4">Days in a row</p>
        </div>
      </div>

      <!-- Quick Stats -->
      <div class="glass-effect rounded-2xl p-6 mt-8">
        <h3 class="text-xl font-semibold mb-4">Today's Summary</h3>
        <div class="grid grid-cols-3 gap-4 text-center">
          <div>
            <div id="today-productive" class="text-3xl font-bold text-green-400">0h 0m</div>
            <div class="text-sm text-gray-400">Productive</div>
          </div>
          <div>
            <div id="today-breaks" class="text-3xl font-bold text-blue-400">0h 0m</div>
            <div class="text-sm text-gray-400">Breaks</div>
          </div>
          <div>
            <div id="today-distractions" class="text-3xl font-bold text-red-400">0h 0m</div>
            <div class="text-sm text-gray-400">Distractions</div>
          </div>
        </div>
      </div>
    </section>

    <!-- Activity Log Section -->
    <section id="log-section" class="hidden pt-20 px-4 py-8 max-w-4xl mx-auto">
      <h2 class="text-3xl font-bold mb-6 text-center">Activity Log</h2>
      
      <!-- Filters -->
      <div class="glass-effect rounded-lg p-4 mb-6">
        <div class="flex gap-4 items-center flex-wrap">
          <label class="text-sm text-gray-400">Filter by tag:</label>
          <button onclick="filterLog('all')" class="tag-filter px-3 py-1 rounded-full text-sm bg-orange-500">All</button>
          <button onclick="filterLog('work')" class="tag-filter px-3 py-1 rounded-full text-sm tag-work">Work</button>
          <button onclick="filterLog('break')" class="tag-filter px-3 py-1 rounded-full text-sm tag-break">Break</button>
          <button onclick="filterLog('distraction')" class="tag-filter px-3 py-1 rounded-full text-sm tag-distraction">Distraction</button>
          <button onclick="filterLog('exercise')" class="tag-filter px-3 py-1 rounded-full text-sm tag-exercise">Exercise</button>
        </div>
      </div>

      <!-- Log Entries -->
      <div id="log-container" class="space-y-4">
        <!-- Entries will be populated here -->
      </div>
    </section>

    <!-- Analytics Section -->
    <section id="analytics-section" class="hidden pt-20 px-4 py-8 max-w-6xl mx-auto">
      <h2 class="text-3xl font-bold mb-6 text-center">Analytics</h2>
      
      <div class="grid md:grid-cols-2 gap-8">
        <!-- Time Distribution Chart -->
        <div class="glass-effect rounded-2xl p-6">
          <h3 class="text-xl font-semibold mb-4">Time Distribution</h3>
          <canvas id="timeChart" width="400" height="300"></canvas>
        </div>

        <!-- Weekly Progress -->
        <div class="glass-effect rounded-2xl p-6">
          <h3 class="text-xl font-semibold mb-4">Weekly Progress</h3>
          <canvas id="weeklyChart" width="400" height="300"></canvas>
        </div>
      </div>

      <!-- Productivity Score -->
      <div class="glass-effect rounded-2xl p-6 mt-8 text-center">
        <h3 class="text-xl font-semibold mb-4">Productivity Score</h3>
        <div class="text-6xl font-bold text-orange-400" id="productivity-score">0%</div>
        <p class="text-gray-400 mt-2">Based on productive vs total time</p>
      </div>
    </section>

    <!-- Settings Section -->
    <section id="settings-section" class="hidden pt-20 px-4 py-8 max-w-2xl mx-auto">
      <h2 class="text-3xl font-bold mb-6 text-center">Settings</h2>
      
      <div class="glass-effect rounded-2xl p-6 space-y-6">
        <!-- Sound Toggle -->
        <div class="flex justify-between items-center">
          <label class="text-lg">Timer Sound</label>
          <label class="relative inline-flex items-center cursor-pointer">
            <input type="checkbox" id="sound-toggle" class="sr-only peer" checked>
            <div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-orange-500"></div>
          </label>
        </div>

        <!-- Theme Toggle -->
        <div class="flex justify-between items-center">
          <label class="text-lg">Dark Mode</label>
          <label class="relative inline-flex items-center cursor-pointer">
            <input type="checkbox" id="theme-toggle" class="sr-only peer" checked>
            <div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-orange-500"></div>
          </label>
        </div>

        <!-- Export Data -->
        <div>
          <h3 class="text-lg mb-4">Export Data</h3>
          <div class="flex gap-4">
            <button onclick="exportData('csv')" class="glow-button px-4 py-2 rounded-lg">Export as CSV</button>
            <button onclick="exportData('json')" class="glass-effect px-4 py-2 rounded-lg">Export as JSON</button>
          </div>
        </div>

        <!-- Clear Data -->
        <div>
          <h3 class="text-lg mb-4 text-red-400">Danger Zone</h3>
          <button onclick="clearAllData()" class="bg-red-600 hover:bg-red-700 px-4 py-2 rounded-lg transition">
            Clear All Data
          </button>
        </div>
      </div>
    </section>

    <!-- Prompt Modal -->
    <div id="prompt-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
      <div class="glass-effect rounded-2xl p-8 max-w-md w-full mx-4 modal-enter">
        <h3 class="text-2xl font-bold mb-4">What did you do in the last 15 minutes?</h3>
        <textarea id="activity-input" maxlength="150" class="w-full h-24 bg-gray-800 border border-gray-600 rounded-lg p-3 resize-none focus:outline-none focus:border-orange-500" placeholder="Describe your activity..."></textarea>
        <div class="mt-4">
          <label class="text-sm text-gray-400">Tag (optional):</label>
          <div class="flex gap-2 mt-2 flex-wrap">
            <button onclick="setTag('work')" class="tag-work px-3 py-1 rounded-full text-sm">Work</button>
            <button onclick="setTag('break')" class="tag-break px-3 py-1 rounded-full text-sm">Break</button>
            <button onclick="setTag('distraction')" class="tag-distraction px-3 py-1 rounded-full text-sm">Distraction</button>
            <button onclick="setTag('exercise')" class="tag-exercise px-3 py-1 rounded-full text-sm">Exercise</button>
          </div>
        </div>
        <div class="flex gap-4 mt-6">
          <button onclick="saveActivity()" class="glow-button flex-1 py-3 rounded-lg font-medium">Save</button>
          <button onclick="skipActivity()" class="glass-effect flex-1 py-3 rounded-lg border border-gray-600">Skip</button>
        </div>
      </div>
    </div>
  </div>

  <script>
    // State management
    let timer = null;
    let timeLeft = 15 * 60; // 15 minutes in seconds
    let isPaused = false;
    let currentTag = 'other';
    let activities = JSON.parse(localStorage.getItem('activities') || '[]');
    let settings = JSON.parse(localStorage.getItem('settings') || '{"sound": true, "theme": "dark"}');

    // Initialize
    document.addEventListener('DOMContentLoaded', () => {
      loadSettings();
      updateStreak();
      updateTodayStats();
      renderLog();
      startTimer();
      updateCharts();
    });

    // Timer functions
    function startTimer() {
      timer = setInterval(() => {
        if (!isPaused) {
          timeLeft--;
          updateTimerDisplay();
          
          if (timeLeft <= 0) {
            clearInterval(timer);
            showPrompt();
          }
        }
      }, 1000);
    }

    function updateTimerDisplay() {
      const minutes = Math.floor(timeLeft / 60);
      const seconds = timeLeft % 60;
      const display = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
      
      document.getElementById('timer-display').textContent = display;
      
      const progress = ((15 * 60 - timeLeft) / (15 * 60)) * 360;
      document.getElementById('timer-circle').style.setProperty('--progress', `${progress}deg`);
    }

    function toggleTimer() {
      isPaused = !isPaused;
      const btn = document.getElementById('pause-btn');
      btn.textContent = isPaused ? 'Resume' : 'Pause';
    }

    function resetTimer() {
      clearInterval(timer);
      timeLeft = 15 * 60;
      updateTimerDisplay();
      startTimer();
    }

    // Modal functions
    function showPrompt() {
      document.getElementById('prompt-modal').classList.remove('hidden');
      document.getElementById('activity-input').focus();
      
      if (settings.sound) {
        playNotification();
      }
    }

    function saveActivity() {
      const description = document.getElementById('activity-input').value.trim();
      if (!description) return;

      const activity = {
        id: Date.now(),
        description,
        tag: currentTag,
        timestamp: new Date().toISOString()
      };

      activities.unshift(activity);
      localStorage.setItem('activities', JSON.stringify(activities));
      
      document.getElementById('activity-input').value = '';
      document.getElementById('prompt-modal').classList.add('hidden');
      
      timeLeft = 15 * 60;
      updateTimerDisplay();
      startTimer();
      
      updateTodayStats();
      renderLog();
      updateCharts();
      checkStreak();
    }

    function skipActivity() {
      document.getElementById('prompt-modal').classList.add('hidden');
      document.getElementById('activity-input').value = '';
      
      timeLeft = 15 * 60;
      updateTimerDisplay();
      startTimer();
    }

    function setTag(tag) {
      currentTag = tag;
      document.querySelectorAll('[onclick^="setTag"]').forEach(btn => {
        btn.style.opacity = '0.5';
      });
      event.target.style.opacity = '1';
    }

    // Analytics
    function updateTodayStats() {
      const today = new Date().toDateString();
      const todayActivities = activities.filter(a => new Date(a.timestamp).toDateString() === today);
      
      const timeByTag = {
        work: 0,
        break: 0,
        distraction: 0,
        exercise: 0,
        other: 0
      };

      todayActivities.forEach(activity => {
        timeByTag[activity.tag] += 15;
      });

      const formatTime = (minutes) => {
        const hours = Math.floor(minutes / 60);
        const mins = minutes % 60;
        return `${hours}h ${mins}m`;
      };

      document.getElementById('today-productive').textContent = formatTime(timeByTag.work + timeByTag.exercise);
      document.getElementById('today-breaks').textContent = formatTime(timeByTag.break);
      document.getElementById('today-distractions').textContent = formatTime(timeByTag.distraction);

      const total = Object.values(timeByTag).reduce((a, b) => a + b, 0);
      const productive = timeByTag.work + timeByTag.exercise;
      const score = total > 0 ? Math.round((productive / total) * 100) : 0;
      document.getElementById('productivity-score').textContent = `${score}%`;
    }

    function updateCharts() {
      const ctx1 = document.getElementById('timeChart');
      if (!ctx1) return;

      const timeByTag = {
        work: 0,
        break: 0,
        distraction: 0,
        exercise: 0,
        other: 0
      };

      const today = new Date().toDateString();
      const todayActivities = activities.filter(a => new Date(a.timestamp).toDateString() === today);
      
      todayActivities.forEach(activity => {
        timeByTag[activity.tag] += 15;
      });

      new Chart(ctx1, {
        type: 'doughnut',
        data: {
          labels: ['Work', 'Break', 'Distraction', 'Exercise', 'Other'],
          datasets: [{
            data: Object.values(timeByTag),
            backgroundColor: ['#10b981', '#3b82f6', '#ef4444', '#8b5cf6', '#6b7280']
          }]
        },
        options: {
          responsive: true,
          plugins: {
            legend: {
              labels: { color: 'white' }
            }
          }
        }
      });

      // Weekly chart
      const ctx2 = document.getElementById('weeklyChart');
      const days = [];
      const productiveTime = [];
      
      for (let i = 6; i >= 0; i--) {
        const date = new Date();
        date.setDate(date.getDate() - i);
        days.push(date.toLocaleDateString('en', { weekday: 'short' }));
        
        const dayActivities = activities.filter(a => new Date(a.timestamp).toDateString() === date.toDateString());
        const productiveMinutes = dayActivities
          .filter(a => a.tag === 'work' || a.tag === 'exercise')
          .length * 15;
        
        productiveTime.push(productiveMinutes);
      }

      new Chart(ctx2, {
        type: 'bar',
        data: {
          labels: days,
          datasets: [{
            label: 'Productive Minutes',
            data: productiveTime,
            backgroundColor: '#ff6b35'
          }]
        },
        options: {
          responsive: true,
          plugins: {
            legend: {
              labels: { color: 'white' }
            }
          },
          scales: {
            y: {
              ticks: { color: 'white' },
              grid: { color: 'rgba(255,255,255,0.1)' }
            },
            x: {
              ticks: { color: 'white' },
              grid: { color: 'rgba(255,255,255,0.1)' }
            }
          }
        }
      });
    }

    // Log rendering
    function renderLog(filter = 'all') {
      const container = document.getElementById('log-container');
      const filteredActivities = filter === 'all' 
        ? activities 
        : activities.filter(a => a.tag === filter);

      container.innerHTML = filteredActivities.map(activity => `
        <div class="glass-effect rounded-lg p-4 fade-in">
          <div class="flex justify-between items-start">
            <div>
              <p class="text-lg">${activity.description}</p>
              <p class="text-sm text-gray-400">${new Date(activity.timestamp).toLocaleString()}</p>
            </div>
            <span class="tag-${activity.tag} px-2 py-1 rounded-full text-xs">${activity.tag}</span>
          </div>
        </div>
      `).join('');
    }

    function filterLog(tag) {
      document.querySelectorAll('.tag-filter').forEach(btn => {
        btn.style.backgroundColor = '';
        btn.style.color = '';
      });
      event.target.style.backgroundColor = '#ff6b35';
      event.target.style.color = 'white';
      
      renderLog(tag);
    }

    // Streak calculation
    function updateStreak() {
      const streak = calculateStreak();
      document.getElementById('streak-count').textContent = streak;
    }

    function calculateStreak() {
      const uniqueDays = new Set(activities.map(a => new Date(a.timestamp).toDateString()));
      const today = new Date().toDateString();
      let streak = 0;
      let currentDate = new Date();

      while (uniqueDays.has(currentDate.toDateString()) || currentDate.toDateString() === today) {
        streak++;
        currentDate.setDate(currentDate.getDate() - 1);
      }

      return streak;
    }

    function checkStreak() {
      const newStreak = calculateStreak();
      const oldStreak = parseInt(localStorage.getItem('streak') || '0');
      
      if (newStreak > oldStreak) {
        localStorage.setItem('streak', newStreak);
        updateStreak();
      }
    }

    // Navigation
    function showSection(section) {
      const sections = ['dashboard-section', 'log-section', 'analytics-section', 'settings-section'];
      sections.forEach(s => document.getElementById(s).classList.add('hidden'));
      document.getElementById(`${section}-section`).classList.remove('hidden');
      
      if (section === 'analytics') {
        setTimeout(updateCharts, 100);
      }
    }

    // Settings
    function loadSettings() {
      document.getElementById('sound-toggle').checked = settings.sound;
      document.getElementById('theme-toggle').checked = settings.theme === 'dark';
    }

    document.getElementById('sound-toggle').addEventListener('change', (e) => {
      settings.sound = e.target.checked;
      localStorage.setItem('settings', JSON.stringify(settings));
    });

    document.getElementById('theme-toggle').addEventListener('change', (e) => {
      settings.theme = e.target.checked ? 'dark' : 'light';
      localStorage.setItem('settings', JSON.stringify(settings));
    });

    // Export functions
    function exportData(format) {
      const data = format === 'csv' 
        ? convertToCSV(activities)
        : JSON.stringify(activities, null, 2);
      
      const blob = new Blob([data], { type: format === 'csv' ? 'text/csv' : 'application/json' });
      const url = URL.createObjectURL(blob);
      const a = document.createElement('a');
      a.href = url;
      a.download = `activities-${new Date().toISOString().split('T')[0]}.${format}`;
      a.click();
    }

    function convertToCSV(data) {
      const headers = ['timestamp', 'description', 'tag'];
      const rows = data.map(row => [row.timestamp, `"${row.description}"`, row.tag]);
      return [headers, ...rows].map(row => row.join(',')).join('\n');
    }

    function clearAllData() {
      if (confirm('Are you sure? This will delete all your data permanently.')) {
        localStorage.removeItem('activities');
        localStorage.removeItem('settings');
        activities = [];
        location.reload();
      }
    }

    // Sound notification
    function playNotification() {
      const audio = new Audio('data:audio/wav;base64,UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqFbF1fdJivrJBhNjVgodDbq2EcBj+a2/LDciUFLIHO8tiJNwgZaLvt559NEAxQp+PwtmMcBjiR1/LMeSwFJHfH8N2QQAoUXrTp66hVFApGn+DyvmwhBSuBzvLZiTYIG2m98OScTgwOUarm7blmFgU7k9n1unEiBC13yO/eizEIHWq+8+OWT');
      audio.play();
    }
  </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=dolorestrd/timely-focus" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>