File size: 26,950 Bytes
4124eb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8b4c63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Powered Debugger | Smart Code Analysis</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
    <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <style>
        .code-editor {
            min-height: 300px;
            font-family: 'Fira Code', monospace;
            tab-size: 4;
            line-height: 1.5;
        }
        .error-highlight {
            background-color: rgba(239, 68, 68, 0.3);
            border-left: 3px solid #ef4444;
            position: relative;
        }
        .warning-highlight {
            background-color: rgba(234, 179, 8, 0.3);
            border-left: 3px solid #eab308;
            position: relative;
        }
        .suggestion-highlight {
            background-color: rgba(34, 197, 94, 0.3);
            border-left: 3px solid #22c55e;
            position: relative;
        }
        .result-container {
            max-height: 400px;
            overflow-y: auto;
        }
        .language-badge {
            position: absolute;
            top: 1rem;
            right: 1rem;
            background: rgba(255,255,255,0.2);
            padding: 0.25rem 0.75rem;
            border-radius: 9999px;
            font-size: 0.875rem;
            font-weight: 500;
        }
        .code-line-highlight {
            background-color: rgba(59, 130, 246, 0.2);
        }
        .highlight-tooltip {
            position: absolute;
            bottom: 100%;
            left: 0;
            background: #1f2937;
            color: white;
            padding: 0.5rem;
            border-radius: 0.375rem;
            font-size: 0.875rem;
            z-index: 10;
            display: none;
        }
        .error-highlight:hover .highlight-tooltip {
            display: block;
        }
    </style>
