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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Preview Profile - AI Resume Builder</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.css">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .preview-container {
            max-width: 1200px;
            margin: 40px auto;
            padding: 30px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .section-title {
            color: #2c3e50;
            margin-bottom: 30px;
            text-align: center;
            font-weight: 600;
        }
        .btn-logout {
            position: absolute;
            top: 20px;
            right: 20px;
        }
        .progress-indicator {
            margin-bottom: 30px;
            text-align: center;
            color: #6c757d;
            font-size: 0.9rem;
        }
        .progress-indicator span {
            display: inline-block;
            margin: 0 10px;
        }
        .progress-indicator span.active {
            color: #4e73df;
            font-weight: 600;
        }
        .preview-layout {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            margin-bottom: 30px;
        }
        .reorder-panel {
            background-color: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            padding: 20px;
        }
        .reorder-panel h5 {
            color: #495057;
            margin-bottom: 15px;
        }
        .help-text {
            font-size: 0.875rem;
            color: #6c757d;
            margin-bottom: 15px;
        }
        .sortable-list {
            list-style: none;
            padding: 0;
        }
        .sortable-item {
            background: white;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            padding: 12px 15px;
            margin-bottom: 8px;
            cursor: move;
            display: flex;
            align-items: center;
            transition: all 0.3s;
        }
        .sortable-item:hover {
            border-color: #4e73df;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .sortable-item.dragging {
            opacity: 0.5;
        }
        .sortable-item.sortable-ghost {
            background: #f8f9fa;
        }
        .sortable-item .drag-handle {
            color: #6c757d;
            margin-right: 10px;
        }
        .sortable-item.fixed {
            background-color: #e9ecef;
            cursor: not-allowed;
            opacity: 0.7;
        }
        .sortable-item.fixed .drag-handle {
            display: none;
        }
        .preview-panel {
            background-color: #ffffff;
            border: 1px solid #e9ecef;
            border-radius: 8px;
            padding: 30px;
            min-height: 600px;
        }
        .preview-section {
            margin-bottom: 25px;
            padding: 15px;
            border-left: 4px solid #4e73df;
            background-color: #f8f9fa;
        }
        .preview-section h5 {
            color: #2c3e50;
            margin-bottom: 15px;
            font-weight: 600;
        }
        .preview-section h6 {
            color: #495057;
            margin-bottom: 10px;
        }
        .contact-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            flex-wrap: wrap;
            gap: 10px;
        }
        .contact-item {
            display: flex;
            align-items: center;
            color: #495057;
            font-size: 0.9rem;
        }
        .contact-item i {
            margin-right: 5px;
            width: 16px;
        }
        .experience-item, .project-item, .education-item {
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid #dee2e6;
        }
        .experience-item:last-child, .project-item:last-child, .education-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }
        .date-range {
            color: #6c757d;
            font-size: 0.9rem;
            font-weight: 500;
        }
        .skills-grid, .achievements-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        .skill-tag, .achievement-tag {
            background-color: #4e73df;
            color: white;
            padding: 4px 12px;
            border-radius: 15px;
            font-size: 0.85rem;
        }
        .achievement-tag {
            background-color: #28a745;
        }
        .action-buttons {
            display: flex;
            justify-content: space-between;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #e9ecef;
        }
        .empty-state {
            text-align: center;
            color: #6c757d;
            font-style: italic;
            padding: 20px;
        }
        .ai-generated-badge {
            background-color: #17a2b8;
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            margin-left: 10px;
        }
        @media (max-width: 768px) {
            .preview-layout {
                grid-template-columns: 1fr;
            }
            .contact-info {
                flex-direction: column;
                align-items: flex-start;
            }
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('profile') }}">AI Resume Builder</a>
            <div class="ms-auto">
                <a href="{{ url_for('logout') }}" class="btn btn-outline-light">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
            </div>
        </div>
    </nav>

    <div class="container">
        <div class="preview-container">
            <div class="progress-indicator">
                <span>Introduction</span>
                <span>β†’</span>
                <span>Profile Summary</span>
                <span>β†’</span>
                <span>Work Experience</span>
                <span>β†’</span>
                <span>Projects</span>
                <span>β†’</span>
                <span>Education</span>
                <span>β†’</span>
                <span>Skills</span>
                <span>β†’</span>
                <span>Achievements</span>
                <span>β†’</span>
                <span class="active">Preview</span>
            </div>

            <h2 class="section-title">Preview Your Profile</h2>
            
            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    {% for category, message in messages %}
                        <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                            {{ message }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    {% endfor %}
                {% endif %}
            {% endwith %}

            <div class="preview-layout">
                <div class="reorder-panel">
                    <h5><i class="fas fa-arrows-alt"></i> Arrange Your Sections</h5>
                    <p class="help-text">
                        Drag and drop sections to reorder them. Introduction and Profile Summary are fixed at the top.
                    </p>
                    <ul id="sortableSections" class="sortable-list">
                        <li class="sortable-item fixed" data-section="introduction">
                            <i class="fas fa-user"></i> Introduction
                        </li>
                        <li class="sortable-item fixed" data-section="profile_summary">
                            <i class="fas fa-file-alt"></i> Profile Summary
                        </li>
                        {% if work_experiences %}
                            <li class="sortable-item" data-section="work_experience">
                                <i class="fas fa-grip-vertical drag-handle"></i>
                                <i class="fas fa-briefcase"></i> Work Experience
                            </li>
                        {% endif %}
                        {% if projects %}
                            <li class="sortable-item" data-section="projects">
                                <i class="fas fa-grip-vertical drag-handle"></i>
                                <i class="fas fa-project-diagram"></i> Projects
                            </li>
                        {% endif %}
                        {% if educations %}
                            <li class="sortable-item" data-section="education">
                                <i class="fas fa-grip-vertical drag-handle"></i>
                                <i class="fas fa-graduation-cap"></i> Education
                            </li>
                        {% endif %}
                        {% if skills %}
                            <li class="sortable-item" data-section="skills">
                                <i class="fas fa-grip-vertical drag-handle"></i>
                                <i class="fas fa-tools"></i> Skills
                            </li>
                        {% endif %}
                        {% if achievements %}
                            <li class="sortable-item" data-section="achievements">
                                <i class="fas fa-grip-vertical drag-handle"></i>
                                <i class="fas fa-trophy"></i> Achievements
                            </li>
                        {% endif %}
                    </ul>
                </div>

                <div class="preview-panel">
                    <div id="previewContent">
                        <!-- Introduction Section -->
                        {% if intro %}
                            <div class="preview-section" data-section="introduction">
                                <h5><i class="fas fa-user"></i> Introduction</h5>
                                <h3 class="text-center mb-3">{{ intro.name }}</h3>
                                <div class="contact-info">
                                    <div class="contact-item">
                                        <i class="fas fa-envelope"></i> {{ intro.email }}
                                    </div>
                                    <div class="contact-item">
                                        <i class="fas fa-phone"></i> {{ intro.phone }}
                                    </div>
                                    {% if intro.linkedin %}
                                        <div class="contact-item">
                                            <i class="fab fa-linkedin"></i> LinkedIn
                                        </div>
                                    {% endif %}
                                    {% if intro.github %}
                                        <div class="contact-item">
                                            <i class="fab fa-github"></i> GitHub
                                        </div>
                                    {% endif %}
                                    {% if intro.website %}
                                        <div class="contact-item">
                                            <i class="fas fa-globe"></i> Website
                                        </div>
                                    {% endif %}
                                </div>
                            </div>
                        {% endif %}

                        <!-- Profile Summary Section -->
                        {% if summary %}
                            <div class="preview-section" data-section="profile_summary">
                                <h5>
                                    <i class="fas fa-file-alt"></i> Profile Summary
                                    {% if summary.ai_generated %}
                                        <span class="ai-generated-badge">AI Generated</span>
                                    {% endif %}
                                </h5>
                                <p>{{ summary.summary }}</p>
                            </div>
                        {% endif %}

                        <!-- Dynamic sections will be inserted here based on order -->
                    </div>
                </div>
            </div>

            <form method="POST" action="{{ url_for('create_preview') }}" id="previewForm">
                <input type="hidden" name="section_order" id="sectionOrderInput" value='[]'>
                
                <div class="action-buttons">
                    <div>
                        <a href="{{ url_for('create_achievements') }}" class="btn btn-outline-secondary">
                            <i class="fas fa-arrow-left"></i> Back
                        </a>
                    </div>
                    <div>
                        <button type="button" class="btn btn-danger" onclick="confirmClear()">
                            <i class="fas fa-trash"></i> Clear All
                        </button>
                        <button type="submit" name="action" value="submit" class="btn btn-primary">
                            <i class="fas fa-check"></i> Submit Profile
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
    <script>
        // Initialize sortable
        const sortable = new Sortable(document.getElementById('sortableSections'), {
            animation: 150,
            ghostClass: 'sortable-ghost',
            dragClass: 'dragging',
            handle: '.drag-handle',
            filter: '.fixed',
            onEnd: function(evt) {
                updateSectionOrder();
                updatePreview();
            }
        });

        // Get all sections data
        const sectionsData = {
            introduction: {% if intro %}true{% else %}false{% endif %},
            profile_summary: {% if summary %}true{% else %}false{% endif %},
            work_experience: {% if work_experiences %}true{% else %}false{% endif %},
            projects: {% if projects %}true{% else %}false{% endif %},
            education: {% if educations %}true{% else %}false{% endif %},
            skills: {% if skills %}true{% else %}false{% endif %},
            achievements: {% if achievements %}true{% else %}false{% endif %}
        };

        // Render templates for each section
        const sectionTemplates = {
            work_experience: `
                {% for exp in work_experiences %}
                    <div class="experience-item">
                        <h6>{{ exp.title }}</h6>
                        <p class="text-muted mb-1">{{ exp.organization }}</p>
                        <p class="date-range mb-2">
                            {{ exp.start_month }}/{{ exp.start_year }} - 
                            {% if exp.end_year %}{{ exp.end_month }}/{{ exp.end_year }}{% else %}Present{% endif %}
                        </p>
                        {% if exp.remarks %}
                            <p class="mb-0">{{ exp.remarks }}</p>
                        {% endif %}
                    </div>
                {% endfor %}
            `,
            projects: `
                {% for project in projects %}
                    <div class="project-item">
                        <h6>{{ project.title }}</h6>
                        {% if project.organization %}
                            <p class="text-muted mb-1">{{ project.organization }}</p>
                        {% endif %}
                        <p class="date-range mb-2">
                            {{ project.start_month }}/{{ project.start_year }} - 
                            {% if project.end_year %}{{ project.end_month }}/{{ project.end_year }}{% else %}Present{% endif %}
                        </p>
                        {% if project.remarks %}
                            <p class="mb-0">{{ project.remarks }}</p>
                        {% endif %}
                    </div>
                {% endfor %}
            `,
            education: `
                {% for edu in educations %}
                    <div class="education-item">
                        <h6>{{ edu.title }}</h6>
                        <p class="text-muted mb-1">{{ edu.organization }}</p>
                        <p class="date-range mb-2">
                            {{ edu.start_month }}/{{ edu.start_year }} - 
                            {% if edu.end_year %}{{ edu.end_month }}/{{ edu.end_year }}{% else %}Present{% endif %}
                        </p>
                        {% if edu.remarks %}
                            <p class="mb-0">{{ edu.remarks }}</p>
                        {% endif %}
                    </div>
                {% endfor %}
            `,
            skills: `
                <div class="skills-grid">
                    {% for skill in skills %}
                        <span class="skill-tag">{{ skill.skill }}</span>
                    {% endfor %}
                </div>
            `,
            achievements: `
                <div class="achievements-grid">
                    {% for achievement in achievements %}
                        <span class="achievement-tag">{{ achievement.achievement }}</span>
                    {% endfor %}
                </div>
            `
        };

        function updateSectionOrder() {
            const items = document.querySelectorAll('#sortableSections .sortable-item');
            const order = [];
            
            items.forEach(item => {
                const section = item.dataset.section;
                if (section && sectionsData[section]) {
                    order.push(section);
                }
            });
            
            document.getElementById('sectionOrderInput').value = JSON.stringify(order);
        }

        function updatePreview() {
            const items = document.querySelectorAll('#sortableSections .sortable-item');
            const previewContent = document.getElementById('previewContent');
            
            // Keep introduction and summary
            const fixedSections = previewContent.querySelectorAll('[data-section="introduction"], [data-section="profile_summary"]');
            const newContent = Array.from(fixedSections);
            
            // Add dynamic sections in order
            items.forEach(item => {
                const section = item.dataset.section;
                if (section && section !== 'introduction' && section !== 'profile_summary' && sectionsData[section]) {
                    const sectionDiv = document.createElement('div');
                    sectionDiv.className = 'preview-section';
                    sectionDiv.dataset.section = section;
                    
                    let title = '';
                    switch(section) {
                        case 'work_experience':
                            title = '<i class="fas fa-briefcase"></i> Work Experience';
                            break;
                        case 'projects':
                            title = '<i class="fas fa-project-diagram"></i> Projects';
                            break;
                        case 'education':
                            title = '<i class="fas fa-graduation-cap"></i> Education';
                            break;
                        case 'skills':
                            title = '<i class="fas fa-tools"></i> Skills';
                            break;
                        case 'achievements':
                            title = '<i class="fas fa-trophy"></i> Achievements';
                            break;
                    }
                    
                    sectionDiv.innerHTML = `<h5>${title}</h5>${sectionTemplates[section]}`;
                    newContent.push(sectionDiv);
                }
            });
            
            previewContent.innerHTML = '';
            newContent.forEach(section => previewContent.appendChild(section));
        }

        function confirmClear() {
            if (confirm('Are you sure you want to clear all your profile data? This action cannot be undone.')) {
                document.getElementById('previewForm').innerHTML += 
                    '<input type="hidden" name="action" value="clear">';
                document.getElementById('previewForm').submit();
            }
        }

        // Initialize on page load
        document.addEventListener('DOMContentLoaded', function() {
            updateSectionOrder();
            updatePreview();
        });
    </script>
</body>
</html>