Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1505 lines (1409 loc) · 75.3 KB
/
Copy pathindex.html
File metadata and controls
1505 lines (1409 loc) · 75.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Vite HMR (dev only) -->
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta
name="description"
content="A mobile-first, offline-first time tracking application"
/>
<title>Pragmatic Focus - Time Tracker</title>
<!-- Initial theme on <html> BEFORE paint (prevents FOUC and respects saved choice) -->
<script>
(function () {
try {
const saved = localStorage.getItem("theme"); // 'light' | 'dark'
const theme =
saved === "light" || saved === "dark"
? saved
: window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
document.documentElement.classList.toggle("dark", theme === "dark");
} catch (_) {}
})();
</script>
<!-- Hide UI until Alpine initializes -->
<style>
[x-cloak] {
display: none !important;
}
</style>
<!-- Fonts -->
<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=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap"
rel="stylesheet"
/>
<script type="module" crossorigin src="/assets/main-D9O-0MtM.js"></script>
<link rel="stylesheet" crossorigin href="/assets/main-DI0-TDfk.css">
</head>
<body class="bg-gray-50 dark:bg-gray-900 transition-colors duration-200">
<div id="app" x-data="appState" x-init="init" x-cloak class="min-h-screen">
<!-- Top Header -->
<header class="bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 sticky top-0 z-30">
<div class="container py-3 flex items-center justify-between">
<h1 class="text-lg font-semibold text-gray-900 dark:text-white">
<span x-show="currentPage === 'timer'">Timer</span>
<span x-show="currentPage === 'timeline'">Timeline</span>
<span x-show="currentPage === 'insights'">Insights</span>
<span x-show="currentPage === 'settings'">Settings</span>
</h1>
<button
@click="$store.theme.toggle()"
class="btn-icon bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors"
>
<span x-text="$store.theme.theme === 'dark' ? '☀️' : '🌙'"></span>
</button>
</div>
<!-- Inline Notifications -->
<div x-data="notifications" x-init="init">
<template x-for="notification in visibleNotifications" :key="notification.id">
<div
x-show="notification"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 transform -translate-y-2"
x-transition:enter-end="opacity-100 transform translate-y-0"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 transform translate-y-0"
x-transition:leave-end="opacity-0 transform -translate-y-2"
class="mx-4 mb-2 px-3 py-2 rounded border text-xs flex items-center gap-2"
:class="getTypeClasses(notification.type)"
>
<span class="text-current font-medium" x-text="getTypeIcon(notification.type)"></span>
<span class="flex-1" x-text="notification.message"></span>
<button
@click="remove(notification.id)"
class="text-current opacity-50 hover:opacity-100 transition-opacity text-sm leading-none"
>
×
</button>
</div>
</template>
</div>
</header>
<div class="pb-20">
<!-- Timer Page -->
<div x-show="currentPage === 'timer'" class="container py-6">
<!-- Parent timer component -->
<div x-data="timer" @toggle-activity="toggleActivity($event.detail)">
<!-- Page Title and Status -->
<div class="text-center mb-8">
<h2
x-show="!currentActivity"
class="text-2xl font-semibold text-gray-900 dark:text-white mb-4"
>
What are you doing?
</h2>
<h2
x-show="currentActivity"
class="text-2xl font-semibold text-gray-900 dark:text-white mb-2"
x-text="currentActivity?.label"
>
</h2>
<p
x-show="currentActivity"
class="text-gray-600 dark:text-gray-400 text-sm mb-4"
>
Started at <span x-text="formatStartTime()"></span>
</p>
</div>
<!-- Timer Display -->
<div class="text-center mb-8">
<div
class="text-5xl md:text-6xl font-mono font-medium text-gray-900 dark:text-white tracking-tight"
x-text="formatTime(elapsed)"
>
00:00:00
</div>
<!-- Subcategory indicator -->
<p
x-show="currentSubcategory"
class="text-sm text-gray-600 dark:text-gray-400 mt-2"
>
<span x-text="currentSubcategory"></span>
</p>
</div>
<!-- Subcategory Picker Modal -->
<div
x-show="showSubcategoryPicker"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
class="mb-8"
>
<div class="card border-blue-200 dark:border-blue-700">
<div class="text-center mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-2">
Choose subcategory for
<span class="text-blue-600 dark:text-blue-400" x-text="currentActivity?.label"></span>
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400">
Select a specific activity or skip to use general category
</p>
</div>
<div class="grid grid-cols-2 gap-2 mb-4">
<template x-for="sub in currentActivity?.subcategories || []" :key="sub">
<button
@click="selectSubcategory(sub)"
class="p-3 text-sm rounded-lg border transition-colors"
:class="currentSubcategory === sub ?
'ring-1' :
'border-gray-200 dark:border-gray-700'"
:style="currentSubcategory === sub ?
`border-color: ${currentActivity?.color}; ring-color: color-mix(in srgb, ${currentActivity?.color} 30%, transparent); background-color: color-mix(in srgb, ${currentActivity?.color} 8%, transparent)` :
`--hover-border: ${currentActivity?.color}; --hover-bg: color-mix(in srgb, ${currentActivity?.color} 8%, transparent)`"
@mouseenter="$event.target.style.borderColor = currentActivity?.color || '#6b7280'; $event.target.style.backgroundColor = `color-mix(in srgb, ${currentActivity?.color || '#6b7280'} 8%, transparent)`"
@mouseleave="if (currentSubcategory !== sub) { $event.target.style.borderColor = ''; $event.target.style.backgroundColor = '' }"
>
<span x-text="sub" class="capitalize"></span>
</button>
</template>
</div>
<div class="flex gap-2">
<button
@click="resetSubcategory()"
class="btn-secondary flex-1"
>
Reset
</button>
</div>
</div>
</div>
<!-- Activity Bubbles (child component; no $parent) -->
<div
class="grid grid-cols-2 gap-4 mb-8"
x-data="activities(currentActivity?.id)"
>
<template x-for="activity in activities" :key="activity.id">
<div
@click="handleActivityClick(activity)"
@dblclick="handleActivityDoubleClick(activity)"
class="activity-bubble relative group"
:class="activity.id === currentActivity?.id ? 'activity-bubble-active' : 'activity-bubble-inactive'"
:style="`--activity-color: ${activity.color}`"
>
<!-- Color indicator -->
<div
class="absolute top-2 right-2 w-4 h-4 rounded-full transition-opacity opacity-30 group-hover:opacity-70"
:style="`background-color: ${activity.color}`"
></div>
<div class="text-2xl mb-1" x-text="activity.icon"></div>
<div
class="font-medium text-sm text-gray-700 dark:text-gray-300"
x-text="activity.label"
></div>
<div
x-show="todayDurations?.[activity.id] > 0"
class="text-xs text-gray-500 dark:text-gray-400 font-mono mt-1"
x-text="formatDurationFromSeconds(todayDurations?.[activity.id] || 0)"
></div>
</div>
</template>
</div>
<!-- Stop Button -->
<button
x-show="currentActivity"
@click="stopTracking"
class="btn-danger w-full mb-6"
>
Stop Tracking
</button>
<!-- Natural Language Input -->
<div class="card">
<h3
class="text-lg font-medium text-gray-900 dark:text-white mb-4"
>
Quick Add
</h3>
<textarea
id="natural-language-input"
name="naturalLanguageInput"
x-model="naturalInput"
@keydown.enter.meta.prevent="parseNaturalLanguage"
class="input mb-4"
rows="3"
placeholder="e.g. work 9-12, break 30min, meeting till 3pm or: 9-12 work, 30min break, till 3pm meeting or: work 20m, break 10m (stacked from now)"
></textarea>
<button
@click="parseNaturalLanguage"
class="btn-secondary w-full"
>
Add Entries
</button>
</div>
</div>
</div>
<!-- Timeline Page -->
<div x-show="currentPage === 'timeline'" class="container py-6">
<div x-data="timeline">
<!-- Period Selection -->
<div class="card mb-4">
<div class="flex flex-wrap items-center justify-between gap-4">
<div class="flex flex-wrap gap-2">
<button
@click="selectPeriod('today')"
class="btn-secondary text-sm"
:class="{ 'bg-blue-600 text-white': selectedPeriod === 'today' }"
>
Today
</button>
<button
@click="selectPeriod('week')"
class="btn-secondary text-sm"
:class="{ 'bg-blue-600 text-white': selectedPeriod === 'week' }"
>
Week
</button>
<button
@click="selectPeriod('2-weeks')"
class="btn-secondary text-sm"
:class="{ 'bg-blue-600 text-white': selectedPeriod === '2-weeks' }"
>
2 Weeks
</button>
<button
@click="selectPeriod('custom')"
class="btn-secondary text-sm"
:class="{ 'bg-blue-600 text-white': selectedPeriod === 'custom' }"
>
Custom
</button>
</div>
<!-- Custom Date Range -->
<div x-show="selectedPeriod === 'custom'" class="flex items-center gap-2 text-sm">
<input
type="date"
x-model="customStartDate"
class="input py-1 text-sm"
/>
<span class="text-gray-500 dark:text-gray-400">to</span>
<input
type="date"
x-model="customEndDate"
class="input py-1 text-sm"
/>
<button
@click="applyCustomDateRange()"
class="btn-primary text-sm"
>
Apply
</button>
</div>
</div>
<!-- Date Range Display -->
<div class="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700">
<p class="text-sm text-gray-500 dark:text-gray-400" x-text="dateRangeText"></p>
</div>
</div>
<!-- Summary Card -->
<div class="card mb-6">
<h2 class="text-lg font-semibold text-gray-900 dark:text-white mb-3" x-text="periodLabel + ' Summary'"></h2>
<div class="grid grid-cols-2 gap-4 text-sm">
<div>
<span class="text-gray-500 dark:text-gray-400">Total Tracked:</span>
<span class="font-medium text-gray-900 dark:text-white ml-2" x-text="formatDuration(totalTime)"></span>
</div>
<div>
<span class="text-gray-500 dark:text-gray-400">Entries:</span>
<span class="font-medium text-gray-900 dark:text-white ml-2" x-text="entries.length"></span>
</div>
</div>
</div>
<!-- Timeline -->
<div class="card">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">Timeline</h2>
<button
@click="exportTimeline()"
class="btn-secondary text-sm"
:disabled="entries.length === 0"
>
📄 Export
</button>
</div>
<!-- Empty State -->
<template x-if="entries.length === 0">
<div class="text-center py-12 text-gray-500 dark:text-gray-400">
<div class="text-4xl mb-4">📅</div>
<h3 class="text-lg font-medium mb-2">No entries yet</h3>
<p class="text-sm">Start tracking to see your timeline</p>
</div>
</template>
<!-- Timeline Items -->
<div x-show="entries.length > 0" class="space-y-2">
<template x-for="(item, index) in timelineItems" :key="index">
<div class="flex items-stretch">
<!-- Time Label -->
<div class="w-16 text-right pr-4 py-2 text-sm text-gray-500 dark:text-gray-400 font-mono flex-shrink-0" x-text="item.timeLabel"></div>
<!-- Entry or Gap -->
<div class="flex-1 min-w-0">
<!-- Entry -->
<template x-if="item.type === 'entry'">
<div
class="bg-gray-100 dark:bg-gray-700 rounded-lg px-4 py-3 cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors border-l-4"
:style="`border-left-color: ${getActivityColor(item.entry)}`"
@click="editEntry(item.entry)"
>
<div class="flex items-center gap-2 mb-1">
<span class="text-lg" x-text="getActivityIcon(item.entry)"></span>
<span class="font-medium text-gray-900 dark:text-white" x-text="item.entry.description"></span>
</div>
<div class="flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400">
<span x-text="formatTime(item.entry.startTime) + ' - ' + (item.entry.endTime ? formatTime(item.entry.endTime) : 'ongoing')"></span>
<span x-text="formatDuration(item.entry.duration || 0)"></span>
</div>
</div>
</template>
<!-- Gap -->
<template x-if="item.type === 'gap'">
<div
class="bg-gray-50 dark:bg-gray-800 rounded-lg px-4 py-3 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border-l-4 border-dashed border-gray-300 dark:border-gray-600"
@click="openFillGapModal(item)"
>
<div class="flex items-center gap-2 mb-1">
<span class="text-lg">⏳</span>
<span class="font-medium text-gray-500 dark:text-gray-400">Untracked time</span>
</div>
<div class="flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400">
<span x-text="formatTime(item.start) + ' - ' + formatTime(item.end)"></span>
<span x-text="formatDuration(item.duration)"></span>
</div>
</div>
</template>
</div>
</div>
</template>
</div>
</div>
<!-- Fill Gap Modal -->
<div
x-show="showFillGapModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-black bg-opacity-50 flex items-end sm:items-center justify-center z-50 p-4"
@click.self="showFillGapModal = false"
>
<div
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 transform translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 transform translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 transform translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 transform translate-y-4 sm:translate-y-0 sm:scale-95"
class="bg-white dark:bg-gray-800 rounded-t-2xl sm:rounded-2xl w-full sm:max-w-md max-h-screen overflow-y-auto"
>
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">What were you doing?</h2>
<p class="text-sm text-gray-500 dark:text-gray-400 mb-6">
<span x-text="gapStart ? formatTime(gapStart) : ''"></span> -
<span x-text="gapEnd ? formatTime(gapEnd) : ''"></span>
(<span x-text="gapStart && gapEnd ? formatDuration(Math.floor((gapEnd.getTime() - gapStart.getTime()) / 1000)) : ''"></span>)
</p>
<!-- Activity Buttons -->
<div class="grid grid-cols-2 gap-3 mb-6">
<template x-for="activity in ($store.activities?.all || [])" :key="activity.id">
<button
@click="fillGapWithActivity(activity)"
class="flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 rounded-lg border-l-4 transition-colors text-left"
:style="`border-left-color: ${activity.color}`"
>
<span class="text-lg" x-text="activity.icon"></span>
<span class="font-medium text-gray-900 dark:text-white" x-text="activity.label"></span>
</button>
</template>
</div>
<!-- Natural Language Input -->
<div class="mb-6">
<input
type="text"
x-model="gapNaturalInput"
@keydown.enter="fillGapNatural"
class="w-full px-4 py-3 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400"
placeholder="e.g. work, break, personal"
/>
</div>
<button
@click="showFillGapModal = false"
class="w-full py-3 px-4 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors"
>
Cancel
</button>
</div>
</div>
</div>
<!-- Edit Entry Modal -->
<div
x-show="showEditModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="fixed inset-0 bg-black bg-opacity-50 flex items-end sm:items-center justify-center z-50 p-4"
@click.self="showEditModal = false"
>
<div
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 transform translate-y-4 sm:translate-y-0 sm:scale-95"
x-transition:enter-end="opacity-100 transform translate-y-0 sm:scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 transform translate-y-0 sm:scale-100"
x-transition:leave-end="opacity-0 transform translate-y-4 sm:translate-y-0 sm:scale-95"
class="bg-white dark:bg-gray-800 rounded-t-2xl sm:rounded-2xl w-full sm:max-w-md max-h-screen overflow-y-auto"
>
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">Edit Entry</h2>
<div class="mb-4">
<p class="text-sm text-gray-500 dark:text-gray-400 mb-4">
<span x-text="editingEntry?.description"></span>
</p>
<div class="grid grid-cols-2 gap-4 mb-6">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Start Time</label>
<input
type="time"
x-model="editStartTime"
class="w-full px-3 py-2 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-gray-900 dark:text-white"
/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">End Time</label>
<input
type="time"
x-model="editEndTime"
class="w-full px-3 py-2 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-gray-900 dark:text-white"
/>
</div>
</div>
<div class="flex gap-3">
<button
@click="saveEntry"
class="flex-1 py-3 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium"
>
Save Changes
</button>
<button
@click="deleteEntry"
class="py-3 px-4 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors"
>
Delete
</button>
</div>
<button
@click="showEditModal = false"
class="w-full mt-3 py-3 px-4 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors"
>
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Insights Page -->
<div x-show="currentPage === 'insights'" class="container py-6">
<div x-data="insights">
<!-- Time Period Filters -->
<div class="card mb-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">
Time Period
</h3>
<button
@click="exportInsights()"
class="btn-secondary text-sm"
:disabled="!summary || loading"
>
📄 Export Insights
</button>
</div>
<div class="flex flex-wrap gap-2 mb-4">
<button
@click="selectPeriod('today')"
:class="selectedPeriod === 'today' ? 'bg-blue-600 text-white' : 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'"
class="px-3 py-2 rounded-md text-sm font-medium"
>
Today
</button>
<button
@click="selectPeriod('week')"
:class="selectedPeriod === 'week' ? 'bg-blue-600 text-white' : 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'"
class="px-3 py-2 rounded-md text-sm font-medium"
>
This Week
</button>
<button
@click="selectPeriod('month')"
:class="selectedPeriod === 'month' ? 'bg-blue-600 text-white' : 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'"
class="px-3 py-2 rounded-md text-sm font-medium"
>
This Month
</button>
<button
@click="selectPeriod('custom')"
:class="selectedPeriod === 'custom' ? 'bg-blue-600 text-white' : 'bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300'"
class="px-3 py-2 rounded-md text-sm font-medium"
>
Custom
</button>
</div>
<!-- Custom Date Range -->
<div x-show="selectedPeriod === 'custom'" class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
Start Date
</label>
<input
type="date"
x-model="customStartDate"
class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
End Date
</label>
<input
type="date"
x-model="customEndDate"
@change="applyCustomDateRange()"
class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
</div>
</div>
<!-- Loading State -->
<div x-show="loading" class="card mb-6">
<div class="text-center py-8">
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4"></div>
<p class="text-gray-600 dark:text-gray-400">Loading insights...</p>
</div>
</div>
<!-- Summary Cards -->
<template x-if="summary && !loading">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<!-- Total Tracked -->
<div class="card">
<div class="text-center">
<div class="text-2xl font-bold text-blue-600 dark:text-blue-400" x-text="formatDuration(summary.totalTracked)"></div>
<div class="text-sm text-gray-600 dark:text-gray-400">Total Tracked</div>
</div>
</div>
<!-- Daily Average -->
<div class="card">
<div class="text-center">
<div class="text-2xl font-bold text-green-600 dark:text-green-400" x-text="formatDuration(summary.avgDailyTracking)"></div>
<div class="text-sm text-gray-600 dark:text-gray-400">Daily Average</div>
</div>
</div>
<!-- Current Streak -->
<div class="card">
<div class="text-center">
<div class="text-2xl font-bold text-orange-600 dark:text-orange-400" x-text="summary.currentStreak + ' days'"></div>
<div class="text-sm text-gray-600 dark:text-gray-400">Current Streak</div>
</div>
</div>
<!-- Active Days -->
<div class="card">
<div class="text-center">
<div class="text-2xl font-bold text-purple-600 dark:text-purple-400" x-text="summary.totalDays"></div>
<div class="text-sm text-gray-600 dark:text-gray-400">Active Days</div>
</div>
</div>
</div>
</template>
<!-- Activity Breakdown -->
<template x-if="activityStats.length > 0 && !loading">
<div class="card mb-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">
Activity Breakdown
</h3>
<div class="text-sm text-gray-600 dark:text-gray-400">
<span x-text="activityStats.length"></span> activities
</div>
</div>
<div class="space-y-4">
<template x-for="activity in activityStats.slice(0, 8)" :key="activity.id">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full flex items-center justify-center text-sm"
:style="`background-color: ${activity.color}20; color: ${activity.color}`">
<span x-text="activity.icon"></span>
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between mb-1">
<span class="text-sm font-medium text-gray-900 dark:text-white" x-text="activity.label"></span>
<span class="text-sm text-gray-600 dark:text-gray-400" x-text="formatDuration(activity.totalSeconds)"></span>
</div>
<div class="flex items-center gap-2">
<div class="flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-2">
<div class="h-2 rounded-full transition-all"
:style="`background-color: ${activity.color}; width: ${activity.percentage}%`"></div>
</div>
<span class="text-xs text-gray-500 dark:text-gray-400" x-text="formatPercentage(activity.percentage)"></span>
</div>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
<span x-text="activity.entryCount"></span> sessions •
avg <span x-text="formatDuration(activity.avgSessionDuration)"></span>
</div>
</div>
</div>
</template>
</div>
</div>
</template>
<!-- Daily Patterns -->
<template x-if="dailyStats.length > 0 && !loading">
<div class="card mb-6">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Daily Patterns
</h3>
<div class="space-y-2">
<template x-for="day in dailyStats.slice(-7)" :key="day.date">
<div class="flex items-center gap-3">
<div class="w-20 text-sm text-gray-600 dark:text-gray-400" x-text="formatDate(day.date)"></div>
<div class="flex-1">
<div class="flex items-center justify-between mb-1">
<span class="text-sm font-medium text-gray-900 dark:text-white" x-text="formatDuration(day.totalSeconds)"></span>
<span class="text-xs text-gray-500 dark:text-gray-400" x-text="day.entryCount + ' sessions'"></span>
</div>
<div class="bg-gray-200 dark:bg-gray-700 rounded-full h-2">
<div class="h-2 bg-blue-500 rounded-full transition-all"
:style="`width: ${day.productivity * 100}%`"></div>
</div>
</div>
</div>
</template>
</div>
</div>
</template>
<!-- Hourly Heatmap -->
<template x-if="hourlyStats.length > 0 && !loading">
<div class="card mb-6">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Time of Day Pattern
</h3>
<div class="grid grid-cols-12 gap-1">
<template x-for="hourStat in hourlyStats" :key="hourStat.hour">
<div class="text-center">
<div class="text-xs text-gray-500 dark:text-gray-400 mb-1" x-show="hourStat.hour % 2 === 0">
<span x-text="hourStat.hour.toString().padStart(2, '0')"></span>
</div>
<div class="w-full h-8 rounded-sm border border-gray-200 dark:border-gray-600 flex items-center justify-center relative group"
:class="hourStat.totalSeconds > 0 ? 'cursor-pointer' : ''"
:style="hourStat.totalSeconds > 0 ? `background-color: rgb(59, 130, 246, ${Math.min(hourStat.totalSeconds / Math.max(...hourlyStats.map(h => h.totalSeconds), 1), 1)})` : ''">
<!-- Tooltip -->
<div class="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900 text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10"
x-show="hourStat.totalSeconds > 0">
<span x-text="hourStat.hour.toString().padStart(2, '0') + ':00 - ' + formatDuration(hourStat.totalSeconds)"></span>
</div>
</div>
</div>
</template>
</div>
<div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mt-2">
<span>Less active</span>
<span>More active</span>
</div>
</div>
</template>
<!-- Key Insights -->
<template x-if="insights.length > 0 && !loading">
<div class="card mb-6">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Key Insights
</h3>
<div class="space-y-3">
<template x-for="insight in insights" :key="insight">
<div class="flex items-start gap-3 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg">
<div class="text-blue-600 dark:text-blue-400 text-sm" x-text="insight"></div>
</div>
</template>
</div>
</div>
</template>
<!-- Empty State -->
<template x-if="!loading && !summary">
<div class="card text-center py-12">
<div class="text-6xl mb-4">📊</div>
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-2">
No Data Available
</h3>
<p class="text-gray-600 dark:text-gray-400 mb-6">
Start tracking your activities to see detailed insights and patterns.
</p>
<button
@click="$store.app.navigateTo('timer')"
class="btn-primary"
>
Start Tracking
</button>
</div>
</template>
</div>
</div>
<!-- Settings Page -->
<div x-show="currentPage === 'settings'" class="container py-6">
<div x-data="settings">
<div class="space-y-6">
<!-- Duration Threshold -->
<div class="card">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Duration Threshold
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
Entries shorter than this will be automatically discarded
</p>
<div class="flex items-center gap-4">
<select
x-model.number="durationThreshold"
class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
>
<template x-for="option in thresholdOptions" :key="option.value">
<option :value="option.value" x-text="option.label"></option>
</template>
</select>
<span class="text-sm font-medium text-gray-900 dark:text-white min-w-[60px]" x-text="getThresholdLabel()"></span>
</div>
</div>
<!-- Time Rounding/Snap -->
<div class="card">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Time Rounding/Snap
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
Snap timer start/end times to specific intervals for cleaner time tracking
</p>
<div class="flex items-center gap-4">
<select
x-model="timeRounding"
class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"
>
<template x-for="(option, index) in timeRoundingOptions" :key="'time-' + index">
<option :value="option.value" x-text="option.label"></option>
</template>
</select>
<span class="text-sm font-medium text-gray-900 dark:text-white min-w-[120px]" x-text="getTimeRoundingLabel()"></span>
</div>
</div>
<!-- Activity Categories -->
<div class="card">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-white">
Activity Categories
</h3>
<button
@click="showAdvanced = !showAdvanced"
class="text-sm text-blue-600 dark:text-blue-400 hover:underline"
>
<span x-show="!showAdvanced">Advanced</span>
<span x-show="showAdvanced">Simple</span>
</button>
</div>
<!-- Simple Mode: Presets -->
<div x-show="!showAdvanced" class="space-y-4">
<p class="text-sm text-gray-600 dark:text-gray-400">
Choose a preset to get started quickly
</p>
<div class="grid grid-cols-1 gap-3">
<template x-for="preset in presets" :key="preset.name">
<button
@click="applyPreset(preset)"
class="text-left p-4 rounded-lg border transition-colors"
:class="currentPreset === preset.name ?
'border-blue-400 ring-1 ring-blue-300/50 hover:bg-blue-50 dark:hover:bg-blue-900/20' :
'border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800'"
>
<div class="font-medium text-gray-900 dark:text-white" x-text="preset.name"></div>
<div class="text-sm text-gray-600 dark:text-gray-400" x-text="preset.description"></div>
<div class="flex gap-2 mt-2">
<template x-for="category in preset.categories" :key="category.id">
<span class="text-lg" x-text="category.icon"></span>
</template>
</div>
</button>
</template>
</div>
</div>
<!-- Advanced Mode: Custom Categories -->
<div x-show="showAdvanced" class="space-y-4">
<!-- Column Headers -->
<div class="grid grid-cols-12 gap-3 items-center text-xs font-medium text-gray-500 dark:text-gray-400 mb-2">
<div class="col-span-2 text-center">Icon</div>
<div class="col-span-4">Name</div>
<div class="col-span-2 text-center">Color</div>
<div class="col-span-2 text-center">Max (h)</div>
<div class="col-span-2 text-center">Subcategories</div>
<div class="col-span-1"></div>
</div>
<template x-for="(category, index) in categories" :key="category.id">
<div class="p-4 rounded-lg border border-gray-200 dark:border-gray-700">
<div class="grid grid-cols-12 gap-3 items-center">
<input
type="text"
x-model="category.icon"
placeholder="🔧"
class="col-span-2 input text-center"
maxlength="2"
/>
<input
type="text"
x-model="category.label"
placeholder="Category name"
class="col-span-4 input"
/>
<input
type="color"
x-model="category.color"
class="col-span-2 h-10 w-full rounded border border-gray-300 dark:border-gray-700"
/>
<div class="col-span-2">
<select
x-model="category.maxDuration"
class="w-full px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white"
>
<template x-for="(option, index) in maxDurationOptions" :key="'max-' + index">
<option :value="option.value" x-text="option.label"></option>
</template>
</select>
</div>
<button
@click="toggleSubcategories(category.id)"
class="col-span-2 btn-secondary text-xs"
>
<span x-show="!category.showSub">+ Subcategories</span>
<span x-show="category.showSub">- Hide</span>
</button>
<button
@click="removeCategory(index)"
class="col-span-1 text-red-600 hover:text-red-700"
>
×
</button>
</div>
<!-- Subcategories -->
<div x-show="category.showSub" class="mt-4 pl-4 border-l-2 border-gray-200 dark:border-gray-700">
<div class="mb-3">
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Subcategories (comma-separated)
</label>
<textarea
x-model="category.subcategoriesText"
@input="updateSubcategories(category)"
placeholder="lunch, coffee break, rest, reading"
class="input"
rows="2"
></textarea>
</div>
<div x-show="category.subcategories.length > 0" class="flex flex-wrap gap-1">
<template x-for="sub in category.subcategories" :key="sub">
<span class="px-2 py-1 bg-gray-100 dark:bg-gray-700 text-xs rounded" x-text="sub"></span>
</template>
</div>
</div>
</div>
</template>
<button
@click="addCategory()"
class="w-full py-3 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:border-gray-400 dark:hover:border-gray-500 transition-colors"
>
+ Add Category
</button>
</div>
</div>
<!-- Data Export -->
<div class="card">
<h3 class="text-lg font-medium text-gray-900 dark:text-white mb-4">
Export Data
</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
Export your time tracking data for backup or analysis
</p>