File size: 31,421 Bytes
329b83e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ChatApp - Realtime Messaging</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* Custom scrollbar */
        .custom-scrollbar::-webkit-scrollbar {
            width: 6px;
        }
        .custom-scrollbar::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 3px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
        
        /* Animation for new messages */
        @keyframes slideIn {
            from {
                transform: translateY(10px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
        
        .new-message {
            animation: slideIn 0.3s ease-out;
        }
        
        /* Online status indicator */
        .online-indicator {
            width: 12px;
            height: 12px;
            background-color: #4ade80;
            border-radius: 50%;
            border: 2px solid white;
            position: absolute;
            bottom: 0;
            right: 0;
        }
        
        /* Typing indicator */
        .typing-indicator {
            display: flex;
            align-items: center;
        }
        
        .typing-dot {
            width: 8px;
            height: 8px;
            background-color: #9ca3af;
            border-radius: 50%;
            margin: 0 2px;
            animation: typingAnimation 1.4s infinite ease-in-out;
        }
        
        .typing-dot:nth-child(1) {
            animation-delay: 0s;
        }
        
        .typing-dot:nth-child(2) {
            animation-delay: 0.2s;
        }
        
        .typing-dot:nth-child(3) {
            animation-delay: 0.4s;
        }
        
        @keyframes typingAnimation {
            0%, 60%, 100% {
                transform: translateY(0);
            }
            30% {
                transform: translateY(-5px);
            }
        }
    </style>
</head>
<body class="bg-gray-100 h-screen flex items-center justify-center">
    <div class="container mx-auto bg-white rounded-lg shadow-xl overflow-hidden" style="width: 90%; max-width: 1400px; height: 90vh;">
        <div class="flex h-full">
            <!-- Sidebar -->
            <div class="w-1/3 border-r border-gray-200 bg-gray-50 flex flex-col">
                <!-- Header -->
                <div class="p-4 bg-gray-100 flex justify-between items-center border-b border-gray-200">
                    <div class="flex items-center">
                        <img src="https://ui-avatars.com/api/?name=User+Name" alt="Profile" class="w-10 h-10 rounded-full">
                        <span class="ml-3 font-semibold">My Profile</span>
                    </div>
                    <div class="flex space-x-4 text-gray-500">
                        <button class="hover:text-gray-700">
                            <i class="fas fa-users"></i>
                        </button>
                        <button class="hover:text-gray-700">
                            <i class="fas fa-comment-dots"></i>
                        </button>
                        <button class="hover:text-gray-700">
                            <i class="fas fa-ellipsis-v"></i>
                        </button>
                    </div>
                </div>
                
                <!-- Search -->
                <div class="p-3 bg-white">
                    <div class="relative">
                        <input type="text" placeholder="Search or start new chat" class="w-full py-2 px-4 pl-10 bg-gray-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
                    </div>
                </div>
                
                <!-- Chat list -->
                <div class="flex-1 overflow-y-auto custom-scrollbar">
                    <!-- Chat item -->
                    <div class="flex items-center p-3 border-b border-gray-100 hover:bg-gray-100 cursor-pointer bg-blue-50">
                        <div class="relative">
                            <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-12 h-12 rounded-full">
                            <span class="online-indicator"></span>
                        </div>
                        <div class="ml-3 flex-1">
                            <div class="flex justify-between items-center">
                                <span class="font-semibold">John Doe</span>
                                <span class="text-xs text-gray-500">10:30 AM</span>
                            </div>
                            <div class="flex justify-between items-center">
                                <p class="text-sm text-gray-600 truncate">Hey, how are you doing?</p>
                                <span class="bg-blue-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs">3</span>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Group chat item -->
                    <div class="flex items-center p-3 border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
                        <div class="relative">
                            <div class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center">
                                <i class="fas fa-users text-purple-500"></i>
                            </div>
                        </div>
                        <div class="ml-3 flex-1">
                            <div class="flex justify-between items-center">
                                <span class="font-semibold">Dev Team</span>
                                <span class="text-xs text-gray-500">Yesterday</span>
                            </div>
                            <div class="flex justify-between items-center">
                                <p class="text-sm text-gray-600 truncate">Meeting at 3 PM tomorrow</p>
                                <span class="bg-blue-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs">1</span>
                            </div>
                        </div>
                    </div>
                    
                    <!-- More chat items -->
                    <div class="flex items-center p-3 border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
                        <div class="relative">
                            <img src="https://ui-avatars.com/api/?name=Jane+Smith" alt="Profile" class="w-12 h-12 rounded-full">
                        </div>
                        <div class="ml-3 flex-1">
                            <div class="flex justify-between items-center">
                                <span class="font-semibold">Jane Smith</span>
                                <span class="text-xs text-gray-500">Monday</span>
                            </div>
                            <div class="flex justify-between items-center">
                                <p class="text-sm text-gray-600 truncate">Did you see the new design?</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Chat with typing indicator -->
                    <div class="flex items-center p-3 border-b border-gray-100 hover:bg-gray-100 cursor-pointer">
                        <div class="relative">
                            <img src="https://ui-avatars.com/api/?name=Mike+Johnson" alt="Profile" class="w-12 h-12 rounded-full">
                            <span class="online-indicator"></span>
                        </div>
                        <div class="ml-3 flex-1">
                            <div class="flex justify-between items-center">
                                <span class="font-semibold">Mike Johnson</span>
                                <span class="text-xs text-gray-500">Just now</span>
                            </div>
                            <div class="flex items-center">
                                <div class="typing-indicator">
                                    <div class="typing-dot"></div>
                                    <div class="typing-dot"></div>
                                    <div class="typing-dot"></div>
                                </div>
                                <span class="text-sm text-gray-500 ml-2">typing...</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Chat area -->
            <div class="flex-1 flex flex-col">
                <!-- Chat header -->
                <div class="p-4 bg-gray-100 flex justify-between items-center border-b border-gray-200">
                    <div class="flex items-center">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-10 h-10 rounded-full">
                        <div class="ml-3">
                            <div class="font-semibold">John Doe</div>
                            <div class="text-xs text-gray-500 flex items-center">
                                <span class="w-2 h-2 rounded-full bg-green-500 mr-1"></span>
                                <span>online</span>
                            </div>
                        </div>
                    </div>
                    <div class="flex space-x-4 text-gray-500">
                        <button class="hover:text-gray-700">
                            <i class="fas fa-phone"></i>
                        </button>
                        <button class="hover:text-gray-700">
                            <i class="fas fa-video"></i>
                        </button>
                        <button class="hover:text-gray-700">
                            <i class="fas fa-search"></i>
                        </button>
                        <button class="hover:text-gray-700">
                            <i class="fas fa-ellipsis-v"></i>
                        </button>
                    </div>
                </div>
                
                <!-- Messages -->
                <div class="flex-1 p-4 overflow-y-auto custom-scrollbar bg-gray-50" id="messages-container">
                    <!-- Date divider -->
                    <div class="flex justify-center my-4">
                        <div class="bg-gray-200 text-xs text-gray-600 px-2 py-1 rounded-full">Today</div>
                    </div>
                    
                    <!-- Incoming message -->
                    <div class="flex mb-4 new-message">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                        <div>
                            <div class="bg-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                                <p>Hey there! How are you doing?</p>
                            </div>
                            <div class="text-xs text-gray-500 mt-1">10:30 AM</div>
                        </div>
                    </div>
                    
                    <!-- Outgoing message -->
                    <div class="flex justify-end mb-4 new-message">
                        <div class="text-right">
                            <div class="bg-blue-500 text-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                                <p>I'm good, thanks! Just working on that new project.</p>
                            </div>
                            <div class="text-xs text-gray-500 mt-1 flex items-center justify-end">
                                10:32 AM
                                <i class="fas fa-check-double text-blue-500 ml-1"></i>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Incoming message with image -->
                    <div class="flex mb-4 new-message">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                        <div>
                            <div class="bg-white p-1 rounded-lg shadow-sm max-w-xs">
                                <img src="https://images.unsplash.com/photo-1682686580391-615b4f716f2b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80" alt="Shared image" class="rounded-lg w-full">
                            </div>
                            <div class="text-xs text-gray-500 mt-1">10:33 AM</div>
                        </div>
                    </div>
                    
                    <!-- Outgoing message with document -->
                    <div class="flex justify-end mb-4 new-message">
                        <div class="text-right">
                            <div class="bg-blue-500 text-white p-2 rounded-lg shadow-sm max-w-xs">
                                <div class="flex items-center p-2">
                                    <i class="fas fa-file-pdf text-2xl mr-2"></i>
                                    <div>
                                        <div class="font-medium">Project_Proposal.pdf</div>
                                        <div class="text-xs">2.4 MB</div>
                                    </div>
                                </div>
                            </div>
                            <div class="text-xs text-gray-500 mt-1 flex items-center justify-end">
                                10:35 AM
                                <i class="fas fa-check-double text-blue-500 ml-1"></i>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Incoming voice message -->
                    <div class="flex mb-4 new-message">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                        <div>
                            <div class="bg-white p-3 rounded-lg shadow-sm max-w-xs flex items-center">
                                <button class="w-8 h-8 rounded-full bg-blue-100 text-blue-500 flex items-center justify-center mr-2">
                                    <i class="fas fa-play"></i>
                                </button>
                                <div class="flex-1">
                                    <div class="h-1 bg-gray-200 rounded-full mb-1">
                                        <div class="h-1 bg-blue-500 rounded-full" style="width: 60%;"></div>
                                    </div>
                                    <div class="text-xs text-gray-500">0:12 / 0:45</div>
                                </div>
                            </div>
                            <div class="text-xs text-gray-500 mt-1">10:36 AM</div>
                        </div>
                    </div>
                    
                    <!-- Typing indicator -->
                    <div class="flex mb-4">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                        <div class="bg-white p-3 rounded-lg shadow-sm">
                            <div class="typing-indicator">
                                <div class="typing-dot"></div>
                                <div class="typing-dot"></div>
                                <div class="typing-dot"></div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Message input -->
                <div class="p-3 bg-gray-100 border-t border-gray-200">
                    <div class="flex items-center">
                        <button class="w-10 h-10 rounded-full text-gray-500 hover:text-gray-700 hover:bg-gray-200 flex items-center justify-center">
                            <i class="fas fa-paperclip"></i>
                        </button>
                        <button class="w-10 h-10 rounded-full text-gray-500 hover:text-gray-700 hover:bg-gray-200 flex items-center justify-center">
                            <i class="fas fa-image"></i>
                        </button>
                        <button class="w-10 h-10 rounded-full text-gray-500 hover:text-gray-700 hover:bg-gray-200 flex items-center justify-center">
                            <i class="fas fa-microphone"></i>
                        </button>
                        <div class="flex-1 mx-2">
                            <input type="text" placeholder="Type a message" class="w-full py-2 px-4 bg-white rounded-full focus:outline-none focus:ring-2 focus:ring-blue-500">
                        </div>
                        <button class="w-10 h-10 rounded-full bg-blue-500 text-white hover:bg-blue-600 flex items-center justify-center">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- Right sidebar (optional) -->
            <div class="w-1/4 border-l border-gray-200 bg-white hidden lg:flex flex-col">
                <!-- Profile header -->
                <div class="p-4 bg-gray-100 border-b border-gray-200">
                    <div class="flex justify-between items-center">
                        <h3 class="font-semibold">Contact Info</h3>
                        <button class="text-gray-500 hover:text-gray-700">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>
                
                <!-- Profile content -->
                <div class="flex-1 overflow-y-auto custom-scrollbar p-4">
                    <div class="flex flex-col items-center mb-6">
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-24 h-24 rounded-full mb-3">
                        <h3 class="font-semibold text-lg">John Doe</h3>
                        <p class="text-gray-500 text-sm">Software Developer</p>
                        <div class="flex mt-3 space-x-4">
                            <button class="w-10 h-10 rounded-full bg-blue-100 text-blue-500 hover:bg-blue-200 flex items-center justify-center">
                                <i class="fas fa-phone"></i>
                            </button>
                            <button class="w-10 h-10 rounded-full bg-green-100 text-green-500 hover:bg-green-200 flex items-center justify-center">
                                <i class="fas fa-video"></i>
                            </button>
                            <button class="w-10 h-10 rounded-full bg-purple-100 text-purple-500 hover:bg-purple-200 flex items-center justify-center">
                                <i class="fas fa-search"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="font-medium text-gray-700 mb-2">About</h4>
                        <p class="text-sm text-gray-600">Hey there! I'm using ChatApp to stay connected with friends and colleagues.</p>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="font-medium text-gray-700 mb-2">Media, links, and docs</h4>
                        <div class="grid grid-cols-3 gap-2">
                            <div class="aspect-square bg-gray-100 rounded-lg overflow-hidden">
                                <img src="https://images.unsplash.com/photo-1682686580391-615b4f716f2b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80" alt="Media" class="w-full h-full object-cover">
                            </div>
                            <div class="aspect-square bg-gray-100 rounded-lg flex items-center justify-center">
                                <i class="fas fa-file-pdf text-3xl text-red-500"></i>
                            </div>
                            <div class="aspect-square bg-gray-100 rounded-lg overflow-hidden">
                                <img src="https://images.unsplash.com/photo-1682686580391-615b4f716f2b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80" alt="Media" class="w-full h-full object-cover">
                            </div>
                        </div>
                        <button class="text-blue-500 text-sm mt-2 hover:underline">Show all</button>
                    </div>
                    
                    <div>
                        <h4 class="font-medium text-gray-700 mb-2">Group members (4)</h4>
                        <div class="space-y-3">
                            <div class="flex items-center">
                                <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                                <span>John Doe</span>
                                <span class="ml-auto text-xs text-gray-500">Admin</span>
                            </div>
                            <div class="flex items-center">
                                <img src="https://ui-avatars.com/api/?name=Jane+Smith" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                                <span>Jane Smith</span>
                            </div>
                            <div class="flex items-center">
                                <img src="https://ui-avatars.com/api/?name=Mike+Johnson" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                                <span>Mike Johnson</span>
                            </div>
                            <div class="flex items-center">
                                <img src="https://ui-avatars.com/api/?name=Sarah+Williams" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                                <span>Sarah Williams</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Group actions -->
                <div class="p-4 border-t border-gray-200">
                    <button class="w-full py-2 px-4 bg-red-100 text-red-500 rounded-lg hover:bg-red-200 flex items-center justify-center">
                        <i class="fas fa-sign-out-alt mr-2"></i>
                        <span>Exit Group</span>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Simulate new messages
        function addNewMessage() {
            const messages = [
                {
                    type: 'incoming',
                    text: 'Have you seen the latest updates?',
                    time: '10:40 AM'
                },
                {
                    type: 'outgoing',
                    text: 'Not yet, I\'ll check them out soon.',
                    time: '10:41 AM'
                },
                {
                    type: 'incoming',
                    text: 'Great! Let me know what you think.',
                    time: '10:42 AM'
                }
            ];
            
            const container = document.getElementById('messages-container');
            
            messages.forEach((msg, index) => {
                setTimeout(() => {
                    const messageDiv = document.createElement('div');
                    messageDiv.className = `flex ${msg.type === 'outgoing' ? 'justify-end' : ''} mb-4 new-message`;
                    
                    if (msg.type === 'incoming') {
                        messageDiv.innerHTML = `
                            <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                            <div>
                                <div class="bg-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                                    <p>${msg.text}</p>
                                </div>
                                <div class="text-xs text-gray-500 mt-1">${msg.time}</div>
                            </div>
                        `;
                    } else {
                        messageDiv.innerHTML = `
                            <div class="text-right">
                                <div class="bg-blue-500 text-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                                    <p>${msg.text}</p>
                                </div>
                                <div class="text-xs text-gray-500 mt-1 flex items-center justify-end">
                                    ${msg.time}
                                    <i class="fas fa-check-double text-blue-500 ml-1"></i>
                                </div>
                            </div>
                        `;
                    }
                    
                    container.appendChild(messageDiv);
                    
                    // Scroll to bottom
                    container.scrollTop = container.scrollHeight;
                }, (index + 1) * 1500);
            });
        }
        
        // Simulate typing indicator
        function showTypingIndicator() {
            const container = document.getElementById('messages-container');
            const typingDiv = document.createElement('div');
            typingDiv.className = 'flex mb-4';
            typingDiv.innerHTML = `
                <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                <div class="bg-white p-3 rounded-lg shadow-sm">
                    <div class="typing-indicator">
                        <div class="typing-dot"></div>
                        <div class="typing-dot"></div>
                        <div class="typing-dot"></div>
                    </div>
                </div>
            `;
            
            container.appendChild(typingDiv);
            container.scrollTop = container.scrollHeight;
            
            // Remove after 3 seconds
            setTimeout(() => {
                typingDiv.remove();
            }, 3000);
        }
        
        // Add event listeners
        document.addEventListener('DOMContentLoaded', () => {
            // Simulate incoming messages after page load
            setTimeout(addNewMessage, 2000);
            
            // Simulate typing indicator
            setTimeout(showTypingIndicator, 5000);
            
            // Message input functionality
            const messageInput = document.querySelector('.p-3.bg-gray-100 input[type="text"]');
            const sendButton = document.querySelector('.p-3.bg-gray-100 button.bg-blue-500');
            
            sendButton.addEventListener('click', () => {
                if (messageInput.value.trim() !== '') {
                    sendMessage(messageInput.value);
                    messageInput.value = '';
                }
            });
            
            messageInput.addEventListener('keypress', (e) => {
                if (e.key === 'Enter' && messageInput.value.trim() !== '') {
                    sendMessage(messageInput.value);
                    messageInput.value = '';
                }
            });
        });
        
        function sendMessage(text) {
            const container = document.getElementById('messages-container');
            const now = new Date();
            const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
            
            const messageDiv = document.createElement('div');
            messageDiv.className = 'flex justify-end mb-4 new-message';
            messageDiv.innerHTML = `
                <div class="text-right">
                    <div class="bg-blue-500 text-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                        <p>${text}</p>
                    </div>
                    <div class="text-xs text-gray-500 mt-1 flex items-center justify-end">
                        ${timeString}
                        <i class="fas fa-check ml-1"></i>
                    </div>
                </div>
            `;
            
            container.appendChild(messageDiv);
            container.scrollTop = container.scrollHeight;
            
            // Simulate reply after 1 second
            setTimeout(() => {
                showTypingIndicator();
                
                setTimeout(() => {
                    const replies = [
                        "Got it!",
                        "Thanks for letting me know.",
                        "I'll get back to you on that.",
                        "Sounds good!",
                        "Let me check and confirm."
                    ];
                    
                    const randomReply = replies[Math.floor(Math.random() * replies.length)];
                    const now = new Date();
                    const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
                    
                    const replyDiv = document.createElement('div');
                    replyDiv.className = 'flex mb-4 new-message';
                    replyDiv.innerHTML = `
                        <img src="https://ui-avatars.com/api/?name=John+Doe" alt="Profile" class="w-8 h-8 rounded-full mr-2">
                        <div>
                            <div class="bg-white p-3 rounded-lg shadow-sm max-w-xs lg:max-w-md">
                                <p>${randomReply}</p>
                            </div>
                            <div class="text-xs text-gray-500 mt-1">${timeString}</div>
                        </div>
                    `;
                    
                    container.appendChild(replyDiv);
                    container.scrollTop = container.scrollHeight;
                }, 2000);
            }, 1000);
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=kingpbaz/ozatech" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>