File size: 89,029 Bytes
4c0e4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749b77e
4c0e4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749b77e
 
4c0e4f4
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
 
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
749b77e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c0e4f4
 
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
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LeadGen Pro - AI-Powered Lead Management</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">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        .sidebar {
            transition: all 0.3s ease;
        }
        .chat-message {
            max-width: 80%;
        }
        .lead-status-new {
            background-color: #EFF6FF;
            color: #3B82F6;
        }
        .lead-status-contacted {
            background-color: #ECFDF5;
            color: #10B981;
        }
        .lead-status-closed {
            background-color: #FEF2F2;
            color: #EF4444;
        }
        .lead-status-scheduled {
            background-color: #F5F3FF;
            color: #8B5CF6;
        }
        .lead-status-interested {
            background-color: #FEF3C7;
            color: #D97706;
        }
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
                position: absolute;
                z-index: 50;
                height: 100vh;
            }
            .sidebar.active {
                transform: translateX(0);
            }
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="flex h-screen overflow-hidden">
        <!-- Sidebar -->
        <div class="sidebar bg-white w-64 border-r border-gray-200 flex flex-col">
            <div class="p-4 border-b border-gray-200">
                <h1 class="text-xl font-bold text-indigo-600">LeadGen Pro</h1>
                <p class="text-xs text-gray-500">AI-Powered Lead Management</p>
            </div>
            <nav class="flex-1 overflow-y-auto p-4">
                <div class="space-y-1">
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md bg-indigo-50 text-indigo-700">
                        <i class="fas fa-tachometer-alt mr-3 text-indigo-600"></i>
                        Dashboard
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fas fa-users mr-3 text-gray-500"></i>
                        Leads
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fas fa-envelope mr-3 text-gray-500"></i>
                        Email Campaigns
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fab fa-whatsapp mr-3 text-gray-500"></i>
                        WhatsApp
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fas fa-robot mr-3 text-gray-500"></i>
                        AI Assistant
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fas fa-chart-bar mr-3 text-gray-500"></i>
                        Reports
                    </a>
                    <a href="#" class="flex items-center px-3 py-2 text-sm font-medium rounded-md text-gray-600 hover:bg-gray-100">
                        <i class="fas fa-cog mr-3 text-gray-500"></i>
                        Settings
                    </a>
                </div>
            </nav>
            <div class="p-4 border-t border-gray-200">
                <div class="flex items-center">
                    <img class="w-8 h-8 rounded-full" src="https://randomuser.me/api/portraits/men/32.jpg" alt="User">
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-700">John Doe</p>
                        <p class="text-xs text-gray-500">Admin</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- Main content -->
        <div class="flex-1 overflow-auto">
            <!-- Mobile header -->
            <div class="lg:hidden bg-white border-b border-gray-200 p-4 flex items-center justify-between">
                <button id="sidebarToggle" class="text-gray-500">
                    <i class="fas fa-bars"></i>
                </button>
                <h1 class="text-lg font-medium text-gray-800">Dashboard</h1>
                <div class="w-6"></div> <!-- Spacer -->
            </div>

            <!-- Dashboard header -->
            <div class="bg-white border-b border-gray-200 p-6">
                <div class="flex justify-between items-center">
                    <div>
                        <h2 class="text-2xl font-bold text-gray-800">Lead Dashboard</h2>
                        <p class="text-gray-600">Manage and track your sales leads</p>
                    </div>
                    <button id="importLeadsBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md flex items-center">
                        <i class="fas fa-plus mr-2"></i>
                        Import Leads
                    </button>
                </div>
            </div>

            <!-- Stats -->
            <div class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                <div class="bg-white rounded-lg shadow p-6">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500">Total Leads</p>
                            <h3 class="text-2xl font-bold">1,248</h3>
                        </div>
                        <div class="bg-indigo-100 p-3 rounded-full">
                            <i class="fas fa-users text-indigo-600"></i>
                        </div>
                    </div>
                    <div class="mt-4">
                        <div class="h-2 bg-gray-200 rounded-full">
                            <div class="h-2 bg-indigo-600 rounded-full" style="width: 75%"></div>
                        </div>
                        <p class="text-xs text-gray-500 mt-2">+12% from last month</p>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow p-6">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500">New Leads</p>
                            <h3 class="text-2xl font-bold">342</h3>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-full">
                            <i class="fas fa-user-plus text-blue-600"></i>
                        </div>
                    </div>
                    <div class="mt-4">
                        <div class="h-2 bg-gray-200 rounded-full">
                            <div class="h-2 bg-blue-600 rounded-full" style="width: 45%"></div>
                        </div>
                        <p class="text-xs text-gray-500 mt-2">+8% from last month</p>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow p-6">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500">Contacted</p>
                            <h3 class="text-2xl font-bold">576</h3>
                        </div>
                        <div class="bg-green-100 p-3 rounded-full">
                            <i class="fas fa-comment-dots text-green-600"></i>
                        </div>
                    </div>
                    <div class="mt-4">
                        <div class="h-2 bg-gray-200 rounded-full">
                            <div class="h-2 bg-green-600 rounded-full" style="width: 65%"></div>
                        </div>
                        <p class="text-xs text-gray-500 mt-2">+15% from last month</p>
                    </div>
                </div>
                <div class="bg-white rounded-lg shadow p-6">
                    <div class="flex items-center justify-between">
                        <div>
                            <p class="text-gray-500">Closed</p>
                            <h3 class="text-2xl font-bold">330</h3>
                        </div>
                        <div class="bg-purple-100 p-3 rounded-full">
                            <i class="fas fa-check-circle text-purple-600"></i>
                        </div>
                    </div>
                    <div class="mt-4">
                        <div class="h-2 bg-gray-200 rounded-full">
                            <div class="h-2 bg-purple-600 rounded-full" style="width: 30%"></div>
                        </div>
                        <p class="text-xs text-gray-500 mt-2">+5% from last month</p>
                    </div>
                </div>
            </div>

            <!-- Leads Page (hidden by default) -->
            <div id="leadsPage" class="hidden p-6">
                <div class="bg-white rounded-lg shadow">
                    <div class="p-4 border-b border-gray-200 flex justify-between items-center">
                        <h3 class="font-medium text-gray-800">All Leads</h3>
                        <div class="flex space-x-2">
                            <div class="relative">
                                <input type="text" id="leadSearch" placeholder="Search leads..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
                                <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
                            </div>
                            <select id="statusFilter" class="border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
                                <option value="all">All Status</option>
                                <option value="new">New</option>
                                <option value="contacted">Contacted</option>
                                <option value="interested">Interested</option>
                                <option value="scheduled">Scheduled</option>
                                <option value="closed">Closed</option>
                            </select>
                            <select id="sourceFilter" class="border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
                                <option value="all">All Sources</option>
                                <option value="website">Website</option>
                                <option value="referral">Referral</option>
                                <option value="social">Social Media</option>
                                <option value="event">Event</option>
                            </select>
                            <button id="exportLeads" class="bg-green-600 text-white px-3 py-2 rounded-md text-sm flex items-center">
                                <i class="fas fa-file-export mr-2"></i> Export
                            </button>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Phone</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Last Contact</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
                                </tr>
                            </thead>
                            <tbody id="leadsTableBody" class="bg-white divide-y divide-gray-200">
                                <!-- Leads will be populated here -->
                            </tbody>
                        </table>
                    </div>
                    <div class="p-4 border-t border-gray-200 flex items-center justify-between">
                        <div class="text-sm text-gray-500">
                            Showing <span id="leadsCount" class="font-medium">0</span> leads
                        </div>
                        <div class="flex space-x-2">
                            <button id="prevPage" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 disabled:opacity-50" disabled>
                                Previous
                            </button>
                            <button id="nextPage" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 disabled:opacity-50" disabled>
                                Next
                            </button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Dashboard Page -->
            <div id="dashboardPage" class="p-6 grid grid-cols-1 lg:grid-cols-3 gap-6">
                <!-- Leads table -->
                <div class="bg-white rounded-lg shadow col-span-2">
                    <div class="p-4 border-b border-gray-200 flex justify-between items-center">
                        <h3 class="font-medium text-gray-800">Recent Leads</h3>
                        <div class="flex space-x-2">
                            <div class="relative">
                                <input type="text" placeholder="Search leads..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
                                <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
                            </div>
                            <select class="border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
                                <option>All Status</option>
                                <option>New</option>
                                <option>Contacted</option>
                                <option>Interested</option>
                                <option>Scheduled</option>
                                <option>Closed</option>
                            </select>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Phone</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                                                <span class="text-indigo-600 font-medium">JD</span>
                                            </div>
                                            <div class="ml-4">
                                                <div class="text-sm font-medium text-gray-900">John Doe</div>
                                                <div class="text-sm text-gray-500">Acme Corp</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">john.doe@example.com</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">+1 555-123-4567</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 py-1 text-xs rounded-full lead-status-new">New</span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                            <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-pink-100 flex items-center justify-center">
                                                <span class="text-pink-600 font-medium">AS</span>
                                            </div>
                                            <div class="ml-4">
                                                <div class="text-sm font-medium text-gray-900">Alice Smith</div>
                                                <div class="text-sm text-gray-500">Tech Solutions</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">alice.smith@example.com</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">+1 555-987-6543</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 py-1 text-xs rounded-full lead-status-contacted">Contacted</span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                            <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-yellow-100 flex items-center justify-center">
                                                <span class="text-yellow-600 font-medium">RJ</span>
                                            </div>
                                            <div class="ml-4">
                                                <div class="text-sm font-medium text-gray-900">Robert Johnson</div>
                                                <div class="text-sm text-gray-500">Global Inc</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">robert.j@example.com</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">+1 555-456-7890</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 py-1 text-xs rounded-full lead-status-interested">Interested</span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                            <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center">
                                                <span class="text-purple-600 font-medium">MB</span>
                                            </div>
                                            <div class="ml-4">
                                                <div class="text-sm font-medium text-gray-900">Maria Brown</div>
                                                <div class="text-sm text-gray-500">Digital Agency</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">maria.b@example.com</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">+1 555-789-0123</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 py-1 text-xs rounded-full lead-status-scheduled">Scheduled</span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                            <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-red-100 flex items-center justify-center">
                                                <span class="text-red-600 font-medium">DW</span>
                                            </div>
                                            <div class="ml-4">
                                                <div class="text-sm font-medium text-gray-900">David Wilson</div>
                                                <div class="text-sm text-gray-500">Finance Group</div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">david.w@example.com</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">+1 555-234-5678</td>
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <span class="px-2 py-1 text-xs rounded-full lead-status-closed">Closed</span>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                            <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="p-4 border-t border-gray-200 flex items-center justify-between">
                        <div class="text-sm text-gray-500">
                            Showing <span class="font-medium">1</span> to <span class="font-medium">5</span> of <span class="font-medium">1248</span> leads
                        </div>
                        <div class="flex space-x-2">
                            <button class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
                                Previous
                            </button>
                            <button class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
                                Next
                            </button>
                        </div>
                    </div>
                </div>

                <!-- Right sidebar -->
                <div class="space-y-6">
                    <!-- Status distribution -->
                    <div class="bg-white rounded-lg shadow p-6">
                        <h3 class="font-medium text-gray-800 mb-4">Lead Status Distribution</h3>
                        <div class="h-64">
                            <canvas id="statusChart"></canvas>
                        </div>
                    </div>

                    <!-- Quick actions -->
                    <div class="bg-white rounded-lg shadow p-6">
                        <h3 class="font-medium text-gray-800 mb-4">Quick Actions</h3>
                        <div class="space-y-3">
                            <button class="w-full flex items-center justify-between px-4 py-3 bg-indigo-50 text-indigo-700 rounded-md hover:bg-indigo-100">
                                <span>Import Leads</span>
                                <i class="fas fa-file-import"></i>
                            </button>
                            <button class="w-full flex items-center justify-between px-4 py-3 bg-green-50 text-green-700 rounded-md hover:bg-green-100">
                                <span>Send Bulk WhatsApp</span>
                                <i class="fab fa-whatsapp"></i>
                            </button>
                            <button class="w-full flex items-center justify-between px-4 py-3 bg-blue-50 text-blue-700 rounded-md hover:bg-blue-100">
                                <span>Start AI Campaign</span>
                                <i class="fas fa-robot"></i>
                            </button>
                            <button class="w-full flex items-center justify-between px-4 py-3 bg-purple-50 text-purple-700 rounded-md hover:bg-purple-100">
                                <span>Generate Report</span>
                                <i class="fas fa-file-export"></i>
                            </button>
                        </div>
                    </div>

                    <!-- AI Assistant -->
                    <div class="bg-white rounded-lg shadow p-6">
                        <h3 class="font-medium text-gray-800 mb-4">AI Assistant</h3>
                        <div class="space-y-3">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center">
                                    <i class="fas fa-robot text-blue-600"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm text-gray-700">I can help you engage with leads automatically. Would you like me to:</p>
                                </div>
                            </div>
                            <div class="space-y-2">
                                <button class="w-full text-left px-4 py-2 bg-gray-100 rounded-md hover:bg-gray-200 text-sm">
                                    <i class="fas fa-comment-dots mr-2 text-blue-500"></i> Chat with new leads
                                </button>
                                <button class="w-full text-left px-4 py-2 bg-gray-100 rounded-md hover:bg-gray-200 text-sm">
                                    <i class="fas fa-calendar-check mr-2 text-green-500"></i> Schedule meetings
                                </button>
                                <button class="w-full text-left px-4 py-2 bg-gray-100 rounded-md hover:bg-gray-200 text-sm">
                                    <i class="fas fa-chart-line mr-2 text-purple-500"></i> Analyze lead data
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Lead details modal (hidden by default) -->
            <div id="leadModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
                <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
                    <div class="fixed inset-0 transition-opacity" aria-hidden="true">
                        <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
                    </div>
                    <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
                    <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-3xl sm:w-full">
                        <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                            <div class="sm:flex sm:items-start">
                                <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
                                    <div class="flex justify-between items-center">
                                        <h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title">Lead Details</h3>
                                        <button id="closeModal" class="text-gray-400 hover:text-gray-500">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="mt-4">
                                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                            <div>
                                                <div class="flex items-center mb-6">
                                                    <div class="flex-shrink-0 h-16 w-16 rounded-full bg-indigo-100 flex items-center justify-center">
                                                        <span class="text-indigo-600 text-xl font-medium">JD</span>
                                                    </div>
                                                    <div class="ml-4">
                                                        <h4 class="text-lg font-medium text-gray-900">John Doe</h4>
                                                        <p class="text-gray-500">Acme Corp</p>
                                                    </div>
                                                </div>
                                                <div class="space-y-4">
                                                    <div>
                                                        <label class="block text-sm font-medium text-gray-700">Email</label>
                                                        <p class="mt-1 text-sm text-gray-900">john.doe@example.com</p>
                                                    </div>
                                                    <div>
                                                        <label class="block text-sm font-medium text-gray-700">Phone</label>
                                                        <p class="mt-1 text-sm text-gray-900">+1 555-123-4567</p>
                                                    </div>
                                                    <div>
                                                        <label class="block text-sm font-medium text-gray-700">Source</label>
                                                        <p class="mt-1 text-sm text-gray-900">Website Form</p>
                                                    </div>
                                                </div>
                                            </div>
                                            <div>
                                                <div class="mb-6">
                                                    <label class="block text-sm font-medium text-gray-700">Status</label>
                                                    <select class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                        <option>New</option>
                                                        <option selected>Contacted</option>
                                                        <option>Interested</option>
                                                        <option>Scheduled</option>
                                                        <option>Closed</option>
                                                    </select>
                                                </div>
                                                <div class="mb-6">
                                                    <label class="block text-sm font-medium text-gray-700">Notes</label>
                                                    <textarea rows="3" class="mt-1 block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border border-gray-300 rounded-md">Interested in our premium plan. Wants to discuss pricing options.</textarea>
                                                </div>
                                                <div class="flex space-x-3">
                                                    <button class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                                                        <i class="fas fa-envelope mr-2"></i> Email
                                                    </button>
                                                    <button class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
                                                        <i class="fab fa-whatsapp mr-2"></i> WhatsApp
                                                    </button>
                                                    <button class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                                                        <i class="fas fa-robot mr-2"></i> AI Chat
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
                            <button type="button" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:ml-3 sm:w-auto sm:text-sm">
                                Save Changes
                            </button>
                            <button id="cancelModal" type="button" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
                                Cancel
                            </button>
                        </div>
                    </div>
                </div>
            </div>

            <!-- AI Chat modal (hidden by default) -->
            <div id="chatModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
                <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
                    <div class="fixed inset-0 transition-opacity" aria-hidden="true">
                        <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
                    </div>
                    <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
                    <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-2xl sm:w-full">
                        <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                            <div class="sm:flex sm:items-start">
                                <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
                                    <div class="flex justify-between items-center">
                                        <div class="flex items-center">
                                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center">
                                                <i class="fas fa-robot text-blue-600"></i>
                                            </div>
                                            <h3 class="ml-3 text-lg leading-6 font-medium text-gray-900">AI Assistant - John Doe</h3>
                                        </div>
                                        <button id="closeChatModal" class="text-gray-400 hover:text-gray-500">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="mt-4">
                                        <div class="h-96 overflow-y-auto p-4 bg-gray-50 rounded-lg">
                                            <div class="space-y-4">
                                                <!-- AI message -->
                                                <div class="flex items-start">
                                                    <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center">
                                                        <i class="fas fa-robot text-blue-600"></i>
                                                    </div>
                                                    <div class="ml-3">
                                                        <div class="bg-white p-3 rounded-lg shadow-sm chat-message">
                                                            <p class="text-sm text-gray-700">Hello John! I'm the AI assistant from LeadGen Pro. I understand you're interested in our services. How can I help you today?</p>
                                                        </div>
                                                        <p class="text-xs text-gray-500 mt-1">2 minutes ago</p>
                                                    </div>
                                                </div>
                                                <!-- User message -->
                                                <div class="flex items-start justify-end">
                                                    <div class="ml-3">
                                                        <div class="bg-indigo-100 p-3 rounded-lg shadow-sm chat-message">
                                                            <p class="text-sm text-gray-700">Hi, I'd like to know more about your pricing plans.</p>
                                                        </div>
                                                        <p class="text-xs text-gray-500 mt-1 text-right">1 minute ago</p>
                                                    </div>
                                                    <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center">
                                                        <span class="text-indigo-600 text-xs font-medium">JD</span>
                                                    </div>
                                                </div>
                                                <!-- AI message -->
                                                <div class="flex items-start">
                                                    <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center">
                                                        <i class="fas fa-robot text-blue-600"></i>
                                                    </div>
                                                    <div class="ml-3">
                                                        <div class="bg-white p-3 rounded-lg shadow-sm chat-message">
                                                            <p class="text-sm text-gray-700">We offer three pricing tiers: Basic ($29/month), Professional ($79/month), and Enterprise (custom pricing). Which one are you most interested in?</p>
                                                        </div>
                                                        <p class="text-xs text-gray-500 mt-1">Just now</p>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="mt-4">
                                            <div class="flex">
                                                <input type="text" placeholder="Type your message..." class="flex-1 border border-gray-300 rounded-l-md px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                                <button class="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
                                                    <i class="fas fa-paper-plane"></i>
                                                </button>
                                            </div>
                                            <div class="mt-2 flex justify-between">
                                                <button class="text-xs text-blue-600 hover:text-blue-800">
                                                    <i class="fas fa-calendar-alt mr-1"></i> Schedule Meeting
                                                </button>
                                                <button class="text-xs text-green-600 hover:text-green-800">
                                                    <i class="fab fa-whatsapp mr-1"></i> Switch to WhatsApp
                                                </button>
                                                <button class="text-xs text-gray-600 hover:text-gray-800">
                                                    <i class="fas fa-history mr-1"></i> View History
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Import leads modal (hidden by default) -->
            <div id="importModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
                <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
                    <div class="fixed inset-0 transition-opacity" aria-hidden="true">
                        <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
                    </div>
                    <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
                    <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
                        <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                            <div class="sm:flex sm:items-start">
                                <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
                                    <div class="flex justify-between items-center">
                                        <h3 class="text-lg leading-6 font-medium text-gray-900">Import Leads</h3>
                                        <button id="closeImportModal" class="text-gray-400 hover:text-gray-500">
                                            <i class="fas fa-times"></i>
                                        </button>
                                    </div>
                                    <div class="mt-4">
                                        <div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center">
                                            <i class="fas fa-file-csv text-4xl text-indigo-600 mb-3"></i>
                                            <p class="text-sm text-gray-600 mb-4">Drag and drop your CSV file here, or click to browse</p>
                                            <input type="file" id="fileUpload" class="hidden" accept=".csv">
                                            <label for="fileUpload" class="cursor-pointer inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                                                <i class="fas fa-upload mr-2"></i> Select File
                                            </label>
                                        </div>
                                        <div class="mt-4">
                                            <p class="text-sm text-gray-500">Your CSV file should include columns for: Name, Email, Phone, Company (optional). <a href="#" class="text-indigo-600 hover:text-indigo-800">Download template</a></p>
                                        </div>
                                        <div class="mt-6">
                                            <label class="block text-sm font-medium text-gray-700">Default Status</label>
                                            <select class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                <option>New</option>
                                                <option>Contacted</option>
                                                <option>Interested</option>
                                                <option>Scheduled</option>
                                                <option>Closed</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
                            <button type="button" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:ml-3 sm:w-auto sm:text-sm">
                                Import Leads
                            </button>
                            <button id="cancelImportModal" type="button" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
                                Cancel
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Page navigation
        const leadsLink = document.getElementById('leadsLink');
        const leadsPage = document.getElementById('leadsPage');
        const dashboardPage = document.getElementById('dashboardPage');

        leadsLink.addEventListener('click', function(e) {
            e.preventDefault();
            dashboardPage.classList.add('hidden');
            leadsPage.classList.remove('hidden');
            loadLeads();
            document.querySelector('.sidebar').classList.remove('active');
        });

        // Sample leads data
        const sampleLeads = [
            { id: 1, name: 'John Doe', email: 'john.doe@example.com', phone: '+1 555-123-4567', company: 'Acme Corp', status: 'new', source: 'website', lastContact: '2023-05-15' },
            { id: 2, name: 'Alice Smith', email: 'alice.smith@example.com', phone: '+1 555-987-6543', company: 'Tech Solutions', status: 'contacted', source: 'referral', lastContact: '2023-05-14' },
            { id: 3, name: 'Robert Johnson', email: 'robert.j@example.com', phone: '+1 555-456-7890', company: 'Global Inc', status: 'interested', source: 'social', lastContact: '2023-05-13' },
            { id: 4, name: 'Maria Brown', email: 'maria.b@example.com', phone: '+1 555-789-0123', company: 'Digital Agency', status: 'scheduled', source: 'event', lastContact: '2023-05-12' },
            { id: 5, name: 'David Wilson', email: 'david.w@example.com', phone: '+1 555-234-5678', company: 'Finance Group', status: 'closed', source: 'website', lastContact: '2023-05-11' },
            { id: 6, name: 'Sarah Davis', email: 'sarah.d@example.com', phone: '+1 555-345-6789', company: 'Marketing Pros', status: 'new', source: 'referral', lastContact: '2023-05-10' },
            { id: 7, name: 'Michael Miller', email: 'michael.m@example.com', phone: '+1 555-456-7890', company: 'Tech Innovators', status: 'contacted', source: 'social', lastContact: '2023-05-09' },
            { id: 8, name: 'Emily Wilson', email: 'emily.w@example.com', phone: '+1 555-567-8901', company: 'Creative Minds', status: 'interested', source: 'event', lastContact: '2023-05-08' }
        ];

        // Filter and display leads
        function loadLeads() {
            const searchTerm = document.getElementById('leadSearch').value.toLowerCase();
            const statusFilter = document.getElementById('statusFilter').value;
            const sourceFilter = document.getElementById('sourceFilter').value;
            
            const filteredLeads = sampleLeads.filter(lead => {
                const matchesSearch = 
                    lead.name.toLowerCase().includes(searchTerm) ||
                    lead.email.toLowerCase().includes(searchTerm) ||
                    lead.phone.includes(searchTerm) ||
                    lead.company.toLowerCase().includes(searchTerm);
                
                const matchesStatus = statusFilter === 'all' || lead.status === statusFilter;
                const matchesSource = sourceFilter === 'all' || lead.source === sourceFilter;
                
                return matchesSearch && matchesStatus && matchesSource;
            });
            
            const tbody = document.getElementById('leadsTableBody');
            tbody.innerHTML = '';
            
            filteredLeads.forEach(lead => {
                const initials = lead.name.split(' ').map(n => n[0]).join('').toUpperCase();
                const row = document.createElement('tr');
                row.className = 'cursor-pointer hover:bg-gray-50';
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap">
                        <div class="flex items-center">
                            <div class="flex-shrink-0 h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                                <span class="text-indigo-600 font-medium">${initials}</span>
                            </div>
                            <div class="ml-4">
                                <div class="text-sm font-medium text-gray-900">${lead.name}</div>
                                <div class="text-sm text-gray-500">${lead.company}</div>
                            </div>
                        </div>
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${lead.email}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${lead.phone}</td>
                    <td class="px-6 py-4 whitespace-nowrap">
                        <span class="px-2 py-1 text-xs rounded-full lead-status-${lead.status}">
                            ${lead.status.charAt(0).toUpperCase() + lead.status.slice(1)}
                        </span>
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                        ${lead.source.charAt(0).toUpperCase() + lead.source.slice(1)}
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                        ${new Date(lead.lastContact).toLocaleDateString()}
                    </td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                        <div class="flex space-x-2">
                            <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                            <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                            <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                        </div>
                    </td>
                `;
                tbody.appendChild(row);
            });
            
            document.getElementById('leadsCount').textContent = filteredLeads.length;
        }

        // Event listeners for filters
        document.getElementById('leadSearch').addEventListener('input', loadLeads);
        document.getElementById('statusFilter').addEventListener('change', loadLeads);
        document.getElementById('sourceFilter').addEventListener('change', loadLeads);

        // Export functionality
        document.getElementById('exportLeads').addEventListener('click', function() {
            alert('Export functionality would be implemented here');
        });

        // Mobile sidebar toggle
        document.getElementById('sidebarToggle').addEventListener('click', function() {
            document.querySelector('.sidebar').classList.toggle('active');
        });

        // Lead modal
        const leadModal = document.getElementById('leadModal');
        const closeModal = document.getElementById('closeModal');
        const cancelModal = document.getElementById('cancelModal');

        // Show modal when clicking on a lead (for demo purposes)
        document.querySelectorAll('table tbody tr').forEach(row => {
            row.addEventListener('click', function() {
                leadModal.classList.remove('hidden');
            });
        });

        closeModal.addEventListener('click', function() {
            leadModal.classList.add('hidden');
        });

        cancelModal.addEventListener('click', function() {
            leadModal.classList.add('hidden');
        });

        // Chat modal
        const chatModal = document.getElementById('chatModal');
        const closeChatModal = document.getElementById('closeChatModal');

        // Show chat modal when clicking on AI chat button (for demo purposes)
        document.querySelectorAll('.fa-robot').forEach(icon => {
            icon.closest('button').addEventListener('click', function(e) {
                e.stopPropagation();
                chatModal.classList.remove('hidden');
            });
        });

        closeChatModal.addEventListener('click', function() {
            chatModal.classList.add('hidden');
        });

        // Import modal
        const importModal = document.getElementById('importModal');
        const closeImportModal = document.getElementById('closeImportModal');
        const cancelImportModal = document.getElementById('cancelImportModal');

        // Show import modal when clicking on import button (for demo purposes)
        document.querySelectorAll('button').forEach(btn => {
            if (btn.textContent.includes('Import Leads')) {
                btn.addEventListener('click', function() {
                    importModal.classList.remove('hidden');
                });
            }
        });

        closeImportModal.addEventListener('click', function() {
            importModal.classList.add('hidden');
        });

        cancelImportModal.addEventListener('click', function() {
            importModal.classList.add('hidden');
        });

        // Status chart
        const statusCtx = document.getElementById('statusChart').getContext('2d');
        const statusChart = new Chart(statusCtx, {
            type: 'doughnut',
            data: {
                labels: ['New', 'Contacted', 'Interested', 'Scheduled', 'Closed'],
                datasets: [{
                    data: [342, 576, 210, 98, 330],
                    backgroundColor: [
                        '#3B82F6',
                        '#10B981',
                        '#F59E0B',
                        '#8B5CF6',
                        '#EF4444'
                    ],
                    borderWidth: 0
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        position: 'right',
                    }
                },
                cutout: '70%'
            }
        });

        // Enhanced import functionality
        const importLeadsBtn = document.getElementById('importLeadsBtn');
        const fileUpload = document.getElementById('fileUpload');
        const importSubmitBtn = document.querySelector('#importModal button.bg-indigo-600');
        const leadsTable = document.querySelector('table tbody');
        
        // Show import modal
        importLeadsBtn.addEventListener('click', function() {
            importModal.classList.remove('hidden');
        });

        // Handle file import
        importSubmitBtn.addEventListener('click', function() {
            const file = fileUpload.files[0];
            if (!file) {
                alert('Please select a file first');
                return;
            }

            const reader = new FileReader();
            reader.onload = function(e) {
                const contents = e.target.result;
                const lines = contents.split('\n');
                const statusSelect = document.querySelector('#importModal select');
                const defaultStatus = statusSelect.value.toLowerCase();
                
                // Skip header row and process each line
                for (let i = 1; i < lines.length; i++) {
                    if (lines[i].trim() === '') continue;
                    
                    const [name, email, phone, company] = lines[i].split(',');
                    if (!name || !email || !phone) continue;
                    
                    // Generate initials for avatar
                    const initials = name.split(' ').map(n => n[0]).join('').toUpperCase();
                    
                    // Create new table row
                    const newRow = document.createElement('tr');
                    newRow.className = 'cursor-pointer hover:bg-gray-50';
                    newRow.innerHTML = `
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="flex items-center">
                                <div class="flex-shrink-0 h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                                    <span class="text-indigo-600 font-medium">${initials}</span>
                                </div>
                                <div class="ml-4">
                                    <div class="text-sm font-medium text-gray-900">${name}</div>
                                    <div class="text-sm text-gray-500">${company || 'No company'}</div>
                                </div>
                            </div>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${email}</td>
                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${phone}</td>
                        <td class="px-6 py-4 whitespace-nowrap">
                            <span class="px-2 py-1 text-xs rounded-full lead-status-${defaultStatus}">${defaultStatus.charAt(0).toUpperCase() + defaultStatus.slice(1)}</span>
                        </td>
                        <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                            <div class="flex space-x-2">
                                <button class="text-indigo-600 hover:text-indigo-900"><i class="fas fa-envelope"></i></button>
                                <button class="text-green-600 hover:text-green-900"><i class="fab fa-whatsapp"></i></button>
                                <button class="text-blue-600 hover:text-blue-900"><i class="fas fa-robot"></i></button>
                                <button class="text-gray-600 hover:text-gray-900"><i class="fas fa-ellipsis-v"></i></button>
                            </div>
                        </td>
                    `;
                    
                    // Add click handler to show details
                    newRow.addEventListener('click', function() {
                        // Update modal with new lead data
                        document.getElementById('modal-title').textContent = 'Lead Details - ' + name;
                        document.querySelector('#leadModal .text-indigo-600').textContent = initials;
                        document.querySelector('#leadModal .text-lg').textContent = name;
                        document.querySelector('#leadModal .text-gray-500').textContent = company || 'No company';
                        document.querySelector('#leadModal .text-sm.text-gray-900:nth-of-type(1)').textContent = email;
                        document.querySelector('#leadModal .text-sm.text-gray-900:nth-of-type(2)').textContent = phone;
                        document.querySelector('#leadModal select option[selected]').removeAttribute('selected');
                        document.querySelector(`#leadModal select option[value="${defaultStatus.charAt(0).toUpperCase() + defaultStatus.slice(1)}"]`).setAttribute('selected', 'selected');
                        
                        leadModal.classList.remove('hidden');
                    });
                    
                    leadsTable.prepend(newRow);
                }
                
                alert(`Successfully imported ${lines.length - 1} leads`);
                importModal.classList.add('hidden');
                fileUpload.value = '';
            };
            
            reader.readAsText(file);
        });

        // Handle drag and drop for file upload
        const dropArea = document.querySelector('#importModal .border-dashed');
        
        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, preventDefaults, false);
        });

        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }

        ['dragenter', 'dragover'].forEach(eventName => {
            dropArea.addEventListener(eventName, highlight, false);
        });

        ['dragleave', 'drop'].forEach(eventName => {
            dropArea.addEventListener(eventName, unhighlight, false);
        });

        function highlight() {
            dropArea.classList.add('border-indigo-500', 'bg-indigo-50');
        }

        function unhighlight() {
            dropArea.classList.remove('border-indigo-500', 'bg-indigo-50');
        }

        dropArea.addEventListener('drop', handleDrop, false);

        function handleDrop(e) {
            const dt = e.dataTransfer;
            const files = dt.files;
            fileUpload.files = files;
            
            // Trigger change event
            const event = new Event('change');
            fileUpload.dispatchEvent(event);
        }

        // Simulate AI chat
        const chatInput = document.querySelector('#chatModal input[type="text"]');
        const chatSendBtn = document.querySelector('#chatModal button.bg-blue-600');
        const chatContainer = document.querySelector('#chatModal .overflow-y-auto');

        chatSendBtn.addEventListener('click', function() {
            if (chatInput.value.trim() === '') return;
            
            // Add user message
            const userMessage = document.createElement('div');
            userMessage.className = 'flex items-start justify-end';
            userMessage.innerHTML = `
                <div class="ml-3">
                    <div class="bg-indigo-100 p-3 rounded-lg shadow-sm chat-message">
                        <p class="text-sm text-gray-700">${chatInput.value}</p>
                    </div>
                    <p class="text-xs text-gray-500 mt-1 text-right">Just now</p>
                </div>
                <div class="flex-shrink-0 h-8 w-8 rounded-full bg-indigo-100 flex items-center justify-center">
                    <span class="text-indigo-600 text-xs font-medium">JD</span>
                </div>
            `;
            chatContainer.appendChild(userMessage);
            
            // Simulate AI response after a delay
            setTimeout(() => {
                const aiMessage = document.createElement('div');
                aiMessage.className = 'flex items-start';
                aiMessage.innerHTML = `
                    <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center">
                        <i class="fas fa-robot text-blue-600"></i>
                    </div>
                    <div class="ml-3">
                        <div class="bg-white p-3 rounded-lg shadow-sm chat-message">
                            <p class="text-sm text-gray-700">${getAIResponse(chatInput.value)}</p>
                        </div>
                        <p class="text-xs text-gray-500 mt-1">Just now</p>
                    </div>
                `;
                chatContainer.appendChild(aiMessage);
                chatContainer.scrollTop = chatContainer.scrollHeight;
            }, 1000);
            
            chatInput.value = '';
            chatContainer.scrollTop = chatContainer.scrollHeight;
        });

        function getAIResponse(message) {
            const lowerMessage = message.toLowerCase();
            
            if (lowerMessage.includes('pricing') || lowerMessage.includes('price') || lowerMessage.includes('cost')) {
                return "We offer three pricing tiers: Basic ($29/month), Professional ($79/month), and Enterprise (custom pricing). Would you like me to schedule a call to discuss which option would be best for you?";
            } else if (lowerMessage.includes('feature') || lowerMessage.includes('what does it do')) {
                return "Our platform includes lead management, automated outreach, AI-powered conversations, and detailed analytics. The Professional plan adds team collaboration and advanced reporting. Would you like a demo?";
            } else if (lowerMessage.includes('demo') || lowerMessage.includes('see it')) {
                return "I can schedule a 30-minute demo with one of our product specialists. Would tomorrow at 2pm work for you?";
            } else if (lowerMessage.includes('yes') || lowerMessage.includes('sure') || lowerMessage.includes('okay')) {
                return "Great! I've scheduled a demo for tomorrow at 2pm. You'll receive a calendar invitation shortly. Is there anything else I can help with?";
            } else if (lowerMessage.includes('no') || lowerMessage.includes('not now')) {
                return "No problem! Feel free to reach out if you have any other questions. Have a great day!";
            } else {
                return "I'd be happy to help with that. Could you tell me more about what you're looking for in a lead management system?";
            }
        }

        // Email Campaign Modal Functionality
        const emailCampaignModal = document.getElementById('emailCampaignModal');
        const emailCampaignsLink = document.getElementById('emailCampaignsLink');
        const closeEmailModal = document.getElementById('closeEmailModal');
        const generateTemplateBtn = document.getElementById('generateTemplateBtn');
        const previewEmailBtn = document.getElementById('previewEmailBtn');
        const sendTestEmailBtn = document.getElementById('sendTestEmailBtn');
        const launchCampaignBtn = document.getElementById('launchCampaignBtn');
        const campaignGoal = document.getElementById('campaignGoal');
        const emailTemplate = document.getElementById('emailTemplate');

        // Show email campaign modal
        emailCampaignsLink.addEventListener('click', function(e) {
            e.preventDefault();
            emailCampaignModal.classList.remove('hidden');
        });

        // Close modal
        closeEmailModal.addEventListener('click', function() {
            emailCampaignModal.classList.add('hidden');
        });

        // Generate AI template
        generateTemplateBtn.addEventListener('click', function() {
            if (!campaignGoal.value.trim()) {
                alert('Please enter a campaign goal first');
                return;
            }

            // Show loading state
            generateTemplateBtn.disabled = true;
            generateTemplateBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Generating...';

            // Simulate AI processing
            setTimeout(() => {
                const goal = campaignGoal.value;
                const sampleTemplate = `Subject: ${getSubjectLine(goal)}

Hi {FirstName},

${getOpeningLine(goal)}

${getBodyContent(goal)}

${getClosingLine(goal)}

Best regards,
{YourName}
{YourPosition}
${getCompanySignature()}`;

                emailTemplate.value = sampleTemplate;
                generateTemplateBtn.disabled = false;
                generateTemplateBtn.innerHTML = '<i class="fas fa-robot mr-2"></i> Generate Template';
            }, 2000);
        });

        // Helper functions for template generation
        function getSubjectLine(goal) {
            if (goal.toLowerCase().includes('demo')) return 'Let me show you how {Company} can help {TheirCompany}';
            if (goal.toLowerCase().includes('feature')) return 'New feature that will help {TheirCompany}';
            return `How {Company} can help {TheirCompany}`;
        }

        function getOpeningLine(goal) {
            if (goal.toLowerCase().includes('demo')) return 'I noticed {TheirCompany} is in the {Industry} space and thought our solution might be a great fit.';
            if (goal.toLowerCase().includes('feature')) return 'We recently launched a new feature that I believe could significantly benefit {TheirCompany}.';
            return 'I wanted to reach out because I believe our solution could help {TheirCompany} with {PainPoint}.';
        }

        function getBodyContent(goal) {
            if (goal.toLowerCase().includes('demo')) return 'Would you be available for a quick 30-minute demo this week? I can show you exactly how we help companies like yours with {ValueProposition}.';
            if (goal.toLowerCase().includes('feature')) return 'Our new {FeatureName} helps companies in your industry by {Benefit}. Based on my research, this could help {TheirCompany} with {SpecificNeed}.';
            return 'Our platform helps companies like yours by {ValueProposition}. I'd love to schedule a quick call to discuss how we can help {TheirCompany} specifically.';
        }

        function getClosingLine(goal) {
            if (goal.toLowerCase().includes('demo')) return 'Let me know a time that works for you, or feel free to book directly on my calendar: {CalendarLink}';
            if (goal.toLowerCase().includes('feature')) return 'I'd be happy to walk you through this in more detail if you're interested.';
            return 'Looking forward to hearing your thoughts!';
        }

        function getCompanySignature() {
            return '{CompanyWebsite}';
        }

        // Preview email
        previewEmailBtn.addEventListener('click', function() {
            if (!emailTemplate.value.trim()) {
                alert('Please generate or enter an email template first');
                return;
            }
            alert('This would show a preview of the email with sample personalization');
        });

        // Send test email
        sendTestEmailBtn.addEventListener('click', function() {
            if (!emailTemplate.value.trim()) {
                alert('Please generate or enter an email template first');
                return;
            }
            alert('Test email sent to your address!');
        });

        // Launch campaign
        launchCampaignBtn.addEventListener('click', function() {
            if (!emailTemplate.value.trim()) {
                alert('Please generate or enter an email template first');
                return;
            }

            const leadFilter = document.getElementById('leadFilter').value;
            const personalization = document.getElementById('personalizationLevel').value;
            const schedule = document.getElementById('emailSchedule').value;
            const followUp = document.getElementById('followUpSetting').value;

            alert(`Campaign launched!\n\nTarget: ${leadFilter}\nPersonalization: ${personalization}\nSchedule: ${schedule}\nFollow-up: ${followUp}`);
            emailCampaignModal.classList.add('hidden');
        });
    </script>

    <!-- Email Campaign Modal -->
    <div id="emailCampaignModal" class="fixed inset-0 z-50 hidden overflow-y-auto">
        <div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
            <div class="fixed inset-0 transition-opacity" aria-hidden="true">
                <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
            </div>
            <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
            <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-4xl sm:w-full">
                <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                    <div class="sm:flex sm:items-start">
                        <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
                            <div class="flex justify-between items-center">
                                <h3 class="text-lg leading-6 font-medium text-gray-900">AI-Powered Email Campaign</h3>
                                <button id="closeEmailModal" class="text-gray-400 hover:text-gray-500">
                                    <i class="fas fa-times"></i>
                                </button>
                            </div>
                            <div class="mt-4">
                                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                                    <div class="col-span-2">
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">Campaign Goal</label>
                                            <textarea id="campaignGoal" rows="2" class="mt-1 block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border border-gray-300 rounded-md" placeholder="What do you want to achieve with this campaign? (e.g. Schedule demos, promote new feature, etc.)"></textarea>
                                        </div>
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">AI-Generated Email Template</label>
                                            <textarea id="emailTemplate" rows="8" class="mt-1 block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border border-gray-300 rounded-md" placeholder="AI will generate this based on your goal and lead data"></textarea>
                                        </div>
                                        <div class="flex justify-between">
                                            <button id="generateTemplateBtn" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                                                <i class="fas fa-robot mr-2"></i> Generate Template
                                            </button>
                                            <div class="flex space-x-2">
                                                <button id="previewEmailBtn" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md shadow-sm text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                                                    <i class="fas fa-eye mr-2"></i> Preview
                                                </button>
                                                <button id="sendTestEmailBtn" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
                                                    <i class="fas fa-paper-plane mr-2"></i> Send Test
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div>
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">Target Leads</label>
                                            <select id="leadFilter" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                <option value="all">All Leads</option>
                                                <option value="new">New Leads</option>
                                                <option value="contacted">Contacted</option>
                                                <option value="interested">Interested</option>
                                                <option value="scheduled">Scheduled</option>
                                                <option value="custom">Custom Filter</option>
                                            </select>
                                        </div>
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">Schedule</label>
                                            <select id="emailSchedule" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                <option value="now">Send Immediately</option>
                                                <option value="morning">Send Tomorrow Morning</option>
                                                <option value="evening">Send Tomorrow Evening</option>
                                                <option value="custom">Custom Schedule</option>
                                            </select>
                                        </div>
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">Personalization Level</label>
                                            <select id="personalizationLevel" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                <option value="basic">Basic (Name/Company)</option>
                                                <option value="moderate">Moderate (Industry Insights)</option>
                                                <option value="high">High (Custom Research)</option>
                                            </select>
                                        </div>
                                        <div class="mb-4">
                                            <label class="block text-sm font-medium text-gray-700">Follow-up</label>
                                            <select id="followUpSetting" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md">
                                                <option value="none">No Follow-up</option>
                                                <option value="3days">After 3 Days</option>
                                                <option value="1week">After 1 Week</option>
                                                <option value="custom">Custom Follow-up</option>
                                            </select>
                                        </div>
                                        <button id="launchCampaignBtn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-purple-600 text-base font-medium text-white hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500">
                                            <i class="fas fa-rocket mr-2"></i> Launch Campaign
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<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=RahymSupari/lead-management" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>