</head>
<body class="bg-gray-50">

    <!-- Hero Section -->
    <div class="relative bg-gradient-to-r from-blue-600 to-indigo-800 text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-4xl md:text-6xl font-bold mb-6" data-aos="fade-down">AI Powered Debugger</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto" data-aos="fade-down" data-aos-delay="100">
                Smart code analysis that detects errors and suggests improvements instantly
            </p>
            <div class="flex flex-col md:flex-row justify-center gap-4" data-aos="fade-up" data-aos-delay="200">
                <button id="tryNowBtn" class="bg-white text-blue-600 hover:bg-gray-100 px-8 py-3 rounded-lg font-semibold text-lg shadow-lg transform transition hover:scale-105">
                    Try Now
                </button>
                <button class="border-2 border-white hover:bg-white hover:text-blue-600 px-8 py-3 rounded-lg font-semibold text-lg shadow-lg transform transition hover:scale-105">
                    How It Works
                </button>
            </div>
        </div>
    </div>

    <!-- Main Debugger Section -->
    <div class="container mx-auto px-6 py-16">
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
            <!-- Code Input Section -->
            <div class="bg-white rounded-xl shadow-xl overflow-hidden" data-aos="fade-right">
                <div class="bg-gray-800 text-white px-6 py-4 flex justify-between items-center">
                    <h2 class="text-xl font-semibold">Your Code</h2>
                    <div class="flex space-x-4">
                        <button id="pasteBtn" class="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg text-sm">
                            <i data-feather="clipboard"></i> Paste
                        </button>
                        <button id="uploadBtn" class="flex items-center gap-2 bg-gray-700 hover:bg-gray-600 px-4 py-2 rounded-lg text-sm">
                            <i data-feather="upload"></i> Upload
                        </button>
                        <input type="file" id="fileInput" class="hidden" accept=".js,.py,.java,.c,.cpp,.php,.html,.css">
                    </div>
                </div>
                <div class="relative">
                    <div id="languageBadge" class="language-badge hidden text-white"></div>
                    <textarea id="codeInput" class="w-full p-4 code-editor bg-gray-900 text-gray-100 font-mono text-sm" 
                              placeholder="Paste your code here or upload a file..." 
                              spellcheck="false"></textarea>
                </div>
                <div class="bg-gray-100 px-6 py-4 flex justify-end">
                    <button id="analyzeBtn" class="bg-green-600 hover:bg-green-700 text-white px-8 py-3 rounded-lg font-semibold shadow-lg transform transition hover:scale-105 flex items-center gap-2">
                        <i data-feather="search"></i> Analyze Code
                    </button>
                </div>
            </div>

            <!-- Results Section -->
            <div class="bg-white rounded-xl shadow-xl overflow-hidden" data-aos="fade-left">
                <div class="bg-gray-800 text-white px-6 py-4">
                    <h2 class="text-xl font-semibold">Analysis Results</h2>
                </div>
                <div id="resultsContainer" class="result-container p-4">
                    <div class="text-center py-16 text-gray-400">
                        <i data-feather="code" class="w-12 h-12 mx-auto mb-4"></i>
                        <p>Your analysis results will appear here</p>
                    </div>
                </div>
                <div class="bg-gray-100 px-6 py-4 flex justify-between items-center">
                    <div id="statsContainer" class="text-sm text-gray-600">
                        <span id="errorCount" class="hidden">0 errors</span>
                        <span id="warningCount" class="hidden ml-4">0 warnings</span>
                        <span id="suggestionCount" class="hidden ml-4">0 suggestions</span>
                    </div>
                    <button id="copyResultsBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm hidden">
                        <i data-feather="copy"></i> Copy Results
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- Features Section -->
    <div class="bg-gray-100 py-16">
        <div class="container mx-auto px-6">
            <h2 class="text-3xl font-bold text-center mb-12" data-aos="fade-up">Powerful Debugging Features</h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="100">
                    <div class="text-blue-600 mb-4">
                        <i data-feather="search" class="w-8 h-8"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">Error Detection</h3>
                    <p class="text-gray-600">Identifies syntax errors, logical flaws, and potential bugs in your code with precision.</p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="200">
                    <div class="text-green-600 mb-4">
                        <i data-feather="lightbulb" class="w-8 h-8"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">Smart Suggestions</h3>
                    <p class="text-gray-600">Provides intelligent recommendations to improve code quality and performance.</p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-lg" data-aos="fade-up" data-aos-delay="300">
                    <div class="text-purple-600 mb-4">
                        <i data-feather="zap" class="w-8 h-8"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">Fast Analysis</h3>
                    <p class="text-gray-600">Processes your code instantly with our powerful AI engine, saving you time.</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-800 text-white py-12">
        <div class="container mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h2 class="text-2xl font-bold">AI Powered Debugger</h2>
                    <p class="text-gray-400 mt-2">Making debugging effortless since 2023</p>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="hover:text-blue-400 transition">Privacy</a>
                    <a href="#" class="hover:text-blue-400 transition">Terms</a>
                    <a href="#" class="hover:text-blue-400 transition">Contact</a>
                </div>
            </div>
            <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
                <p>© 2023 AI Powered Debugger. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <script>
        AOS.init();
        feather.replace();

        // Sample functionality
        document.getElementById('tryNowBtn').addEventListener('click', () => {
            document.getElementById('codeInput').scrollIntoView({ behavior: 'smooth' });
        });

        document.getElementById('pasteBtn').addEventListener('click', async () => {
            try {
                const text = await navigator.clipboard.readText();
                document.getElementById('codeInput').value = text;
            } catch (err) {
                alert('Failed to read clipboard. Please paste manually.');
            }
        });

        document.getElementById('uploadBtn').addEventListener('click', () => {
            document.getElementById('fileInput').click();
        });

        document.getElementById('fileInput').addEventListener('change', (e) => {
            const file = e.target.files[0];
            if (file) {
                const reader = new FileReader();
                reader.onload = (event) => {
                    document.getElementById('codeInput').value = event.target.result;
                };
                reader.readAsText(file);
            }
        });

        document.getElementById('analyzeBtn').addEventListener('click', () => {
            const code = codeInput.value;
            if (!code.trim()) {
                alert('Please enter or upload some code to analyze');
                return;
            }

            analyzeCode(code);
        });

        // Auto-detect and analyze when pasting significant code
        codeInput.addEventListener('paste', (e) => {
            setTimeout(() => {
                const code = codeInput.value;
                if (code.length > 100) { // Only auto-analyze if substantial code was pasted
                    detectLanguage();
                    analyzeCode(code);
                }
            }, 100);
        });

        function detectLanguage(code) {
            const languageBadge = document.getElementById('languageBadge');
            languageBadge.classList.remove('hidden');
            
            // Simple language detection based on code patterns
            if (code.includes('<?php') || code.includes('<?=')) {
                languageBadge.textContent = 'PHP';
                return 'php';
            } else if (code.includes('def ') || code.includes('import ')) {
                languageBadge.textContent = 'Python';
                return 'python';
            } else if (code.includes('function ') || code.includes('=>') || code.includes('const ') || code.includes('let ')) {
                languageBadge.textContent = 'JavaScript';
                return 'javascript';
            } else if (code.includes('#include') || code.includes('int main(')) {
                languageBadge.textContent = 'C/C++';
                return 'cpp';
            } else if (code.includes('public class') || code.includes('System.out.')) {
                languageBadge.textContent = 'Java';
                return 'java';
            } else if (code.includes('<html') || code.includes('<div')) {
                languageBadge.textContent = 'HTML';
                return 'html';
            } else if (code.includes('{') && code.includes('}') && code.includes(':')) {
                languageBadge.textContent = 'CSS';
                return 'css';
            } else {
                languageBadge.textContent = 'Unknown';
                return 'unknown';
            }
        }

        async function analyzeCode(code) {
            // Show loading state
            const resultsContainer = document.getElementById('resultsContainer');
            resultsContainer.innerHTML = `
                <div class="text-center py-16">
                    <div class="inline-block animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-600 mb-4"></div>
                    <p>Analyzing your code with AI...</p>
                </div>
            `;

            try {
                // Detect language first
                const language = detectLanguage(code);
                
                // More robust analysis with better error detection
                const analysisResults = await performDeepAnalysis(code, language);
                displayResults(analysisResults);
                
                // Highlight error lines in the code
                const errorLines = analysisResults.filter(r => r.type === 'error').map(r => r.line);
                const warningLines = analysisResults.filter(r => r.type === 'warning').map(r => r.line);
                const suggestionLines = analysisResults.filter(r => r.type === 'suggestion').map(r => r.line);
                
                if (errorLines.length > 0) highlightErrorLines(errorLines, 'error');
                if (warningLines.length > 0) highlightErrorLines(warningLines, 'warning');
                if (suggestionLines.length > 0) highlightErrorLines(suggestionLines, 'suggestion');
                
            } catch (error) {
                console.error('Analysis error:', error);
                resultsContainer.innerHTML = `
                    <div class="bg-red-50 border-l-4 border-red-500 p-4">
                        <div class="flex">
                            <div class="flex-shrink-0 text-red-500">
                                <i data-feather="alert-circle" class="w-5 h-5"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm text-red-700 font-medium">Analysis failed</p>
                                <div class="mt-2 text-sm text-red-600">
                                    <p>${error.message || 'Unknown error occurred during analysis'}</p>
                                    <p class="mt-1">Please try again or check your code for obvious errors.</p>
                                </div>
                            </div>
                        </div>
                    </div>
                `;
                feather.replace();
                
                // Reset stats
                document.getElementById('statsContainer').innerHTML = '';
                document.getElementById('copyResultsBtn').classList.add('hidden');
            }
        }

        async function performDeepAnalysis(code, language) {
            return new Promise((resolve) => {
                // Simulate API call delay
                setTimeout(() => {
                    const lines = code.split('\n');
                    const results = [];
                    
                    // More accurate error detection
                    lines.forEach((line, index) => {
                        const lineNumber = index + 1;
                        const trimmedLine = line.trim();
                        
                        // Common error patterns
                        if (language === 'javascript') {
                            if (trimmedLine.includes('=') && !trimmedLine.includes('let') && 
                                !trimmedLine.includes('const') && !trimmedLine.includes('var')) {
                                results.push(createErrorResult(
                                    lineNumber,
                                    'Undeclared variable assignment',
                                    `Add declaration (let/const/var) before assignment`,
                                    line
                                ));
                            }
                            
                            if (trimmedLine.includes('function(') || trimmedLine.includes('function (')) {
                                results.push(createWarningResult(
                                    lineNumber,
                                    'Consider using arrow function',
                                    `Replace with: const myFunc = () => {...}`,
                                    line
                                ));
                            }
                        }
                        
                        // Syntax error detection
                        if (trimmedLine.includes('{') && !trimmedLine.includes('}') ||
                            trimmedLine.includes('(') && !trimmedLine.includes(')') ||
                            trimmedLine.includes('[') && !trimmedLine.includes(']')) {
                            results.push(createErrorResult(
                                lineNumber,
                                'Possible unclosed bracket/parenthesis',
                                `Check for matching closing character`,
                                line
                            ));
                        }
                        
                        // Empty catch blocks
                        if (trimmedLine.includes('catch') && trimmedLine.includes('{') && 
                            lines[index+1] && lines[index+1].trim() === '}') {
                            results.push(createWarningResult(
                                lineNumber,
                                'Empty catch block',
                                `Add error handling logic in catch block`,
                                line
                            ));
                        }
                    });
                    
                    // If no issues found
                    if (results.length === 0) {
                        results.push({
                            type: 'success',
                            message: 'No issues found in your code!',
                            suggestion: 'Great job! Your code looks clean.'
                        });
                    }
                    
                    resolve(results);
                }, 1000);
            });
        }

        function createErrorResult(line, message, suggestion, codeLine) {
            return {
                type: 'error',
                line: line,
                message: message,
                suggestion: `${suggestion}\n\nError location: "${codeLine.trim()}"`,
                code: codeLine
            };
        }

        function createWarningResult(line, message, suggestion, codeLine) {
            return {
                type: 'warning',
                line: line,
                message: message,
                suggestion: `${suggestion}\n\nWarning location: "${codeLine.trim()}"`,
                code: codeLine
            };
        }


        function highlightErrorLines(lines, type) {
            const codeInput = document.getElementById('codeInput');
            const code = codeInput.value.split('\n');
            let highlightedCode = '';
            
            code.forEach((line, index) => {
                const lineNumber = index + 1;
                if (lines.includes(lineNumber)) {
                    highlightedCode += `<span class="${type}-highlight">${escapeHtml(line)}</span>\n`;
                } else {
                    highlightedCode += `${escapeHtml(line)}\n`;
                }
            });
            
            // Create a temporary div to hold the highlighted code
            const tempDiv = document.createElement('div');
            tempDiv.innerHTML = highlightedCode;
            
            // Replace the textarea with the highlighted version
            const codeContainer = document.createElement('div');
            codeContainer.className = 'code-editor bg-gray-900 text-gray-100 font-mono text-sm p-4 whitespace-pre';
            codeContainer.innerHTML = highlightedCode;
            
            codeInput.parentNode.replaceChild(codeContainer, codeInput);
            
            // Add tooltips to highlighted lines
            document.querySelectorAll(`.${type}-highlight`).forEach(highlight => {
                const tooltip = document.createElement('div');
                tooltip.className = 'highlight-tooltip';
                tooltip.textContent = `${type.charAt(0).toUpperCase() + type.slice(1)} detected`;
                highlight.appendChild(tooltip);
            });
        }

        function escapeHtml(unsafe) {
            return unsafe
                .replace(/&/g, "&amp;")
                .replace(/</g, "&lt;")
                .replace(/>/g, "&gt;")
                .replace(/"/g, "&quot;")
                .replace(/'/g, "&#039;");
        }

        function displayResults(results) {
            const resultsContainer = document.getElementById('resultsContainer');
            const errorCount = results.filter(r => r.type === 'error').length;
            const warningCount = results.filter(r => r.type === 'warning').length;
            const suggestionCount = results.filter(r => r.type === 'suggestion').length;
            
            let html = '';
            
            if (results.some(r => r.type === 'success')) {
                html = `
                    <div class="bg-green-50 border-l-4 border-green-500 p-4 mb-4">
                        <div class="flex">
                            <div class="flex-shrink-0 text-green-500">
                                <i data-feather="check-circle" class="w-5 h-5"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm text-green-700">${results[0].message}</p>
                            </div>
                        </div>
                    </div>
                `;
            } else {
                results.forEach(result => {
                    const colorClass = result.type === 'error' ? 'red' : 
                                      result.type === 'warning' ? 'yellow' : 'green';
                    
                    html += `
                        <div class="bg-${colorClass}-50 border-l-4 border-${colorClass}-500 p-4 mb-4">
                            <div class="flex">
                                <div class="flex-shrink-0 text-${colorClass}-500">
                                    <i data-feather="${result.type === 'error' ? 'x-circle' : 
                                                     result.type === 'warning' ? 'alert-triangle' : 'info'}" 
                                       class="w-5 h-5"></i>
                                </div>
                                <div class="ml-3">
                                    <p class="text-sm text-${colorClass}-700 font-medium">
                                        ${result.type.toUpperCase()}${result.line ? ` on line ${result.line}` : ''}: ${result.message}
                                    </p>
                                    ${result.suggestion ? `
                                        <div class="mt-2 text-sm text-${colorClass}-600">
                                            <p class="font-semibold">Suggestion:</p>
                                            <div class="bg-white p-3 rounded mt-2 font-mono text-sm">
                                                ${result.suggestion.replace(/\n/g, '<br>')}
                                            </div>
                                            ${result.code ? `
                                            <div class="mt-2">
                                                <p class="font-semibold">Problematic code:</p>
                                                <div class="bg-gray-800 text-gray-100 p-2 rounded mt-1 font-mono text-sm">
                                                    ${escapeHtml(result.code)}
                                                </div>
                                            </div>
                                            ` : ''}
                                        </div>
                                    ` : ''}
                                </div>
                            </div>
                        </div>
                    `;
                });
            }
            
            resultsContainer.innerHTML = html;
            feather.replace();
            
            // Update stats
            const statsContainer = document.getElementById('statsContainer');
            const copyBtn = document.getElementById('copyResultsBtn');
            
            if (errorCount + warningCount + suggestionCount > 0) {
                statsContainer.innerHTML = `
                    <span class="text-red-600">${errorCount} errors</span>
                    <span class="text-yellow-600 ml-4">${warningCount} warnings</span>
                    <span class="text-green-600 ml-4">${suggestionCount} suggestions</span>
                `;
                copyBtn.classList.remove('hidden');
            } else {
                statsContainer.innerHTML = '';
                copyBtn.classList.add('hidden');
            }
        }

        document.getElementById('copyResultsBtn').addEventListener('click', () => {
            const resultsText = document.getElementById('resultsContainer').innerText;
            navigator.clipboard.writeText(resultsText).then(() => {
                const originalText = document.getElementById('copyResultsBtn').innerHTML;
                document.getElementById('copyResultsBtn').innerHTML = '<i data-feather="check"></i> Copied!';
                feather.replace();
                setTimeout(() => {
                    document.getElementById('copyResultsBtn').innerHTML = originalText;
                    feather.replace();
                }, 2000);
            });
        });
    </script>
</body>
</html>