Mousco commited on
Commit
c78f85f
·
verified ·
1 Parent(s): 743a80b

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +752 -19
index.html CHANGED
@@ -1,19 +1,752 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Répond AI - Assistant Virtuel</title>
7
+
8
+ <!-- Importation des icônes RemixIcon -->
9
+ <link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
10
+
11
+ <!-- Police Google Fonts (Inter) -->
12
+ <link rel="preconnect" href="https://fonts.googleapis.com">
13
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
15
+
16
+ <style>
17
+ :root {
18
+ /* Palette de couleurs (Thème Sombre / Néon) */
19
+ --bg-body: #0f172a;
20
+ --bg-sidebar: #1e293b;
21
+ --bg-chat: #0f172a;
22
+ --primary: #6366f1;
23
+ --primary-hover: #4f46e5;
24
+ --accent: #ec4899;
25
+ --glass-bg: rgba(30, 41, 59, 0.7);
26
+ --glass-border: rgba(255, 255, 255, 0.1);
27
+ --text-main: #f8fafc;
28
+ --text-muted: #94a3b8;
29
+ --msg-user-bg: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
30
+ --msg-ai-bg: #1e293b;
31
+ --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
32
+ --radius-lg: 16px;
33
+ --radius-md: 12px;
34
+ --header-height: 60px;
35
+ }
36
+
37
+ * {
38
+ margin: 0;
39
+ padding: 0;
40
+ box-sizing: border-box;
41
+ font-family: 'Inter', sans-serif;
42
+ }
43
+
44
+ body {
45
+ background-color: var(--bg-body);
46
+ color: var(--text-main);
47
+ height: 100vh;
48
+ overflow: hidden;
49
+ display: flex;
50
+ flex-direction: column;
51
+ }
52
+
53
+ /* --- Header --- */
54
+ header {
55
+ height: var(--header-height);
56
+ background: rgba(15, 23, 42, 0.8);
57
+ backdrop-filter: blur(10px);
58
+ border-bottom: 1px solid var(--glass-border);
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: space-between;
62
+ padding: 0 20px;
63
+ position: fixed;
64
+ top: 0;
65
+ width: 100%;
66
+ z-index: 100;
67
+ }
68
+
69
+ .brand {
70
+ display: flex;
71
+ align-items: center;
72
+ gap: 10px;
73
+ font-weight: 700;
74
+ font-size: 1.2rem;
75
+ color: var(--text-main);
76
+ }
77
+
78
+ .brand i {
79
+ color: var(--primary);
80
+ font-size: 1.5rem;
81
+ }
82
+
83
+ .anycoder-link {
84
+ font-size: 0.85rem;
85
+ color: var(--text-muted);
86
+ text-decoration: none;
87
+ transition: color 0.3s;
88
+ background: rgba(255,255,255,0.05);
89
+ padding: 5px 12px;
90
+ border-radius: 20px;
91
+ border: 1px solid var(--glass-border);
92
+ }
93
+
94
+ .anycoder-link:hover {
95
+ color: var(--primary);
96
+ border-color: var(--primary);
97
+ }
98
+
99
+ /* --- Main Layout --- */
100
+ .app-container {
101
+ display: flex;
102
+ height: 100vh;
103
+ padding-top: var(--header-height);
104
+ }
105
+
106
+ /* --- Sidebar --- */
107
+ aside {
108
+ width: 260px;
109
+ background-color: var(--bg-sidebar);
110
+ border-right: 1px solid var(--glass-border);
111
+ display: flex;
112
+ flex-direction: column;
113
+ transition: transform 0.3s ease;
114
+ z-index: 50;
115
+ }
116
+
117
+ .sidebar-header {
118
+ padding: 20px;
119
+ }
120
+
121
+ .new-chat-btn {
122
+ width: 100%;
123
+ padding: 12px;
124
+ background: var(--primary);
125
+ color: white;
126
+ border: none;
127
+ border-radius: var(--radius-md);
128
+ font-weight: 500;
129
+ cursor: pointer;
130
+ display: flex;
131
+ align-items: center;
132
+ justify-content: center;
133
+ gap: 8px;
134
+ transition: background 0.2s;
135
+ }
136
+
137
+ .new-chat-btn:hover {
138
+ background: var(--primary-hover);
139
+ }
140
+
141
+ .history-list {
142
+ flex: 1;
143
+ overflow-y: auto;
144
+ padding: 0 10px;
145
+ }
146
+
147
+ .history-group-title {
148
+ font-size: 0.75rem;
149
+ color: var(--text-muted);
150
+ padding: 15px 10px 5px;
151
+ text-transform: uppercase;
152
+ letter-spacing: 0.5px;
153
+ }
154
+
155
+ .history-item {
156
+ padding: 10px 12px;
157
+ border-radius: 8px;
158
+ color: var(--text-main);
159
+ text-decoration: none;
160
+ display: flex;
161
+ align-items: center;
162
+ gap: 10px;
163
+ font-size: 0.9rem;
164
+ cursor: pointer;
165
+ transition: background 0.2s;
166
+ white-space: nowrap;
167
+ overflow: hidden;
168
+ text-overflow: ellipsis;
169
+ }
170
+
171
+ .history-item:hover {
172
+ background: rgba(255, 255, 255, 0.05);
173
+ }
174
+
175
+ .history-item i {
176
+ color: var(--text-muted);
177
+ }
178
+
179
+ .user-profile {
180
+ padding: 20px;
181
+ border-top: 1px solid var(--glass-border);
182
+ display: flex;
183
+ align-items: center;
184
+ gap: 10px;
185
+ }
186
+
187
+ .avatar {
188
+ width: 32px;
189
+ height: 32px;
190
+ border-radius: 50%;
191
+ object-fit: cover;
192
+ border: 2px solid var(--primary);
193
+ }
194
+
195
+ .user-info h4 {
196
+ font-size: 0.9rem;
197
+ font-weight: 500;
198
+ }
199
+
200
+ .user-info span {
201
+ font-size: 0.75rem;
202
+ color: var(--text-muted);
203
+ }
204
+
205
+ /* --- Chat Area --- */
206
+ main {
207
+ flex: 1;
208
+ display: flex;
209
+ flex-direction: column;
210
+ background-color: var(--bg-chat);
211
+ position: relative;
212
+ }
213
+
214
+ .chat-container {
215
+ flex: 1;
216
+ overflow-y: auto;
217
+ padding: 20px 0;
218
+ display: flex;
219
+ flex-direction: column;
220
+ gap: 20px;
221
+ scroll-behavior: smooth;
222
+ }
223
+
224
+ /* Scrollbar styling */
225
+ .chat-container::-webkit-scrollbar {
226
+ width: 8px;
227
+ }
228
+ .chat-container::-webkit-scrollbar-track {
229
+ background: transparent;
230
+ }
231
+ .chat-container::-webkit-scrollbar-thumb {
232
+ background: rgba(255, 255, 255, 0.1);
233
+ border-radius: 4px;
234
+ }
235
+
236
+ .message-wrapper {
237
+ display: flex;
238
+ justify-content: center;
239
+ padding: 0 20px;
240
+ animation: fadeIn 0.3s ease-out;
241
+ }
242
+
243
+ .message {
244
+ max-width: 800px;
245
+ width: 100%;
246
+ display: flex;
247
+ gap: 16px;
248
+ }
249
+
250
+ .message.user {
251
+ flex-direction: row-reverse;
252
+ }
253
+
254
+ .message-avatar {
255
+ width: 36px;
256
+ height: 36px;
257
+ border-radius: 8px;
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ flex-shrink: 0;
262
+ }
263
+
264
+ .ai-avatar {
265
+ background: linear-gradient(135deg, #10b981, #059669);
266
+ color: white;
267
+ }
268
+
269
+ .user-avatar-img {
270
+ width: 100%;
271
+ height: 100%;
272
+ border-radius: 8px;
273
+ object-fit: cover;
274
+ }
275
+
276
+ .message-content {
277
+ padding: 12px 16px;
278
+ border-radius: var(--radius-lg);
279
+ font-size: 0.95rem;
280
+ line-height: 1.5;
281
+ position: relative;
282
+ }
283
+
284
+ .message.ai .message-content {
285
+ background-color: var(--msg-ai-bg);
286
+ color: var(--text-main);
287
+ border-top-left-radius: 2px;
288
+ }
289
+
290
+ .message.user .message-content {
291
+ background: var(--msg-user-bg);
292
+ color: white;
293
+ border-top-right-radius: 2px;
294
+ }
295
+
296
+ .message-time {
297
+ font-size: 0.7rem;
298
+ margin-top: 5px;
299
+ opacity: 0.7;
300
+ text-align: right;
301
+ }
302
+
303
+ .message.ai .message-time {
304
+ text-align: left;
305
+ }
306
+
307
+ /* --- Input Area --- */
308
+ .input-area {
309
+ padding: 20px;
310
+ background: linear-gradient(to top, var(--bg-chat) 80%, transparent);
311
+ display: flex;
312
+ justify-content: center;
313
+ }
314
+
315
+ .input-wrapper {
316
+ max-width: 800px;
317
+ width: 100%;
318
+ position: relative;
319
+ background: var(--glass-bg);
320
+ border: 1px solid var(--glass-border);
321
+ border-radius: 24px;
322
+ padding: 8px 16px;
323
+ display: flex;
324
+ align-items: flex-end;
325
+ gap: 10px;
326
+ box-shadow: var(--shadow-lg);
327
+ backdrop-filter: blur(12px);
328
+ }
329
+
330
+ .input-wrapper:focus-within {
331
+ border-color: var(--primary);
332
+ box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
333
+ }
334
+
335
+ textarea {
336
+ flex: 1;
337
+ background: transparent;
338
+ border: none;
339
+ color: var(--text-main);
340
+ font-size: 1rem;
341
+ resize: none;
342
+ max-height: 150px;
343
+ padding: 10px 0;
344
+ outline: none;
345
+ line-height: 1.4;
346
+ }
347
+
348
+ .send-btn {
349
+ background: var(--primary);
350
+ color: white;
351
+ border: none;
352
+ width: 36px;
353
+ height: 36px;
354
+ border-radius: 50%;
355
+ display: flex;
356
+ align-items: center;
357
+ justify-content: center;
358
+ cursor: pointer;
359
+ transition: transform 0.2s, background 0.2s;
360
+ margin-bottom: 4px;
361
+ }
362
+
363
+ .send-btn:hover {
364
+ background: var(--primary-hover);
365
+ transform: scale(1.05);
366
+ }
367
+
368
+ .send-btn:disabled {
369
+ background: var(--text-muted);
370
+ cursor: not-allowed;
371
+ opacity: 0.5;
372
+ }
373
+
374
+ /* --- Animations --- */
375
+ @keyframes fadeIn {
376
+ from { opacity: 0; transform: translateY(10px); }
377
+ to { opacity: 1; transform: translateY(0); }
378
+ }
379
+
380
+ @keyframes bounce {
381
+ 0%, 100% { transform: translateY(0); }
382
+ 50% { transform: translateY(-4px); }
383
+ }
384
+
385
+ .typing-indicator {
386
+ display: flex;
387
+ gap: 4px;
388
+ padding: 4px 8px;
389
+ }
390
+
391
+ .dot {
392
+ width: 6px;
393
+ height: 6px;
394
+ background: var(--text-muted);
395
+ border-radius: 50%;
396
+ animation: bounce 1.4s infinite ease-in-out both;
397
+ }
398
+
399
+ .dot:nth-child(1) { animation-delay: -0.32s; }
400
+ .dot:nth-child(2) { animation-delay: -0.16s; }
401
+
402
+ /* --- Toast Notification --- */
403
+ .toast {
404
+ position: fixed;
405
+ bottom: 20px;
406
+ left: 50%;
407
+ transform: translateX(-50%) translateY(100px);
408
+ background: #ef4444;
409
+ color: white;
410
+ padding: 10px 20px;
411
+ border-radius: 8px;
412
+ font-size: 0.9rem;
413
+ opacity: 0;
414
+ transition: all 0.3s ease;
415
+ z-index: 1000;
416
+ box-shadow: 0 4px 6px rgba(0,0,0,0.2);
417
+ }
418
+ .toast.show {
419
+ transform: translateX(-50%) translateY(0);
420
+ opacity: 1;
421
+ }
422
+
423
+ /* --- Mobile Responsive --- */
424
+ .mobile-menu-btn {
425
+ display: none;
426
+ background: none;
427
+ border: none;
428
+ color: var(--text-main);
429
+ font-size: 1.5rem;
430
+ cursor: pointer;
431
+ }
432
+
433
+ @media (max-width: 768px) {
434
+ aside {
435
+ position: absolute;
436
+ height: calc(100vh - var(--header-height));
437
+ transform: translateX(-100%);
438
+ box-shadow: var(--shadow-lg);
439
+ }
440
+
441
+ aside.open {
442
+ transform: translateX(0);
443
+ }
444
+
445
+ .mobile-menu-btn {
446
+ display: block;
447
+ }
448
+
449
+ .message {
450
+ gap: 8px;
451
+ }
452
+
453
+ .message-content {
454
+ font-size: 0.9rem;
455
+ }
456
+ }
457
+ </style>
458
+ </head>
459
+ <body>
460
+
461
+ <!-- Header -->
462
+ <header>
463
+ <div class="brand">
464
+ <button class="mobile-menu-btn" id="menuToggle" aria-label="Menu">
465
+ <i class="ri-menu-line"></i>
466
+ </button>
467
+ <i class="ri-robot-2-fill"></i>
468
+ <span>Répond AI</span>
469
+ </div>
470
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
471
+ Built with anycoder <i class="ri-external-link-line" style="font-size: 0.8em;"></i>
472
+ </a>
473
+ </header>
474
+
475
+ <div class="app-container">
476
+ <!-- Sidebar -->
477
+ <aside id="sidebar">
478
+ <div class="sidebar-header">
479
+ <button class="new-chat-btn" id="newChatBtn">
480
+ <i class="ri-add-line"></i> Nouvelle Discussion
481
+ </button>
482
+ </div>
483
+
484
+ <div class="history-list">
485
+ <div class="history-group-title">Aujourd'hui</div>
486
+ <div class="history-item"><i class="ri-message-3-line"></i> Idées marketing</div>
487
+ <div class="history-item"><i class="ri-message-3-line"></i> Recette Python</div>
488
+ <div class="history-item"><i class="ri-message-3-line"></i> Voyage au Japon</div>
489
+
490
+ <div class="history-group-title">Hier</div>
491
+ <div class="history-item"><i class="ri-message-3-line"></i> Analyse de données</div>
492
+ <div class="history-item"><i class="ri-message-3-line"></i> Email professionnel</div>
493
+ </div>
494
+
495
+ <div class="user-profile">
496
+ <img src="https://picsum.photos/seed/user123/64/64" alt="User" class="avatar">
497
+ <div class="user-info">
498
+ <h4>Utilisateur</h4>
499
+ <span>Plan Gratuit</span>
500
+ </div>
501
+ </div>
502
+ </aside>
503
+
504
+ <!-- Main Chat Area -->
505
+ <main>
506
+ <div class="chat-container" id="chatContainer">
507
+ <!-- Welcome Message -->
508
+ <div class="message-wrapper">
509
+ <div class="message ai">
510
+ <div class="message-avatar ai-avatar">
511
+ <i class="ri-sparkling-fill"></i>
512
+ </div>
513
+ <div class="message-content">
514
+ Bonjour ! Je suis <strong>Répond AI</strong>. Posez-moi une question, demandez-moi d'écrire du code ou simplement discutons. Comment puis-je vous aider ?
515
+ <div class="message-time">Maintenant</div>
516
+ </div>
517
+ </div>
518
+ </div>
519
+ </div>
520
+
521
+ <!-- Input Area -->
522
+ <div class="input-area">
523
+ <div class="input-wrapper">
524
+ <textarea id="userInput" rows="1" placeholder="Écrivez votre message ici..."></textarea>
525
+ <button class="send-btn" id="sendBtn" disabled aria-label="Envoyer">
526
+ <i class="ri-send-plane-fill"></i>
527
+ </button>
528
+ </div>
529
+ </div>
530
+ </main>
531
+ </div>
532
+
533
+ <!-- Toast Notification -->
534
+ <div id="toast" class="toast">Veuillez entrer un message.</div>
535
+
536
+ <script>
537
+ // DOM Elements
538
+ const chatContainer = document.getElementById('chatContainer');
539
+ const userInput = document.getElementById('userInput');
540
+ const sendBtn = document.getElementById('sendBtn');
541
+ const menuToggle = document.getElementById('menuToggle');
542
+ const sidebar = document.getElementById('sidebar');
543
+ const newChatBtn = document.getElementById('newChatBtn');
544
+ const toast = document.getElementById('toast');
545
+
546
+ // State
547
+ let isTyping = false;
548
+
549
+ // Auto-resize textarea
550
+ userInput.addEventListener('input', function() {
551
+ this.style.height = 'auto';
552
+ this.style.height = (this.scrollHeight) + 'px';
553
+
554
+ // Enable/Disable button
555
+ if (this.value.trim().length > 0) {
556
+ sendBtn.disabled = false;
557
+ } else {
558
+ sendBtn.disabled = true;
559
+ }
560
+ });
561
+
562
+ // Toggle Sidebar on Mobile
563
+ menuToggle.addEventListener('click', () => {
564
+ sidebar.classList.toggle('open');
565
+ });
566
+
567
+ // Close sidebar when clicking outside on mobile
568
+ document.addEventListener('click', (e) => {
569
+ if (window.innerWidth <= 768) {
570
+ if (!sidebar.contains(e.target) && !menuToggle.contains(e.target) && sidebar.classList.contains('open')) {
571
+ sidebar.classList.remove('open');
572
+ }
573
+ }
574
+ });
575
+
576
+ // Send Message Logic
577
+ function sendMessage() {
578
+ const text = userInput.value.trim();
579
+ if (!text) {
580
+ showToast("Veuillez entrer un message.");
581
+ return;
582
+ }
583
+
584
+ if (isTyping) return;
585
+
586
+ // 1. Add User Message
587
+ addMessage(text, 'user');
588
+ userInput.value = '';
589
+ userInput.style.height = 'auto';
590
+ sendBtn.disabled = true;
591
+
592
+ // 2. Simulate AI Thinking
593
+ isTyping = true;
594
+ const typingId = showTypingIndicator();
595
+
596
+ // 3. Generate Response (Simulation)
597
+ setTimeout(() => {
598
+ removeMessage(typingId);
599
+ const response = generateAIResponse(text);
600
+ addMessage(response, 'ai');
601
+ isTyping = false;
602
+ }, 1500 + Math.random() * 1000); // Random delay 1.5s - 2.5s
603
+ }
604
+
605
+ // Handle Enter key
606
+ userInput.addEventListener('keydown', (e) => {
607
+ if (e.key === 'Enter' && !e.shiftKey) {
608
+ e.preventDefault();
609
+ sendMessage();
610
+ }
611
+ });
612
+
613
+ sendBtn.addEventListener('click', sendMessage);
614
+
615
+ // Add Message to DOM
616
+ function addMessage(text, sender) {
617
+ const wrapper = document.createElement('div');
618
+ wrapper.className = 'message-wrapper';
619
+
620
+ const messageDiv = document.createElement('div');
621
+ messageDiv.className = `message ${sender}`;
622
+
623
+ const time = new Date().toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
624
+
625
+ let avatarHtml = '';
626
+ if (sender === 'ai') {
627
+ avatarHtml = `<div class="message-avatar ai-avatar"><i class="ri-sparkling-fill"></i></div>`;
628
+ } else {
629
+ avatarHtml = `<img src="https://picsum.photos/seed/user123/64/64" class="message-avatar user-avatar-img" alt="User">`;
630
+ }
631
+
632
+ messageDiv.innerHTML = `
633
+ ${avatarHtml}
634
+ <div class="message-content">
635
+ ${formatText(text)}
636
+ <div class="message-time">${time}</div>
637
+ </div>
638
+ `;
639
+
640
+ wrapper.appendChild(messageDiv);
641
+ chatContainer.appendChild(wrapper);
642
+ scrollToBottom();
643
+ }
644
+
645
+ // Show Typing Indicator
646
+ function showTypingIndicator() {
647
+ const id = 'typing-' + Date.now();
648
+ const wrapper = document.createElement('div');
649
+ wrapper.className = 'message-wrapper';
650
+ wrapper.id = id;
651
+
652
+ const messageDiv = document.createElement('div');
653
+ messageDiv.className = 'message ai';
654
+
655
+ messageDiv.innerHTML = `
656
+ <div class="message-avatar ai-avatar"><i class="ri-sparkling-fill"></i></div>
657
+ <div class="message-content">
658
+ <div class="typing-indicator">
659
+ <div class="dot"></div>
660
+ <div class="dot"></div>
661
+ <div class="dot"></div>
662
+ </div>
663
+ </div>
664
+ `;
665
+
666
+ wrapper.appendChild(messageDiv);
667
+ chatContainer.appendChild(wrapper);
668
+ scrollToBottom();
669
+ return id;
670
+ }
671
+
672
+ // Remove Message (Typing indicator)
673
+ function removeMessage(id) {
674
+ const el = document.getElementById(id);
675
+ if (el) el.remove();
676
+ }
677
+
678
+ // Scroll to bottom
679
+ function scrollToBottom() {
680
+ chatContainer.scrollTop = chatContainer.scrollHeight;
681
+ }
682
+
683
+ // Simple Text Formatter (Bold, Code blocks)
684
+ function formatText(text) {
685
+ // Replace **text** with <b>text</b>
686
+ text = text.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
687
+ // Replace `code` with <code>code</code> (simple inline code)
688
+ text = text.replace(/`(.*?)`/g, '<code style="background:rgba(255,255,255,0.1); padding:2px 4px; border-radius:4px; font-family:monospace;">$1</code>');
689
+ return text;
690
+ }
691
+
692
+ // Simple AI Response Simulator
693
+ function generateAIResponse(input) {
694
+ const lowerInput = input.toLowerCase();
695
+
696
+ if (lowerInput.includes('bonjour') || lowerInput.includes('salut') || lowerInput.includes('hello')) {
697
+ return "Bonjour ! Ravi de vous revoir. Sur quel sujet souhaitez-vous échanger aujourd'hui ?";
698
+ }
699
+ if (lowerInput.includes('code') || lowerInput.includes('html') || lowerInput.includes('css') || lowerInput.includes('js')) {
700
+ return "Je peux vous aider avec le code ! Voici un exemple de structure HTML :\n\n`<div class='container'>Contenu</div>`\n\nVoulez-vous que je développe un composant spécifique ?";
701
+ }
702
+ if (lowerInput.includes('qui es-tu') || lowerInput.includes('ton nom')) {
703
+ return "Je suis **Répond AI**, une interface de démonstration conçue pour montrer une expérience utilisateur moderne et fluide.";
704
+ }
705
+ if (lowerInput.includes('merci')) {
706
+ return "Je vous en prie ! N'hésitez pas si vous avez d'autres questions.";
707
+ }
708
+ if (lowerInput.includes('aide') || lowerInput.includes('help')) {
709
+ return "Bien sûr ! Je peux répondre à des questions, générer du texte, simuler du code, ou simplement discuter. Essayez de me demander 'Explique-moi le CSS Flexbox'.";
710
+ }
711
+
712
+ // Fallback generic responses
713
+ const generics = [
714
+ "C'est une perspective intéressante. Pouvez-vous développer ?",
715
+ "Je comprends. Avez-vous considéré d'autres approches pour ce problème ?",
716
+ "C'est noté. Je peux vous fournir plus de détails sur ce sujet si vous le souhaitez.",
717
+ "Intéressant ! Dites-m'en plus.",
718
+ "Je suis une IA, donc j'apprends de chaque interaction. Merci pour votre question !"
719
+ ];
720
+ return generics[Math.floor(Math.random() * generics.length)];
721
+ }
722
+
723
+ // New Chat Button
724
+ newChatBtn.addEventListener('click', () => {
725
+ chatContainer.innerHTML = '';
726
+ // Re-add welcome message
727
+ const wrapper = document.createElement('div');
728
+ wrapper.className = 'message-wrapper';
729
+ wrapper.innerHTML = `
730
+ <div class="message ai">
731
+ <div class="message-avatar ai-avatar"><i class="ri-sparkling-fill"></i></div>
732
+ <div class="message-content">
733
+ Nouvelle discussion commencée. Je suis prêt !
734
+ <div class="message-time">Maintenant</div>
735
+ </div>
736
+ </div>
737
+ `;
738
+ chatContainer.appendChild(wrapper);
739
+ if (window.innerWidth <= 768) sidebar.classList.remove('open');
740
+ });
741
+
742
+ // Toast Helper
743
+ function showToast(message) {
744
+ toast.textContent = message;
745
+ toast.classList.add('show');
746
+ setTimeout(() => {
747
+ toast.classList.remove('show');
748
+ }, 3000);
749
+ }
750
+ </script>
751
+ </body>
752
+ </html>