File size: 60,889 Bytes
7cd5812
f8d56cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7cd5812
f8d56cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7cd5812
f8d56cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Membership Platform</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">
    <link rel="manifest" href="/manifest.json">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#4F46E5',
                        secondary: '#10B981',
                        dark: '#1F2937',
                        light: '#F9FAFB',
                    }
                }
            }
        }
    </script>
    <style>
        /* Custom styles */
        .gradient-bg {
            background: linear-gradient(135deg, #4F46E5 0%, #10B981 100%);
        }
        .chat-bubble {
            border-radius: 1rem;
            max-width: 80%;
        }
        .user-bubble {
            background-color: #4F46E5;
            color: white;
            margin-left: auto;
        }
        .other-bubble {
            background-color: #E5E7EB;
            color: #1F2937;
            margin-right: auto;
        }
        .language-selector:hover .language-dropdown {
            display: block;
        }
        /* PWA specific */
        #installButton {
            display: none;
        }
        /* Animation */
        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.5;
            }
        }
        .animate-pulse {
            animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <!-- PWA Install Prompt -->
    <div id="installContainer" class="fixed bottom-4 right-4 z-50 hidden">
        <div class="bg-white p-4 rounded-lg shadow-xl max-w-xs">
            <p class="text-sm text-gray-700 mb-2">Install our app for a better experience</p>
            <div class="flex space-x-2">
                <button id="installButton" class="bg-primary text-white px-3 py-1 rounded text-sm">Install</button>
                <button id="dismissInstall" class="border border-gray-300 px-3 py-1 rounded text-sm">Later</button>
            </div>
        </div>
    </div>

    <!-- Loading Screen -->
    <div id="loadingScreen" class="fixed inset-0 bg-white z-50 flex flex-col items-center justify-center">
        <div class="w-16 h-16 border-4 border-primary border-t-transparent rounded-full animate-spin"></div>
        <p class="mt-4 text-gray-600">Loading your experience...</p>
    </div>

    <!-- Auth Modal -->
    <div id="authModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4 hidden">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-md">
            <div class="p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-xl font-semibold text-gray-800">Welcome</h3>
                    <button id="closeAuthModal" class="text-gray-500 hover:text-gray-700">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <div class="space-y-4">
                    <button id="googleAuth" class="w-full flex items-center justify-center space-x-2 bg-white border border-gray-300 rounded-lg px-4 py-2 text-gray-700 hover:bg-gray-50">
                        <i class="fab fa-google text-red-500"></i>
                        <span>Continue with Google</span>
                    </button>
                    
                    <div class="relative flex items-center">
                        <div class="flex-grow border-t border-gray-300"></div>
                        <span class="flex-shrink mx-4 text-gray-500">or</span>
                        <div class="flex-grow border-t border-gray-300"></div>
                    </div>
                    
                    <div class="space-y-2">
                        <label for="whatsappNumber" class="block text-sm font-medium text-gray-700">WhatsApp Number</label>
                        <div class="flex">
                            <select class="border border-gray-300 rounded-l-lg px-3 py-2 bg-gray-50 text-gray-700">
                                <option>+1</option>
                                <option>+44</option>
                                <option>+49</option>
                                <option>+33</option>
                                <option>+34</option>
                                <option>+81</option>
                                <option>+63</option>
                                <option>+91</option>
                            </select>
                            <input type="tel" id="whatsappNumber" placeholder="1234567890" class="flex-grow border border-gray-300 rounded-r-lg px-3 py-2 focus:ring-primary focus:border-primary">
                        </div>
                    </div>
                    
                    <button id="whatsappAuth" class="w-full flex items-center justify-center space-x-2 bg-green-600 text-white rounded-lg px-4 py-2 hover:bg-green-700">
                        <i class="fab fa-whatsapp"></i>
                        <span>Continue with WhatsApp</span>
                    </button>
                </div>
                
                <div class="mt-6 text-center text-sm text-gray-500">
                    <p>By continuing, you agree to our <a href="#" class="text-primary hover:underline">Terms</a> and <a href="#" class="text-primary hover:underline">Privacy Policy</a></p>
                </div>
            </div>
        </div>
    </div>

    <!-- Role Selection Modal -->
    <div id="roleModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4 hidden">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-md">
            <div class="p-6">
                <h3 class="text-xl font-semibold text-gray-800 mb-6 text-center">Select Your Role</h3>
                
                <div class="grid grid-cols-1 gap-4">
                    <button data-role="member" class="role-btn flex flex-col items-center p-4 border border-gray-200 rounded-lg hover:border-primary hover:bg-primary hover:bg-opacity-5 transition-all">
                        <div class="w-12 h-12 bg-primary bg-opacity-10 rounded-full flex items-center justify-center mb-2">
                            <i class="fas fa-user text-primary text-xl"></i>
                        </div>
                        <h4 class="font-medium text-gray-800">Member</h4>
                        <p class="text-sm text-gray-500 text-center mt-1">Join clubs, access services, and connect with others</p>
                    </button>
                    
                    <button data-role="vendor" class="role-btn flex flex-col items-center p-4 border border-gray-200 rounded-lg hover:border-secondary hover:bg-secondary hover:bg-opacity-5 transition-all">
                        <div class="w-12 h-12 bg-secondary bg-opacity-10 rounded-full flex items-center justify-center mb-2">
                            <i class="fas fa-store text-secondary text-xl"></i>
                        </div>
                        <h4 class="font-medium text-gray-800">Vendor</h4>
                        <p class="text-sm text-gray-500 text-center mt-1">Offer services and manage bookings</p>
                    </button>
                    
                    <button data-role="agent" class="role-btn flex flex-col items-center p-4 border border-gray-200 rounded-lg hover:border-purple-500 hover:bg-purple-500 hover:bg-opacity-5 transition-all">
                        <div class="w-12 h-12 bg-purple-500 bg-opacity-10 rounded-full flex items-center justify-center mb-2">
                            <i class="fas fa-robot text-purple-500 text-xl"></i>
                        </div>
                        <h4 class="font-medium text-gray-800">Agent</h4>
                        <p class="text-sm text-gray-500 text-center mt-1">Connect members and facilitate services</p>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- Main App Container -->
    <div id="appContainer" class="hidden">
        <!-- Header -->
        <header class="bg-white shadow-sm">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <div class="flex justify-between items-center py-4">
                    <div class="flex items-center">
                        <button id="menuToggle" class="mr-4 text-gray-500 hover:text-gray-700 md:hidden">
                            <i class="fas fa-bars text-xl"></i>
                        </button>
                        <div class="flex items-center">
                            <div class="w-8 h-8 rounded-full gradient-bg flex items-center justify-center text-white">
                                <i class="fas fa-brain"></i>
                            </div>
                            <span class="ml-2 font-semibold text-gray-800">AI Membership</span>
                        </div>
                    </div>
                    
                    <div class="flex items-center space-x-4">
                        <!-- Voice Search -->
                        <button id="voiceSearchBtn" class="p-2 text-gray-500 hover:text-primary rounded-full hover:bg-gray-100">
                            <i class="fas fa-microphone"></i>
                        </button>
                        
                        <!-- Language Selector -->
                        <div class="language-selector relative">
                            <button class="flex items-center space-x-1 p-2 text-gray-500 hover:text-primary rounded-full hover:bg-gray-100">
                                <i class="fas fa-globe"></i>
                                <span class="text-sm">EN</span>
                            </button>
                            <div class="language-dropdown absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-10 hidden">
                                <div class="px-4 py-2 text-xs text-gray-500">Select Language</div>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Deutsch</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Français</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Español</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">日本語</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Tagalog</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">हिन्दी</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">বাংলা</a>
                            </div>
                        </div>
                        
                        <!-- Notifications -->
                        <div class="relative">
                            <button id="notificationsBtn" class="p-2 text-gray-500 hover:text-primary rounded-full hover:bg-gray-100">
                                <i class="fas fa-bell"></i>
                                <span class="absolute top-0 right-0 h-2 w-2 rounded-full bg-red-500"></span>
                            </button>
                            <div id="notificationsDropdown" class="absolute right-0 mt-2 w-72 bg-white rounded-md shadow-lg py-1 z-10 hidden">
                                <div class="px-4 py-2 border-b border-gray-200">
                                    <div class="flex justify-between items-center">
                                        <h3 class="text-sm font-medium">Notifications</h3>
                                        <button class="text-xs text-primary">Mark all as read</button>
                                    </div>
                                </div>
                                <div class="max-h-60 overflow-y-auto">
                                    <a href="#" class="block px-4 py-3 text-sm text-gray-700 hover:bg-gray-50 border-b border-gray-100">
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-500">
                                                <i class="fas fa-user-plus"></i>
                                            </div>
                                            <div class="ml-3">
                                                <p class="font-medium">New connection request</p>
                                                <p class="text-xs text-gray-500">2 hours ago</p>
                                            </div>
                                        </div>
                                    </a>
                                    <a href="#" class="block px-4 py-3 text-sm text-gray-700 hover:bg-gray-50 border-b border-gray-100">
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-green-100 flex items-center justify-center text-green-500">
                                                <i class="fas fa-calendar-check"></i>
                                            </div>
                                            <div class="ml-3">
                                                <p class="font-medium">Your booking is confirmed</p>
                                                <p class="text-xs text-gray-500">5 hours ago</p>
                                            </div>
                                        </div>
                                    </a>
                                    <a href="#" class="block px-4 py-3 text-sm text-gray-700 hover:bg-gray-50">
                                        <div class="flex items-start">
                                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-purple-100 flex items-center justify-center text-purple-500">
                                                <i class="fas fa-robot"></i>
                                            </div>
                                            <div class="ml-3">
                                                <p class="font-medium">AI Agent has a suggestion for you</p>
                                                <p class="text-xs text-gray-500">Yesterday</p>
                                            </div>
                                        </div>
                                    </a>
                                </div>
                                <div class="px-4 py-2 border-t border-gray-200 text-center">
                                    <a href="#" class="text-xs text-primary font-medium">View all notifications</a>
                                </div>
                            </div>
                        </div>
                        
                        <!-- User Profile -->
                        <div class="relative">
                            <button id="userMenuBtn" class="flex items-center space-x-2">
                                <div class="w-8 h-8 rounded-full bg-primary text-white flex items-center justify-center">
                                    <span id="userInitial">U</span>
                                </div>
                            </button>
                            <div id="userMenuDropdown" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-10 hidden">
                                <div class="px-4 py-2 border-b border-gray-200">
                                    <p class="text-sm font-medium">Signed in as</p>
                                    <p class="text-sm text-gray-500 truncate" id="userEmail">user@example.com</p>
                                </div>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Your Profile</a>
                                <a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Settings</a>
                                <div class="border-t border-gray-200"></div>
                                <button id="logoutBtn" class="block w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Sign out</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </header>

        <!-- Mobile Sidebar -->
        <div id="mobileSidebar" class="fixed inset-0 bg-black bg-opacity-50 z-40 transform -translate-x-full md:hidden transition-transform duration-300 ease-in-out">
            <div class="w-64 bg-white h-full relative">
                <div class="p-4 border-b border-gray-200">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded-full gradient-bg flex items-center justify-center text-white">
                            <i class="fas fa-brain"></i>
                        </div>
                        <span class="ml-2 font-semibold text-gray-800">AI Membership</span>
                    </div>
                </div>
                <nav class="p-4">
                    <div class="space-y-2">
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg bg-primary bg-opacity-10 text-primary">
                            <i class="fas fa-home w-5"></i>
                            <span>Dashboard</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-users w-5"></i>
                            <span>Clubs</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-store w-5"></i>
                            <span>Vendors</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-comments w-5"></i>
                            <span>Messages</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-calendar w-5"></i>
                            <span>Bookings</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-cog w-5"></i>
                            <span>Settings</span>
                        </a>
                    </div>
                </nav>
                <div class="absolute bottom-0 left-0 right-0 p-4 border-t border-gray-200">
                    <button class="w-full flex items-center justify-center space-x-2 text-gray-700 hover:text-primary">
                        <i class="fas fa-sign-out-alt"></i>
                        <span>Logout</span>
                    </button>
                </div>
            </div>
        </div>

        <!-- Main Content -->
        <div class="flex">
            <!-- Desktop Sidebar -->
            <aside class="hidden md:block w-64 bg-white border-r border-gray-200 h-[calc(100vh-65px)] sticky top-[65px]">
                <nav class="p-4">
                    <div class="space-y-1">
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg bg-primary bg-opacity-10 text-primary">
                            <i class="fas fa-home w-5"></i>
                            <span>Dashboard</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-users w-5"></i>
                            <span>Clubs</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-store w-5"></i>
                            <span>Vendors</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-comments w-5"></i>
                            <span>Messages</span>
                            <span class="ml-auto bg-red-500 text-white text-xs px-2 py-0.5 rounded-full">3</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-calendar w-5"></i>
                            <span>Bookings</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-robot w-5"></i>
                            <span>AI Assistant</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-wallet w-5"></i>
                            <span>Payments</span>
                        </a>
                        <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                            <i class="fas fa-cog w-5"></i>
                            <span>Settings</span>
                        </a>
                    </div>
                    
                    <div class="mt-8">
                        <h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider">Your Clubs</h3>
                        <div class="mt-2 space-y-1">
                            <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                                <div class="w-5 h-5 rounded-full bg-blue-500"></div>
                                <span class="text-sm">Tech Enthusiasts</span>
                            </a>
                            <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                                <div class="w-5 h-5 rounded-full bg-green-500"></div>
                                <span class="text-sm">Fitness Group</span>
                            </a>
                            <a href="#" class="flex items-center space-x-3 p-2 rounded-lg text-gray-700 hover:bg-gray-100">
                                <div class="w-5 h-5 rounded-full bg-purple-500"></div>
                                <span class="text-sm">Book Club</span>
                            </a>
                        </div>
                    </div>
                </nav>
            </aside>

            <!-- Dashboard Content -->
            <main class="flex-1 pb-8">
                <!-- Page header -->
                <div class="bg-white shadow">
                    <div class="px-4 sm:px-6 lg:px-8">
                        <div class="py-6 md:flex md:items-center md:justify-between">
                            <div class="min-w-0 flex-1">
                                <h1 class="text-2xl font-bold leading-7 text-gray-900 sm:truncate sm:text-3xl sm:tracking-tight">
                                    Welcome back, <span id="userName">User</span>
                                </h1>
                                <div class="mt-1 flex flex-col sm:mt-0 sm:flex-row sm:flex-wrap sm:space-x-6">
                                    <div class="mt-2 flex items-center text-sm text-gray-500">
                                        <i class="fas fa-map-marker-alt mr-1.5 h-4 w-4 flex-shrink-0 text-gray-400"></i>
                                        <span id="userLocation">Detecting your location...</span>
                                    </div>
                                    <div class="mt-2 flex items-center text-sm text-gray-500">
                                        <i class="fas fa-user-tag mr-1.5 h-4 w-4 flex-shrink-0 text-gray-400"></i>
                                        <span id="userRole">Member</span>
                                    </div>
                                </div>
                            </div>
                            <div class="mt-4 flex md:mt-0 md:ml-4">
                                <button type="button" class="inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
                                    <i class="fas fa-robot mr-2"></i> AI Assistant
                                </button>
                                <button type="button" class="ml-3 inline-flex items-center rounded-md bg-primary px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-dark focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary">
                                    <i class="fas fa-plus mr-2"></i> New Club
                                </button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Main content -->
                <div class="mt-8 px-4 sm:px-6 lg:px-8">
                    <div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
                        <!-- Stats -->
                        <div class="bg-white overflow-hidden shadow rounded-lg">
                            <div class="px-4 py-5 sm:p-6">
                                <div class="flex items-center">
                                    <div class="flex-shrink-0 bg-indigo-500 rounded-md p-3">
                                        <i class="fas fa-users text-white text-xl"></i>
                                    </div>
                                    <div class="ml-5 w-0 flex-1">
                                        <dt class="text-sm font-medium text-gray-500 truncate">Your Clubs</dt>
                                        <dd class="flex items-baseline">
                                            <div class="text-2xl font-semibold text-gray-900">3</div>
                                            <div class="ml-2 flex items-baseline text-sm font-semibold text-green-600">
                                                <i class="fas fa-arrow-up text-xs"></i>
                                                <span class="sr-only">Increased by</span>
                                                12%
                                            </div>
                                        </dd>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="bg-white overflow-hidden shadow rounded-lg">
                            <div class="px-4 py-5 sm:p-6">
                                <div class="flex items-center">
                                    <div class="flex-shrink-0 bg-green-500 rounded-md p-3">
                                        <i class="fas fa-store text-white text-xl"></i>
                                    </div>
                                    <div class="ml-5 w-0 flex-1">
                                        <dt class="text-sm font-medium text-gray-500 truncate">Connected Vendors</dt>
                                        <dd class="flex items-baseline">
                                            <div class="text-2xl font-semibold text-gray-900">5</div>
                                            <div class="ml-2 flex items-baseline text-sm font-semibold text-green-600">
                                                <i class="fas fa-arrow-up text-xs"></i>
                                                <span class="sr-only">Increased by</span>
                                                2%
                                            </div>
                                        </dd>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="bg-white overflow-hidden shadow rounded-lg">
                            <div class="px-4 py-5 sm:p-6">
                                <div class="flex items-center">
                                    <div class="flex-shrink-0 bg-purple-500 rounded-md p-3">
                                        <i class="fas fa-calendar-check text-white text-xl"></i>
                                    </div>
                                    <div class="ml-5 w-0 flex-1">
                                        <dt class="text-sm font-medium text-gray-500 truncate">Upcoming Bookings</dt>
                                        <dd class="flex items-baseline">
                                            <div class="text-2xl font-semibold text-gray-900">2</div>
                                            <div class="ml-2 flex items-baseline text-sm font-semibold text-red-600">
                                                <i class="fas fa-arrow-down text-xs"></i>
                                                <span class="sr-only">Decreased by</span>
                                                1%
                                            </div>
                                        </dd>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- AI Recommendations -->
                    <div class="mt-8">
                        <h2 class="text-lg font-medium text-gray-900">AI Recommendations For You</h2>
                        <div class="mt-4 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
                            <!-- Recommendation 1 -->
                            <div class="bg-white overflow-hidden shadow rounded-lg">
                                <div class="px-4 py-5 sm:p-6">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 bg-blue-500 rounded-md p-3">
                                            <i class="fas fa-users text-white text-xl"></i>
                                        </div>
                                        <div class="ml-4">
                                            <h3 class="text-lg font-medium text-gray-900">Tech Innovators Club</h3>
                                            <p class="mt-1 text-sm text-gray-500">Join other tech enthusiasts to discuss the latest innovations.</p>
                                        </div>
                                    </div>
                                    <div class="mt-4 flex justify-end">
                                        <button type="button" class="inline-flex items-center rounded-md bg-primary px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-dark">
                                            Join Club
                                        </button>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Recommendation 2 -->
                            <div class="bg-white overflow-hidden shadow rounded-lg">
                                <div class="px-4 py-5 sm:p-6">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 bg-green-500 rounded-md p-3">
                                            <i class="fas fa-store text-white text-xl"></i>
                                        </div>
                                        <div class="ml-4">
                                            <h3 class="text-lg font-medium text-gray-900">FitLife Gym</h3>
                                            <p class="mt-1 text-sm text-gray-500">Personal training sessions tailored to your fitness goals.</p>
                                        </div>
                                    </div>
                                    <div class="mt-4 flex justify-end">
                                        <button type="button" class="inline-flex items-center rounded-md bg-primary px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-dark">
                                            View Services
                                        </button>
                                    </div>
                                </div>
                            </div>
                            
                            <!-- Recommendation 3 -->
                            <div class="bg-white overflow-hidden shadow rounded-lg">
                                <div class="px-4 py-5 sm:p-6">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 bg-purple-500 rounded-md p-3">
                                            <i class="fas fa-user-friends text-white text-xl"></i>
                                        </div>
                                        <div class="ml-4">
                                            <h3 class="text-lg font-medium text-gray-900">Connect with Sarah</h3>
                                            <p class="mt-1 text-sm text-gray-500">Based on your interests, you might enjoy connecting with Sarah.</p>
                                        </div>
                                    </div>
                                    <div class="mt-4 flex justify-end">
                                        <button type="button" class="inline-flex items-center rounded-md bg-primary px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-dark">
                                            Send Message
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Recent Activity -->
                    <div class="mt-8">
                        <h2 class="text-lg font-medium text-gray-900">Recent Activity</h2>
                        <div class="mt-4 bg-white shadow overflow-hidden sm:rounded-lg">
                            <ul class="divide-y divide-gray-200">
                                <li class="px-6 py-4">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 h-10 w-10 rounded-full bg-green-100 flex items-center justify-center text-green-500">
                                            <i class="fas fa-calendar-check"></i>
                                        </div>
                                        <div class="ml-4">
                                            <div class="text-sm font-medium text-gray-900">Booking confirmed</div>
                                            <div class="text-sm text-gray-500">Your session with FitLife Gym has been confirmed for tomorrow at 5 PM.</div>
                                        </div>
                                        <div class="ml-auto text-sm text-gray-500">2 hours ago</div>
                                    </div>
                                </li>
                                <li class="px-6 py-4">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-500">
                                            <i class="fas fa-comment"></i>
                                        </div>
                                        <div class="ml-4">
                                            <div class="text-sm font-medium text-gray-900">New message</div>
                                            <div class="text-sm text-gray-500">You have a new message from the Book Club organizer.</div>
                                        </div>
                                        <div class="ml-auto text-sm text-gray-500">5 hours ago</div>
                                    </div>
                                </li>
                                <li class="px-6 py-4">
                                    <div class="flex items-center">
                                        <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-500">
                                            <i class="fas fa-robot"></i>
                                        </div>
                                        <div class="ml-4">
                                            <div class="text-sm font-medium text-gray-900">AI suggestion</div>
                                            <div class="text-sm text-gray-500">Based on your interests, we found a new coding workshop you might enjoy.</div>
                                        </div>
                                        <div class="ml-auto text-sm text-gray-500">1 day ago</div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </main>
        </div>

        <!-- AI Chat Modal -->
        <div id="aiChatModal" class="fixed bottom-4 right-4 z-40 hidden">
            <div class="w-80 bg-white rounded-t-lg shadow-xl overflow-hidden">
                <div class="bg-primary px-4 py-3 flex justify-between items-center">
                    <div class="flex items-center space-x-2">
                        <div class="w-8 h-8 rounded-full bg-white text-primary flex items-center justify-center">
                            <i class="fas fa-robot"></i>
                        </div>
                        <span class="text-white font-medium">AI Assistant</span>
                    </div>
                    <button id="closeAIChat" class="text-white hover:text-gray-200">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                <div id="aiChatMessages" class="h-64 overflow-y-auto p-4 bg-gray-50 space-y-3">
                    <div class="flex">
                        <div class="other-bubble px-4 py-2">
                            <p class="text-sm">Hello! I'm your AI assistant. How can I help you today?</p>
                            <p class="text-xs text-gray-500 mt-1">Just now</p>
                        </div>
                    </div>
                </div>
                <div class="bg-white border-t border-gray-200 p-3">
                    <div class="flex">
                        <input type="text" id="aiChatInput" placeholder="Type your message..." class="flex-grow border border-gray-300 rounded-l-lg px-3 py-2 focus:ring-primary focus:border-primary">
                        <button id="sendAIMessage" class="bg-primary text-white px-4 py-2 rounded-r-lg hover:bg-primary-dark">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Test Data Modal -->
    <div id="testDataModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4 hidden">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-2xl">
            <div class="p-6">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-xl font-semibold text-gray-800">Test Data</h3>
                    <button id="closeTestDataModal" class="text-gray-500 hover:text-gray-700">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <div class="space-y-4">
                    <div>
                        <h4 class="font-medium text-gray-800 mb-2">Members (5)</h4>
                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">John Doe</p>
                                <p class="text-sm text-gray-600">john@example.com</p>
                                <p class="text-xs text-gray-500">Interests: Tech, Fitness</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Jane Smith</p>
                                <p class="text-sm text-gray-600">jane@example.com</p>
                                <p class="text-xs text-gray-500">Interests: Books, Travel</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Mike Johnson</p>
                                <p class="text-sm text-gray-600">mike@example.com</p>
                                <p class="text-xs text-gray-500">Interests: Sports, Music</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Sarah Williams</p>
                                <p class="text-sm text-gray-600">sarah@example.com</p>
                                <p class="text-xs text-gray-500">Interests: Art, Cooking</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">David Brown</p>
                                <p class="text-sm text-gray-600">david@example.com</p>
                                <p class="text-xs text-gray-500">Interests: Photography, Hiking</p>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-800 mb-2">Vendors (3)</h4>
                        <div class="grid grid-cols-1 sm:grid-cols-3 gap-2">
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">FitLife Gym</p>
                                <p class="text-sm text-gray-600">fitlife@example.com</p>
                                <p class="text-xs text-gray-500">Services: Personal Training, Yoga</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Tech Workshops</p>
                                <p class="text-sm text-gray-600">tech@example.com</p>
                                <p class="text-xs text-gray-500">Services: Coding Classes, Seminars</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Book Haven</p>
                                <p class="text-sm text-gray-600">books@example.com</p>
                                <p class="text-xs text-gray-500">Services: Book Clubs, Readings</p>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-800 mb-2">Agents (2)</h4>
                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">AI Agent</p>
                                <p class="text-sm text-gray-600">ai@example.com</p>
                                <p class="text-xs text-gray-500">AI-powered connection facilitator</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Lisa Taylor</p>
                                <p class="text-sm text-gray-600">lisa@example.com</p>
                                <p class="text-xs text-gray-500">Human community manager</p>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-800 mb-2">Clubs (2)</h4>
                        <div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Tech Enthusiasts</p>
                                <p class="text-sm text-gray-600">12 members</p>
                                <p class="text-xs text-gray-500">Focus: Technology discussions</p>
                            </div>
                            <div class="bg-gray-50 p-3 rounded-lg">
                                <p class="font-medium">Book Club</p>
                                <p class="text-sm text-gray-600">8 members</p>
                                <p class="text-xs text-gray-500">Focus: Monthly book readings</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="mt-6 flex justify-end space-x-3">
                    <button id="useTestData" class="bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary-dark">
                        Use Test Data
                    </button>
                    <button id="closeTestData" class="border border-gray-300 px-4 py-2 rounded-lg text-gray-700 hover:bg-gray-50">
                        Close
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // DOM Elements
        const loadingScreen = document.getElementById('loadingScreen');
        const appContainer = document.getElementById('appContainer');
        const authModal = document.getElementById('authModal');
        const roleModal = document.getElementById('roleModal');
        const closeAuthModal = document.getElementById('closeAuthModal');
        const googleAuth = document.getElementById('googleAuth');
        const whatsappAuth = document.getElementById('whatsappAuth');
        const roleButtons = document.querySelectorAll('.role-btn');
        const menuToggle = document.getElementById('menuToggle');
        const mobileSidebar = document.getElementById('mobileSidebar');
        const userMenuBtn = document.getElementById('userMenuBtn');
        const userMenuDropdown = document.getElementById('userMenuDropdown');
        const notificationsBtn = document.getElementById('notificationsBtn');
        const notificationsDropdown = document.getElementById('notificationsDropdown');
        const voiceSearchBtn = document.getElementById('voiceSearchBtn');
        const logoutBtn = document.getElementById('logoutBtn');
        const aiChatModal = document.getElementById('aiChatModal');
        const closeAIChat = document.getElementById('closeAIChat');
        const aiChatMessages = document.getElementById('aiChatMessages');
        const aiChatInput = document.getElementById('aiChatInput');
        const sendAIMessage = document.getElementById('sendAIMessage');
        const testDataModal = document.getElementById('testDataModal');
        const closeTestDataModal = document.getElementById('closeTestDataModal');
        const useTestData = document.getElementById('useTestData');
        const closeTestData = document.getElementById('closeTestData');
        const installContainer = document.getElementById('installContainer');
        const installButton = document.getElementById('installButton');
        const dismissInstall = document.getElementById('dismissInstall');
        
        // Current user state
        let currentUser = null;
        let currentRole = null;
        let deferredPrompt = null;
        
        // Simulate loading
        setTimeout(() => {
            loadingScreen.classList.add('hidden');
            authModal.classList.remove('hidden');
        }, 2000);
        
        // Event Listeners
        closeAuthModal.addEventListener('click', () => {
            authModal.classList.add('hidden');
        });
        
        googleAuth.addEventListener('click', () => {
            // Simulate Google auth
            simulateAuth('Google');
        });
        
        whatsappAuth.addEventListener('click', () => {
            const number = document.getElementById('whatsappNumber').value;
            if (number) {
                // Simulate WhatsApp auth
                simulateAuth('WhatsApp');
            } else {
                alert('Please enter your WhatsApp number');
            }
        });
        
        roleButtons.forEach(button => {
            button.addEventListener('click', () => {
                currentRole = button.getAttribute('data-role');
                document.getElementById('userRole').textContent = currentRole.charAt(0).toUpperCase() + currentRole.slice(1);
                roleModal.classList.add('hidden');
                appContainer.classList.remove('hidden');
                
                // Update UI based on role
                updateUIForRole(currentRole);
            });
        });
        
        menuToggle.addEventListener('click', () => {
            mobileSidebar.classList.toggle('-translate-x-full');
        });
        
        userMenuBtn.addEventListener('click', () => {
            userMenuDropdown.classList.toggle('hidden');
            notificationsDropdown.classList.add('hidden');
        });
        
        notificationsBtn.addEventListener('click', () => {
            notificationsDropdown.classList.toggle('hidden');
            userMenuDropdown.classList.add('hidden');
        });
        
        voiceSearchBtn.addEventListener('click', () => {
            startVoiceSearch();
        });
        
        logoutBtn.addEventListener('click', () => {
            // Simulate logout
            currentUser = null;
            currentRole = null;
            appContainer.classList.add('hidden');
            authModal.classList.remove('hidden');
            userMenuDropdown.classList.add('hidden');
        });
        
        closeAIChat.addEventListener('click', () => {
            aiChatModal.classList.add('hidden');
        });
        
        sendAIMessage.addEventListener('click', () => {
            sendAIMessageHandler();
        });
        
        aiChatInput.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') {
                sendAIMessageHandler();
            }
        });
        
        document.addEventListener('click', (e) => {
            // Close dropdowns when clicking outside
            if (!userMenuBtn.contains(e.target) && !userMenuDropdown.contains(e.target)) {
                userMenuDropdown.classList.add('hidden');
            }
            
            if (!notificationsBtn.contains(e.target) && !notificationsDropdown.contains(e.target)) {
                notificationsDropdown.classList.add('hidden');
            }
        });
        
        // Show test data modal after 5 seconds (for demo purposes)
        setTimeout(() => {
            testDataModal.classList.remove('hidden');
        }, 5000);
        
        closeTestDataModal.addEventListener('click', () => {
            testDataModal.classList.add('hidden');
        });
        
        closeTestData.addEventListener('click', () => {
            testDataModal.classList.add('hidden');
        });
        
        useTestData.addEventListener('click', () => {
            // Simulate loading test data
            testDataModal.classList.add('hidden');
            alert('Test data loaded successfully!');
        });
        
        // PWA Installation
        window.addEventListener('beforeinstallprompt', (e) => {
            // Prevent the mini-infobar from appearing on mobile
            e.preventDefault();
            // Stash the event so it can be triggered later.
            deferredPrompt = e;
            // Update UI notify the user they can install the PWA
            installContainer.classList.remove('hidden');
        });
        
        installButton.addEventListener('click', () => {
            // Hide the app provided install promotion
            installContainer.classList.add('hidden');
            // Show the install prompt
            deferredPrompt.prompt();
            // Wait for the user to respond to the prompt
            deferredPrompt.userChoice.then((choiceResult) => {
                if (choiceResult.outcome === 'accepted') {
                    console.log('User accepted the install prompt');
                } else {
                    console.log('User dismissed the install prompt');
                }
                deferredPrompt = null;
            });
        });
        
        dismissInstall.addEventListener('click', () => {
            installContainer.classList.add('hidden');
        });
        
        // Functions
        function simulateAuth(provider) {
            // Simulate authentication
            loadingScreen.classList.remove('hidden');
            authModal.classList.add('hidden');
            
            setTimeout(() => {
                currentUser = {
                    name: provider === 'Google' ? 'Demo User' : 'WhatsApp User',
                    email: provider === 'Google' ? 'demo@example.com' : 'whatsapp@example.com',
                    initial: provider === 'Google' ? 'D' : 'W'
                };
                
                document.getElementById('userInitial').textContent = currentUser.initial;
                document.getElementById('userEmail').textContent = currentUser.email;
                document.getElementById('userName').textContent = currentUser.name;
                
                loadingScreen.classList.add('hidden');
                roleModal.classList.remove('hidden');
                
                // Detect location
                if (navigator.geolocation) {
                    navigator.geolocation.getCurrentPosition(
                        (position) => {
                            // In a real app, you would reverse geocode to get city/country
                            document.getElementById('userLocation').textContent = `Lat: ${position.coords.latitude.toFixed(2)}, Long: ${position.coords.longitude.toFixed(2)}`;
                        },
                        (error) => {
                            document.getElementById('userLocation').textContent = 'Location access denied';
                        }
                    );
                } else {
                    document.getElementById('userLocation').textContent = 'Geolocation not supported';
                }
            }, 1500);
        }
        
        function updateUIForRole(role) {
            // In a real app, you would update the UI based on the user's role
            console.log(`UI updated for ${role} role`);
        }
        
        function startVoiceSearch() {
            if ('webkitSpeechRecognition' in window) {
                const recognition = new webkitSpeechRecognition();
                recognition.lang = 'en-US';
                recognition.start();
                
                voiceSearchBtn.innerHTML = '<i class="fas fa-microphone-slash"></i>';
                voiceSearchBtn.classList.add('animate-pulse');
                
                recognition.onresult = (event) => {
                    const transcript = event.results[0][0].transcript;
                    alert(`You said: ${transcript}`);
                    voiceSearchBtn.innerHTML = '<i class="fas fa-microphone"></i>';
                    voiceSearchBtn.classList.remove('animate-pulse');
                };
                
                recognition.onerror = (event) => {
                    console.error('Voice recognition error', event.error);
                    voiceSearchBtn.innerHTML = '<i class="fas fa-microphone"></i>';
                    voiceSearchBtn.classList.remove('animate-pulse');
                };
            } else {
                alert('Voice search is not supported in your browser');
            }
        }
        
        function sendAIMessageHandler() {
            const message = aiChatInput.value.trim();
            if (message) {
                // Add user message
                addAIMessage(message, true);
                aiChatInput.value = '';
                
                // Simulate AI response after a delay
                setTimeout(() => {
                    const responses = [
                        "I understand you're asking about " + message + ". Here's what I can tell you...",
                        "That's an interesting question about " + message + ". Let me help with that.",
                        "I've analyzed your query about " + message + " and here's my suggestion...",
                        message + " is something I can certainly help with. Here's the information you need."
                    ];
                    
                    const randomResponse = responses[Math.floor(Math.random() * responses.length)];
                    addAIMessage(randomResponse, false);
                }, 1000);
            }
        }
        
        function addAIMessage(message, isUser) {
            const messageDiv = document.createElement('div');
            messageDiv.className = 'flex';
            
            const bubbleDiv = document.createElement('div');
            bubbleDiv.className = isUser ? 'user-bubble chat-bubble px-4 py-2' : 'other-bubble chat-bubble px-4 py-2';
            
            const messageText = document.createElement('p');
            messageText.className = 'text-sm';
            messageText.textContent = message;
            
            const timeText = document.createElement('p');
            timeText.className = 'text-xs text-gray-500 mt-1';
            timeText.textContent = 'Just now';
            
            bubbleDiv.appendChild(messageText);
            bubbleDiv.appendChild(timeText);
            messageDiv.appendChild(bubbleDiv);
            aiChatMessages.appendChild(messageDiv);
            
            // Scroll to bottom
            aiChatMessages.scrollTop = aiChatMessages.scrollHeight;
        }
        
        // Initialize AI chat button in header
        document.querySelector('[aria-label="AI Assistant"]').addEventListener('click', () => {
            aiChatModal.classList.remove('hidden');
        });
        
        // Service Worker Registration for PWA
        if ('serviceWorker' in navigator) {
            window.addEventListener('load', () => {
                navigator.serviceWorker.register('/sw.js').then(registration => {
                    console.log('ServiceWorker registration successful with scope: ', registration.scope);
                }).catch(err => {
                    console.log('ServiceWorker registration failed: ', err);
                });
            });
        }
    </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=isubbu/first" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>