File size: 30,169 Bytes
111b79f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document Assistant</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 */
        ::-webkit-scrollbar {
            width: 6px;
        }
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        ::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 3px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
        
        /* PDF viewer styling */
        .pdf-container {
            height: calc(100vh - 150px);
            overflow-y: auto;
        }
        
        /* Document preview transitions */
        .document-preview {
            transition: all 0.3s ease;
        }
        
        /* Chat message animations */
        .message-enter {
            animation: messageEnter 0.3s ease-out;
        }
        
        @keyframes messageEnter {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* Pulse animation for AI typing indicator */
        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.5;
            }
        }
        
        .typing-dot {
            animation: pulse 1.5s infinite ease-in-out;
        }
        
        .typing-dot:nth-child(1) {
            animation-delay: 0s;
        }
        
        .typing-dot:nth-child(2) {
            animation-delay: 0.3s;
        }
        
        .typing-dot:nth-child(3) {
            animation-delay: 0.6s;
        }
    </style>
</head>
<body class="bg-gray-100 h-screen flex flex-col">
    <header class="bg-indigo-600 text-white p-4 shadow-md">
        <div class="container mx-auto flex justify-between items-center">
            <div class="flex items-center space-x-2">
                <i class="fas fa-robot text-2xl"></i>
                <h1 class="text-xl font-bold">Document Assistant</h1>
            </div>
            <div class="flex items-center space-x-4">
                <button class="bg-indigo-700 hover:bg-indigo-800 px-4 py-2 rounded-lg flex items-center">
                    <i class="fas fa-plus mr-2"></i>
                    New Document
                </button>
                <div class="relative">
                    <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="User" class="w-8 h-8 rounded-full cursor-pointer">
                    <div class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-10 hidden">
                        <a href="#" class="block px-4 py-2 text-gray-800 hover:bg-gray-100">Profile</a>
                        <a href="#" class="block px-4 py-2 text-gray-800 hover:bg-gray-100">Settings</a>
                        <a href="#" class="block px-4 py-2 text-gray-800 hover:bg-gray-100">Sign out</a>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <div class="flex flex-1 overflow-hidden">
        <!-- Left sidebar - Document selection -->
        <div class="w-64 bg-white border-r border-gray-200 flex flex-col">
            <div class="p-4 border-b border-gray-200">
                <div class="relative">
                    <input type="text" placeholder="Search documents..." class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
                    <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
                </div>
            </div>
            <div class="flex-1 overflow-y-auto">
                <div class="p-4">
                    <h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">Recent Documents</h3>
                    <ul class="space-y-2">
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center document-item active" data-doc="research-paper">
                            <i class="fas fa-file-pdf text-red-500 mr-3"></i>
                            <span>Research Paper.pdf</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center document-item" data-doc="business-plan">
                            <i class="fas fa-file-word text-blue-500 mr-3"></i>
                            <span>Business Plan.docx</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center document-item" data-doc="project-proposal">
                            <i class="fas fa-file-pdf text-red-500 mr-3"></i>
                            <span>Project Proposal.pdf</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center document-item" data-doc="meeting-notes">
                            <i class="fas fa-file-word text-blue-500 mr-3"></i>
                            <span>Meeting Notes.docx</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center document-item" data-doc="web-content">
                            <i class="fas fa-file-code text-green-500 mr-3"></i>
                            <span>Web Content.html</span>
                        </li>
                    </ul>
                </div>
                <div class="p-4 border-t border-gray-200">
                    <h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">Collections</h3>
                    <ul class="space-y-2">
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center">
                            <i class="fas fa-folder text-yellow-500 mr-3"></i>
                            <span>Work Projects</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center">
                            <i class="fas fa-folder text-yellow-500 mr-3"></i>
                            <span>Personal Research</span>
                        </li>
                        <li class="p-2 hover:bg-gray-100 rounded-lg cursor-pointer flex items-center">
                            <i class="fas fa-folder text-yellow-500 mr-3"></i>
                            <span>Archived</span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="p-4 border-t border-gray-200 bg-gray-50">
                <button class="w-full bg-indigo-600 hover:bg-indigo-700 text-white py-2 px-4 rounded-lg flex items-center justify-center">
                    <i class="fas fa-upload mr-2"></i>
                    Upload Document
                </button>
            </div>
        </div>

        <!-- Main chat area -->
        <div class="flex-1 flex flex-col bg-white">
            <div class="flex-1 overflow-y-auto p-4 space-y-4" id="chat-container">
                <!-- Welcome message -->
                <div class="message-enter flex space-x-3">
                    <div class="flex-shrink-0">
                        <div class="h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                            <i class="fas fa-robot text-indigo-600"></i>
                        </div>
                    </div>
                    <div class="bg-gray-100 rounded-lg p-4 max-w-3xl">
                        <p class="text-gray-800">Hello! I'm your Document Assistant. I can help you analyze and cite documents. Select a document from the left sidebar to get started.</p>
                    </div>
                </div>
                
                <!-- Sample chat messages will be added here by JavaScript -->
            </div>
            
            <!-- Input area -->
            <div class="p-4 border-t border-gray-200 bg-white">
                <div class="flex items-center space-x-2">
                    <button class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
                        <i class="fas fa-paperclip"></i>
                    </button>
                    <div class="flex-1 relative">
                        <textarea id="message-input" rows="1" placeholder="Ask about the document..." class="w-full border border-gray-300 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 resize-none" style="min-height: 50px;"></textarea>
                        <button id="send-button" class="absolute right-2 bottom-2 bg-indigo-600 text-white p-1 rounded-full w-8 h-8 flex items-center justify-center hover:bg-indigo-700">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
                <div class="mt-2 text-xs text-gray-500">
                    <p>Document Assistant may produce inaccurate information about people, places, or facts. Always verify citations.</p>
                </div>
            </div>
        </div>

        <!-- Right sidebar - Document preview -->
        <div class="w-80 bg-white border-l border-gray-200 flex flex-col document-preview">
            <div class="p-4 border-b border-gray-200 flex justify-between items-center">
                <h2 class="font-semibold text-gray-800">Document Preview</h2>
                <button class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <div class="flex-1 overflow-y-auto p-4">
                <!-- Default state when no document is selected -->
                <div id="no-document-selected" class="h-full flex flex-col items-center justify-center text-center text-gray-500">
                    <i class="fas fa-file-alt text-4xl mb-4"></i>
                    <p>Select a document from the left sidebar to view it here</p>
                </div>
                
                <!-- PDF Preview -->
                <div id="research-paper-preview" class="hidden">
                    <div class="flex items-center justify-between mb-4">
                        <div class="flex items-center">
                            <i class="fas fa-file-pdf text-red-500 mr-2"></i>
                            <h3 class="font-medium">Research Paper.pdf</h3>
                        </div>
                        <div class="flex space-x-2">
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-download"></i>
                            </button>
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-print"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="pdf-container bg-gray-100 rounded-lg p-4 mb-4">
                        <div class="bg-white p-6 shadow-sm mb-4">
                            <h2 class="text-xl font-bold mb-2">The Impact of Artificial Intelligence on Modern Business</h2>
                            <p class="text-sm text-gray-500 mb-4">By: Dr. Sarah Johnson, Published: March 2023</p>
                            <p class="text-sm mb-4">Abstract: This paper examines the transformative effects of artificial intelligence on various business sectors, focusing on productivity gains, workforce implications, and ethical considerations...</p>
                            <div class="border-t pt-4">
                                <p class="text-xs text-gray-500">Pages: 1 of 24 | Last updated: 2 days ago</p>
                            </div>
                        </div>
                        
                        <div class="bg-white p-6 shadow-sm">
                            <h3 class="font-bold mb-2">1. Introduction</h3>
                            <p class="text-sm mb-4">Artificial Intelligence (AI) has emerged as one of the most significant technological advancements of the 21st century. Its applications span across industries, from healthcare to finance, revolutionizing traditional business models and operational processes...</p>
                            
                            <h3 class="font-bold mb-2">2. Methodology</h3>
                            <p class="text-sm mb-4">Our research methodology combines quantitative analysis of industry data with qualitative interviews from 50 business leaders across different sectors...</p>
                            
                            <div class="border-t pt-4">
                                <p class="text-xs text-gray-500">Pages: 2 of 24</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-sm mb-2">Suggested Citations</h4>
                        <div class="bg-white p-3 rounded text-xs mb-2">
                            <p>APA: Johnson, S. (2023). The Impact of Artificial Intelligence on Modern Business. <em>Journal of Business Technology</em>, 15(2), 45-68.</p>
                        </div>
                        <div class="bg-white p-3 rounded text-xs">
                            <p>MLA: Johnson, Sarah. "The Impact of Artificial Intelligence on Modern Business." <em>Journal of Business Technology</em>, vol. 15, no. 2, 2023, pp. 45-68.</p>
                        </div>
                    </div>
                </div>
                
                <!-- DOCX Preview -->
                <div id="business-plan-preview" class="hidden">
                    <div class="flex items-center justify-between mb-4">
                        <div class="flex items-center">
                            <i class="fas fa-file-word text-blue-500 mr-2"></i>
                            <h3 class="font-medium">Business Plan.docx</h3>
                        </div>
                        <div class="flex space-x-2">
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-download"></i>
                            </button>
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-print"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="bg-gray-100 rounded-lg p-4 mb-4">
                        <div class="bg-white p-6 shadow-sm">
                            <h2 class="text-xl font-bold mb-4 text-center">TechStart Business Plan</h2>
                            
                            <h3 class="font-bold mb-2">Executive Summary</h3>
                            <p class="text-sm mb-4">TechStart is a technology consulting firm specializing in helping small businesses implement digital transformation strategies. Our services include website development, cloud migration, and AI integration...</p>
                            
                            <h3 class="font-bold mb-2">Market Analysis</h3>
                            <p class="text-sm mb-4">The small business technology consulting market is valued at $12 billion annually, with an expected growth rate of 8% over the next five years...</p>
                            
                            <h3 class="font-bold mb-2">Financial Projections</h3>
                            <p class="text-sm mb-4">Year 1 Revenue: $500,000<br>Year 2 Revenue: $1.2 million<br>Year 3 Revenue: $2.5 million</p>
                            
                            <div class="border-t pt-4">
                                <p class="text-xs text-gray-500">Last updated: 1 week ago</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-sm mb-2">Document Information</h4>
                        <div class="grid grid-cols-2 gap-2 text-xs">
                            <div>
                                <p class="text-gray-500">Author:</p>
                                <p>Alex Turner</p>
                            </div>
                            <div>
                                <p class="text-gray-500">Created:</p>
                                <p>January 15, 2023</p>
                            </div>
                            <div>
                                <p class="text-gray-500">Word Count:</p>
                                <p>4,582</p>
                            </div>
                            <div>
                                <p class="text-gray-500">Pages:</p>
                                <p>12</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- HTML Preview -->
                <div id="web-content-preview" class="hidden">
                    <div class="flex items-center justify-between mb-4">
                        <div class="flex items-center">
                            <i class="fas fa-file-code text-green-500 mr-2"></i>
                            <h3 class="font-medium">Web Content.html</h3>
                        </div>
                        <div class="flex space-x-2">
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-download"></i>
                            </button>
                            <button class="p-1 text-gray-500 hover:text-gray-700">
                                <i class="fas fa-code"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div class="bg-gray-100 rounded-lg p-4 mb-4">
                        <div class="bg-white p-6 shadow-sm">
                            <h1 class="text-2xl font-bold mb-4">Sustainable Web Design Practices</h1>
                            
                            <div class="prose prose-sm max-w-none">
                                <p>In the digital age, sustainability isn't just about physical products - it extends to our online presence as well. Sustainable web design focuses on creating websites that are efficient, accessible, and environmentally friendly.</p>
                                
                                <h2>Key Principles</h2>
                                <ul>
                                    <li>Optimized images and media</li>
                                    <li>Efficient code structure</li>
                                    <li>Green hosting solutions</li>
                                    <li>Dark mode implementation</li>
                                    <li>Reduced JavaScript dependencies</li>
                                </ul>
                                
                                <h2>Performance Metrics</h2>
                                <p>A sustainable website should aim for:</p>
                                <table class="w-full border">
                                    <thead>
                                        <tr class="bg-gray-50">
                                            <th class="p-2 text-left border">Metric</th>
                                            <th class="p-2 text-left border">Target</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td class="p-2 border">Page Weight</td>
                                            <td class="p-2 border">&lt; 1MB</td>
                                        </tr>
                                        <tr class="bg-gray-50">
                                            <td class="p-2 border">Load Time</td>
                                            <td class="p-2 border">&lt; 2s</td>
                                        </tr>
                                        <tr>
                                            <td class="p-2 border">Carbon Footprint</td>
                                            <td class="p-2 border">&lt; 0.5g CO2/page view</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            
                            <div class="border-t pt-4 mt-4">
                                <p class="text-xs text-gray-500">Last updated: 3 days ago</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-sm mb-2">Code Snippets</h4>
                        <pre class="bg-gray-800 text-gray-100 p-3 rounded text-xs overflow-x-auto">
