Kishore200630 commited on
Commit
63b1747
·
verified ·
1 Parent(s): 6d4249a

Update templates/chat.html

Browse files
Files changed (1) hide show
  1. templates/chat.html +579 -579
templates/chat.html CHANGED
@@ -1,580 +1,580 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>MediChat - Medical Assistant</title>
8
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
9
- <style>
10
- * {
11
- margin: 0;
12
- padding: 0;
13
- box-sizing: border-box;
14
- }
15
-
16
- body {
17
- font-family: 'Inter', sans-serif;
18
- background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
19
- min-height: 100vh;
20
- display: flex;
21
- justify-content: center;
22
- align-items: center;
23
- padding: 20px;
24
- }
25
-
26
- .chat-container {
27
- width: 100%;
28
- max-width: 420px;
29
- height: 90vh;
30
- max-height: 700px;
31
- background: #ffffff;
32
- border-radius: 24px;
33
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
34
- display: flex;
35
- flex-direction: column;
36
- overflow: hidden;
37
- animation: slideUp 0.5s ease-out;
38
- }
39
-
40
- @keyframes slideUp {
41
- from {
42
- opacity: 0;
43
- transform: translateY(30px);
44
- }
45
-
46
- to {
47
- opacity: 1;
48
- transform: translateY(0);
49
- }
50
- }
51
-
52
- /* Header */
53
- .chat-header {
54
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
55
- padding: 20px;
56
- display: flex;
57
- align-items: center;
58
- gap: 15px;
59
- }
60
-
61
- .medical-icon {
62
- width: 50px;
63
- height: 50px;
64
- background: rgba(255, 255, 255, 0.2);
65
- border-radius: 50%;
66
- display: flex;
67
- align-items: center;
68
- justify-content: center;
69
- animation: pulse 2s infinite;
70
- }
71
-
72
- @keyframes pulse {
73
-
74
- 0%,
75
- 100% {
76
- transform: scale(1);
77
- }
78
-
79
- 50% {
80
- transform: scale(1.05);
81
- }
82
- }
83
-
84
- .medical-icon svg {
85
- width: 28px;
86
- height: 28px;
87
- fill: white;
88
- }
89
-
90
- .header-info h1 {
91
- color: white;
92
- font-size: 18px;
93
- font-weight: 600;
94
- }
95
-
96
- .header-info p {
97
- color: rgba(255, 255, 255, 0.85);
98
- font-size: 13px;
99
- display: flex;
100
- align-items: center;
101
- gap: 5px;
102
- }
103
-
104
- .online-dot {
105
- width: 8px;
106
- height: 8px;
107
- background: #4ade80;
108
- border-radius: 50%;
109
- animation: blink 1.5s infinite;
110
- }
111
-
112
- @keyframes blink {
113
-
114
- 0%,
115
- 100% {
116
- opacity: 1;
117
- }
118
-
119
- 50% {
120
- opacity: 0.5;
121
- }
122
- }
123
-
124
- /* Chat Messages Area */
125
- .chat-messages {
126
- flex: 1;
127
- padding: 20px;
128
- overflow-y: auto;
129
- background: #f8fafc;
130
- display: flex;
131
- flex-direction: column;
132
- gap: 15px;
133
- }
134
-
135
- .message {
136
- display: flex;
137
- flex-direction: column;
138
- max-width: 85%;
139
- animation: fadeIn 0.3s ease-out;
140
- }
141
-
142
- @keyframes fadeIn {
143
- from {
144
- opacity: 0;
145
- transform: translateY(10px);
146
- }
147
-
148
- to {
149
- opacity: 1;
150
- transform: translateY(0);
151
- }
152
- }
153
-
154
- .message.bot {
155
- align-self: flex-start;
156
- }
157
-
158
- .message.user {
159
- align-self: flex-end;
160
- }
161
-
162
- .message-content {
163
- padding: 12px 16px;
164
- border-radius: 18px;
165
- font-size: 14px;
166
- line-height: 1.5;
167
- position: relative;
168
- }
169
-
170
- .message.bot .message-content {
171
- background: white;
172
- color: #1f2937;
173
- border-bottom-left-radius: 4px;
174
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
175
- }
176
-
177
- .message.user .message-content {
178
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
179
- color: white;
180
- border-bottom-right-radius: 4px;
181
- }
182
-
183
- .message-time {
184
- font-size: 11px;
185
- color: #9ca3af;
186
- margin-top: 5px;
187
- display: flex;
188
- align-items: center;
189
- gap: 4px;
190
- }
191
-
192
- .message.user .message-time {
193
- align-self: flex-end;
194
- }
195
-
196
- .message.bot .message-time {
197
- align-self: flex-start;
198
- }
199
-
200
- .question-options {
201
- display: flex;
202
- flex-direction: column;
203
- gap: 10px;
204
- margin-top: 10px;
205
- }
206
-
207
- .question-btn {
208
- background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
209
- border: 1px solid #a7f3d0;
210
- padding: 12px 16px;
211
- border-radius: 12px;
212
- font-size: 13px;
213
- color: #047857;
214
- cursor: pointer;
215
- text-align: left;
216
- transition: all 0.2s ease;
217
- font-family: 'Inter', sans-serif;
218
- display: flex;
219
- align-items: center;
220
- gap: 10px;
221
- }
222
-
223
- .question-btn:hover {
224
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
225
- color: white;
226
- border-color: #10b981;
227
- transform: translateX(5px);
228
- }
229
-
230
- .question-btn .icon {
231
- font-size: 16px;
232
- }
233
-
234
- .typing-indicator {
235
- display: none;
236
- align-items: center;
237
- gap: 4px;
238
- padding: 12px 16px;
239
- background: white;
240
- border-radius: 18px;
241
- border-bottom-left-radius: 4px;
242
- width: fit-content;
243
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
244
- }
245
-
246
- .typing-indicator.show {
247
- display: flex;
248
- }
249
-
250
- .typing-indicator span {
251
- width: 8px;
252
- height: 8px;
253
- background: #10b981;
254
- border-radius: 50%;
255
- animation: typing 1.4s infinite;
256
- }
257
-
258
- .typing-indicator span:nth-child(2) {
259
- animation-delay: 0.2s;
260
- }
261
-
262
- .typing-indicator span:nth-child(3) {
263
- animation-delay: 0.4s;
264
- }
265
-
266
- @keyframes typing {
267
-
268
- 0%,
269
- 60%,
270
- 100% {
271
- transform: translateY(0);
272
- opacity: 0.4;
273
- }
274
-
275
- 30% {
276
- transform: translateY(-8px);
277
- opacity: 1;
278
- }
279
- }
280
-
281
- /* Input Area */
282
- .chat-input {
283
- padding: 15px 20px;
284
- background: white;
285
- border-top: 1px solid #e5e7eb;
286
- display: flex;
287
- align-items: center;
288
- gap: 12px;
289
- }
290
-
291
- .input-wrapper {
292
- flex: 1;
293
- display: flex;
294
- align-items: center;
295
- background: #f3f4f6;
296
- border-radius: 25px;
297
- padding: 0 20px;
298
- transition: all 0.2s ease;
299
- }
300
-
301
- .input-wrapper:focus-within {
302
- background: #e5e7eb;
303
- box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
304
- }
305
-
306
- .chat-input input {
307
- flex: 1;
308
- border: none;
309
- background: transparent;
310
- padding: 14px 0;
311
- font-size: 14px;
312
- font-family: 'Inter', sans-serif;
313
- outline: none;
314
- color: #1f2937;
315
- }
316
-
317
- .chat-input input::placeholder {
318
- color: #9ca3af;
319
- }
320
-
321
- .send-btn {
322
- width: 48px;
323
- height: 48px;
324
- background: linear-gradient(135deg, #10b981 0%, #059669 100%);
325
- border: none;
326
- border-radius: 50%;
327
- cursor: pointer;
328
- display: flex;
329
- align-items: center;
330
- justify-content: center;
331
- transition: all 0.2s ease;
332
- }
333
-
334
- .send-btn:hover {
335
- transform: scale(1.1);
336
- box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
337
- }
338
-
339
- .send-btn:active {
340
- transform: scale(0.95);
341
- }
342
-
343
- .send-btn:disabled {
344
- opacity: 0.6;
345
- cursor: not-allowed;
346
- transform: none;
347
- }
348
-
349
- .send-btn svg {
350
- width: 20px;
351
- height: 20px;
352
- fill: white;
353
- transform: translateX(1px);
354
- }
355
-
356
- /* Date Separator */
357
- .date-separator {
358
- text-align: center;
359
- margin: 10px 0;
360
- }
361
-
362
- .date-separator span {
363
- background: #e5e7eb;
364
- padding: 5px 12px;
365
- border-radius: 10px;
366
- font-size: 12px;
367
- color: #6b7280;
368
- }
369
-
370
- /* Scrollbar Styling */
371
- .chat-messages::-webkit-scrollbar {
372
- width: 6px;
373
- }
374
-
375
- .chat-messages::-webkit-scrollbar-track {
376
- background: transparent;
377
- }
378
-
379
- .chat-messages::-webkit-scrollbar-thumb {
380
- background: #d1d5db;
381
- border-radius: 3px;
382
- }
383
-
384
- .chat-messages::-webkit-scrollbar-thumb:hover {
385
- background: #9ca3af;
386
- }
387
-
388
- .hidden {
389
- display: none !important;
390
- }
391
- </style>
392
- </head>
393
-
394
- <body>
395
- <div class="chat-container">
396
- <div class="chat-header">
397
- <div class="medical-icon">
398
- <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
399
- <path
400
- d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" />
401
- </svg>
402
- </div>
403
- <div class="header-info">
404
- <h1>MediChat Assistant</h1>
405
- <p><span class="online-dot"></span> Online</p>
406
- </div>
407
- </div>
408
-
409
- <div class="chat-messages" id="chatMessages">
410
- <div class="date-separator">
411
- <span id="currentDate"></span>
412
- </div>
413
-
414
- <div class="message bot">
415
- <div class="message-content">
416
- Hello! I'm your MediChat Assistant. I can help answer your medical questions based on my medical
417
- knowledge.
418
- <br><br>
419
- Try asking me about:
420
-
421
- <div class="question-options" id="questionOptions">
422
- <button class="question-btn" data-question="What are the symptoms of diabetes?">
423
- What are the symptoms of diabetes?
424
- </button>
425
-
426
- <button class="question-btn" data-question="What causes headache?">
427
- What causes headache?
428
- </button>
429
-
430
- <button class="question-btn" data-question="What medicines are commonly used for diabetes?">
431
- What medicines are commonly used for diabetes?
432
- </button>
433
-
434
- <button class="question-btn"
435
- data-question="Which medicines are used to control high blood pressure?">
436
- Which medicines are used to control high blood pressure?
437
- </button>
438
- </div>
439
-
440
- </div>
441
- <span class="message-time" id="initialTime"></span>
442
- </div>
443
-
444
- <div class="typing-indicator" id="typingIndicator">
445
- <span></span>
446
- <span></span>
447
- <span></span>
448
- </div>
449
- </div>
450
-
451
- <div class="chat-input">
452
- <div class="input-wrapper">
453
- <input type="text" id="messageInput" placeholder="Type your health question...">
454
- </div>
455
- <button class="send-btn" id="sendBtn">
456
- <svg viewBox="0 0 24 24">
457
- <path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" />
458
- </svg>
459
- </button>
460
- </div>
461
- </div>
462
-
463
- <script>
464
- const chatMessages = document.getElementById('chatMessages');
465
- const typingIndicator = document.getElementById('typingIndicator');
466
- const questionOptions = document.getElementById('questionOptions');
467
- const messageInput = document.getElementById('messageInput');
468
- const sendBtn = document.getElementById('sendBtn');
469
-
470
- function getCurrentTime() {
471
- const now = new Date();
472
- let hours = now.getHours();
473
- const minutes = now.getMinutes().toString().padStart(2, '0');
474
- const ampm = hours >= 12 ? 'PM' : 'AM';
475
- hours = hours % 12;
476
- hours = hours ? hours : 12;
477
- return `${hours}:${minutes} ${ampm}`;
478
- }
479
-
480
- function getCurrentDate() {
481
- const now = new Date();
482
- const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
483
- return now.toLocaleDateString('en-US', options);
484
- }
485
-
486
- document.getElementById('currentDate').textContent = getCurrentDate();
487
- document.getElementById('initialTime').textContent = getCurrentTime();
488
-
489
- function addMessage(content, isUser = false) {
490
- const messageDiv = document.createElement('div');
491
- messageDiv.className = `message ${isUser ? 'user' : 'bot'}`;
492
- messageDiv.innerHTML = `
493
- <div class="message-content">${content}</div>
494
- <span class="message-time">${getCurrentTime()}</span>
495
- `;
496
- chatMessages.insertBefore(messageDiv, typingIndicator);
497
- chatMessages.scrollTop = chatMessages.scrollHeight;
498
- }
499
-
500
- function showTyping() {
501
- typingIndicator.classList.add('show');
502
- chatMessages.scrollTop = chatMessages.scrollHeight;
503
- }
504
-
505
- function hideTyping() {
506
- typingIndicator.classList.remove('show');
507
- }
508
-
509
- function setInputEnabled(enabled) {
510
- messageInput.disabled = !enabled;
511
- sendBtn.disabled = !enabled;
512
- }
513
-
514
- async function sendMessageToBackend(message) {
515
- const formData = new FormData();
516
- formData.append('msg', message);
517
-
518
- try {
519
- const response = await fetch('/get', {
520
- method: 'POST',
521
- body: formData
522
- });
523
-
524
- if (!response.ok) {
525
- throw new Error('Network response was not ok');
526
- }
527
-
528
- return await response.text();
529
- } catch (error) {
530
- console.error('Error:', error);
531
- return 'Sorry, I encountered an error processing your request. Please try again.';
532
- }
533
- }
534
-
535
- async function handleQuestionClick(question) {
536
- questionOptions.classList.add('hidden');
537
-
538
- addMessage(question, true);
539
-
540
- showTyping();
541
- setInputEnabled(false);
542
-
543
- const response = await sendMessageToBackend(question);
544
-
545
- hideTyping();
546
- setInputEnabled(true);
547
- addMessage(response);
548
- }
549
-
550
- document.querySelectorAll('.question-btn').forEach(btn => {
551
- btn.addEventListener('click', () => {
552
- handleQuestionClick(btn.dataset.question);
553
- });
554
- });
555
-
556
- async function sendMessage() {
557
- const text = messageInput.value.trim();
558
- if (!text) return;
559
-
560
- addMessage(text, true);
561
- messageInput.value = '';
562
-
563
- showTyping();
564
- setInputEnabled(false);
565
-
566
- const response = await sendMessageToBackend(text);
567
-
568
- hideTyping();
569
- setInputEnabled(true);
570
- addMessage(response);
571
- }
572
-
573
- sendBtn.addEventListener('click', sendMessage);
574
- messageInput.addEventListener('keypress', (e) => {
575
- if (e.key === 'Enter' && !sendBtn.disabled) sendMessage();
576
- });
577
- </script>
578
- </body>
579
-
580
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>MediChat - Medical Assistant</title>
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
9
+ <style>
10
+ * {
11
+ margin: 0;
12
+ padding: 0;
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ body {
17
+ font-family: 'Inter', sans-serif;
18
+ background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 100%);
19
+ min-height: 100vh;
20
+ display: flex;
21
+ justify-content: center;
22
+ align-items: center;
23
+ padding: 20px;
24
+ }
25
+
26
+ .chat-container {
27
+ width: 100%;
28
+ max-width: 420px;
29
+ height: 90vh;
30
+ max-height: 700px;
31
+ background: #ffffff;
32
+ border-radius: 24px;
33
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
34
+ display: flex;
35
+ flex-direction: column;
36
+ overflow: hidden;
37
+ animation: slideUp 0.5s ease-out;
38
+ }
39
+
40
+ @keyframes slideUp {
41
+ from {
42
+ opacity: 0;
43
+ transform: translateY(30px);
44
+ }
45
+
46
+ to {
47
+ opacity: 1;
48
+ transform: translateY(0);
49
+ }
50
+ }
51
+
52
+ /* Header */
53
+ .chat-header {
54
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
55
+ padding: 20px;
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 15px;
59
+ }
60
+
61
+ .medical-icon {
62
+ width: 50px;
63
+ height: 50px;
64
+ background: rgba(255, 255, 255, 0.2);
65
+ border-radius: 50%;
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: center;
69
+ animation: pulse 2s infinite;
70
+ }
71
+
72
+ @keyframes pulse {
73
+
74
+ 0%,
75
+ 100% {
76
+ transform: scale(1);
77
+ }
78
+
79
+ 50% {
80
+ transform: scale(1.05);
81
+ }
82
+ }
83
+
84
+ .medical-icon svg {
85
+ width: 28px;
86
+ height: 28px;
87
+ fill: white;
88
+ }
89
+
90
+ .header-info h1 {
91
+ color: white;
92
+ font-size: 18px;
93
+ font-weight: 600;
94
+ }
95
+
96
+ .header-info p {
97
+ color: rgba(255, 255, 255, 0.85);
98
+ font-size: 13px;
99
+ display: flex;
100
+ align-items: center;
101
+ gap: 5px;
102
+ }
103
+
104
+ .online-dot {
105
+ width: 8px;
106
+ height: 8px;
107
+ background: #4ade80;
108
+ border-radius: 50%;
109
+ animation: blink 1.5s infinite;
110
+ }
111
+
112
+ @keyframes blink {
113
+
114
+ 0%,
115
+ 100% {
116
+ opacity: 1;
117
+ }
118
+
119
+ 50% {
120
+ opacity: 0.5;
121
+ }
122
+ }
123
+
124
+ /* Chat Messages Area */
125
+ .chat-messages {
126
+ flex: 1;
127
+ padding: 20px;
128
+ overflow-y: auto;
129
+ background: #f8fafc;
130
+ display: flex;
131
+ flex-direction: column;
132
+ gap: 15px;
133
+ }
134
+
135
+ .message {
136
+ display: flex;
137
+ flex-direction: column;
138
+ max-width: 85%;
139
+ animation: fadeIn 0.3s ease-out;
140
+ }
141
+
142
+ @keyframes fadeIn {
143
+ from {
144
+ opacity: 0;
145
+ transform: translateY(10px);
146
+ }
147
+
148
+ to {
149
+ opacity: 1;
150
+ transform: translateY(0);
151
+ }
152
+ }
153
+
154
+ .message.bot {
155
+ align-self: flex-start;
156
+ }
157
+
158
+ .message.user {
159
+ align-self: flex-end;
160
+ }
161
+
162
+ .message-content {
163
+ padding: 12px 16px;
164
+ border-radius: 18px;
165
+ font-size: 14px;
166
+ line-height: 1.5;
167
+ position: relative;
168
+ }
169
+
170
+ .message.bot .message-content {
171
+ background: white;
172
+ color: #1f2937;
173
+ border-bottom-left-radius: 4px;
174
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
175
+ }
176
+
177
+ .message.user .message-content {
178
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
179
+ color: white;
180
+ border-bottom-right-radius: 4px;
181
+ }
182
+
183
+ .message-time {
184
+ font-size: 11px;
185
+ color: #9ca3af;
186
+ margin-top: 5px;
187
+ display: flex;
188
+ align-items: center;
189
+ gap: 4px;
190
+ }
191
+
192
+ .message.user .message-time {
193
+ align-self: flex-end;
194
+ }
195
+
196
+ .message.bot .message-time {
197
+ align-self: flex-start;
198
+ }
199
+
200
+ .question-options {
201
+ display: flex;
202
+ flex-direction: column;
203
+ gap: 10px;
204
+ margin-top: 10px;
205
+ }
206
+
207
+ .question-btn {
208
+ background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
209
+ border: 1px solid #a7f3d0;
210
+ padding: 12px 16px;
211
+ border-radius: 12px;
212
+ font-size: 13px;
213
+ color: #047857;
214
+ cursor: pointer;
215
+ text-align: left;
216
+ transition: all 0.2s ease;
217
+ font-family: 'Inter', sans-serif;
218
+ display: flex;
219
+ align-items: center;
220
+ gap: 10px;
221
+ }
222
+
223
+ .question-btn:hover {
224
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
225
+ color: white;
226
+ border-color: #10b981;
227
+ transform: translateX(5px);
228
+ }
229
+
230
+ .question-btn .icon {
231
+ font-size: 16px;
232
+ }
233
+
234
+ .typing-indicator {
235
+ display: none;
236
+ align-items: center;
237
+ gap: 4px;
238
+ padding: 12px 16px;
239
+ background: white;
240
+ border-radius: 18px;
241
+ border-bottom-left-radius: 4px;
242
+ width: fit-content;
243
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
244
+ }
245
+
246
+ .typing-indicator.show {
247
+ display: flex;
248
+ }
249
+
250
+ .typing-indicator span {
251
+ width: 8px;
252
+ height: 8px;
253
+ background: #10b981;
254
+ border-radius: 50%;
255
+ animation: typing 1.4s infinite;
256
+ }
257
+
258
+ .typing-indicator span:nth-child(2) {
259
+ animation-delay: 0.2s;
260
+ }
261
+
262
+ .typing-indicator span:nth-child(3) {
263
+ animation-delay: 0.4s;
264
+ }
265
+
266
+ @keyframes typing {
267
+
268
+ 0%,
269
+ 60%,
270
+ 100% {
271
+ transform: translateY(0);
272
+ opacity: 0.4;
273
+ }
274
+
275
+ 30% {
276
+ transform: translateY(-8px);
277
+ opacity: 1;
278
+ }
279
+ }
280
+
281
+ /* Input Area */
282
+ .chat-input {
283
+ padding: 15px 20px;
284
+ background: white;
285
+ border-top: 1px solid #e5e7eb;
286
+ display: flex;
287
+ align-items: center;
288
+ gap: 12px;
289
+ }
290
+
291
+ .input-wrapper {
292
+ flex: 1;
293
+ display: flex;
294
+ align-items: center;
295
+ background: #f3f4f6;
296
+ border-radius: 25px;
297
+ padding: 0 20px;
298
+ transition: all 0.2s ease;
299
+ }
300
+
301
+ .input-wrapper:focus-within {
302
+ background: #e5e7eb;
303
+ box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
304
+ }
305
+
306
+ .chat-input input {
307
+ flex: 1;
308
+ border: none;
309
+ background: transparent;
310
+ padding: 14px 0;
311
+ font-size: 14px;
312
+ font-family: 'Inter', sans-serif;
313
+ outline: none;
314
+ color: #1f2937;
315
+ }
316
+
317
+ .chat-input input::placeholder {
318
+ color: #9ca3af;
319
+ }
320
+
321
+ .send-btn {
322
+ width: 48px;
323
+ height: 48px;
324
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
325
+ border: none;
326
+ border-radius: 50%;
327
+ cursor: pointer;
328
+ display: flex;
329
+ align-items: center;
330
+ justify-content: center;
331
+ transition: all 0.2s ease;
332
+ }
333
+
334
+ .send-btn:hover {
335
+ transform: scale(1.1);
336
+ box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
337
+ }
338
+
339
+ .send-btn:active {
340
+ transform: scale(0.95);
341
+ }
342
+
343
+ .send-btn:disabled {
344
+ opacity: 0.6;
345
+ cursor: not-allowed;
346
+ transform: none;
347
+ }
348
+
349
+ .send-btn svg {
350
+ width: 20px;
351
+ height: 20px;
352
+ fill: white;
353
+ transform: translateX(1px);
354
+ }
355
+
356
+ /* Date Separator */
357
+ .date-separator {
358
+ text-align: center;
359
+ margin: 10px 0;
360
+ }
361
+
362
+ .date-separator span {
363
+ background: #e5e7eb;
364
+ padding: 5px 12px;
365
+ border-radius: 10px;
366
+ font-size: 12px;
367
+ color: #6b7280;
368
+ }
369
+
370
+ /* Scrollbar Styling */
371
+ .chat-messages::-webkit-scrollbar {
372
+ width: 6px;
373
+ }
374
+
375
+ .chat-messages::-webkit-scrollbar-track {
376
+ background: transparent;
377
+ }
378
+
379
+ .chat-messages::-webkit-scrollbar-thumb {
380
+ background: #d1d5db;
381
+ border-radius: 3px;
382
+ }
383
+
384
+ .chat-messages::-webkit-scrollbar-thumb:hover {
385
+ background: #9ca3af;
386
+ }
387
+
388
+ .hidden {
389
+ display: none !important;
390
+ }
391
+ </style>
392
+ </head>
393
+
394
+ <body>
395
+ <div class="chat-container">
396
+ <div class="chat-header">
397
+ <div class="medical-icon">
398
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
399
+ <path
400
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" />
401
+ </svg>
402
+ </div>
403
+ <div class="header-info">
404
+ <h1>MediChat Assistant</h1>
405
+ <p><span class="online-dot"></span> Online</p>
406
+ </div>
407
+ </div>
408
+
409
+ <div class="chat-messages" id="chatMessages">
410
+ <div class="date-separator">
411
+ <span id="currentDate"></span>
412
+ </div>
413
+
414
+ <div class="message bot">
415
+ <div class="message-content">
416
+ Hello! I'm your MediChat Assistant. I can help answer your medical questions based on my medical
417
+ knowledge.
418
+ <br><br>
419
+ Try asking me about:
420
+
421
+ <div class="question-options" id="questionOptions">
422
+ <button class="question-btn" data-question="What are the symptoms of diabetes?">
423
+ What are the symptoms of diabetes?
424
+ </button>
425
+
426
+ <button class="question-btn" data-question="What is endoscopy?">
427
+ What is Endoscopy?
428
+ </button>
429
+
430
+ <button class="question-btn" data-question="What medicines are commonly used for diabetes?">
431
+ What medicines are commonly used for diabetes?
432
+ </button>
433
+
434
+ <button class="question-btn"
435
+ data-question="Which medicines are used to control high blood pressure?">
436
+ Which medicines are used to control high blood pressure?
437
+ </button>
438
+ </div>
439
+
440
+ </div>
441
+ <span class="message-time" id="initialTime"></span>
442
+ </div>
443
+
444
+ <div class="typing-indicator" id="typingIndicator">
445
+ <span></span>
446
+ <span></span>
447
+ <span></span>
448
+ </div>
449
+ </div>
450
+
451
+ <div class="chat-input">
452
+ <div class="input-wrapper">
453
+ <input type="text" id="messageInput" placeholder="Type your health question...">
454
+ </div>
455
+ <button class="send-btn" id="sendBtn">
456
+ <svg viewBox="0 0 24 24">
457
+ <path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" />
458
+ </svg>
459
+ </button>
460
+ </div>
461
+ </div>
462
+
463
+ <script>
464
+ const chatMessages = document.getElementById('chatMessages');
465
+ const typingIndicator = document.getElementById('typingIndicator');
466
+ const questionOptions = document.getElementById('questionOptions');
467
+ const messageInput = document.getElementById('messageInput');
468
+ const sendBtn = document.getElementById('sendBtn');
469
+
470
+ function getCurrentTime() {
471
+ const now = new Date();
472
+ let hours = now.getHours();
473
+ const minutes = now.getMinutes().toString().padStart(2, '0');
474
+ const ampm = hours >= 12 ? 'PM' : 'AM';
475
+ hours = hours % 12;
476
+ hours = hours ? hours : 12;
477
+ return `${hours}:${minutes} ${ampm}`;
478
+ }
479
+
480
+ function getCurrentDate() {
481
+ const now = new Date();
482
+ const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
483
+ return now.toLocaleDateString('en-US', options);
484
+ }
485
+
486
+ document.getElementById('currentDate').textContent = getCurrentDate();
487
+ document.getElementById('initialTime').textContent = getCurrentTime();
488
+
489
+ function addMessage(content, isUser = false) {
490
+ const messageDiv = document.createElement('div');
491
+ messageDiv.className = `message ${isUser ? 'user' : 'bot'}`;
492
+ messageDiv.innerHTML = `
493
+ <div class="message-content">${content}</div>
494
+ <span class="message-time">${getCurrentTime()}</span>
495
+ `;
496
+ chatMessages.insertBefore(messageDiv, typingIndicator);
497
+ chatMessages.scrollTop = chatMessages.scrollHeight;
498
+ }
499
+
500
+ function showTyping() {
501
+ typingIndicator.classList.add('show');
502
+ chatMessages.scrollTop = chatMessages.scrollHeight;
503
+ }
504
+
505
+ function hideTyping() {
506
+ typingIndicator.classList.remove('show');
507
+ }
508
+
509
+ function setInputEnabled(enabled) {
510
+ messageInput.disabled = !enabled;
511
+ sendBtn.disabled = !enabled;
512
+ }
513
+
514
+ async function sendMessageToBackend(message) {
515
+ const formData = new FormData();
516
+ formData.append('msg', message);
517
+
518
+ try {
519
+ const response = await fetch('/get', {
520
+ method: 'POST',
521
+ body: formData
522
+ });
523
+
524
+ if (!response.ok) {
525
+ throw new Error('Network response was not ok');
526
+ }
527
+
528
+ return await response.text();
529
+ } catch (error) {
530
+ console.error('Error:', error);
531
+ return 'Sorry, I encountered an error processing your request. Please try again.';
532
+ }
533
+ }
534
+
535
+ async function handleQuestionClick(question) {
536
+ questionOptions.classList.add('hidden');
537
+
538
+ addMessage(question, true);
539
+
540
+ showTyping();
541
+ setInputEnabled(false);
542
+
543
+ const response = await sendMessageToBackend(question);
544
+
545
+ hideTyping();
546
+ setInputEnabled(true);
547
+ addMessage(response);
548
+ }
549
+
550
+ document.querySelectorAll('.question-btn').forEach(btn => {
551
+ btn.addEventListener('click', () => {
552
+ handleQuestionClick(btn.dataset.question);
553
+ });
554
+ });
555
+
556
+ async function sendMessage() {
557
+ const text = messageInput.value.trim();
558
+ if (!text) return;
559
+
560
+ addMessage(text, true);
561
+ messageInput.value = '';
562
+
563
+ showTyping();
564
+ setInputEnabled(false);
565
+
566
+ const response = await sendMessageToBackend(text);
567
+
568
+ hideTyping();
569
+ setInputEnabled(true);
570
+ addMessage(response);
571
+ }
572
+
573
+ sendBtn.addEventListener('click', sendMessage);
574
+ messageInput.addEventListener('keypress', (e) => {
575
+ if (e.key === 'Enter' && !sendBtn.disabled) sendMessage();
576
+ });
577
+ </script>
578
+ </body>
579
+
580
  </html>