File size: 40,598 Bytes
fd27334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ZA License Scanner</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .scanner-overlay {
            position: relative;
            width: 100%;
            height: 60vh;
            overflow: hidden;
            border-radius: 20px;
        }
        .scanner-overlay::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            border: 2px dashed rgba(255, 255, 255, 0.5);
            border-radius: 20px;
            z-index: 1;
        }
        .scanning-animation {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 10px;
            background: linear-gradient(to right, rgba(59, 130, 246, 0), rgba(59, 130, 246, 0.8), rgba(59, 130, 246, 0));
            animation: scan 2s linear infinite;
            z-index: 2;
        }
        @keyframes scan {
            0% { top: 0; }
            100% { top: 100%; }
        }
        .result-card {
            transition: all 0.3s ease;
            transform: translateY(20px);
            opacity: 0;
        }
        .result-card.show {
            transform: translateY(0);
            opacity: 1;
        }
        .tab-indicator {
            transition: all 0.3s ease;
        }
        .page {
            display: none;
        }
        .page.active {
            display: block;
        }
    </style>
</head>
<body class="bg-gray-100 font-sans">
    <div class="max-w-md mx-auto bg-white min-h-screen shadow-lg overflow-hidden">
        <!-- Header -->
        <div class="bg-blue-600 text-white p-4 flex justify-between items-center">
            <div>
                <h1 class="text-xl font-bold">ZA License Scanner</h1>
                <p class="text-xs opacity-80">Official South African License Verification</p>
            </div>
            <div class="flex space-x-2">
                <button id="history-btn" class="p-2 rounded-full bg-blue-500">
                    <i class="fas fa-history"></i>
                </button>
                <button id="settings-btn" class="p-2 rounded-full bg-blue-500">
                    <i class="fas fa-cog"></i>
                </button>
            </div>
        </div>

        <!-- Tabs -->
        <div class="flex border-b border-gray-200 relative">
            <button id="vehicle-tab" class="flex-1 py-3 font-medium text-blue-600 tab-button active">
                Vehicle Disk
            </button>
            <button id="driver-tab" class="flex-1 py-3 font-medium text-gray-500 tab-button">
                Driver License
            </button>
            <div class="tab-indicator absolute bottom-0 left-0 h-1 bg-blue-600 w-1/2"></div>
        </div>

        <!-- Main Pages -->
        <div id="scanner-page" class="page active p-4">
            <!-- Scanner View -->
            <div id="scanner-view" class="mb-6">
                <div class="scanner-overlay bg-gray-800 mb-4">
                    <div class="scanning-animation hidden" id="scan-line"></div>
                    <div class="absolute inset-0 flex items-center justify-center">
                        <div class="text-center text-white">
                            <i class="fas fa-camera text-4xl mb-2"></i>
                            <p id="scan-instruction">Align vehicle license disk within frame</p>
                        </div>
                    </div>
                </div>
                
                <button id="scan-button" class="w-full bg-blue-600 text-white py-3 rounded-full font-bold flex items-center justify-center">
                    <i class="fas fa-camera mr-2"></i> SCAN NOW
                </button>
                
                <div class="mt-4 text-center text-sm text-gray-500">
                    <p>Ensure good lighting and hold steady for accurate scanning</p>
                </div>
            </div>

            <!-- Manual Entry Option -->
            <div class="mt-6 border-t border-gray-200 pt-4">
                <button class="text-blue-600 font-medium flex items-center justify-center w-full">
                    <i class="fas fa-keyboard mr-2"></i> Enter Details Manually
                </button>
            </div>

            <!-- Results Section (Initially Hidden) -->
            <div id="results-section" class="hidden mt-6">
                <div class="bg-white rounded-lg shadow-md p-4 mb-4 result-card">
                    <div class="flex justify-between items-center mb-3">
                        <h3 class="font-bold text-lg" id="result-title">Vehicle Details</h3>
                        <span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full">Verified</span>
                    </div>
                    
                    <div id="vehicle-result" class="space-y-3">
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Registration:</span>
                            <span class="font-medium" id="reg-number">CA 123-456</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Make/Model:</span>
                            <span class="font-medium" id="vehicle-make">Toyota Hilux</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Year:</span>
                            <span class="font-medium" id="vehicle-year">2020</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">License Expiry:</span>
                            <span class="font-medium text-red-600" id="license-expiry">31 Dec 2023</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Owner:</span>
                            <span class="font-medium" id="vehicle-owner">John Doe</span>
                        </div>
                    </div>
                    
                    <div id="driver-result" class="space-y-3 hidden">
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Full Name:</span>
                            <span class="font-medium" id="driver-name">Sarah Johnson</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">ID Number:</span>
                            <span class="font-medium" id="driver-id">9001011234088</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">License Code:</span>
                            <span class="font-medium" id="license-code">B</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Expiry Date:</span>
                            <span class="font-medium text-green-600" id="license-expiry">31 Dec 2028</span>
                        </div>
                        <div class="flex justify-between border-b border-gray-100 pb-2">
                            <span class="text-gray-500">Issued:</span>
                            <span class="font-medium" id="license-issued">Gauteng</span>
                        </div>
                    </div>
                    
                    <div class="mt-4 flex space-x-2">
                        <button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="share-btn">
                            <i class="fas fa-share-alt mr-1"></i> Share
                        </button>
                        <button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="print-btn">
                            <i class="fas fa-print mr-1"></i> Print
                        </button>
                        <button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="save-btn">
                            <i class="fas fa-save mr-1"></i> Save
                        </button>
                    </div>
                </div>
                
                <div class="bg-white rounded-lg shadow-md p-4 result-card">
                    <h3 class="font-bold text-lg mb-3">Additional Information</h3>
                    <div class="text-sm text-gray-600">
                        <p id="additional-info">This vehicle is registered in Gauteng province. No outstanding fines detected.</p>
                        <p id="driver-additional" class="hidden">This driver license is valid. Professional driving permit (PDP) not required.</p>
                    </div>
                    <button class="mt-3 w-full bg-gray-100 text-gray-800 py-2 rounded-full font-medium">
                        <i class="fas fa-search mr-1"></i> Check for Fines
                    </button>
                </div>
            </div>
        </div>

        <!-- History Page -->
        <div id="history-page" class="page p-4">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-bold">Scan History</h2>
                <button class="text-blue-600" id="clear-history">Clear All</button>
            </div>
            
            <div id="history-list" class="space-y-3">
                <!-- History items will be added here dynamically -->
            </div>
            
            <div id="empty-history" class="text-center py-10">
                <i class="fas fa-history text-4xl text-gray-300 mb-3"></i>
                <p class="text-gray-500">No scan history yet</p>
            </div>
        </div>

        <!-- Saved Page -->
        <div id="saved-page" class="page p-4">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-bold">Saved Scans</h2>
                <button class="text-blue-600" id="clear-saved">Clear All</button>
            </div>
            
            <div id="saved-list" class="space-y-3">
                <!-- Saved items will be added here dynamically -->
            </div>
            
            <div id="empty-saved" class="text-center py-10">
                <i class="fas fa-bookmark text-4xl text-gray-300 mb-3"></i>
                <p class="text-gray-500">No saved scans yet</p>
            </div>
        </div>

        <!-- Account Page -->
        <div id="account-page" class="page p-4">
            <div class="flex flex-col items-center mb-6">
                <div class="w-20 h-20 rounded-full bg-blue-100 flex items-center justify-center mb-3">
                    <i class="fas fa-user text-3xl text-blue-600"></i>
                </div>
                <h2 class="text-xl font-bold" id="account-name">Guest User</h2>
                <p class="text-gray-500 text-sm" id="account-email">guest@example.com</p>
            </div>
            
            <div class="bg-white rounded-lg shadow-md p-4 mb-4">
                <h3 class="font-bold mb-3">Account Settings</h3>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm text-gray-500 mb-1">Name</label>
                        <input type="text" id="name-input" class="w-full p-2 border border-gray-300 rounded" value="Guest User">
                    </div>
                    <div>
                        <label class="block text-sm text-gray-500 mb-1">Email</label>
                        <input type="email" id="email-input" class="w-full p-2 border border-gray-300 rounded" value="guest@example.com">
                    </div>
                    <div>
                        <label class="block text-sm text-gray-500 mb-1">Password</label>
                        <input type="password" id="password-input" class="w-full p-2 border border-gray-300 rounded" placeholder="••••••••">
                    </div>
                </div>
                <button id="save-account" class="w-full bg-blue-600 text-white py-2 rounded-full font-medium mt-4">
                    Save Changes
                </button>
            </div>
            
            <div class="bg-white rounded-lg shadow-md p-4">
                <h3 class="font-bold mb-3">App Settings</h3>
                <div class="flex justify-between items-center py-2 border-b border-gray-100">
                    <span>Dark Mode</span>
                    <label class="relative inline-flex items-center cursor-pointer">
                        <input type="checkbox" id="dark-mode-toggle" class="sr-only peer">
                        <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 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:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
                    </label>
                </div>
                <div class="flex justify-between items-center py-2 border-b border-gray-100">
                    <span>Scan Sound</span>
                    <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-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 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:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
                    </label>
                </div>
                <div class="flex justify-between items-center py-2">
                    <span>Auto-save scans</span>
                    <label class="relative inline-flex items-center cursor-pointer">
                        <input type="checkbox" id="autosave-toggle" class="sr-only peer" checked>
                        <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 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:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
                    </label>
                </div>
            </div>
            
            <button id="logout-btn" class="w-full bg-red-100 text-red-600 py-2 rounded-full font-medium mt-6">
                <i class="fas fa-sign-out-alt mr-1"></i> Logout
            </button>
        </div>

        <!-- Bottom Navigation -->
        <div class="fixed bottom-0 left-0 right-0 max-w-md mx-auto bg-white border-t border-gray-200 flex justify-around py-2">
            <button class="p-3 text-blue-600 nav-btn" data-page="scanner-page">
                <i class="fas fa-home text-xl"></i>
            </button>
            <button class="p-3 text-gray-500 nav-btn" data-page="history-page">
                <i class="fas fa-history text-xl"></i>
            </button>
            <button class="p-3 text-gray-500 nav-btn" data-page="saved-page">
                <i class="fas fa-bookmark text-xl"></i>
            </button>
            <button class="p-3 text-gray-500 nav-btn" data-page="account-page">
                <i class="fas fa-user text-xl"></i>
            </button>
        </div>
    </div>

    <script>
        // Data storage
        let scanHistory = JSON.parse(localStorage.getItem('scanHistory')) || [];
        let savedScans = JSON.parse(localStorage.getItem('savedScans')) || [];
        let accountData = JSON.parse(localStorage.getItem('accountData')) || {
            name: "Guest User",
            email: "guest@example.com",
            password: ""
        };
        let settings = JSON.parse(localStorage.getItem('settings')) || {
            darkMode: false,
            scanSound: true,
            autoSave: true
        };

        // DOM Elements
        const vehicleTab = document.getElementById('vehicle-tab');
        const driverTab = document.getElementById('driver-tab');
        const tabIndicator = document.querySelector('.tab-indicator');
        const scanInstruction = document.getElementById('scan-instruction');
        const resultTitle = document.getElementById('result-title');
        const vehicleResult = document.getElementById('vehicle-result');
        const driverResult = document.getElementById('driver-result');
        const additionalInfo = document.getElementById('additional-info');
        const driverAdditional = document.getElementById('driver-additional');
        const scanButton = document.getElementById('scan-button');
        const scanLine = document.getElementById('scan-line');
        const scannerView = document.getElementById('scanner-view');
        const resultsSection = document.getElementById('results-section');
        const historyBtn = document.getElementById('history-btn');
        const settingsBtn = document.getElementById('settings-btn');
        const shareBtn = document.getElementById('share-btn');
        const printBtn = document.getElementById('print-btn');
        const saveBtn = document.getElementById('save-btn');
        const historyPage = document.getElementById('history-page');
        const savedPage = document.getElementById('saved-page');
        const accountPage = document.getElementById('account-page');
        const scannerPage = document.getElementById('scanner-page');
        const historyList = document.getElementById('history-list');
        const savedList = document.getElementById('saved-list');
        const emptyHistory = document.getElementById('empty-history');
        const emptySaved = document.getElementById('empty-saved');
        const clearHistory = document.getElementById('clear-history');
        const clearSaved = document.getElementById('clear-saved');
        const accountName = document.getElementById('account-name');
        const accountEmail = document.getElementById('account-email');
        const nameInput = document.getElementById('name-input');
        const emailInput = document.getElementById('email-input');
        const passwordInput = document.getElementById('password-input');
        const saveAccount = document.getElementById('save-account');
        const darkModeToggle = document.getElementById('dark-mode-toggle');
        const soundToggle = document.getElementById('sound-toggle');
        const autosaveToggle = document.getElementById('autosave-toggle');
        const logoutBtn = document.getElementById('logout-btn');
        const navBtns = document.querySelectorAll('.nav-btn');
        const pages = document.querySelectorAll('.page');

        // Sample data for demonstration
        const sampleVehicleData = {
            type: 'vehicle',
            regNumber: 'CA 123-456',
            make: 'Toyota Hilux',
            year: '2020',
            expiry: '31 Dec 2023',
            owner: 'John Doe',
            info: 'This vehicle is registered in Gauteng province. No outstanding fines detected.',
            timestamp: new Date().toISOString()
        };
        
        const sampleDriverData = {
            type: 'driver',
            name: 'Sarah Johnson',
            id: '9001011234088',
            code: 'B',
            expiry: '31 Dec 2028',
            issued: 'Gauteng',
            info: 'This driver license is valid. Professional driving permit (PDP) not required.',
            timestamp: new Date().toISOString()
        };

        // Initialize the app
        function initApp() {
            // Apply settings
            darkModeToggle.checked = settings.darkMode;
            soundToggle.checked = settings.scanSound;
            autosaveToggle.checked = settings.autoSave;
            
            if (settings.darkMode) {
                document.body.classList.add('bg-gray-900');
                document.body.classList.remove('bg-gray-100');
            }
            
            // Load account data
            accountName.textContent = accountData.name;
            accountEmail.textContent = accountData.email;
            nameInput.value = accountData.name;
            emailInput.value = accountData.email;
            
            // Load history and saved scans
            renderHistory();
            renderSavedScans();
        }

        // Tab switching functionality
        vehicleTab.addEventListener('click', () => {
            vehicleTab.classList.remove('text-gray-500');
            vehicleTab.classList.add('text-blue-600');
            driverTab.classList.remove('text-blue-600');
            driverTab.classList.add('text-gray-500');
            tabIndicator.style.transform = 'translateX(0)';
            scanInstruction.textContent = 'Align vehicle license disk within frame';
        });
        
        driverTab.addEventListener('click', () => {
            driverTab.classList.remove('text-gray-500');
            driverTab.classList.add('text-blue-600');
            vehicleTab.classList.remove('text-blue-600');
            vehicleTab.classList.add('text-gray-500');
            tabIndicator.style.transform = 'translateX(100%)';
            scanInstruction.textContent = 'Align driver license within frame';
        });

        // Scan button functionality
        scanButton.addEventListener('click', () => {
            // Show scanning animation
            scanButton.disabled = true;
            scanButton.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> SCANNING...';
            scanLine.classList.remove('hidden');
            
            // Play scan sound if enabled
            if (settings.scanSound) {
                const audio = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-scanning-sci-fi-905.mp3');
                audio.volume = 0.3;
                audio.play();
            }
            
            // Simulate scanning process
            setTimeout(() => {
                scanLine.classList.add('hidden');
                scanButton.disabled = false;
                scanButton.innerHTML = '<i class="fas fa-camera mr-2"></i> SCAN AGAIN';
                
                // Show results
                scannerView.classList.add('hidden');
                resultsSection.classList.remove('hidden');
                
                // Determine which data to use based on selected tab
                const isVehicle = vehicleTab.classList.contains('text-blue-600');
                const scanData = isVehicle ? sampleVehicleData : sampleDriverData;
                
                // Add to history
                scanHistory.unshift(scanData);
                if (scanHistory.length > 50) scanHistory.pop(); // Limit history
                localStorage.setItem('scanHistory', JSON.stringify(scanHistory));
                renderHistory();
                
                // Auto-save if enabled
                if (settings.autoSave) {
                    savedScans.unshift(scanData);
                    if (savedScans.length > 100) savedScans.pop(); // Limit saved
                    localStorage.setItem('savedScans', JSON.stringify(savedScans));
                    renderSavedScans();
                }
                
                // Populate with appropriate data
                if (isVehicle) {
                    // Vehicle results
                    resultTitle.textContent = 'Vehicle Details';
                    document.getElementById('reg-number').textContent = scanData.regNumber;
                    document.getElementById('vehicle-make').textContent = scanData.make;
                    document.getElementById('vehicle-year').textContent = scanData.year;
                    document.getElementById('license-expiry').textContent = scanData.expiry;
                    document.getElementById('vehicle-owner').textContent = scanData.owner;
                    additionalInfo.textContent = scanData.info;
                    vehicleResult.classList.remove('hidden');
                    driverResult.classList.add('hidden');
                    additionalInfo.classList.remove('hidden');
                    driverAdditional.classList.add('hidden');
                } else {
                    // Driver results
                    resultTitle.textContent = 'Driver License Details';
                    document.getElementById('driver-name').textContent = scanData.name;
                    document.getElementById('driver-id').textContent = scanData.id;
                    document.getElementById('license-code').textContent = scanData.code;
                    document.getElementById('license-expiry').textContent = scanData.expiry;
                    document.getElementById('license-issued').textContent = scanData.issued;
                    driverAdditional.textContent = scanData.info;
                    vehicleResult.classList.add('hidden');
                    driverResult.classList.remove('hidden');
                    additionalInfo.classList.add('hidden');
                    driverAdditional.classList.remove('hidden');
                }
                
                // Animate results in
                const resultCards = document.querySelectorAll('.result-card');
                resultCards.forEach((card, index) => {
                    setTimeout(() => {
                        card.classList.add('show');
                    }, index * 100);
                });
            }, 2000);
        });

        // Save button functionality
        saveBtn.addEventListener('click', () => {
            const isVehicle = vehicleTab.classList.contains('text-blue-600');
            const scanData = isVehicle ? sampleVehicleData : sampleDriverData;
            
            // Check if already saved
            const isAlreadySaved = savedScans.some(item => 
                item.type === scanData.type && 
                (item.regNumber === scanData.regNumber || item.id === scanData.id)
            );
            
            if (isAlreadySaved) {
                alert('This scan is already saved.');
                return;
            }
            
            savedScans.unshift(scanData);
            localStorage.setItem('savedScans', JSON.stringify(savedScans));
            renderSavedScans();
            
            // Show confirmation
            const originalText = saveBtn.innerHTML;
            saveBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Saved';
            setTimeout(() => {
                saveBtn.innerHTML = originalText;
            }, 2000);
        });

        // Share button functionality
        shareBtn.addEventListener('click', () => {
            const isVehicle = vehicleTab.classList.contains('text-blue-600');
            const data = isVehicle ? 
                `Vehicle Details:\nRegistration: ${sampleVehicleData.regNumber}\nMake/Model: ${sampleVehicleData.make}\nYear: ${sampleVehicleData.year}\nExpiry: ${sampleVehicleData.expiry}\nOwner: ${sampleVehicleData.owner}` :
                `Driver License Details:\nName: ${sampleDriverData.name}\nID: ${sampleDriverData.id}\nLicense Code: ${sampleDriverData.code}\nExpiry: ${sampleDriverData.expiry}\nIssued: ${sampleDriverData.issued}`;
            
            if (navigator.share) {
                navigator.share({
                    title: 'ZA License Scan Results',
                    text: data,
                }).catch(err => {
                    console.log('Error sharing:', err);
                    copyToClipboard(data);
                });
            } else {
                copyToClipboard(data);
            }
        });

        // Print button functionality
        printBtn.addEventListener('click', () => {
            window.print();
        });

        // Copy to clipboard helper
        function copyToClipboard(text) {
            const textarea = document.createElement('textarea');
            textarea.value = text;
            document.body.appendChild(textarea);
            textarea.select();
            document.execCommand('copy');
            document.body.removeChild(textarea);
            alert('Scan results copied to clipboard!');
        }

        // Render history list
        function renderHistory() {
            historyList.innerHTML = '';
            
            if (scanHistory.length === 0) {
                emptyHistory.classList.remove('hidden');
                return;
            }
            
            emptyHistory.classList.add('hidden');
            
            scanHistory.forEach((item, index) => {
                const historyItem = document.createElement('div');
                historyItem.className = 'bg-white rounded-lg shadow p-3 flex justify-between items-center';
                
                if (item.type === 'vehicle') {
                    historyItem.innerHTML = `
                        <div>
                            <div class="font-medium">${item.regNumber}</div>
                            <div class="text-sm text-gray-500">${item.make} • ${new Date(item.timestamp).toLocaleString()}</div>
                        </div>
                        <button class="text-blue-600 save-history-item" data-index="${index}">
                            <i class="fas fa-bookmark"></i>
                        </button>
                    `;
                } else {
                    historyItem.innerHTML = `
                        <div>
                            <div class="font-medium">${item.name}</div>
                            <div class="text-sm text-gray-500">${item.id} • ${new Date(item.timestamp).toLocaleString()}</div>
                        </div>
                        <button class="text-blue-600 save-history-item" data-index="${index}">
                            <i class="fas fa-bookmark"></i>
                        </button>
                    `;
                }
                
                historyList.appendChild(historyItem);
            });
            
            // Add event listeners to save buttons
            document.querySelectorAll('.save-history-item').forEach(btn => {
                btn.addEventListener('click', (e) => {
                    const index = e.currentTarget.getAttribute('data-index');
                    const item = scanHistory[index];
                    
                    // Check if already saved
                    const isAlreadySaved = savedScans.some(savedItem => 
                        savedItem.type === item.type && 
                        (savedItem.regNumber === item.regNumber || savedItem.id === item.id)
                    );
                    
                    if (isAlreadySaved) {
                        alert('This scan is already saved.');
                        return;
                    }
                    
                    savedScans.unshift(item);
                    localStorage.setItem('savedScans', JSON.stringify(savedScans));
                    renderSavedScans();
                    
                    // Show confirmation
                    e.currentTarget.innerHTML = '<i class="fas fa-check"></i>';
                    setTimeout(() => {
                        e.currentTarget.innerHTML = '<i class="fas fa-bookmark"></i>';
                    }, 1000);
                });
            });
        }

        // Render saved scans list
        function renderSavedScans() {
            savedList.innerHTML = '';
            
            if (savedScans.length === 0) {
                emptySaved.classList.remove('hidden');
                return;
            }
            
            emptySaved.classList.add('hidden');
            
            savedScans.forEach((item, index) => {
                const savedItem = document.createElement('div');
                savedItem.className = 'bg-white rounded-lg shadow p-3 flex justify-between items-center';
                
                if (item.type === 'vehicle') {
                    savedItem.innerHTML = `
                        <div>
                            <div class="font-medium">${item.regNumber}</div>
                            <div class="text-sm text-gray-500">${item.make} • ${new Date(item.timestamp).toLocaleString()}</div>
                        </div>
                        <button class="text-red-600 remove-saved-item" data-index="${index}">
                            <i class="fas fa-trash"></i>
                        </button>
                    `;
                } else {
                    savedItem.innerHTML = `
                        <div>
                            <div class="font-medium">${item.name}</div>
                            <div class="text-sm text-gray-500">${item.id} • ${new Date(item.timestamp).toLocaleString()}</div>
                        </div>
                        <button class="text-red-600 remove-saved-item" data-index="${index}">
                            <i class="fas fa-trash"></i>
                        </button>
                    `;
                }
                
                savedList.appendChild(savedItem);
            });
            
            // Add event listeners to remove buttons
            document.querySelectorAll('.remove-saved-item').forEach(btn => {
                btn.addEventListener('click', (e) => {
                    const index = e.currentTarget.getAttribute('data-index');
                    savedScans.splice(index, 1);
                    localStorage.setItem('savedScans', JSON.stringify(savedScans));
                    renderSavedScans();
                });
            });
        }

        // Clear history
        clearHistory.addEventListener('click', () => {
            if (confirm('Are you sure you want to clear all scan history?')) {
                scanHistory = [];
                localStorage.setItem('scanHistory', JSON.stringify(scanHistory));
                renderHistory();
            }
        });

        // Clear saved scans
        clearSaved.addEventListener('click', () => {
            if (confirm('Are you sure you want to clear all saved scans?')) {
                savedScans = [];
                localStorage.setItem('savedScans', JSON.stringify(savedScans));
                renderSavedScans();
            }
        });

        // Save account settings
        saveAccount.addEventListener('click', () => {
            accountData.name = nameInput.value;
            accountData.email = emailInput.value;
            if (passwordInput.value) {
                accountData.password = passwordInput.value;
                passwordInput.value = '';
            }
            
            localStorage.setItem('accountData', JSON.stringify(accountData));
            
            accountName.textContent = accountData.name;
            accountEmail.textContent = accountData.email;
            
            // Show confirmation
            const originalText = saveAccount.innerHTML;
            saveAccount.innerHTML = '<i class="fas fa-check mr-1"></i> Saved';
            setTimeout(() => {
                saveAccount.innerHTML = originalText;
            }, 2000);
        });

        // Logout
        logoutBtn.addEventListener('click', () => {
            if (confirm('Are you sure you want to logout?')) {
                // Reset account to guest
                accountData = {
                    name: "Guest User",
                    email: "guest@example.com",
                    password: ""
                };
                localStorage.setItem('accountData', JSON.stringify(accountData));
                
                // Update UI
                accountName.textContent = accountData.name;
                accountEmail.textContent = accountData.email;
                nameInput.value = accountData.name;
                emailInput.value = accountData.email;
                passwordInput.value = '';
                
                // Go to scanner page
                showPage('scanner-page');
                updateNavButtons('scanner-page');
            }
        });

        // Settings toggles
        darkModeToggle.addEventListener('change', () => {
            settings.darkMode = darkModeToggle.checked;
            localStorage.setItem('settings', JSON.stringify(settings));
            
            if (settings.darkMode) {
                document.body.classList.add('bg-gray-900');
                document.body.classList.remove('bg-gray-100');
            } else {
                document.body.classList.remove('bg-gray-900');
                document.body.classList.add('bg-gray-100');
            }
        });

        soundToggle.addEventListener('change', () => {
            settings.scanSound = soundToggle.checked;
            localStorage.setItem('settings', JSON.stringify(settings));
        });

        autosaveToggle.addEventListener('change', () => {
            settings.autoSave = autosaveToggle.checked;
            localStorage.setItem('settings', JSON.stringify(settings));
        });

        // Navigation buttons
        historyBtn.addEventListener('click', () => {
            showPage('history-page');
            updateNavButtons('history-page');
        });

        settingsBtn.addEventListener('click', () => {
            showPage('account-page');
            updateNavButtons('account-page');
        });

        navBtns.forEach(btn => {
            btn.addEventListener('click', () => {
                const page = btn.getAttribute('data-page');
                showPage(page);
                updateNavButtons(page);
            });
        });

        // Show page function
        function showPage(pageId) {
            pages.forEach(page => {
                if (page.id === pageId) {
                    page.classList.add('active');
                } else {
                    page.classList.remove('active');
                }
            });
        }

        // Update nav buttons
        function updateNavButtons(activePage) {
            navBtns.forEach(btn => {
                if (btn.getAttribute('data-page') === activePage) {
                    btn.classList.remove('text-gray-500');
                    btn.classList.add('text-blue-600');
                } else {
                    btn.classList.remove('text-blue-600');
                    btn.classList.add('text-gray-500');
                }
            });
        }

        // Reset scanner (not shown in UI but would be needed)
        function resetScanner() {
            scannerView.classList.remove('hidden');
            resultsSection.classList.add('hidden');
            const resultCards = document.querySelectorAll('.result-card');
            resultCards.forEach(card => {
                card.classList.remove('show');
            });
        }

        // Initialize the app
        initApp();
    </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=serverghost/red-falcon" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>