&lt;!-- Example of optimized image --&gt;
&lt;picture&gt;
    &lt;source srcset="image.webp" type="image/webp"&gt;
    &lt;source srcset="image.jpg" type="image/jpeg"&gt;
    &lt;img src="image.jpg" alt="Description" loading="lazy"&gt;
&lt;/picture&gt;
                        </pre>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Document selection
            const documentItems = document.querySelectorAll('.document-item');
            const noDocumentSelected = document.getElementById('no-document-selected');
            const previewContainers = document.querySelectorAll('[id$="-preview"]');
            
            documentItems.forEach(item => {
                item.addEventListener('click', function() {
                    // Remove active class from all items
                    documentItems.forEach(i => i.classList.remove('active'));
                    // Add active class to clicked item
                    this.classList.add('active');
                    
                    // Get the document ID
                    const docId = this.getAttribute('data-doc');
                    
                    // Hide all preview containers
                    previewContainers.forEach(container => {
                        container.classList.add('hidden');
                    });
                    
                    // Hide the no document selected message
                    noDocumentSelected.classList.add('hidden');
                    
                    // Show the selected preview container
                    document.getElementById(`${docId}-preview`).classList.remove('hidden');
                    
                    // Add a message to the chat about the document selection
                    addMessageToChat('user', `I've selected ${this.querySelector('span').textContent}`);
                    
                    // Simulate AI response
                    setTimeout(() => {
                        addMessageToChat('assistant', `You've selected ${this.querySelector('span').textContent}. I can help you analyze this document. What would you like to know?`);
                    }, 1000);
                });
            });
            
            // Chat functionality
            const chatContainer = document.getElementById('chat-container');
            const messageInput = document.getElementById('message-input');
            const sendButton = document.getElementById('send-button');
            
            function addMessageToChat(role, content) {
                const messageDiv = document.createElement('div');
                messageDiv.classList.add('message-enter', 'flex', 'space-x-3');
                
                if (role === 'user') {
                    messageDiv.innerHTML = `
                        <div class="flex-shrink-0">
                            <div class="h-10 w-10 rounded-full bg-gray-200 flex items-center justify-center">
                                <i class="fas fa-user text-gray-600"></i>
                            </div>
                        </div>
                        <div class="bg-indigo-100 rounded-lg p-4 max-w-3xl">
                            <p class="text-gray-800">${content}</p>
                        </div>
                    `;
                } else {
                    messageDiv.innerHTML = `
                        <div class="flex-shrink-0">
                            <div class="h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                                <i class="fas fa-robot text-indigo-600"></i>
                            </div>
                        </div>
                        <div class="bg-gray-100 rounded-lg p-4 max-w-3xl">
                            <p class="text-gray-800">${content}</p>
                        </div>
                    `;
                }
                
                chatContainer.appendChild(messageDiv);
                chatContainer.scrollTop = chatContainer.scrollHeight;
            }
            
            function sendMessage() {
                const message = messageInput.value.trim();
                if (message) {
                    addMessageToChat('user', message);
                    messageInput.value = '';
                    
                    // Show typing indicator
                    const typingDiv = document.createElement('div');
                    typingDiv.classList.add('flex', 'space-x-3', 'items-center');
                    typingDiv.innerHTML = `
                        <div class="flex-shrink-0">
                            <div class="h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center">
                                <i class="fas fa-robot text-indigo-600"></i>
                            </div>
                        </div>
                        <div class="bg-gray-100 rounded-lg p-4 max-w-xs">
                            <div class="flex space-x-1">
                                <div class="typing-dot h-2 w-2 bg-gray-500 rounded-full"></div>
                                <div class="typing-dot h-2 w-2 bg-gray-500 rounded-full"></div>
                                <div class="typing-dot h-2 w-2 bg-gray-500 rounded-full"></div>
                            </div>
                        </div>
                    `;
                    chatContainer.appendChild(typingDiv);
                    chatContainer.scrollTop = chatContainer.scrollHeight;
                    
                    // Simulate AI response after a delay
                    setTimeout(() => {
                        // Remove typing indicator
                        chatContainer.removeChild(typingDiv);
                        
                        // Add response
                        const responses = [
                            "Based on the document, I found that...",
                            "The document mentions this information...",
                            "Here's a relevant citation from the document...",
                            "According to the document, the key points are...",
                            "I've analyzed the document and here's what I found..."
                        ];
                        const randomResponse = responses[Math.floor(Math.random() * responses.length)];
                        addMessageToChat('assistant', randomResponse);
                    }, 1500 + Math.random() * 2000);
                }
            }
            
            sendButton.addEventListener('click', sendMessage);
            
            messageInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter' && !e.shiftKey) {
                    e.preventDefault();
                    sendMessage();
                }
            });
            
            // Auto-resize textarea
            messageInput.addEventListener('input', function() {
                this.style.height = 'auto';
                this.style.height = (this.scrollHeight) + 'px';
            });
            
            // Toggle user dropdown
            const userAvatar = document.querySelector('.relative img');
            const userDropdown = document.querySelector('.relative .hidden');
            
            userAvatar.addEventListener('click', function() {
                userDropdown.classList.toggle('hidden');
            });
            
            // Close dropdown when clicking outside
            document.addEventListener('click', function(e) {
                if (!e.target.closest('.relative')) {
                    userDropdown.classList.add('hidden');
                }
            });
        });
    </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=taprosoft/document-assistant" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>