File size: 22,439 Bytes
1e13925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Streakly - Beautiful Habit Tracker</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 900px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            border-radius: 24px;
            padding: 32px;
            box-shadow: 0 32px 64px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 32px;
        }

        .greeting h1 {
            font-size: 28px;
            font-weight: 700;
            color: #1a202c;
            margin-bottom: 4px;
        }

        .greeting p {
            color: #718096;
            font-size: 16px;
        }

        .date-section {
            text-align: right;
        }

        .current-date {
            font-size: 18px;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 4px;
        }

        .progress-text {
            color: #718096;
            font-size: 14px;
        }

        .progress-card {
            background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
            border-radius: 16px;
            padding: 24px;
            margin-bottom: 32px;
            text-align: center;
            border: 1px solid rgba(255, 255, 255, 0.5);
        }

        .progress-title {
            font-size: 20px;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 12px;
        }

        .progress-bar-container {
            background: rgba(255, 255, 255, 0.8);
            height: 12px;
            border-radius: 6px;
            overflow: hidden;
            margin-bottom: 8px;
        }

        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #48bb78, #38a169);
            border-radius: 6px;
            transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 4px rgba(72, 187, 120, 0.3);
        }

        .add-habit-section {
            display: flex;
            gap: 12px;
            margin-bottom: 32px;
        }

        .habit-input {
            flex: 1;
            padding: 16px 20px;
            border: 2px solid #e2e8f0;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.9);
            transition: all 0.3s ease;
            outline: none;
        }

        .habit-input:focus {
            border-color: #4299e1;
            box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
            transform: translateY(-1px);
        }

        .add-btn {
            padding: 16px 24px;
            background: linear-gradient(135deg, #4299e1, #3182ce);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(66, 153, 225, 0.3);
        }

        .add-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(66, 153, 225, 0.4);
        }

        .habits-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 20px;
            margin-bottom: 40px;
        }

        .habit-card {
            background: rgba(255, 255, 255, 0.9);
            border: 2px solid #e2e8f0;
            border-radius: 16px;
            padding: 24px;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: hidden;
        }

        .habit-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, #e2e8f0, #cbd5e0);
            transition: background 0.3s ease;
        }

        .habit-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
            border-color: #4299e1;
        }

        .habit-card.completed {
            background: linear-gradient(135deg, #48bb78, #38a169);
            color: white;
            border-color: #48bb78;
        }

        .habit-card.completed::before {
            background: linear-gradient(90deg, rgba(255,255,255,0.3), rgba(255,255,255,0.1));
        }

        .habit-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }

        .habit-name {
            font-size: 20px;
            font-weight: 600;
        }

        .habit-icon {
            font-size: 24px;
            opacity: 0.8;
        }

        .habit-status {
            font-size: 14px;
            opacity: 0.9;
            font-weight: 500;
        }

        .delete-btn {
            position: absolute;
            top: 12px;
            right: 12px;
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 8px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            transition: all 0.3s ease;
            color: #e53e3e;
            font-size: 16px;
        }

        .habit-card:hover .delete-btn {
            opacity: 1;
        }

        .delete-btn:hover {
            background: rgba(229, 62, 62, 0.1);
            transform: scale(1.1);
        }

        .week-section {
            background: rgba(247, 250, 252, 0.8);
            border-radius: 20px;
            padding: 28px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.3);
        }

        .week-header {
            font-size: 22px;
            font-weight: 700;
            color: #2d3748;
            margin-bottom: 24px;
            text-align: center;
        }

        .week-grid {
            display: grid;
            grid-template-columns: 120px repeat(7, 1fr);
            gap: 12px;
            align-items: center;
        }

        .day-header {
            text-align: center;
            font-size: 14px;
            font-weight: 600;
            color: #718096;
            padding: 12px 4px;
        }

        .habit-label {
            font-size: 16px;
            font-weight: 500;
            color: #4a5568;
            padding: 12px 0;
            border-right: 2px solid #e2e8f0;
            text-align: right;
            padding-right: 16px;
        }

        .day-cell {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 600;
            margin: 0 auto;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            cursor: pointer;
        }

        .day-cell:hover {
            transform: scale(1.1);
        }

        .day-empty {
            background: rgba(226, 232, 240, 0.6);
            color: #a0aec0;
            border: 2px solid transparent;
        }

        .day-completed {
            background: linear-gradient(135deg, #48bb78, #38a169);
            color: white;
            box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
            border: 2px solid transparent;
        }

        .day-today {
            border: 2px solid #4299e1;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% { box-shadow: 0 0 0 0 rgba(66, 153, 225, 0.4); }
            70% { box-shadow: 0 0 0 8px rgba(66, 153, 225, 0); }
            100% { box-shadow: 0 0 0 0 rgba(66, 153, 225, 0); }
        }

        .streak-info {
            text-align: center;
            margin-top: 24px;
            padding: 20px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.3);
        }

        .streak-number {
            font-size: 32px;
            font-weight: 700;
            color: #48bb78;
            margin-bottom: 4px;
        }

        .streak-label {
            color: #718096;
            font-size: 14px;
            font-weight: 500;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #718096;
        }

        .empty-state h3 {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 12px;
            color: #4a5568;
        }

        .floating-add {
            position: fixed;
            bottom: 32px;
            right: 32px;
            width: 64px;
            height: 64px;
            background: linear-gradient(135deg, #4299e1, #3182ce);
            border: none;
            border-radius: 50%;
            color: white;
            font-size: 24px;
            cursor: pointer;
            box-shadow: 0 8px 24px rgba(66, 153, 225, 0.4);
            transition: all 0.3s ease;
            display: none;
        }

        .floating-add:hover {
            transform: scale(1.1);
            box-shadow: 0 12px 32px rgba(66, 153, 225, 0.5);
        }

        @media (max-width: 768px) {
            .container {
                margin: 10px;
                padding: 24px;
            }
            
            .header {
                flex-direction: column;
                gap: 16px;
                text-align: center;
            }
            
            .habits-grid {
                grid-template-columns: 1fr;
            }
            
            .week-grid {
                grid-template-columns: 80px repeat(7, 1fr);
                gap: 8px;
            }
            
            .day-cell {
                width: 32px;
                height: 32px;
                font-size: 12px;
            }
            
            .floating-add {
                display: flex;
                align-items: center;
                justify-content: center;
            }
            
            .add-habit-section {
                display: none;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="greeting">
                <h1>Hey there! πŸ‘‹</h1>
                <p>Keep building those amazing habits</p>
            </div>
            <div class="date-section">
                <div class="current-date" id="currentDate"></div>
                <div class="progress-text" id="progressText">0% of daily goals achieved</div>
            </div>
        </div>

        <div class="progress-card">
            <div class="progress-title" id="progressTitle">Today's Progress: 0/0 habits completed</div>
            <div class="progress-bar-container">
                <div class="progress-bar" id="progressBar" style="width: 0%"></div>
            </div>
        </div>

        <div class="add-habit-section">
            <input type="text" class="habit-input" id="habitInput" placeholder="Add a new habit..." maxlength="50">
            <button class="add-btn" onclick="addHabit()">+ Add Habit</button>
        </div>

        <div class="habits-grid" id="habitsGrid"></div>

        <div class="week-section">
            <div class="week-header" id="weekHeader">This Week</div>
            <div class="week-grid" id="weekGrid"></div>
            <div class="streak-info">
                <div class="streak-number" id="streakNumber">0</div>
                <div class="streak-label">day current streak</div>
            </div>
        </div>
    </div>

    <button class="floating-add" onclick="showAddHabitPrompt()">+</button>

    <script>
        // Sample data - in a real app, this would be stored in localStorage or a database
        let habits = [
            { id: 1, name: 'Exercise', icon: 'πŸ’ͺ' },
            { id: 2, name: 'Read', icon: 'πŸ“š' },
            { id: 3, name: 'Meditate', icon: '🧘' },
            { id: 4, name: 'Drink Water', icon: 'πŸ’§' }
        ];

        let completedHabits = {}; // Format: { 'YYYY-MM-DD': [habitId1, habitId2, ...] }

        // Initialize with some sample data
        const today = new Date();
        const yesterday = new Date(today);
        yesterday.setDate(yesterday.getDate() - 1);
        
        completedHabits[formatDate(today)] = [1, 3]; // Exercise and Meditate completed today
        completedHabits[formatDate(yesterday)] = [1, 2, 4]; // Exercise, Read, Water completed yesterday

        function formatDate(date) {
            return date.toISOString().split('T')[0];
        }

        function formatDateForDisplay(date) {
            return date.toLocaleDateString('en-US', { 
                weekday: 'short', 
                month: 'short', 
                day: 'numeric' 
            });
        }

        function updateHeader() {
            const now = new Date();
            document.getElementById('currentDate').textContent = formatDateForDisplay(now);
            
            const todayCompleted = getTodayCompletedCount();
            const totalHabits = habits.length;
            const percentage = totalHabits > 0 ? Math.round((todayCompleted / totalHabits) * 100) : 0;
            
            document.getElementById('progressText').textContent = `${percentage}% of daily goals achieved`;
            document.getElementById('progressTitle').textContent = `Today's Progress: ${todayCompleted}/${totalHabits} habits completed`;
            document.getElementById('progressBar').style.width = `${percentage}%`;
        }

        function getTodayCompletedCount() {
            const today = formatDate(new Date());
            return completedHabits[today] ? completedHabits[today].length : 0;
        }

        function isHabitCompletedToday(habitId) {
            const today = formatDate(new Date());
            return completedHabits[today] && completedHabits[today].includes(habitId);
        }

        function toggleHabit(habitId) {
            const today = formatDate(new Date());
            
            if (!completedHabits[today]) {
                completedHabits[today] = [];
            }

            const index = completedHabits[today].indexOf(habitId);
            if (index > -1) {
                completedHabits[today].splice(index, 1);
                if (completedHabits[today].length === 0) {
                    delete completedHabits[today];
                }
            } else {
                completedHabits[today].push(habitId);
            }

            renderHabits();
            renderWeekView();
            updateHeader();
            updateStreak();
        }

        function addHabit() {
            const input = document.getElementById('habitInput');
            const habitName = input.value.trim();
            
            if (habitName && habitName.length > 0) {
                const newId = Math.max(...habits.map(h => h.id), 0) + 1;
                const icons = ['🎯', '⭐', 'πŸ”₯', '✨', '🌟', 'πŸ’Ž', '🎊', 'πŸ†', '⚑', '🌈'];
                const randomIcon = icons[Math.floor(Math.random() * icons.length)];
                
                habits.push({
                    id: newId,
                    name: habitName,
                    icon: randomIcon
                });
                
                input.value = '';
                renderHabits();
                updateHeader();
                renderWeekView();
            }
        }

        function deleteHabit(habitId) {
            habits = habits.filter(h => h.id !== habitId);
            
            // Remove from completed habits
            Object.keys(completedHabits).forEach(date => {
                completedHabits[date] = completedHabits[date].filter(id => id !== habitId);
                if (completedHabits[date].length === 0) {
                    delete completedHabits[date];
                }
            });

            renderHabits();
            updateHeader();
            renderWeekView();
        }

        function renderHabits() {
            const grid = document.getElementById('habitsGrid');
            
            if (habits.length === 0) {
                grid.innerHTML = `
                    <div class="empty-state" style="grid-column: 1 / -1;">
                        <h3>No habits yet! 🌱</h3>
                        <p>Add your first habit to start building amazing streaks</p>
                    </div>
                `;
                return;
            }

            grid.innerHTML = habits.map(habit => {
                const isCompleted = isHabitCompletedToday(habit.id);
                return `
                    <div class="habit-card ${isCompleted ? 'completed' : ''}" onclick="toggleHabit(${habit.id})">
                        <button class="delete-btn" onclick="event.stopPropagation(); deleteHabit(${habit.id})" title="Delete habit">Γ—</button>
                        <div class="habit-header">
                            <div class="habit-name">${habit.name}</div>
                            <div class="habit-icon">${habit.icon}</div>
                        </div>
                        <div class="habit-status">${isCompleted ? 'βœ“ Completed today!' : 'Click to mark complete'}</div>
                    </div>
                `;
            }).join('');
        }

        function renderWeekView() {
            const weekGrid = document.getElementById('weekGrid');
            const today = new Date();
            const startOfWeek = new Date(today);
            startOfWeek.setDate(today.getDate() - today.getDay() + 1); // Monday

            const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
            const weekDates = [];
            
            for (let i = 0; i < 7; i++) {
                const date = new Date(startOfWeek);
                date.setDate(startOfWeek.getDate() + i);
                weekDates.push(date);
            }

            // Update week header
            document.getElementById('weekHeader').textContent = 
                `This Week - ${startOfWeek.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })} to ${weekDates[6].toLocaleDateString('en-US', { month: 'short', day: 'numeric' })}`;

            let gridHTML = '<div></div>'; // Empty corner cell
            
            // Day headers
            days.forEach((day, index) => {
                gridHTML += `<div class="day-header">${day}<br><span style="font-size: 12px; opacity: 0.7;">${weekDates[index].getDate()}</span></div>`;
            });

            // Habit rows
            habits.forEach(habit => {
                gridHTML += `<div class="habit-label">${habit.name}</div>`;
                
                weekDates.forEach(date => {
                    const dateStr = formatDate(date);
                    const isCompleted = completedHabits[dateStr] && completedHabits[dateStr].includes(habit.id);
                    const isToday = formatDate(date) === formatDate(today);
                    
                    let classes = 'day-cell ';
                    classes += isCompleted ? 'day-completed' : 'day-empty';
                    classes += isToday ? ' day-today' : '';

                    gridHTML += `<div class="${classes}" onclick="toggleHabitForDate(${habit.id}, '${dateStr}')">${isCompleted ? '●' : 'β—‹'}</div>`;
                });
            });

            weekGrid.innerHTML = gridHTML;
        }

        function toggleHabitForDate(habitId, dateStr) {
            if (!completedHabits[dateStr]) {
                completedHabits[dateStr] = [];
            }

            const index = completedHabits[dateStr].indexOf(habitId);
            if (index > -1) {
                completedHabits[dateStr].splice(index, 1);
                if (completedHabits[dateStr].length === 0) {
                    delete completedHabits[dateStr];
                }
            } else {
                completedHabits[dateStr].push(habitId);
            }

            renderWeekView();
            if (dateStr === formatDate(new Date())) {
                renderHabits();
                updateHeader();
            }
            updateStreak();
        }

        function updateStreak() {
            // Calculate current streak (simplified - just counts consecutive days with any habit completed)
            let streak = 0;
            const today = new Date();
            
            for (let i = 0; i < 30; i++) {
                const date = new Date(today);
                date.setDate(today.getDate() - i);
                const dateStr = formatDate(date);
                
                if (completedHabits[dateStr] && completedHabits[dateStr].length > 0) {
                    streak++;
                } else {
                    break;
                }
            }
            
            document.getElementById('streakNumber').textContent = streak;
        }

        function showAddHabitPrompt() {
            const habitName = prompt('Enter new habit name:');
            if (habitName && habitName.trim()) {
                document.getElementById('habitInput').value = habitName.trim();
                addHabit();
            }
        }

        // Handle Enter key in input
        document.getElementById('habitInput').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                addHabit();
            }
        });

        // Initialize app
        updateHeader();
        renderHabits();
        renderWeekView();
        updateStreak();
    </script>
</body>
</html>