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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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI Video Generator Pro - Demo Mode</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px 40px;
            text-align: center;
        }

        .header h1 {
            font-size: 32px;
            margin-bottom: 10px;
        }

        .header p {
            font-size: 16px;
            opacity: 0.9;
        }

        .demo-notice {
            background: #fff3cd;
            color: #856404;
            padding: 15px;
            text-align: center;
            border-bottom: 2px solid #ffc107;
            font-weight: 500;
        }

        .main-content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            padding: 40px;
        }

        .section {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 12px;
        }

        .section h3 {
            color: #333;
            margin-bottom: 15px;
            font-size: 18px;
        }

        label {
            display: block;
            color: #555;
            margin-bottom: 8px;
            font-weight: 500;
            font-size: 14px;
        }

        textarea, select {
            width: 100%;
            padding: 12px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            font-size: 14px;
            font-family: inherit;
            transition: border-color 0.3s;
        }

        textarea {
            resize: vertical;
            min-height: 100px;
        }

        textarea:focus, select:focus {
            outline: none;
            border-color: #667eea;
        }

        .options-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-top: 15px;
        }

        button {
            width: 100%;
            padding: 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
            margin-top: 20px;
        }

        button:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
        }

        button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .loader {
            border: 3px solid #f3f3f3;
            border-top: 3px solid #667eea;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 20px auto;
            display: none;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .status {
            padding: 12px;
            border-radius: 8px;
            text-align: center;
            font-size: 14px;
            display: none;
            margin-top: 15px;
        }

        .status.info {
            background: #e3f2fd;
            color: #1976d2;
            display: block;
        }

        .status.success {
            background: #e8f5e9;
            color: #388e3c;
            display: block;
        }

        .status.error {
            background: #ffebee;
            color: #d32f2f;
            display: block;
        }

        .video-container {
            background: #000;
            border-radius: 12px;
            overflow: hidden;
            display: none;
            margin-top: 15px;
        }

        video {
            width: 100%;
            display: block;
        }

        .video-info {
            background: #f8f9fa;
            padding: 15px;
            margin-top: 10px;
            border-radius: 8px;
            font-size: 13px;
            color: #666;
        }

        .example-prompts {
            margin-top: 15px;
        }

        .example-prompt {
            display: inline-block;
            padding: 8px 16px;
            margin: 4px;
            background: white;
            border: 2px solid #667eea;
            border-radius: 20px;
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s;
            color: #667eea;
            font-weight: 500;
        }

        .example-prompt:hover {
            background: #667eea;
            color: white;
        }

        .features-list {
            list-style: none;
            margin-top: 15px;
        }

        .features-list li {
            padding: 8px 0;
            color: #555;
        }

        .features-list li:before {
            content: "βœ“ ";
            color: #667eea;
            font-weight: bold;
            margin-right: 8px;
        }

        @media (max-width: 768px) {
            .main-content {
                grid-template-columns: 1fr;
            }
            .options-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🎬 AI Video Generator Pro</h1>
            <p>Hailuo-Inspired Features with Multiple AI Models</p>
        </div>

        <div class="demo-notice">
            ⚠️ DEMO MODE: This demo uses a sample video to showcase the UI. Real video generation requires Hugging Face Space connections.
        </div>

        <div class="main-content">
            <!-- Left Panel -->
            <div>
                <div class="section">
                    <h3>πŸ“ Enter Your Prompt</h3>
                    <label for="prompt">Describe the video you want to create:</label>
                    <textarea 
                        id="prompt" 
                        rows="4"
                        placeholder="e.g., A golden retriever running through a field of sunflowers at sunset"
                    >A golden retriever running through a field of flowers</textarea>
                </div>

                <div class="section">
                    <h3>πŸŽ₯ Advanced Options (Hailuo-Inspired)</h3>
                    <div class="options-grid">
                        <div>
                            <label for="camera">Camera Movement:</label>
                            <select id="camera">
                                <option value="">Static</option>
                                <option value="[Zoom in]">Zoom In</option>
                                <option value="[Zoom out]">Zoom Out</option>
                                <option value="[Pan left]">Pan Left</option>
                                <option value="[Pan right]">Pan Right</option>
                                <option value="[Tracking shot]" selected>Tracking Shot</option>
                                <option value="[Dolly in]">Dolly In</option>
                            </select>
                        </div>
                        <div>
                            <label for="effect">Visual Effect:</label>
                            <select id="effect">
                                <option value="">None</option>
                                <option value="cinematic lighting, film grain" selected>Cinematic</option>
                                <option value="dramatic lighting, high contrast">Dramatic</option>
                                <option value="golden hour, warm sunset lighting">Golden Hour</option>
                                <option value="fog, misty atmosphere">Foggy</option>
                            </select>
                        </div>
                    </div>
                    <div style="margin-top: 15px;">
                        <label for="style">Video Style:</label>
                        <select id="style">
                            <option value="">Default</option>
                            <option value="photorealistic, 4k, high detail" selected>Realistic</option>
                            <option value="anime style, animated">Anime</option>
                            <option value="3D render, CGI, Pixar style">3D Render</option>
                            <option value="cinematic, movie scene">Cinematic</option>
                        </select>
                    </div>
                </div>

                <button onclick="generateVideo()">🎬 Generate Video (Demo)</button>
            </div>

            <!-- Right Panel -->
            <div>
                <div class="section">
                    <h3>🎞️ Generated Video</h3>
                    <div class="loader" id="loader"></div>
                    <div class="status" id="status"></div>
                    
                    <div class="video-container" id="video-container">
                        <video id="video-output" controls></video>
                    </div>

                    <div id="video-info" class="video-info" style="display: none;"></div>
                </div>

                <div class="section">
                    <h3>πŸ’‘ Example Prompts</h3>
                    <div class="example-prompts">
                        <span class="example-prompt" onclick="setPrompt('A golden retriever running through a field of flowers')">πŸ• Dog in field</span>
                        <span class="example-prompt" onclick="setPrompt('Ocean waves crashing on a beach at sunset')">🌊 Ocean sunset</span>
                        <span class="example-prompt" onclick="setPrompt('A sports car drifting around a corner')">🏎️ Racing car</span>
                        <span class="example-prompt" onclick="setPrompt('A dragon flying over a medieval castle')">πŸ‰ Fantasy dragon</span>
                    </div>
                </div>

                <div class="section">
                    <h3>✨ Features</h3>
                    <ul class="features-list">
                        <li>5 AI Models (CogVideoX, LTX, SVD, AnimateDiff, Zeroscope)</li>
                        <li>Text-to-Video & Image-to-Video</li>
                        <li>12 Camera Movements (Hailuo-style)</li>
                        <li>8 Visual Effects</li>
                        <li>8 Video Styles</li>
                        <li>Enhanced Prompt Building</li>
                        <li>Professional UI Design</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <script>
        let currentVideoUrl = null;

        function setPrompt(text) {
            document.getElementById('prompt').value = text;
        }

        function showStatus(message, type) {
            const status = document.getElementById('status');
            status.textContent = message;
            status.className = 'status ' + type;
        }

        async function generateVideo() {
            const prompt = document.getElementById('prompt').value.trim();
            const camera = document.getElementById('camera').value;
            const effect = document.getElementById('effect').value;
            const style = document.getElementById('style').value;

            if (!prompt) {
                showStatus('Please enter a prompt', 'error');
                return;
            }

            // Build enhanced prompt
            let enhancedPrompt = prompt;
            if (style) enhancedPrompt = style + ', ' + enhancedPrompt;
            if (camera) enhancedPrompt += ' ' + camera;
            if (effect) enhancedPrompt += ', ' + effect;

            // UI updates
            const btn = document.querySelector('button');
            btn.disabled = true;
            btn.textContent = '🎬 Generating...';
            document.getElementById('loader').style.display = 'block';
            document.getElementById('video-container').style.display = 'none';
            document.getElementById('video-info').style.display = 'none';
            showStatus('🎨 Generating your video... (Demo mode - instant)', 'info');

            try {
                // Simulate API delay
                await new Promise(resolve => setTimeout(resolve, 2000));

                const response = await fetch('http://localhost:5000/test-video', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ prompt: enhancedPrompt })
                });

                const data = await response.json();

                if (!response.ok || data.error) {
                    throw new Error(data.error || 'Failed to generate video');
                }

                // Success
                currentVideoUrl = data.video_url;
                const videoOutput = document.getElementById('video-output');
                videoOutput.src = currentVideoUrl;
                document.getElementById('video-container').style.display = 'block';
                
                // Show video info
                const videoInfo = document.getElementById('video-info');
                videoInfo.innerHTML = `
                    <strong>Mode:</strong> ${data.model_name}<br>
                    <strong>Your Prompt:</strong> ${prompt}<br>
                    <strong>Enhanced Prompt:</strong> ${data.enhanced_prompt}<br>
                    <strong>Note:</strong> ${data.note}
                `;
                videoInfo.style.display = 'block';
                
                showStatus('βœ… Demo video loaded! This showcases the UI. Connect to HF Spaces for real generation.', 'success');
                videoOutput.play().catch(() => {});

            } catch (error) {
                console.error('Error:', error);
                showStatus('❌ Error: ' + error.message, 'error');
            } finally {
                btn.disabled = false;
                btn.textContent = '🎬 Generate Video (Demo)';
                document.getElementById('loader').style.display = 'none';
            }
        }

        // Check server health on load
        window.addEventListener('load', async () => {
            try {
                const response = await fetch('http://localhost:5000/health');
                const data = await response.json();
                if (data.status === 'healthy') {
                    console.log('βœ… Server is healthy');
                    showStatus('βœ… Server connected! Try the demo by clicking Generate Video', 'success');
                }
            } catch (error) {
                showStatus('⚠️ Cannot connect to server. Make sure backend is running on port 5000', 'error');
            }
        });
    </script>
</body>
</html>