-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
6438 lines (6026 loc) · 359 KB
/
index.html
File metadata and controls
6438 lines (6026 loc) · 359 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>WhatsApp Manager</title>
<script src="https://unpkg.com/libphonenumber-js@1.11.4/bundle/libphonenumber-max.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet"/>
<style>
* { font-family: 'Inter', sans-serif; }
.sidebar-btn { transition: all .15s ease; }
.sidebar-btn.active { background: #25D366; color: white; }
.sidebar-btn:not(.active):hover { background: #f0fdf4; color: #15803d; }
.tab-panel { display: none !important; }
.tab-panel.active { display: block !important; }
textarea, input, select { transition: border-color .15s; }
textarea:focus, input:focus, select:focus { outline: none; border-color: #25D366; box-shadow: 0 0 0 3px rgba(37,211,102,.15); }
.chip-box input:focus { border-color: transparent !important; box-shadow: none !important; }
.response-box { font-family: 'Courier New', monospace; font-size: 13px; }
.btn-send { background: #25D366; transition: background .15s; }
.btn-send:hover { background: #1ebe5d; }
.btn-send:active { background: #17a34a; }
.pill { display: inline-block; background: #dcfce7; color: #166534; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill.error { background: #fee2e2; color: #991b1b; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
#config-modal { display: none; }
#config-modal.open { display: flex; }
.chip-box { display:flex; flex-wrap:wrap; gap:6px; border:1px solid #d1d5db; border-radius:0.5rem; padding:8px 10px; min-height:46px; cursor:text; background:#fff; }
.chip-box:focus-within { border-color:#25D366; box-shadow:0 0 0 3px rgba(37,211,102,.15); }
.chip { display:inline-flex; align-items:center; gap:4px; background:#dcfce7; color:#166534; border-radius:999px; padding:2px 8px 2px 10px; font-size:12px; font-weight:500; white-space:nowrap; }
.chip button { background:none; border:none; cursor:pointer; font-size:13px; line-height:1; padding:0 0 0 2px; color:inherit; opacity:.55; }
.chip button:hover { opacity:1; }
.btn-send:disabled { background:#9ca3af !important; cursor:not-allowed; }
.field-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.12) !important; }
.field-error-msg { color: #dc2626; font-size: 11px; margin-top: 4px; display: block; }
#instance-picker-dropdown .inst-opt {
display: flex; align-items: center; gap: 8px;
padding: 6px 12px; cursor: pointer; font-size: 13px; white-space: nowrap; color: #374151;
}
#instance-picker-dropdown .inst-opt:hover { background: #f3f4f6; }
#instance-picker-dropdown .inst-opt.active { font-weight: 600; color: #16a34a; }
/* ── Chat Feature ──────────────────────────────────────────────── */
#tab-chat { height: 100%; }
#tab-chat.active { display: flex !important; }
.chat-list-item { transition: background .1s; }
.chat-list-item.active { background-color: #f0f2f5; }
.chat-list-item:hover { background-color: #f5f6f6; }
.chat-bubble-out { background: #d9fdd3; border-radius: 8px 0 8px 8px; }
.chat-bubble-in { background: #ffffff; border-radius: 0 8px 8px 8px; }
.chat-date-sep { font-size: 12px; background: #e2ddd5; color: #54656f; border-radius: 8px; padding: 4px 12px; display: inline-block; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); }
.typing-dots span { display:inline-block; width:6px; height:6px; background:#8696a0; border-radius:50%; animation:typingBounce 1.4s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay:.2s; }
.typing-dots span:nth-child(3) { animation-delay:.4s; }
@keyframes typingBounce { 0%,80%,100%{transform:scale(0)} 40%{transform:scale(1)} }
.emoji-picker { max-height:280px; overflow-y:auto; }
.emoji-picker button { width:36px; height:36px; font-size:20px; cursor:pointer; border:none; background:none; border-radius:4px; }
.emoji-picker button:hover { background:#f0f0f0; }
.queue-drag-handle { cursor:grab; color:#d1d5db; padding:0 4px; user-select:none; line-height:1; font-size:16px; }
.queue-drag-handle:hover { color:#6b7280; }
.queue-drag-handle:active { cursor:grabbing; }
.qitem-dragging { opacity:0.35; box-shadow:0 4px 16px rgba(0,0,0,.12); }
.qitem-drop-placeholder { border:2px dashed #22c55e; border-radius:12px; background:#f0fdf4; min-height:52px; transition:min-height .1s; }
#chat-lightbox { background:rgba(0,0,0,.85); }
#chat-input { min-height:40px; line-height:1.4; }
#chat-input:focus { border-color:transparent !important; box-shadow:none !important; }
.chat-ctx-menu { position:fixed; z-index:200; background:#fff; border:1px solid #e5e7eb; border-radius:8px; box-shadow:0 4px 16px rgba(0,0,0,.12); min-width:160px; padding:4px 0; }
.chat-ctx-menu button { display:flex; align-items:center; gap:8px; width:100%; padding:8px 16px; font-size:13px; border:none; background:none; cursor:pointer; color:#374151; }
.chat-ctx-menu button:hover { background:#f3f4f6; }
.chat-react-picker { position:fixed; display:flex; gap:2px; background:#fff; border-radius:24px; box-shadow:0 2px 12px rgba(0,0,0,.15); padding:4px 8px; z-index:500; }
.chat-react-picker button { font-size:20px; border:none; background:none; cursor:pointer; padding:4px; border-radius:50%; }
.chat-react-picker button:hover { background:#f0f0f0; }
.chat-reaction-badge { display:inline-flex; align-items:center; gap:2px; background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:2px 7px; font-size:15px; cursor:default; box-shadow:0 1px 3px rgba(0,0,0,.08); transition:transform .1s; }
.chat-reaction-badge:hover { transform:scale(1.12); }
.chat-reaction-count { font-size:11px; color:#374151; font-weight:600; margin-left:2px; }
.chat-reactions { display:flex; gap:4px; flex-wrap:wrap; margin-top:3px; }
.chat-select-toolbar { background:#075e54; color:#fff; display:flex; align-items:center; gap:10px; padding:10px 16px; shrink-0; }
.chat-select-toolbar button { background:rgba(255,255,255,.18); color:#fff; border:none; border-radius:8px; padding:6px 14px; cursor:pointer; font-size:13px; font-weight:500; transition:background .15s; }
.chat-select-toolbar button:hover:not(:disabled) { background:rgba(255,255,255,.32); }
.chat-select-toolbar button:disabled { opacity:0.35; cursor:not-allowed; }
.chat-msg-selected .chat-sel-bubble { outline:2px solid #25D366; outline-offset:2px; background:#d2f8d2 !important; }
.chat-delete-modal { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:700; display:flex; align-items:center; justify-content:center; }
.chat-delete-box { background:#fff; border-radius:16px; padding:28px 24px 20px; min-width:280px; max-width:340px; width:90%; box-shadow:0 8px 32px rgba(0,0,0,.22); }
.chat-delete-title { font-size:17px; font-weight:500; color:#111827; margin:0 0 28px; }
.chat-delete-actions { display:flex; flex-direction:column; gap:10px; align-items:flex-end; }
.chat-delete-btn { background:none; border:1.5px solid #00a884; color:#00a884; border-radius:24px; padding:10px 24px; font-size:15px; font-weight:500; cursor:pointer; min-width:190px; text-align:center; transition:background .15s, border-color .15s, color .15s; }
.chat-delete-btn:hover:not(:disabled) { background:#e6f7f4; }
.chat-delete-btn:disabled { border-color:#d1d5db; color:#9ca3af; cursor:not-allowed; }
.chat-delete-btn.cancel { border-color:#d1d5db; color:#374151; min-width:120px; }
.chat-delete-btn.cancel:hover { background:#f3f4f6; }
.chat-toast { position:fixed; bottom:84px; left:50%; transform:translateX(-50%); background:#323232; color:#fff; padding:10px 22px; border-radius:8px; font-size:13px; z-index:1100; pointer-events:none; white-space:nowrap; box-shadow:0 2px 10px rgba(0,0,0,.2); }
.chat-toast-error { background:#ef4444; }
.chat-forward-modal { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:600; display:flex; align-items:center; justify-content:center; }
.chat-forward-box { background:#fff; border-radius:12px; width:340px; max-height:70vh; display:flex; flex-direction:column; box-shadow:0 8px 32px rgba(0,0,0,.2); overflow:hidden; }
.chat-forward-list { flex:1; overflow-y:auto; }
.chat-forward-item { display:flex; align-items:center; gap:10px; padding:10px 16px; cursor:pointer; transition:background .1s; }
.chat-forward-item:hover { background:#f3f4f6; }
.chat-filter-btn { background:#fff; color:#54656f; border-color:#d1d5db; cursor:pointer; transition:all .15s; }
.chat-filter-btn:hover { background:#f0f2f5; }
.chat-filter-btn.active { background:#e7fce9; color:#008069; border-color:#25D366; }
.chat-archived-bar { display:flex; align-items:center; gap:8px; padding:12px 16px; cursor:pointer; color:#008069; font-size:13px; font-weight:500; border-bottom:1px solid #f1f1f1; }
.chat-archived-bar:hover { background:#f5f6f6; }
.chat-ticks { cursor: pointer; display: inline-flex; align-items: center; vertical-align: middle; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.chat-ticks svg { transition: color 0.35s ease; }
.chat-ticks-static { display: inline-flex; align-items: center; vertical-align: middle; }
.chat-ticks-static svg { transition: color 0.35s ease; }
.chat-msg-info-popup { position:fixed; z-index:999; background:#fff; border-radius:10px; box-shadow:0 4px 24px rgba(0,0,0,.18); padding:12px 16px; min-width:200px; font-size:12px; color:#374151; }
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Header -->
<header class="bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between sticky top-0 z-50 shadow-sm">
<div class="flex items-center gap-3">
<div class="w-9 h-9 rounded-full bg-[#25D366] flex items-center justify-center">
<svg class="w-5 h-5 text-white" fill="currentColor" viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>
</div>
<div>
<h1 id="header-title" class="text-base font-bold text-gray-900">WhatsApp Manager</h1>
<p class="text-xs text-gray-500">WhatsApp Manager</p>
</div>
</div>
<div class="flex items-center gap-4">
<div class="flex items-center gap-2 bg-green-50 text-green-700 px-3 py-1.5 rounded-full text-sm font-medium border border-green-200">
<span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
Connected
</div>
<div class="text-xs text-gray-400 relative">
Instance:
<button id="header-instance-btn" onclick="openInstancePicker(event)"
class="font-semibold text-gray-600 hover:text-green-600 inline-flex items-center gap-1 focus:outline-none cursor-pointer"
title="Click to switch instance">
<span id="header-instance"></span>
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 9l-7 7-7-7"/></svg>
</button>
<div id="instance-picker-dropdown"
class="hidden absolute right-0 top-full mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1">
</div>
</div>
<button onclick="openConfig()" class="flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-800 border border-gray-200 hover:border-gray-300 px-3 py-1.5 rounded-lg transition-colors" title="Connection Settings">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><circle cx="12" cy="12" r="3" stroke-width="2"/></svg>
Settings
</button>
</div>
</header>
<!-- Config Modal -->
<div id="config-modal" class="fixed inset-0 z-[100] items-center justify-center bg-black/40 backdrop-blur-sm">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden flex flex-col max-h-[90vh]">
<div class="px-6 py-5 border-b border-gray-100 flex items-center justify-between shrink-0">
<div>
<h2 class="text-base font-bold text-gray-900">Connection Settings</h2>
<p class="text-xs text-gray-500 mt-0.5">Saved locally in your browser</p>
</div>
<button onclick="closeConfig()" class="text-gray-400 hover:text-gray-600 transition-colors p-1 rounded-lg hover:bg-gray-100">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
</div>
<div class="px-6 py-5 space-y-4 overflow-y-auto flex-1">
<div id="cfg-server-notice" class="hidden bg-blue-50 border border-blue-200 text-blue-700 text-xs rounded-lg px-3 py-2">
⚙ Server configuration loaded from <code>config.json</code> — those values take priority over local settings.
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Business / App Name</label>
<input id="cfg-app-name" type="text" placeholder="WhatsApp Manager" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
<p class="text-xs text-gray-400 mt-1">Shown in the header. Leave blank to use the default.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Server URL <span class="text-red-400">*</span></label>
<input id="cfg-base" type="text" placeholder="https://your-server.example.com" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
<p class="text-xs text-gray-400 mt-1">No trailing slash</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Instance Name <span class="text-red-400">*</span></label>
<input id="cfg-instance" type="text" placeholder="MyInstance" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">API Key <span class="text-red-400">*</span></label>
<div class="relative">
<input id="cfg-apikey" type="password" placeholder="••••••••••••••••" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm pr-10"/>
<button onclick="toggleApiKeyVisibility()" class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600">
<svg id="eye-icon" class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
</button>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Default Country <span class="text-gray-400 font-normal">(for local number format)</span></label>
<select id="cfg-country" onchange="toggleCustomCountry(this.value)" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white">
<option value="IL">🇮🇱 Israel (+972)</option>
<option value="US">🇺🇸 United States (+1)</option>
<option value="GB">🇬🇧 United Kingdom (+44)</option>
<option value="FR">🇫🇷 France (+33)</option>
<option value="DE">🇩🇪 Germany (+49)</option>
<option value="AU">🇦🇺 Australia (+61)</option>
<option value="CA">🇨🇦 Canada (+1)</option>
<option value="BR">🇧🇷 Brazil (+55)</option>
<option value="IN">🇮🇳 India (+91)</option>
<option value="ZA">🇿🇦 South Africa (+27)</option>
<option value="__custom__">✏️ Other (type manually)…</option>
</select>
<input id="cfg-country-custom" type="text" placeholder="e.g. 972, 44, 1, 55" maxlength="5" class="hidden w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm mt-2"/>
<p class="text-xs text-gray-400 mt-1">Used to auto-complete local numbers (e.g. 0501234567 → 972501234567)</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Delay Between Bulk Messages <span class="text-gray-400 font-normal">(random range, per message)</span></label>
<div class="flex items-center gap-2">
<div class="flex-1">
<label class="block text-xs text-gray-500 mb-1">Min (seconds)</label>
<input id="cfg-delay-min" type="number" min="0" max="300" step="0.1" placeholder="1" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm"/>
</div>
<span class="text-gray-400 mt-5">–</span>
<div class="flex-1">
<label class="block text-xs text-gray-500 mb-1">Max (seconds)</label>
<input id="cfg-delay-max" type="number" min="0" max="300" step="0.1" placeholder="3" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm"/>
</div>
</div>
<p class="text-xs text-gray-400 mt-1">Each message in a bulk send waits its own random delay — mimics human sending behaviour.</p>
</div>
<div id="cfg-status" class="hidden text-xs rounded-lg px-3 py-2"></div>
</div>
<div class="px-6 pb-5 flex gap-3 shrink-0">
<button onclick="saveConfig()" class="btn-send flex-1 text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/></svg>
Save & Apply
</button>
<button onclick="testConnection()" class="flex-1 border border-gray-300 text-gray-600 font-semibold py-2.5 rounded-lg text-sm hover:bg-gray-50 transition-colors flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>
Test Connection
</button>
</div>
</div>
</div>
<div class="flex h-[calc(100vh-65px)]">
<!-- Sidebar -->
<aside class="w-56 bg-white border-r border-gray-200 flex flex-col py-4 gap-1 px-3 overflow-y-auto shrink-0">
<p class="text-xs font-semibold text-gray-400 uppercase tracking-wider px-2 mb-2">Chat</p>
<button class="sidebar-btn active text-sm font-medium px-3 py-2.5 rounded-lg text-left flex items-center gap-2.5" onclick="switchTab('chat', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-2.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"/></svg>
Inbox
<span id="chat-unread-badge" class="hidden ml-auto bg-green-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full min-w-[20px] text-center"></span>
</button>
<div class="my-3 border-t border-gray-200"></div>
<p class="text-xs font-semibold text-gray-400 uppercase tracking-wider px-2 mb-2">Messages</p>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('text', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/></svg>
Compose
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('media', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>
Media
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('audio', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"/></svg>
Voice Note
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('location', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
Location
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('contact', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/></svg>
Contact
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('reaction', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
Reaction
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('poll', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>
Poll
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('buttons', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>
Buttons
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('list', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/></svg>
List Message
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('status', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" stroke-width="2"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3"/></svg>
Status / Story
</button>
<div class="my-3 border-t border-gray-200"></div>
<p class="text-xs font-semibold text-gray-400 uppercase tracking-wider px-2 mb-2">Groups</p>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('groups', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/></svg>
Groups
</button>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('scheduled', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
Scheduled
<span id="scheduled-badge" class="hidden ml-auto bg-green-500 text-white text-xs font-bold px-1.5 py-0.5 rounded-full"></span>
</button>
<div class="my-3 border-t border-gray-200"></div>
<p class="text-xs font-semibold text-gray-400 uppercase tracking-wider px-2 mb-2">Account</p>
<button class="sidebar-btn text-sm font-medium px-3 py-2.5 rounded-lg text-left text-gray-600 flex items-center gap-2.5" onclick="switchTab('settings', this)">
<svg class="w-4 h-4 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><circle cx="12" cy="12" r="3" stroke-width="2"/></svg>
Profile Settings
</button>
</aside>
<!-- Main -->
<main class="flex-1 flex flex-col overflow-hidden">
<div id="content-scroll" class="flex-1 overflow-y-auto p-6">
<!-- CHAT / INBOX -->
<div id="tab-chat" class="tab-panel flex h-full">
<!-- LEFT: Chat list -->
<div id="chat-list-panel" class="w-[350px] border-r border-gray-200 flex flex-col bg-white shrink-0 h-full">
<div class="p-3 border-b border-gray-100 space-y-2">
<div class="relative">
<svg class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
<input id="chat-search" type="text" placeholder="Search or start new chat" class="w-full bg-gray-100 border-0 rounded-lg pl-10 pr-4 py-2 text-sm" oninput="chatFilterList(this.value)"/>
</div>
<!-- Filter tabs -->
<div id="chat-filter-tabs" class="flex gap-1.5 overflow-x-auto pb-0.5">
<button class="chat-filter-btn active text-xs font-medium px-3 py-1 rounded-full border whitespace-nowrap" data-filter="all" onclick="chatSetFilter('all',this)">All</button>
<button class="chat-filter-btn text-xs font-medium px-3 py-1 rounded-full border whitespace-nowrap" data-filter="unread" onclick="chatSetFilter('unread',this)">Unread</button>
<button class="chat-filter-btn text-xs font-medium px-3 py-1 rounded-full border whitespace-nowrap" data-filter="favorites" onclick="chatSetFilter('favorites',this)">Favorites</button>
<button class="chat-filter-btn text-xs font-medium px-3 py-1 rounded-full border whitespace-nowrap" data-filter="groups" onclick="chatSetFilter('groups',this)">Groups</button>
<button class="chat-filter-btn text-xs font-medium px-3 py-1 rounded-full border whitespace-nowrap" data-filter="archived" onclick="chatSetFilter('archived',this)">
<svg class="w-3 h-3 inline -mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"/></svg>
Archived <span id="chat-archived-count" class="text-[10px] text-gray-400"></span>
</button>
</div>
</div>
<div id="chat-load-status" class="px-4 py-1 text-xs text-gray-400 flex items-center gap-1.5 border-b border-gray-100 bg-gray-50 invisible">
<svg id="chat-load-spinner" class="w-3 h-3 animate-spin shrink-0" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"/><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8z"/></svg>
<span id="chat-load-status-text"></span>
</div>
<div id="chat-list" class="flex-1 overflow-y-auto">
<div class="flex items-center justify-center h-full text-gray-400 text-sm">Loading chats...</div>
</div>
<div class="p-3 border-t border-gray-100">
<button onclick="chatStartNew()" class="w-full btn-send text-white text-sm font-medium py-2 rounded-lg flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
New Chat
</button>
</div>
</div>
<!-- RIGHT: Thread -->
<div id="chat-thread-panel" class="flex-1 flex flex-col h-full bg-[#efeae2]">
<!-- Empty state -->
<div id="chat-empty-state" class="flex-1 flex items-center justify-center">
<div class="text-center text-gray-500">
<svg class="w-16 h-16 mx-auto mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-2.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"/></svg>
<p class="text-lg font-medium">WhatsApp Chat</p>
<p class="text-sm mt-1">Select a conversation to start messaging</p>
</div>
</div>
<!-- Active chat (hidden until selected) -->
<div id="chat-active" class="hidden flex-col h-full relative" style="display:none">
<!-- Header -->
<div id="chat-header" class="bg-white px-4 py-2.5 flex items-center gap-3 border-b border-gray-200 shrink-0">
<button onclick="chatCloseConversation()" class="p-1 hover:bg-gray-100 rounded-full mr-1 lg:hidden" title="Back">
<svg class="w-5 h-5 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
</button>
<div id="chat-header-avatar" class="w-10 h-10 rounded-full bg-gray-300 flex items-center justify-center text-white font-bold text-sm shrink-0 overflow-hidden"></div>
<div class="flex-1 min-w-0">
<p id="chat-header-name" class="text-sm font-semibold text-gray-900 truncate"></p>
<p id="chat-header-status" class="text-xs text-gray-500 truncate"></p>
</div>
<div class="flex items-center gap-1">
<button onclick="chatSearchMessages()" class="p-2 hover:bg-gray-100 rounded-full" title="Search messages">
<svg class="w-5 h-5 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
</button>
</div>
</div>
<!-- Messages -->
<div id="chat-messages" class="flex-1 overflow-y-auto px-12 py-4 space-y-1" style="background-color:#efeae2"></div>
<!-- Reply bar -->
<div id="chat-reply-bar" class="hidden bg-white border-t border-gray-200 px-4 py-2 items-center gap-3" style="display:none">
<div class="flex-1 border-l-4 border-green-500 pl-3 min-w-0">
<p id="chat-reply-name" class="text-xs font-semibold text-green-700"></p>
<p id="chat-reply-text" class="text-xs text-gray-500 truncate"></p>
</div>
<button onclick="chatCancelReply()" class="text-gray-400 hover:text-gray-600 shrink-0">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
</div>
<!-- Selection toolbar (shown in select mode) -->
<div id="chat-select-toolbar" class="chat-select-toolbar hidden shrink-0">
<button onclick="chatExitSelectMode()" title="Cancel">✕ Cancel</button>
<span id="chat-select-count" class="flex-1 text-sm font-medium">0 selected</span>
<button onclick="chatCopySelected()">📋 Copy</button>
<button onclick="chatForwardSelected()">↗ Forward</button>
<button id="chat-delete-selected-btn" onclick="chatDeleteSelected()" title="Delete" disabled>
<svg xmlns="http://www.w3.org/2000/svg" class="inline w-4 h-4 -mt-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
Delete
</button>
</div>
<!-- Input bar -->
<div id="chat-input-bar" class="bg-white px-4 py-3 flex items-end gap-2 border-t border-gray-200 shrink-0">
<button onclick="chatToggleEmoji()" class="p-2 hover:bg-gray-100 rounded-full shrink-0" title="Emoji">
<svg class="w-6 h-6 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
</button>
<div id="chat-emoji-panel" class="hidden absolute bottom-16 left-16 bg-white border border-gray-200 rounded-xl shadow-xl p-3 z-50 w-80">
<div class="emoji-picker flex flex-wrap"></div>
</div>
<button onclick="chatAttachMedia()" class="p-2 hover:bg-gray-100 rounded-full shrink-0" title="Attach">
<svg class="w-6 h-6 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"/></svg>
</button>
<input type="file" id="chat-file-input" class="hidden" onchange="chatOnFileSelected(this)"/>
<div class="flex-1 relative">
<textarea id="chat-input" rows="1" placeholder="Type a message" class="w-full bg-gray-100 border-0 rounded-2xl px-4 py-2.5 text-sm resize-none max-h-32 overflow-y-auto" oninput="chatAutoResize(this); chatOnTyping()" onkeydown="if(event.key==='Enter'&&!event.shiftKey){event.preventDefault();chatSend()}" onpaste="chatOnPaste(event)"></textarea>
</div>
<button id="chat-send-btn" onclick="chatSend()" class="p-2.5 bg-[#25D366] hover:bg-[#1ebe5d] text-white rounded-full shrink-0" title="Send">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14M12 5l7 7-7 7"/></svg>
</button>
<button onclick="chatToggleSchedule()" class="p-2.5 hover:bg-gray-100 rounded-full shrink-0 text-gray-500" title="Schedule send">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
</button>
</div>
<!-- Schedule send panel -->
<div id="chat-schedule-panel" class="hidden bg-white border-t border-gray-200 px-4 py-3 shrink-0">
<div class="flex items-center gap-3">
<svg class="w-5 h-5 text-gray-400 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<input type="datetime-local" id="chat-schedule-dt" class="flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm"/>
<button onclick="chatScheduleSend()" class="px-4 py-2 bg-[#25D366] hover:bg-[#1ebe5d] text-white rounded-lg text-sm font-medium whitespace-nowrap">Schedule</button>
<button onclick="chatToggleSchedule()" class="text-gray-400 hover:text-gray-600 p-1">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
</div>
</div>
<!-- Poll details panel (slides in over messages) -->
<div id="poll-details-panel" class="hidden absolute inset-0 bg-white z-40 flex-col" style="display:none!important">
<div class="flex items-center gap-3 px-4 py-3 border-b border-gray-200 shrink-0">
<button onclick="chatClosePollDetails()" class="p-1 hover:bg-gray-100 rounded-full">
<svg class="w-5 h-5 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
<span class="text-[15px] font-medium text-gray-800">Poll details</span>
</div>
<div id="poll-details-content" class="flex-1 overflow-y-auto px-5 py-4"></div>
</div>
</div>
</div>
</div>
<!-- New Chat Modal -->
<div id="chat-new-modal" class="fixed inset-0 z-[100] items-center justify-center bg-black/40 backdrop-blur-sm" style="display:none">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md mx-4 overflow-hidden">
<div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
<h2 class="text-base font-bold text-gray-900">New Chat</h2>
<button onclick="chatCloseNewModal()" class="text-gray-400 hover:text-gray-600 p-1 rounded-lg hover:bg-gray-100">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
</div>
<div class="px-6 py-4 space-y-3">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Phone number</label>
<input id="chat-new-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm" onkeydown="if(event.key==='Enter')chatOpenNewByNumber()"/>
</div>
<button onclick="chatOpenNewByNumber()" class="w-full btn-send text-white text-sm font-medium py-2 rounded-lg">Start Chat</button>
<div class="border-t border-gray-100 pt-3">
<p class="text-xs text-gray-400 mb-2">Or select a contact:</p>
<input id="chat-new-search" type="text" placeholder="Search contacts..." class="w-full bg-gray-100 border-0 rounded-lg px-3 py-2 text-sm mb-2" oninput="chatFilterNewContacts(this.value)"/>
<div id="chat-new-contacts" class="max-h-48 overflow-y-auto space-y-1"></div>
</div>
</div>
</div>
</div>
<!-- Image Lightbox -->
<div id="chat-lightbox" class="fixed inset-0 z-[110] items-center justify-center" style="display:none;background:rgba(0,0,0,.85)">
<button onclick="chatCloseLightbox()" class="absolute top-4 right-4 text-white hover:text-gray-300 z-10">
<svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/></svg>
</button>
<img id="chat-lightbox-img" class="max-w-[90vw] max-h-[90vh] object-contain mx-auto" src="" alt=""/>
</div>
<!-- COMPOSE -->
<div id="tab-text" class="tab-panel active max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Compose & Send</h2>
<p class="text-sm text-gray-500 mb-5">Build a message sequence and send it to one or multiple recipients in one click.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-5">
<!-- Recipients -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient(s) <span class="text-red-400">*</span></label>
<div id="text-chip-box" class="chip-box" onclick="document.getElementById('text-number').focus()">
<input id="text-number" type="text" autocomplete="off" placeholder="Type a number and press Enter…"
class="flex-1 min-w-[180px] border-none outline-none text-sm bg-transparent py-0.5 focus:ring-0 focus:border-none focus:outline-none focus:shadow-none"/>
</div>
<p class="text-xs text-gray-400 mt-1">
International format without + ·
Press <kbd class="bg-gray-100 border border-gray-200 px-1 rounded text-xs">Enter</kbd> or comma after each number ·
Paste multiple numbers (comma or newline separated)
</p>
</div>
<!-- Message Queue -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Message Sequence</label>
<div id="compose-queue" class="space-y-3"></div>
<div id="compose-queue-empty" class="text-center py-8 text-gray-400 text-sm border-2 border-dashed border-gray-200 rounded-xl">
No messages yet — add one below
</div>
</div>
<!-- Add message buttons -->
<div>
<p class="text-xs text-gray-500 mb-2 font-medium">Add to sequence:</p>
<div class="flex gap-2 flex-wrap">
<button onclick="addQueueItem('text')" class="inline-flex items-center gap-1 text-xs font-medium px-3 py-1.5 rounded-lg border border-gray-200 hover:border-green-400 hover:text-green-700 hover:bg-green-50 transition-colors text-gray-600">💬 Text</button>
<button onclick="addQueueItem('media')" class="inline-flex items-center gap-1 text-xs font-medium px-3 py-1.5 rounded-lg border border-gray-200 hover:border-green-400 hover:text-green-700 hover:bg-green-50 transition-colors text-gray-600">🖼 Media</button>
<button onclick="addQueueItem('voice')" class="inline-flex items-center gap-1 text-xs font-medium px-3 py-1.5 rounded-lg border border-gray-200 hover:border-green-400 hover:text-green-700 hover:bg-green-50 transition-colors text-gray-600">🎤 Voice</button>
<button onclick="addQueueItem('poll')" class="inline-flex items-center gap-1 text-xs font-medium px-3 py-1.5 rounded-lg border border-gray-200 hover:border-green-400 hover:text-green-700 hover:bg-green-50 transition-colors text-gray-600">📊 Poll</button>
<button onclick="addQueueItem('buttons')" class="inline-flex items-center gap-1 text-xs font-medium px-3 py-1.5 rounded-lg border border-gray-200 hover:border-green-400 hover:text-green-700 hover:bg-green-50 transition-colors text-gray-600">⬜ Buttons</button>
</div>
</div>
<!-- Progress + Send -->
<div id="text-progress" class="hidden text-xs rounded-lg px-3 py-2"></div>
<div class="flex gap-2">
<button id="text-send-btn" onclick="sendCompose()" class="btn-send flex-1 text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
<span id="text-send-label">Send Message</span>
</button>
<button onclick="toggleSchedulePanel('compose')" class="border border-gray-300 hover:border-green-400 hover:text-green-700 hover:bg-green-50 text-gray-600 font-medium py-2.5 px-4 rounded-lg text-sm transition-colors flex items-center gap-1.5">
🕐 Schedule
</button>
</div>
<!-- Schedule panel (compose) -->
<div id="compose-schedule-panel" class="hidden border border-gray-200 rounded-xl p-4 space-y-3 bg-gray-50">
<p class="text-xs font-medium text-gray-700">Schedule this sequence</p>
<div class="flex gap-2 items-center">
<input id="compose-schedule-dt" type="datetime-local" class="flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm"/>
<button onclick="scheduleCompose()" class="btn-send text-white font-semibold px-4 py-2 rounded-lg text-sm whitespace-nowrap">Confirm</button>
</div>
<p class="text-xs text-gray-400">The browser tab must remain open at send time (it doesn't need to be the active tab).</p>
</div>
</div>
</div>
<!-- MEDIA -->
<div id="tab-media" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Media</h2>
<p class="text-sm text-gray-500 mb-5">Send image, video, document, or audio file via URL.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="media-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Media Type <span class="text-red-400">*</span></label>
<select id="media-type" onchange="updateMimetype()" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white">
<option value="image">Image</option>
<option value="video">Video</option>
<option value="document">Document</option>
<option value="audio">Audio</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Media URL <span class="text-red-400">*</span></label>
<input id="media-url" type="text" placeholder="https://example.com/image.jpg" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm" oninput="mediaFileBase64=null;document.getElementById('media-file-badge').classList.add('hidden')"/>
<div class="flex items-center gap-2 mt-2">
<span class="text-xs text-gray-400">or</span>
<label class="cursor-pointer inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 font-medium">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"/></svg>
Choose file from computer
<input type="file" id="media-file" class="hidden" onchange="onMediaFileSelected(this)"/>
</label>
<span id="media-file-badge" class="hidden text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full"></span>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">MIME Type <span class="text-red-400">*</span></label>
<input id="media-mimetype" type="text" placeholder="image/jpeg" value="image/jpeg" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">File Name</label>
<input id="media-filename" type="text" placeholder="file.jpg" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Caption</label>
<textarea id="media-caption" rows="3" placeholder="Optional caption..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm resize-none"></textarea>
</div>
<button onclick="sendMedia()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Media
</button>
</div>
</div>
<!-- AUDIO / VOICE NOTE -->
<div id="tab-audio" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Voice Note</h2>
<p class="text-sm text-gray-500 mb-5">Send an audio file as a WhatsApp voice note (PTT).</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="audio-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Audio URL <span class="text-red-400">*</span></label>
<input id="audio-url" type="text" placeholder="https://example.com/audio.mp3" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm" oninput="audioFileBase64=null;document.getElementById('audio-file-badge').classList.add('hidden')"/>
<div class="flex items-center gap-2 mt-2">
<span class="text-xs text-gray-400">or</span>
<label class="cursor-pointer inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 font-medium">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"/></svg>
Choose file from computer
<input type="file" id="audio-file" class="hidden" accept="audio/*" onchange="onAudioFileSelected(this)"/>
</label>
<span id="audio-file-badge" class="hidden text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full"></span>
</div>
<p class="text-xs text-gray-400 mt-1">Supported: mp3, ogg, m4a, wav</p>
</div>
<div class="flex items-center gap-2">
<input id="audio-encoding" type="checkbox" checked class="w-4 h-4 accent-green-500"/>
<label for="audio-encoding" class="text-sm text-gray-600">Auto-encode to WhatsApp format</label>
</div>
<button onclick="sendAudio()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Voice Note
</button>
</div>
</div>
<!-- LOCATION -->
<div id="tab-location" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Location</h2>
<p class="text-sm text-gray-500 mb-5">Share a map location with a contact.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="loc-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Latitude <span class="text-red-400">*</span></label>
<input id="loc-lat" type="number" step="any" placeholder="31.7683" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Longitude <span class="text-red-400">*</span></label>
<input id="loc-lng" type="number" step="any" placeholder="35.2137" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Place Name</label>
<input id="loc-name" type="text" placeholder="Our Office" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Address</label>
<input id="loc-address" type="text" placeholder="Full address..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<button onclick="sendLocation()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Location
</button>
</div>
</div>
<!-- CONTACT -->
<div id="tab-contact" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Contact Card</h2>
<p class="text-sm text-gray-500 mb-5">Share a contact card (vCard) with a recipient.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="contact-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div class="border border-gray-200 rounded-lg p-4 space-y-3 bg-gray-50">
<p class="text-sm font-semibold text-gray-700">Contact to share</p>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Full Name <span class="text-red-400">*</span></label>
<input id="contact-name" type="text" placeholder="John Doe" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Phone Number (with country code) <span class="text-red-400">*</span></label>
<input id="contact-phone" type="text" placeholder="972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">WhatsApp Number (wuid)</label>
<input id="contact-wuid" type="text" placeholder="Same as phone if on WhatsApp" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white"/>
</div>
</div>
<button onclick="sendContact()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Contact
</button>
</div>
</div>
<!-- REACTION -->
<div id="tab-reaction" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Reaction</h2>
<p class="text-sm text-gray-500 mb-5">React to an existing message with an emoji.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Chat JID <span class="text-red-400">*</span></label>
<input id="react-jid" type="text" placeholder="972501234567@s.whatsapp.net" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
<p class="text-xs text-gray-400 mt-1">For groups use JID ending in @g.us</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Message ID <span class="text-red-400">*</span></label>
<input id="react-msgid" type="text" placeholder="3EB0..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="flex items-center gap-2 cursor-pointer text-sm text-gray-700">
<input id="react-fromme" type="checkbox" checked class="w-4 h-4 accent-green-500"/>
Message sent by me (fromMe)
</label>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Reaction Emoji <span class="text-red-400">*</span></label>
<div class="flex flex-wrap gap-2 mb-3">
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '👍')">👍</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '❤️')">❤️</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '😂')">😂</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '😮')">😮</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '😢')">😢</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '🙏')">🙏</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '🔥')">🔥</button>
<button class="emoji-btn text-2xl p-1.5 rounded-lg hover:bg-gray-100 transition-colors" onclick="selectEmoji(this, '✅')">✅</button>
</div>
<input id="react-emoji" type="text" placeholder="Or type any emoji" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<button onclick="sendReaction()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Reaction
</button>
</div>
</div>
<!-- POLL -->
<div id="tab-poll" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Poll</h2>
<p class="text-sm text-gray-500 mb-5">Create a poll with multiple choice options.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="poll-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Poll Question <span class="text-red-400">*</span></label>
<input id="poll-question" type="text" placeholder="What is your question?" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Options <span class="text-red-400">*</span> <span class="text-gray-400 font-normal">(min 2, max 12)</span></label>
<div id="poll-options" class="space-y-2">
<div class="flex gap-2">
<input type="text" placeholder="Option 1" class="poll-opt flex-1 border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div class="flex gap-2">
<input type="text" placeholder="Option 2" class="poll-opt flex-1 border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
</div>
<button onclick="addPollOption()" class="mt-2 text-sm text-green-600 font-medium flex items-center gap-1 hover:text-green-700">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
Add Option
</button>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Max Selections Allowed</label>
<select id="poll-selectable" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white">
<option value="1">1 (single choice)</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="0">Unlimited</option>
</select>
</div>
<button onclick="sendPoll()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Poll
</button>
</div>
</div>
<!-- BUTTONS -->
<div id="tab-buttons" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Button Message</h2>
<p class="text-sm text-gray-500 mb-5">Send a message with quick reply buttons (up to 3).</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="btn-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Title <span class="text-red-400">*</span></label>
<input id="btn-title" type="text" placeholder="Message title" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Description</label>
<textarea id="btn-description" rows="3" placeholder="Message body text..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm resize-none"></textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Footer</label>
<input id="btn-footer" type="text" placeholder="Footer text" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Buttons <span class="text-red-400">*</span> <span class="text-gray-400 font-normal">(max 3)</span></label>
<div id="buttons-list" class="space-y-2">
<div class="flex gap-2 items-center btn-row">
<input type="text" placeholder="Button label" class="btn-label flex-1 border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
<input type="text" placeholder="Button ID" class="btn-id w-32 border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
</div>
<button onclick="addButton()" class="mt-2 text-sm text-green-600 font-medium flex items-center gap-1 hover:text-green-700">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
Add Button
</button>
</div>
<button onclick="sendButtons()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send Buttons
</button>
</div>
</div>
<!-- LIST -->
<div id="tab-list" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send List Message</h2>
<p class="text-sm text-gray-500 mb-5">Send a message with a scrollable list of options grouped in sections.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Recipient Number <span class="text-red-400">*</span></label>
<input id="list-number" type="text" placeholder="e.g. 972501234567" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Title <span class="text-red-400">*</span></label>
<input id="list-title" type="text" placeholder="Message title" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Description</label>
<textarea id="list-description" rows="2" placeholder="Message body..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm resize-none"></textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Button Text <span class="text-red-400">*</span></label>
<input id="list-btntext" type="text" placeholder="View Options" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Footer</label>
<input id="list-footer" type="text" placeholder="Footer text" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Sections <span class="text-red-400">*</span></label>
<div id="list-sections" class="space-y-3">
<div class="section-block border border-gray-200 rounded-lg p-3 space-y-2 bg-gray-50">
<input type="text" placeholder="Section title" class="section-title w-full border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white font-medium"/>
<div class="rows-container space-y-2">
<div class="flex gap-2 row-entry">
<input type="text" placeholder="Option title" class="row-title flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white"/>
<input type="text" placeholder="Description" class="row-desc flex-1 border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white"/>
<input type="text" placeholder="ID" class="row-id w-20 border border-gray-300 rounded-lg px-3 py-2 text-sm bg-white"/>
</div>
</div>
<button onclick="addListRow(this)" class="text-xs text-green-600 font-medium flex items-center gap-1 hover:text-green-700">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
Add row
</button>
</div>
</div>
<button onclick="addListSection()" class="mt-2 text-sm text-green-600 font-medium flex items-center gap-1 hover:text-green-700">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
Add Section
</button>
</div>
<button onclick="sendList()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Send List
</button>
</div>
</div>
<!-- STATUS / STORY -->
<div id="tab-status" class="tab-panel max-w-2xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Send Status / Story</h2>
<p class="text-sm text-gray-500 mb-5">Post a WhatsApp status update visible to your contacts.</p>
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1.5">Type <span class="text-red-400">*</span></label>
<select id="status-type" onchange="updateStatusFields()" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white">
<option value="text">Text</option>
<option value="image">Image</option>
<option value="video">Video</option>
<option value="audio">Audio</option>
</select>
</div>
<div id="status-content-wrap">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Content <span class="text-red-400">*</span></label>
<textarea id="status-content" rows="4" placeholder="Your status text..." class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm resize-none"></textarea>
</div>
<div id="status-media-wrap" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Media URL <span class="text-red-400">*</span></label>
<input id="status-media-url" type="text" placeholder="https://example.com/image.jpg" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div id="status-caption-wrap" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Caption</label>
<input id="status-caption" type="text" placeholder="Caption text" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm"/>
</div>
<div id="status-bg-wrap">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Background Color</label>
<div class="flex items-center gap-3">
<input id="status-bgcolor" type="color" value="#25D366" class="w-10 h-10 rounded cursor-pointer border border-gray-300"/>
<input id="status-bgcolor-text" type="text" value="#25D366" placeholder="#000000" class="w-32 border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm" oninput="syncColor(this)"/>
</div>
</div>
<div id="status-font-wrap">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Font Style</label>
<select id="status-font" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm bg-white">
<option value="0">Default (Sans)</option>
<option value="1">Serif</option>
<option value="2">Monospace</option>
<option value="3">Italic</option>
<option value="4">Handwriting</option>
</select>
</div>
<div>
<label class="flex items-center gap-2 cursor-pointer">
<input id="status-allcontacts" type="checkbox" checked class="w-4 h-4 accent-green-500" onchange="toggleStatusContacts()"/>
<span class="text-sm text-gray-700">Send to all contacts</span>
</label>
</div>
<div id="status-jids-wrap" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-1.5">Specific JIDs</label>
<textarea id="status-jids" rows="3" placeholder="One per line: 972501234567@s.whatsapp.net" class="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm resize-none"></textarea>
</div>
<button onclick="sendStatus()" class="btn-send w-full text-white font-semibold py-2.5 rounded-lg text-sm flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"/></svg>
Post Status
</button>
</div>
</div>
<!-- GROUPS -->
<div id="tab-groups" class="tab-panel max-w-4xl">
<h2 class="text-lg font-semibold text-gray-800 mb-1">Groups</h2>
<p class="text-sm text-gray-500 mb-5">Browse, message, create and manage your WhatsApp groups.</p>
<!-- Inner tabs -->
<div class="flex gap-1 bg-gray-100 p-1 rounded-xl mb-6 w-fit">
<button id="gtab-browse-btn" onclick="switchGroupTab('browse')" class="gtab-btn px-4 py-2 text-sm font-medium rounded-lg bg-white shadow-sm text-gray-800 transition-all">Browse & Send</button>
<button id="gtab-create-btn" onclick="switchGroupTab('create')" class="gtab-btn px-4 py-2 text-sm font-medium rounded-lg text-gray-500 hover:text-gray-700 transition-all">Create Group</button>
<button id="gtab-manage-btn" onclick="switchGroupTab('manage')" class="gtab-btn px-4 py-2 text-sm font-medium rounded-lg text-gray-500 hover:text-gray-700 transition-all">Manage Group</button>
</div>
<!-- BROWSE & SEND -->
<div id="gtab-browse" class="gtab-panel">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-5 items-start">
<!-- Group list -->
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-5 flex flex-col gap-3">
<div class="flex items-center justify-between">
<h3 class="text-sm font-semibold text-gray-800">My Groups</h3>
<button onclick="fetchGroups()" class="btn-send text-white text-xs font-semibold px-3 py-1.5 rounded-lg flex items-center gap-1.5">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/></svg>
Load Groups
</button>
</div>
<input id="group-search" type="text" placeholder="Search groups..." oninput="filterGroups()" class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm"/>
<div class="flex items-center justify-between text-xs text-gray-500">
<span id="groups-count">No groups loaded</span>
<div class="flex gap-3">
<button onclick="selectAllGroups()" class="text-green-600 hover:text-green-700 font-medium">Select All</button>
<button onclick="clearGroupSelection()" class="text-gray-400 hover:text-gray-600 font-medium">Clear</button>
</div>
</div>
<div id="group-list" class="overflow-y-auto max-h-[60vh] space-y-1 pr-1">
<p class="text-xs text-gray-400 text-center py-8">Click "Load Groups" to fetch your groups</p>
</div>
</div>
<!-- Selected + Broadcast composer -->
<div class="flex flex-col gap-4">
<!-- Selected chips -->
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-sm font-semibold text-gray-800">Selected Groups</h3>
<span id="selected-count" class="text-xs text-gray-400">0 selected</span>
</div>
<div id="selected-chips" class="flex flex-wrap gap-2 min-h-[40px]">
<p class="text-xs text-gray-400 self-center">No groups selected</p>
</div>
</div>
<!-- Manage selected shortcut -->
<button onclick="manageSelectedGroups()" class="w-full border border-green-300 text-green-700 bg-green-50 hover:bg-green-100 text-sm font-semibold py-2.5 rounded-xl transition-colors flex items-center justify-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"/><circle cx="12" cy="12" r="3" stroke-width="2"/></svg>
Manage Selected Groups
</button>
<!-- Group broadcast queue -->
<div class="bg-white rounded-xl border border-gray-200 shadow-sm p-5 flex flex-col gap-4">
<h3 class="text-sm font-semibold text-gray-800">Message Sequence</h3>
<div id="group-queue" class="space-y-3"></div>
<div id="group-queue-empty" class="text-center py-6 text-xs text-gray-400 border border-dashed border-gray-200 rounded-xl">
Add messages to your sequence below
</div>