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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Thirukkural Wisdom</title>
7
+ <link
8
+ href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Noto+Sans+Tamil:wght@400;500;600&display=swap"
9
+ rel="stylesheet"
10
+ />
11
+ <style>
12
+ * {
13
+ margin: 0;
14
+ padding: 0;
15
+ box-sizing: border-box;
16
+ }
17
+
18
+ body {
19
+ font-family: "Poppins", sans-serif;
20
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
21
+ min-height: 100vh;
22
+ color: #333;
23
+ line-height: 1.6;
24
+ }
25
+
26
+ .container {
27
+ max-width: 900px;
28
+ margin: 0 auto;
29
+ padding: 20px;
30
+ }
31
+
32
+ /* Header */
33
+ .header {
34
+ text-align: center;
35
+ margin-bottom: 40px;
36
+ padding: 30px 0;
37
+ }
38
+
39
+ .header h1 {
40
+ color: white;
41
+ font-size: 2.5rem;
42
+ font-weight: 600;
43
+ margin-bottom: 10px;
44
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
45
+ }
46
+
47
+ .header p {
48
+ color: rgba(255, 255, 255, 0.9);
49
+ font-size: 1.1rem;
50
+ font-weight: 300;
51
+ }
52
+
53
+ /* Search Section */
54
+ .search-section {
55
+ background: white;
56
+ border-radius: 20px;
57
+ padding: 30px;
58
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
59
+ margin-bottom: 30px;
60
+ }
61
+
62
+ .search-form {
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: 20px;
66
+ }
67
+
68
+ .input-group {
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: 8px;
72
+ }
73
+
74
+ .input-group label {
75
+ font-weight: 500;
76
+ color: #555;
77
+ font-size: 0.95rem;
78
+ }
79
+
80
+ .query-input {
81
+ padding: 15px 20px;
82
+ border: 2px solid #e0e6ff;
83
+ border-radius: 12px;
84
+ font-size: 1rem;
85
+ transition: all 0.3s ease;
86
+ font-family: "Poppins", sans-serif;
87
+ background: #fafbff;
88
+ }
89
+
90
+ .query-input:focus {
91
+ outline: none;
92
+ border-color: #667eea;
93
+ box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
94
+ background: white;
95
+ }
96
+
97
+ .form-row {
98
+ display: flex;
99
+ gap: 20px;
100
+ align-items: end;
101
+ }
102
+
103
+ .language-selector {
104
+ flex: 1;
105
+ }
106
+
107
+ .language-selector select {
108
+ padding: 12px 15px;
109
+ border: 2px solid #e0e6ff;
110
+ border-radius: 12px;
111
+ font-size: 1rem;
112
+ font-family: "Poppins", sans-serif;
113
+ background: #fafbff;
114
+ cursor: pointer;
115
+ transition: all 0.3s ease;
116
+ }
117
+
118
+ .language-selector select:focus {
119
+ outline: none;
120
+ border-color: #667eea;
121
+ box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
122
+ background: white;
123
+ }
124
+
125
+ .search-button {
126
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
127
+ color: white;
128
+ border: none;
129
+ padding: 15px 30px;
130
+ border-radius: 12px;
131
+ font-size: 1.1rem;
132
+ font-weight: 600;
133
+ cursor: pointer;
134
+ transition: all 0.3s ease;
135
+ font-family: "Poppins", sans-serif;
136
+ min-width: 180px;
137
+ }
138
+
139
+ .search-button:hover {
140
+ transform: translateY(-2px);
141
+ box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
142
+ }
143
+
144
+ .search-button:active {
145
+ transform: translateY(0);
146
+ }
147
+
148
+ .search-button:disabled {
149
+ opacity: 0.6;
150
+ cursor: not-allowed;
151
+ transform: none;
152
+ }
153
+
154
+ /* Loading State */
155
+ .loading {
156
+ text-align: center;
157
+ padding: 40px;
158
+ color: #667eea;
159
+ }
160
+
161
+ .loading-spinner {
162
+ width: 40px;
163
+ height: 40px;
164
+ border: 4px solid #e0e6ff;
165
+ border-top: 4px solid #667eea;
166
+ border-radius: 50%;
167
+ animation: spin 1s linear infinite;
168
+ margin: 0 auto 15px;
169
+ }
170
+
171
+ @keyframes spin {
172
+ 0% {
173
+ transform: rotate(0deg);
174
+ }
175
+ 100% {
176
+ transform: rotate(360deg);
177
+ }
178
+ }
179
+
180
+ /* Results Section */
181
+ .results-section {
182
+ display: none;
183
+ }
184
+
185
+ .results-section.show {
186
+ display: block;
187
+ }
188
+
189
+ /* Explanation Card */
190
+ .explanation-card {
191
+ background: white;
192
+ border-radius: 20px;
193
+ padding: 30px;
194
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
195
+ margin-bottom: 30px;
196
+ border-left: 5px solid #667eea;
197
+ }
198
+
199
+ .explanation-card h3 {
200
+ color: #333;
201
+ font-size: 1.3rem;
202
+ margin-bottom: 20px;
203
+ display: flex;
204
+ align-items: center;
205
+ gap: 10px;
206
+ }
207
+
208
+ .explanation-text {
209
+ color: #555;
210
+ font-size: 1rem;
211
+ line-height: 1.7;
212
+ }
213
+
214
+ .explanation-text p {
215
+ margin-bottom: 15px;
216
+ }
217
+
218
+ .explanation-text strong {
219
+ color: #333;
220
+ }
221
+
222
+ .explanation-text ul,
223
+ .explanation-text ol {
224
+ padding-left: 20px;
225
+ margin-bottom: 15px;
226
+ }
227
+
228
+ .explanation-text li {
229
+ margin-bottom: 5px;
230
+ }
231
+
232
+ /* Kural Cards */
233
+ .kurals-container {
234
+ display: grid;
235
+ gap: 20px;
236
+ }
237
+
238
+ .kural-card {
239
+ background: white;
240
+ border-radius: 15px;
241
+ padding: 25px;
242
+ box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
243
+ transition: all 0.3s ease;
244
+ border: 1px solid #f0f0f0;
245
+ }
246
+
247
+ .kural-card:hover {
248
+ transform: translateY(-3px);
249
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
250
+ }
251
+
252
+ .kural-number {
253
+ display: inline-block;
254
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
255
+ color: white;
256
+ padding: 5px 12px;
257
+ border-radius: 20px;
258
+ font-size: 0.85rem;
259
+ font-weight: 600;
260
+ margin-bottom: 15px;
261
+ }
262
+
263
+ .kural-tamil {
264
+ font-family: "Noto Sans Tamil", sans-serif;
265
+ font-size: 1.2rem;
266
+ line-height: 1.8;
267
+ color: #2c3e50;
268
+ margin-bottom: 15px;
269
+ font-weight: 500;
270
+ text-align: center;
271
+ background: #f8f9ff;
272
+ padding: 15px;
273
+ border-radius: 10px;
274
+ white-space: pre-line;
275
+ }
276
+
277
+ .kural-english {
278
+ font-size: 1rem;
279
+ color: #555;
280
+ font-style: italic;
281
+ text-align: center;
282
+ margin-bottom: 15px;
283
+ line-height: 1.6;
284
+ }
285
+
286
+ .kural-category {
287
+ display: inline-block;
288
+ background: #e8f2ff;
289
+ color: #667eea;
290
+ padding: 4px 10px;
291
+ border-radius: 15px;
292
+ font-size: 0.8rem;
293
+ font-weight: 500;
294
+ }
295
+
296
+ .kural-explanation {
297
+ margin-top: 15px;
298
+ padding-top: 15px;
299
+ border-top: 1px solid #f0f0f0;
300
+ color: #666;
301
+ font-size: 0.9rem;
302
+ line-height: 1.6;
303
+ }
304
+
305
+ /* Error State */
306
+ .error-message {
307
+ background: #fff5f5;
308
+ border: 1px solid #fed7d7;
309
+ border-radius: 12px;
310
+ padding: 20px;
311
+ color: #c53030;
312
+ text-align: center;
313
+ margin-bottom: 20px;
314
+ }
315
+
316
+ /* Responsive Design */
317
+ @media (max-width: 768px) {
318
+ .container {
319
+ padding: 15px;
320
+ }
321
+
322
+ .header h1 {
323
+ font-size: 2rem;
324
+ }
325
+
326
+ .search-section {
327
+ padding: 20px;
328
+ }
329
+
330
+ .form-row {
331
+ flex-direction: column;
332
+ gap: 15px;
333
+ }
334
+
335
+ .search-button {
336
+ width: 100%;
337
+ }
338
+
339
+ .explanation-card,
340
+ .kural-card {
341
+ padding: 20px;
342
+ }
343
+
344
+ .kural-tamil {
345
+ font-size: 1.1rem;
346
+ }
347
+ }
348
+
349
+ /* Hidden elements for future features */
350
+ .action-buttons {
351
+ display: none;
352
+ gap: 10px;
353
+ margin-top: 15px;
354
+ }
355
+
356
+ .action-btn {
357
+ padding: 8px 15px;
358
+ border: 1px solid #ddd;
359
+ border-radius: 8px;
360
+ background: white;
361
+ cursor: pointer;
362
+ font-size: 0.85rem;
363
+ transition: all 0.3s ease;
364
+ }
365
+
366
+ .action-btn:hover {
367
+ background: #f5f5f5;
368
+ }
369
+ </style>
370
+ </head>
371
+ <body>
372
+ <div class="container">
373
+ <!-- Header -->
374
+ <div class="header">
375
+ <h1>திருக்குறள் Wisdom</h1>
376
+ <p>Discover timeless guidance from Thiruvalluvar's sacred verses</p>
377
+ </div>
378
+
379
+ <!-- Search Section -->
380
+ <div class="search-section">
381
+ <form class="search-form" id="searchForm">
382
+ <div class="input-group">
383
+ <label for="query">What guidance are you seeking?</label>
384
+ <textarea
385
+ id="query"
386
+ class="query-input"
387
+ placeholder="e.g., I want to be happy in my life, How to be a good leader, What is true friendship..."
388
+ rows="3"
389
+ required
390
+ ></textarea>
391
+ </div>
392
+
393
+ <div class="form-row">
394
+ <div class="language-selector">
395
+ <label for="language">Language Preference</label>
396
+ <select id="language" name="language">
397
+ <option value="en">English</option>
398
+ <option value="ta">தமிழ்</option>
399
+ </select>
400
+ </div>
401
+ <button type="submit" class="search-button">✨ Find Wisdom</button>
402
+ </div>
403
+ </form>
404
+ </div>
405
+
406
+ <!-- Loading State -->
407
+ <div id="loading" class="loading" style="display: none">
408
+ <div class="loading-spinner"></div>
409
+ <p>Searching ancient wisdom...</p>
410
+ </div>
411
+
412
+ <!-- Error Message -->
413
+ <div id="errorMessage" class="error-message" style="display: none"></div>
414
+
415
+ <!-- Results Section -->
416
+ <div id="resultsSection" class="results-section">
417
+ <!-- Explanation Card -->
418
+ <div id="explanationCard" class="explanation-card">
419
+ <h3>🧘 Answer to Reflect On</h3>
420
+ <div id="explanationText" class="explanation-text"></div>
421
+ </div>
422
+
423
+ <!-- Kurals Container -->
424
+ <div id="kuralsContainer" class="kurals-container"></div>
425
+ </div>
426
+ </div>
427
+
428
+ <script>
429
+ // Get form elements
430
+ const searchForm = document.getElementById("searchForm");
431
+ const queryInput = document.getElementById("query");
432
+ const languageSelect = document.getElementById("language");
433
+ const searchButton = document.querySelector(".search-button");
434
+ const loading = document.getElementById("loading");
435
+ const errorMessage = document.getElementById("errorMessage");
436
+ const resultsSection = document.getElementById("resultsSection");
437
+ const explanationText = document.getElementById("explanationText");
438
+ const kuralsContainer = document.getElementById("kuralsContainer");
439
+
440
+ // API configuration - Update this with your actual API endpoint
441
+ const API_BASE_URL =
442
+ "https://viswadarshan06-Thirukkural-AI-Backend.hf.space"; // Replace with your actual API URL
443
+
444
+ // Handle form submission
445
+ searchForm.addEventListener("submit", async (e) => {
446
+ e.preventDefault();
447
+
448
+ const query = queryInput.value.trim();
449
+ if (!query) return;
450
+
451
+ // Show loading state
452
+ showLoading();
453
+ hideError();
454
+ hideResults();
455
+
456
+ try {
457
+ // Make API call
458
+ const response = await fetch(`${API_BASE_URL}/search/`, {
459
+ method: "POST",
460
+ headers: {
461
+ "Content-Type": "application/json",
462
+ },
463
+ body: JSON.stringify({
464
+ query: query,
465
+ lang: languageSelect.value,
466
+ top_k: 3,
467
+ }),
468
+ });
469
+
470
+ if (!response.ok) {
471
+ throw new Error(`HTTP error! status: ${response.status}`);
472
+ }
473
+
474
+ const data = await response.json();
475
+ displayResults(data);
476
+ } catch (error) {
477
+ console.error("Search error:", error);
478
+ showError(
479
+ "Unable to search for wisdom at this time. Please try again later."
480
+ );
481
+ } finally {
482
+ hideLoading();
483
+ }
484
+ });
485
+
486
+ function showLoading() {
487
+ loading.style.display = "block";
488
+ searchButton.disabled = true;
489
+ }
490
+
491
+ function hideLoading() {
492
+ loading.style.display = "none";
493
+ searchButton.disabled = false;
494
+ }
495
+
496
+ function showError(message) {
497
+ errorMessage.textContent = message;
498
+ errorMessage.style.display = "block";
499
+ }
500
+
501
+ function hideError() {
502
+ errorMessage.style.display = "none";
503
+ }
504
+
505
+ function hideResults() {
506
+ resultsSection.classList.remove("show");
507
+ }
508
+
509
+ function showResults() {
510
+ resultsSection.classList.add("show");
511
+ }
512
+
513
+ function displayResults(data) {
514
+ // Display explanation (handle markdown formatting)
515
+ explanationText.innerHTML = formatMarkdown(data.explanation);
516
+
517
+ // Display kurals
518
+ kuralsContainer.innerHTML = "";
519
+ data.matched_kurals.forEach((kural) => {
520
+ const kuralCard = createKuralCard(kural);
521
+ kuralsContainer.appendChild(kuralCard);
522
+ });
523
+
524
+ showResults();
525
+ }
526
+
527
+ function createKuralCard(kural) {
528
+ const card = document.createElement("div");
529
+ card.className = "kural-card";
530
+
531
+ // Format Tamil text with proper line breaks
532
+ const tamilText = kural.Tamil
533
+ ? kural.Tamil.replace(/\n/g, "\n")
534
+ : "Tamil text not available";
535
+
536
+ card.innerHTML = `
537
+ <div class="kural-number">Kural ${kural.Number}</div>
538
+ <div class="kural-tamil">${tamilText}</div>
539
+ <div class="kural-english">${
540
+ kural.English || "English translation not available"
541
+ }</div>
542
+ <div class="kural-category">${kural.Category || "General"}</div>
543
+ ${
544
+ kural.Explanation
545
+ ? `<div class="kural-explanation">${kural.Explanation}</div>`
546
+ : ""
547
+ }
548
+
549
+ <!-- Hidden action buttons for future features -->
550
+ <div class="action-buttons">
551
+ <button class="action-btn">📋 Copy</button>
552
+ <button class="action-btn">🔊 Speak</button>
553
+ <button class="action-btn">💾 Save</button>
554
+ </div>
555
+ `;
556
+
557
+ return card;
558
+ }
559
+
560
+ function formatMarkdown(text) {
561
+ if (!text) return "";
562
+
563
+ // Simple markdown formatting
564
+ return text
565
+ .replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>")
566
+ .replace(/\*(.*?)\*/g, "<em>$1</em>")
567
+ .replace(/^- (.+)$/gm, "<li>$1</li>")
568
+ .replace(/(<li>.*<\/li>)/s, "<ul>$1</ul>")
569
+ .replace(/^\d+\. (.+)$/gm, "<li>$1</li>")
570
+ .replace(/(<li>.*<\/li>)/s, "<ol>$1</ol>")
571
+ .replace(/\n\n/g, "</p><p>")
572
+ .replace(/^(.+)$/, "<p>$1</p>")
573
+ .replace(/<p><\/p>/g, "");
574
+ }
575
+
576
+ // Auto-resize textarea
577
+ queryInput.addEventListener("input", function () {
578
+ this.style.height = "auto";
579
+ this.style.height = this.scrollHeight + "px";
580
+ });
581
+ </script>
582
+ </body>
583
+ </html>