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
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
<!DOCTYPE html>
<html lang="az">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CodeCraft AI Studio</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: {
                            50: '#f0f9ff',
                            100: '#e0f2fe',
                            200: '#bae6fd',
                            300: '#7dd3fc',
                            400: '#38bdf8',
                            500: '#0ea5e9',
                            600: '#0284c7',
                            700: '#0369a1',
                            800: '#075985',
                            900: '#0c4a6e',
                        },
                        secondary: {
                            50: '#fefce8',
                            100: '#fef9c3',
                            200: '#fef08a',
                            300: '#fde047',
                            400: '#facc15',
                            500: '#eab308',
                            600: '#ca8a04',
                            700: '#a16207',
                            800: '#854d0e',
                            900: '#713f12',
                        }
                    }
                }
            }
        }
    </script>
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #0ea5e9 0%, #eab308 100%);
        }
        .glass-effect {
            backdrop-filter: blur(16px);
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        .code-block-gradient {
            background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
            border: 1px solid #e2e8f0;
        }
        .ai-response-animation {
            animation: slideInUp 0.5s ease-out;
        }
        @keyframes slideInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .typing-indicator {
            display: inline-block;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #0ea5e9;
            animation: typing 1.4s infinite ease-in-out;
        }
        .typing-indicator:nth-child(2) {
            animation-delay: 0.2s;
        }
        .typing-indicator:nth-child(3) {
            animation-delay: 0.4s;
        }
        @keyframes typing {
            0%, 60%, 100% {
                transform: scale(0.8);
                opacity: 0.5;
            }
            30% {
                transform: scale(1);
                opacity: 1;
            }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen font-sans">
    <!-- Header -->
    <header class="gradient-bg text-white shadow-lg">
        <div class="container mx-auto px-4 py-6">
            <div class="flex items-center justify-between">
                <div class="flex items-center space-x-3">
                    <div class="w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center">
                        <i data-feather="code" class="w-6 h-6"></i>
                    </div>
                    <div>
                        <h1 class="text-2xl font-bold">CodeCraft AI Studio</h1>
                        <p class="text-primary-100 text-sm">Azərbaycan dilində kod köməkçisi</p>
                    </div>
                </div>
                <div class="flex items-center space-x-4">
                    <button class="glass-effect px-4 py-2 rounded-lg flex items-center space-x-2 hover:bg-white/20 transition-colors">
                        <i data-feather="sun" class="w-4 h-4"></i>
                        <span>Açıq</span>
                    </button>
                    <button class="glass-effect px-4 py-2 rounded-lg flex items-center space-x-2 hover:bg-white/20 transition-colors">
                        <i data-feather="settings" class="w-4 h-4"></i>
                        <span>Ayarlar</span>
                    </button>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="container mx-auto px-4 py-8">
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- AI Assistant Section -->
            <div class="lg:col-span-2">
                <div class="bg-white rounded-2xl shadow-xl overflow-hidden">
                    <div class="p-6 border-b border-gray-100">
                        <div class="flex items-center space-x-3">
                            <div class="w-16 h-16 bg-gradient-to-br from-primary-400 to-secondary-400 rounded-2xl flex items-center justify-center">
                                <i data-feather="bot" class="w-8 h-8 text-white"></i>
                            </div>
                            <div>
                                <h2 class="text-xl font-semibold text-gray-800">AI Köməkçi</h2>
                                <p class="text-gray-600">Kod yazmaqda kömək lazımdır? Burada yazın!</p>
                            </div>
                        </div>
                    </div>

                    <!-- Chat Log -->
                    <div class="h-96 overflow-y-auto p-6 bg-gray-50/50">
                        <div id="chat-log" class="space-y-4">
                            <div class="ai-response-animation">
                                <div class="flex items-start space-x-3">
                                    <div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center flex-shrink-0">
                                        <i data-feather="bot" class="w-4 h-4 text-primary-600"></i>
                                    </div>
                                    <div class="bg-white rounded-2xl p-4 shadow-sm max-w-3xl">
                                        <p class="text-gray-700">Salam! Mən CodeCraft AI Studio köməkçisiyəm. HTML, CSS və JavaScript kodları yazmaqda sizə kömək edə bilərəm. Nə hazırlamaq istəyirsiniz?</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Chat Input -->
                    <div class="p-6 border-t border-gray-100">
                        <form id="chat-form" class="space-y-4">
                            <div class="flex space-x-3">
                                <button type="button" id="reset-all" class="px-4 py-2 bg-red-50 text-red-600 rounded-lg border border-red-200 hover:bg-red-100 transition-colors flex items-center space-x-2">
                                    <i data-feather="refresh-cw" class="w-4 h-4"></i>
                                    <span>Təmizlə</span>
                                </button>
                                <button type="button" id="prompt-optimize" class="px-4 py-2 bg-secondary-50 text-secondary-600 rounded-lg border border-secondary-200 hover:bg-secondary-100 transition-colors flex items-center space-x-2">
                                    <i data-feather="edit-3" class="w-4 h-4"></i>
                                    <span>Detallı Göndər</span>
                                </button>
                            </div>
                            <div class="flex space-x-3">
                                <input type="text" id="chat-input" placeholder="AI-ya yazın... (Məsələn: 'Responsive navbar yarat')" 
                                       class="flex-1 px-4 py-3 border border-gray-200 rounded-lg focus:outline-none focus:border-primary-400 focus:ring-2 focus:ring-primary-100 transition-all">
                                <button type="submit" class="px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-colors flex items-center space-x-2">
                                    <i data-feather="send" class="w-4 h-4"></i>
                                    <span>Göndər</span>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            <!-- Code Editors Sidebar -->
            <div class="lg:col-span-1">
                <div class="bg-white rounded-2xl shadow-xl overflow-hidden">
                    <div class="p-6 border-b border-gray-100">
                        <h2 class="text-xl font-semibold text-gray-800">Kod Editorları</h2>
                        <p class="text-gray-600">AI tərəfindən yaradılan kodlar</p>
                    </div>

                    <div class="p-6 space-y-6">
                        <!-- HTML Editor -->
                        <div>
                            <div class="flex items-center justify-between mb-3">
                                <label class="text-sm font-medium text-gray-700 flex items-center space-x-2">
                                    <i data-feather="file-text" class="w-4 h-4 text-primary-500"></i>
                                    <span>HTML Kodu</span>
                                </label>
                                <button class="copy-btn px-3 py-1 bg-primary-500 text-white text-xs rounded hover:bg-primary-600 transition-colors" data-target="html-code">
                                    Kopyala
                                </button>
                            </div>
                            <textarea id="html-code" placeholder="HTML kodu burada görünəcək..." 
                                     class="w-full h-32 p-3 border border-gray-200 rounded-lg focus:outline-none focus:border-primary-400 focus:ring-2 focus:ring-primary-100 resize-none code-block-gradient font-mono text-sm transition-all"></textarea>
                        </div>

                        <!-- CSS Editor -->
                        <div>
                            <div class="flex items-center justify-between mb-3">
                                <label class="text-sm font-medium text-gray-700 flex items-center space-x-2">
                                    <i data-feather="pen-tool" class="w-4 h-4 text-secondary-500"></i>
                                    <span>CSS Kodu</span>
                                </label>
                                <button class="copy-btn px-3 py-1 bg-primary-500 text-white text-xs rounded hover:bg-primary-600 transition-colors" data-target="css-code">
                                    Kopyala
                                </button>
                            </div>
                            <textarea id="css-code" placeholder="CSS kodu burada görünəcək..." 
                                     class="w-full h-32 p-3 border border-gray-200 rounded-lg focus:outline-none focus:border-primary-400 focus:ring-2 focus:ring-primary-100 resize-none code-block-gradient font-mono text-sm transition-all"></textarea>
                        </div>

                        <!-- JavaScript Editor -->
                        <div>
                            <div class="flex items-center justify-between mb-3">
                                <label class="text-sm font-medium text-gray-700 flex items-center space-x-2">
                                    <i data-feather="code" class="w-4 h-4 text-gray-600"></i>
                                    <span>JavaScript Kodu</span>
                                </label>
                                <button class="copy-btn px-3 py-1 bg-primary-500 text-white text-xs rounded hover:bg-primary-600 transition-colors" data-target="js-code">
                                    Kopyala
                                </button>
                            </div>
                            <textarea id="js-code" placeholder="JavaScript kodu burada görünəcək..." 
                                     class="w-full h-32 p-3 border border-gray-200 rounded-lg focus:outline-none focus:border-primary-400 focus:ring-2 focus:ring-primary-100 resize-none code-block-gradient font-mono text-sm transition-all"></textarea>
                        </div>
                    </div>
                </div>

                <!-- Preview Section -->
                <div class="mt-6 bg-white rounded-2xl shadow-xl overflow-hidden">
                    <div class="p-6 border-b border-gray-100">
                        <h2 class="text-xl font-semibold text-gray-800">Real-time Preview</h2>
                        <p class="text-gray-600">Kodunuzun canlı nümayişi</p>
                    </div>
                    <div id="output-game" class="h-64 bg-gray-900 flex items-center justify-center">
                        <div class="text-center text-gray-400">
                            <i data-feather="monitor" class="w-12 h-12 mx-auto mb-3"></i>
                            <p>Preview burada görünəcək</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- Toast Notification -->
    <div id="copy-toast" class="fixed bottom-8 left-1/2 transform -translate-x-1/2 bg-primary-500 text-white px-6 py-3 rounded-lg shadow-lg hidden z-50">
        <div class="flex items-center space-x-2">
            <i data-feather="check" class="w-4 h-4"></i>
            <span>Kopyalandı!</span>
        </div>
    </div>

    <script>
        // Initialize Feather Icons
        feather.replace();

        // Copy functionality
        document.querySelectorAll('.copy-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                const targetId = this.getAttribute('data-target');
                const textarea = document.getElementById(targetId);
                navigator.clipboard.writeText(textarea.value);
                
                const toast = document.getElementById('copy-toast');
                toast.classList.remove('hidden');
                setTimeout(() => toast.classList.add('hidden'), 2000);
            });
        });

        // Reset functionality
        document.getElementById('reset-all').addEventListener('click', function() {
            document.getElementById('html-code').value = '';
            document.getElementById('css-code').value = '';
            document.getElementById('js-code').value = '';
            document.getElementById('chat-log').innerHTML = `
                <div class="ai-response-animation">
                    <div class="flex items-start space-x-3">
                        <div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center flex-shrink-0">
                            <i data-feather="bot" class="w-4 h-4 text-primary-600"></i>
                        </div>
                        <div class="bg-white rounded-2xl p-4 shadow-sm max-w-3xl">
                            <p class="text-gray-700">Salam! Mən CodeCraft AI Studio köməkçisiyəm. HTML, CSS və JavaScript kodları yazmaqda sizə kömək edə bilərəm. Nə hazırlamaq istəyirsiniz?</p>
                        </div>
                    </div>
                </div>
            `;
        });

        // Chat form submission
        document.getElementById('chat-form').addEventListener('submit', function(e) {
            e.preventDefault();
            const input = document.getElementById('chat-input');
            const message = input.value.trim();
            
            if (message) {
                // Add user message
                const userMessage = document.createElement('div');
                userMessage.className = 'ai-response-animation';
                userMessage.innerHTML = `
                    <div class="flex items-start space-x-3 justify-end">
                        <div class="bg-primary-500 text-white rounded-2xl p-4 shadow-sm max-w-3xl">
                            <p>${message}</p>
                        </div>
                        <div class="w-8 h-8 bg-primary-500 rounded-full flex items-center justify-center flex-shrink-0">
                            <i data-feather="user" class="w-4 h-4 text-white"></i>
                        </div>
                    </div>
                `;
                document.getElementById('chat-log').appendChild(userMessage);
                
                // Clear input
                input.value = '';
                
                // Add typing indicator
                const typingIndicator = document.createElement('div');
                typingIndicator.className = 'ai-response-animation';
                typingIndicator.innerHTML = `
                    <div class="flex items-start space-x-3">
                        <div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center flex-shrink-0">
                            <i data-feather="bot" class="w-4 h-4 text-primary-600"></i>
                        </div>
                        <div class="bg-white rounded-2xl p-4 shadow-sm">
                            <div class="flex space-x-1">
                                <div class="typing-indicator"></div>
                                <div class="typing-indicator"></div>
                                <div class="typing-indicator"></div>
                            </div>
                        </div>
                    </div>
                `;
                document.getElementById('chat-log').appendChild(typingIndicator);
                
                // Scroll to bottom
                const chatLog = document.getElementById('chat-log');
                chatLog.scrollTop = chatLog.scrollHeight;
                
                // Simulate AI response after delay
                setTimeout(() => {
                    // Remove typing indicator
                    typingIndicator.remove();
                    
                    // Add AI response
                    const aiResponse = document.createElement('div');
                    aiResponse.className = 'ai-response-animation';
                    aiResponse.innerHTML = `
                        <div class="flex items-start space-x-3">
                            <div class="w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center flex-shrink-0">
                                <i data-feather="bot" class="w-4 h-4 text-primary-600"></i>
                            </div>
                            <div class="bg-white rounded-2xl p-4 shadow-sm max-w-3xl">
                                <p class="text-gray-700">Başa düşdüm! Burada sizin üçün bir nümunə hazırladım. Kod bloklarında HTML, CSS və JavaScript kodlarını görə bilərsiniz.</p>
                                <div class="mt-3 space-y-3">
                                    <div class="code-block-gradient rounded-lg p-3">
                                        <div class="flex justify-between items-center mb-2">
                                            <span class="text-sm font-medium text-primary-600">HTML</span>
                                            <button class="copy-btn px-2 py-1 bg-primary-500 text-white text-xs rounded" data-target="html-code">
                                                Kopyala
                                            </button>
                                        </div>
                                        <pre class="text-xs font-mono text-gray-700 overflow-x-auto">${escapeHTML(`<!DOCTYPE html>
<html>
<head>
    <title>Nümunə Səhifə</title>
</head>
<body>
    <h1>Salam Dünya!</h1>
</body>
</html>`)}</pre>
                                    </div>
                                </div>
                            </div>
                        </div>
                    `;
                    document.getElementById('chat-log').appendChild(aiResponse);
                    
                    // Update code editors with sample code
                    document.getElementById('html-code').value = `<!DOCTYPE html>
<html>
<head>
    <title>Nümunə Səhifə</title>
</head>
<body>
    <h1>Salam Dünya!</h1>
</body>
</html>`;
                    
                    document.getElementById('css-code').value = `body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

h1 {
    color: white;
    text-align: center;
    margin-top: 50px;
}`;
                    
                    document.getElementById('js-code').value = `// JavaScript kodu burada
console.log('Salam Dünya!');

// Elementləri seç və manipulyasiya et
document.querySelector('h1').addEventListener('click', function() {
    this.style.color = this.style.color === 'yellow' ? 'white' : 'yellow';
});`;
                    
                    // Update preview
                    updatePreview();
                    
                    // Scroll to bottom
                    chatLog.scrollTop = chatLog.scrollHeight;
                    
                    // Re-initialize copy buttons
                    feather.replace();
                    document.querySelectorAll('.copy-btn').forEach(btn => {
                        btn.addEventListener('click', function() {
                            const targetId = this.getAttribute('data-target');
                            const textarea = document.getElementById(targetId);
                            navigator.clipboard.writeText(textarea.value);
                            
                            const toast = document.getElementById('copy-toast');
                            toast.classList.remove('hidden');
                            setTimeout(() => toast.classList.add('hidden'), 2000);
                        });
                    });
                }, 2000);
            }
        });

        function escapeHTML(str) {
            return str.replace(/[&<>"']/g, function(m) {
                return ({
                    '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'
                })[m];
            });
        }

        function updatePreview() {
            const html = document.getElementById('html-code').value;
            const css = document.getElementById('css-code').value;
            const js = document.getElementById('js-code').value;
            
            const preview = document.getElementById('output-game');
            preview.innerHTML = `
                <iframe class="w-full h-full border-0" srcdoc="
                    <!DOCTYPE html>
                    <html>
                    <head>
                        <style>${css}</style>
                    </head>
                    <body>${html}
                        <script>
                            try {
                                ${js}
                            } catch(e) {
                                console.error('JS Error:', e);
                            }
                        <\\/script>
                    </body>
                    </html>
                "></iframe>
            `;
        }

        // Auto-update preview when code changes
        ['html-code', 'css-code', 'js-code'].forEach(id => {
            document.getElementById(id).addEventListener('input', updatePreview);
        });

        // Initialize preview
        updatePreview();
    </script>
</body>
</html>