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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
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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Step 2: Upload Event Photos - Smart Photo Selection</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>

        * {

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }



        body {

            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

            background: #f5f7fa;

            min-height: 100vh;

            color: #333;

        }



        /* Header */

        .header {

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            padding: 30px 20px;

            text-align: center;

            color: white;

        }



        .header h1 {

            font-size: 28px;

            font-weight: 600;

            margin-bottom: 5px;

        }



        .header h1 .highlight {

            color: #ffd700;

        }



        .header p {

            opacity: 0.9;

            font-size: 14px;

        }



        /* Container */

        .container {

            max-width: 900px;

            margin: 0 auto;

            padding: 30px 20px;

        }



        /* Steps */

        .steps {

            display: flex;

            justify-content: center;

            align-items: flex-start;

            gap: 15px;

            margin-bottom: 40px;

            flex-wrap: wrap;

        }



        .step {

            display: flex;

            flex-direction: column;

            align-items: center;

            gap: 8px;

            min-width: 80px;

        }



        .step-circle {

            width: 40px;

            height: 40px;

            border-radius: 50%;

            background: #e0e0e0;

            color: #999;

            display: flex;

            align-items: center;

            justify-content: center;

            font-weight: 600;

            font-size: 16px;

            transition: all 0.3s;

        }



        .step.active .step-circle {

            background: #667eea;

            color: white;

            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);

        }



        .step.completed .step-circle {

            background: #4CAF50;

            color: white;

        }



        .step-label {

            font-size: 12px;

            color: #666;

            text-align: center;

            max-width: 80px;

        }



        .step.active .step-label {

            color: #667eea;

            font-weight: 500;

        }



        .step-connector {

            width: 40px;

            height: 2px;

            background: #e0e0e0;

            margin-top: 20px;

        }



        .step.completed + .step-connector {

            background: #4CAF50;

        }



        /* Reference Status Banner */

        .status-banner {

            border-radius: 12px;

            padding: 15px 20px;

            margin-bottom: 25px;

            display: flex;

            align-items: center;

            justify-content: space-between;

            gap: 15px;

        }



        .status-banner.has-ref {

            background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);

        }



        .status-banner.no-ref {

            background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);

        }



        .status-banner .info {

            display: flex;

            align-items: center;

            gap: 12px;

        }



        .status-banner .icon {

            font-size: 24px;

        }



        .status-banner .text {

            font-size: 14px;

        }



        .status-banner .text strong {

            color: #2e7d32;

        }



        .status-banner.no-ref .text strong {

            color: #e65100;

        }



        .status-banner a {

            color: #667eea;

            text-decoration: none;

            font-size: 14px;

            font-weight: 500;

            white-space: nowrap;

        }



        .status-banner a:hover {

            text-decoration: underline;

        }



        /* Card */

        .card {

            background: white;

            border-radius: 16px;

            box-shadow: 0 2px 20px rgba(0,0,0,0.08);

            padding: 40px;

            margin-bottom: 20px;

        }



        .card-icon {

            width: 60px;

            height: 60px;

            margin: 0 auto 20px;

            background: #f0f4ff;

            border-radius: 16px;

            display: flex;

            align-items: center;

            justify-content: center;

        }



        .card-icon svg {

            width: 30px;

            height: 30px;

            color: #667eea;

        }



        .card h2 {

            text-align: center;

            font-size: 22px;

            font-weight: 600;

            margin-bottom: 10px;

            color: #333;

        }



        .card > p {

            text-align: center;

            color: #666;

            margin-bottom: 30px;

        }



        /* Upload Method Tabs */

        .upload-tabs {

            display: flex;

            gap: 10px;

            margin-bottom: 20px;

        }



        .upload-tab {

            flex: 1;

            padding: 12px 20px;

            border: 2px solid #e0e0e0;

            border-radius: 8px;

            background: white;

            font-size: 14px;

            font-weight: 500;

            cursor: pointer;

            transition: all 0.2s;

            font-family: inherit;

        }



        .upload-tab:hover {

            border-color: #667eea;

        }



        .upload-tab.active {

            border-color: #667eea;

            background: #f0f4ff;

            color: #667eea;

        }



        /* Folder Path Input */

        .folder-input-area {

            border: 2px dashed #d0d7e3;

            border-radius: 12px;

            padding: 50px 20px;

            text-align: center;

            background: #fafbfc;

        }



        .folder-input-area.hidden {

            display: none;

        }



        .folder-input-area h3 {

            font-size: 18px;

            font-weight: 500;

            margin-bottom: 8px;

            color: #333;

        }



        .folder-input-area > p {

            color: #888;

            font-size: 14px;

            margin-bottom: 20px;

        }



        .folder-path-input {

            width: 100%;

            max-width: 500px;

            padding: 14px 18px;

            border: 2px solid #e0e0e0;

            border-radius: 8px;

            font-size: 14px;

            font-family: 'Consolas', monospace;

            transition: border-color 0.2s;

        }



        .folder-path-input:focus {

            outline: none;

            border-color: #667eea;

        }



        .folder-hint {

            font-size: 12px;

            color: #999;

            margin-top: 10px;

        }



        /* Upload Area */

        .upload-area {

            border: 2px dashed #d0d7e3;

            border-radius: 12px;

            padding: 50px 20px;

            text-align: center;

            cursor: pointer;

            transition: all 0.3s;

            background: #fafbfc;

        }



        .upload-area.hidden {

            display: none;

        }



        .upload-area:hover {

            border-color: #667eea;

            background: #f0f4ff;

        }



        .upload-area.drag-over {

            border-color: #667eea;

            background: #e8edff;

            transform: scale(1.01);

        }



        .upload-icon {

            font-size: 56px;

            margin-bottom: 15px;

        }



        .upload-area h3 {

            font-size: 18px;

            font-weight: 500;

            margin-bottom: 8px;

            color: #333;

        }



        .upload-area p {

            color: #888;

            font-size: 14px;

            margin-bottom: 20px;

        }



        /* Buttons */

        .btn {

            padding: 12px 28px;

            border: none;

            border-radius: 8px;

            font-size: 15px;

            font-weight: 500;

            cursor: pointer;

            transition: all 0.2s;

            font-family: inherit;

        }



        .btn-primary {

            background: #667eea;

            color: white;

        }



        .btn-primary:hover {

            background: #5a6fd6;

            transform: translateY(-1px);

        }



        .btn-success {

            background: #4CAF50;

            color: white;

        }



        .btn-success:hover {

            background: #43a047;

        }



        .btn-secondary {

            background: #f0f0f0;

            color: #666;

        }



        .btn-secondary:hover {

            background: #e0e0e0;

        }



        /* Settings Panel */

        .settings-panel {

            margin-top: 30px;

            padding-top: 30px;

            border-top: 1px solid #eee;

        }



        .settings-panel h3 {

            font-size: 16px;

            font-weight: 600;

            margin-bottom: 8px;

            color: #333;

        }



        .settings-panel > p {

            color: #888;

            font-size: 13px;

            margin-bottom: 20px;

        }



        /* Quality Mode Buttons */

        .quality-buttons {

            display: grid;

            grid-template-columns: repeat(3, 1fr);

            gap: 12px;

            margin-bottom: 25px;

        }



        .quality-btn {

            padding: 15px;

            border: 2px solid #e0e0e0;

            border-radius: 12px;

            background: white;

            cursor: pointer;

            text-align: center;

            transition: all 0.2s;

        }



        .quality-btn:hover {

            border-color: #667eea;

        }



        .quality-btn.active {

            border-color: #667eea;

            background: #f0f4ff;

        }



        .quality-btn .icon {

            font-size: 28px;

            margin-bottom: 8px;

            display: block;

        }



        .quality-btn .label {

            font-weight: 600;

            font-size: 14px;

            color: #333;

            display: block;

            margin-bottom: 4px;

        }



        .quality-btn .desc {

            font-size: 11px;

            color: #888;

            display: block;

        }



        .quality-btn.active .label {

            color: #667eea;

        }



        /* Slider */

        .slider-group {

            margin-top: 20px;

        }



        .slider-group label {

            display: block;

            font-size: 14px;

            font-weight: 500;

            margin-bottom: 10px;

            color: #333;

        }



        .slider-group input[type="range"] {

            width: 100%;

            height: 6px;

            border-radius: 3px;

            background: #e0e0e0;

            outline: none;

            -webkit-appearance: none;

        }



        .slider-group input[type="range"]::-webkit-slider-thumb {

            -webkit-appearance: none;

            width: 20px;

            height: 20px;

            border-radius: 50%;

            background: #667eea;

            cursor: pointer;

        }



        .slider-labels {

            display: flex;

            justify-content: space-between;

            margin-top: 8px;

            font-size: 12px;

            color: #888;

        }



        .slider-labels .value {

            color: #667eea;

            font-weight: 600;

        }



        /* File Preview */

        .file-preview {

            margin-top: 30px;

            padding-top: 30px;

            border-top: 1px solid #eee;

        }



        .file-preview.hidden {

            display: none;

        }



        .file-preview-header {

            display: flex;

            justify-content: space-between;

            align-items: center;

            margin-bottom: 15px;

        }



        .file-preview h3 {

            font-size: 16px;

            font-weight: 500;

            color: #333;

        }



        .file-count {

            background: #667eea;

            color: white;

            padding: 4px 12px;

            border-radius: 20px;

            font-size: 13px;

            font-weight: 500;

        }



        .preview-grid {

            display: grid;

            grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));

            gap: 10px;

            max-height: 200px;

            overflow-y: auto;

            margin-bottom: 20px;

        }



        .preview-item {

            aspect-ratio: 1;

            border-radius: 8px;

            overflow: hidden;

            background: #f0f0f0;

        }



        .preview-item img {

            width: 100%;

            height: 100%;

            object-fit: cover;

        }



        .more-indicator {

            display: flex;

            align-items: center;

            justify-content: center;

            background: #667eea;

            color: white;

            font-weight: 600;

            font-size: 14px;

        }



        /* Processing Overlay */

        .processing-overlay {

            position: fixed;

            top: 0;

            left: 0;

            right: 0;

            bottom: 0;

            background: rgba(255,255,255,0.98);

            display: flex;

            flex-direction: column;

            align-items: center;

            justify-content: center;

            z-index: 1000;

        }



        .processing-overlay.hidden {

            display: none;

        }



        .spinner {

            width: 60px;

            height: 60px;

            border: 4px solid #f0f0f0;

            border-top-color: #667eea;

            border-radius: 50%;

            animation: spin 1s linear infinite;

        }



        @keyframes spin {

            to { transform: rotate(360deg); }

        }



        .processing-overlay h2 {

            margin-top: 25px;

            font-size: 20px;

            color: #333;

        }



        .progress-container {

            width: 300px;

            margin-top: 20px;

        }



        .progress-bar {

            height: 8px;

            background: #e0e0e0;

            border-radius: 4px;

            overflow: hidden;

        }



        .progress-fill {

            height: 100%;

            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

            transition: width 0.3s;

            border-radius: 4px;

        }



        .progress-text {

            text-align: center;

            margin-top: 10px;

            font-size: 14px;

            color: #666;

        }



        .progress-text span {

            font-weight: 600;

            color: #667eea;

        }



        /* How it works */

        .how-it-works {

            background: white;

            border-radius: 16px;

            box-shadow: 0 2px 20px rgba(0,0,0,0.08);

            padding: 30px 40px;

        }



        .how-it-works h3 {

            font-size: 16px;

            font-weight: 600;

            margin-bottom: 20px;

            color: #333;

        }



        .how-it-works ol {

            list-style: none;

            padding: 0;

            margin: 0;

        }



        .how-it-works li {

            display: flex;

            align-items: flex-start;

            gap: 12px;

            padding: 10px 0;

            color: #555;

            font-size: 14px;

        }



        .how-it-works .step-num {

            width: 24px;

            height: 24px;

            background: #f0f4ff;

            color: #667eea;

            border-radius: 50%;

            display: flex;

            align-items: center;

            justify-content: center;

            font-size: 12px;

            font-weight: 600;

            flex-shrink: 0;

        }



        @media (max-width: 600px) {

            .card {

                padding: 25px 20px;

            }



            .quality-buttons {

                grid-template-columns: 1fr;

            }



            .status-banner {

                flex-direction: column;

                text-align: center;

            }

        }

    </style>
</head>
<body>
    <!-- Header -->
    <div class="header">
        <h1>Create a Personalized Photo Book for <span class="highlight">Your Child</span>!</h1>
        <p>AI-powered photo selection to find the best moments</p>
    </div>

    <div class="container">
        <!-- Step Indicator -->
        <div class="steps">
            <div class="step completed">
                <div class="step-circle">&#10003;</div>
                <div class="step-label">Reference</div>
            </div>
            <div class="step-connector" style="background: #4CAF50;"></div>
            <div class="step active">
                <div class="step-circle">2</div>
                <div class="step-label">Pre-processing</div>
            </div>
            <div class="step-connector"></div>
            <div class="step">
                <div class="step-circle">3</div>
                <div class="step-label">Review</div>
            </div>
            <div class="step-connector"></div>
            <div class="step">
                <div class="step-circle">4</div>
                <div class="step-label">Detecting Favorites</div>
            </div>
        </div>

        <!-- Reference Status Banner -->
        {% if reference_count > 0 %}
        <div class="status-banner has-ref">
            <div class="info">
                <span class="icon">&#9989;</span>
                <span class="text"><strong>{{ reference_count }} reference photo(s) loaded</strong> - AI will find your child in uploaded photos</span>
            </div>
            <a href="/step1">Change</a>
        </div>
        {% else %}
        <div class="status-banner no-ref">
            <div class="info">
                <span class="icon">&#9888;</span>
                <span class="text"><strong>No reference photos</strong> - Processing all photos without face filtering</span>
            </div>
            <a href="/step1">Add reference photos</a>
        </div>
        {% endif %}

        <!-- Main Card -->
        <div class="card">
            <div class="card-icon">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
                    <path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-5-7l-3 3.72L9 13l-3 4h12l-4-5z"/>
                </svg>
            </div>
            <h2>Upload Your Event Photos</h2>
            <p>Upload all photos from the event - we'll find the best ones of your child</p>

            <!-- Google Drive Input -->
            <div class="folder-input-area" id="drive-input-area">
                <div class="upload-icon" style="font-size: 48px;">&#9729;</div>
                <h3>Import from Google Drive</h3>
                <p>Paste a Google Drive folder URL (folder must be shared with the service account)</p>
                <input type="text" id="drive-folder-url" class="folder-path-input"

                       placeholder="https://drive.google.com/drive/folders/1AbCdEfGhIjKlMnOpQrS">
                <p class="folder-hint">Paste the folder URL from your browser address bar</p>
                <div id="drive-preview" style="margin-top: 15px; display: none;">
                    <div style="background: #e8f5e9; padding: 12px 16px; border-radius: 8px; text-align: left;">
                        <strong id="drive-folder-name" style="color: #2e7d32;"></strong>
                        <span id="drive-image-count" style="color: #666; margin-left: 10px;"></span>
                    </div>
                </div>
                <button class="btn btn-secondary" id="preview-drive-btn" onclick="previewDriveFolder()" style="margin-top: 15px;">
                    Preview Folder
                </button>
            </div>

            <!-- Settings Panel -->
            <div class="settings-panel">
                <h3>Selection Settings</h3>
                <p>Adjust how strict the quality filter should be</p>

                <div class="quality-buttons">
                    <button class="quality-btn" data-mode="lenient" onclick="setQualityMode('lenient')">
                        <span class="icon">&#128247;</span>
                        <span class="label">Keep More</span>
                        <span class="desc">Lower standards, more photos</span>
                    </button>
                    <button class="quality-btn active" data-mode="balanced" onclick="setQualityMode('balanced')">
                        <span class="icon">&#10024;</span>
                        <span class="label">Balanced</span>
                        <span class="desc">Recommended setting</span>
                    </button>
                    <button class="quality-btn" data-mode="strict" onclick="setQualityMode('strict')">
                        <span class="icon">&#127942;</span>
                        <span class="label">Best Only</span>
                        <span class="desc">Highest quality only</span>
                    </button>
                </div>

                <div class="slider-group">
                    <label>Duplicate Detection</label>
                    <input type="range" id="similarity" min="0.80" max="0.98" step="0.02" value="0.92">
                    <div class="slider-labels">
                        <span>Keep similar</span>
                        <span class="value" id="similarity-value">92%</span>
                        <span>Remove similar</span>
                    </div>
                </div>
            </div>

            <!-- File Preview -->
            <div id="file-preview" class="file-preview hidden">
                <div class="file-preview-header">
                    <h3>Selected Files</h3>
                    <span class="file-count" id="file-count">0 photos</span>
                </div>
                <div id="preview-grid" class="preview-grid"></div>
                <button class="btn btn-success" id="process-btn" onclick="startProcessing()">
                    {% if reference_count > 0 %}
                    Find My Child &amp; Select Best Photos
                    {% else %}
                    Select Best Photos
                    {% endif %}
                </button>
            </div>
        </div>

        <!-- How it works -->
        <div class="how-it-works">
            <h3>How it works:</h3>
            <ol>
                <li><span class="step-num">1</span> Upload all your event/school photos</li>
                <li><span class="step-num">2</span> AI scans every photo looking for your child's face</li>
                <li><span class="step-num">3</span> Review the matches and confirm which ones to keep</li>
                <li><span class="step-num">4</span> AI selects the best quality photos from your selection</li>
                <li><span class="step-num">5</span> Download your curated photo collection</li>
            </ol>
        </div>
    </div>

    <!-- Processing Overlay -->
    <div id="processing-overlay" class="processing-overlay hidden">
        <div class="spinner"></div>
        <h2 id="processing-message">Processing your photos...</h2>
        <p id="files-checked" style="color: #667eea; font-size: 18px; font-weight: 600; margin-top: 10px;"></p>
        <div class="progress-container">
            <div class="progress-bar">
                <div class="progress-fill" id="progress-fill" style="width: 0%"></div>
            </div>
            <p class="progress-text"><span id="progress-percent">0</span>%</p>
        </div>
    </div>

    <script>

        const hasReferences = {{ reference_count }} > 0;

        let qualityMode = 'balanced';

        let jobId = null;

        let driveFolderVerified = false;



        function updateDrivePreview() {

            const driveUrl = document.getElementById('drive-folder-url').value.trim();

            const preview = document.getElementById('file-preview');



            if (driveUrl && driveFolderVerified) {

                preview.classList.remove('hidden');

            } else {

                preview.classList.add('hidden');

            }

        }



        async function previewDriveFolder() {

            const driveUrl = document.getElementById('drive-folder-url').value.trim();

            if (!driveUrl) {

                alert('Please enter a Google Drive folder URL');

                return;

            }



            const btn = document.getElementById('preview-drive-btn');

            btn.textContent = 'Checking...';

            btn.disabled = true;



            try {

                const response = await fetch('/preview_drive_folder', {

                    method: 'POST',

                    headers: { 'Content-Type': 'application/json' },

                    body: JSON.stringify({ folder_url: driveUrl })

                });



                const data = await response.json();



                if (data.error) {

                    alert('Error: ' + data.error);

                    driveFolderVerified = false;

                } else {

                    // Show preview

                    document.getElementById('drive-folder-name').textContent = data.folder_name;

                    document.getElementById('drive-image-count').textContent = `(${data.image_count} images found)`;

                    document.getElementById('drive-preview').style.display = 'block';

                    driveFolderVerified = true;



                    // Show file preview section with process button

                    const preview = document.getElementById('file-preview');

                    preview.classList.remove('hidden');

                    document.getElementById('file-count').textContent = `${data.image_count} images`;

                    document.getElementById('preview-grid').innerHTML = '<div style="padding: 20px; color: #666; font-size: 14px;">Ready to import from: ' + data.folder_name + '</div>';

                }

            } catch (e) {

                console.error('Preview error:', e);

                alert('Failed to preview folder. Please check the URL.');

                driveFolderVerified = false;

            } finally {

                btn.textContent = 'Preview Folder';

                btn.disabled = false;

            }

        }



        // Drive URL input handler - reset verification on change

        document.getElementById('drive-folder-url').addEventListener('input', function() {

            driveFolderVerified = false;

            document.getElementById('drive-preview').style.display = 'none';

            document.getElementById('file-preview').classList.add('hidden');

        });



        function setQualityMode(mode) {

            qualityMode = mode;

            document.querySelectorAll('.quality-btn').forEach(btn => {

                btn.classList.toggle('active', btn.dataset.mode === mode);

            });

        }



        // Similarity slider

        document.getElementById('similarity').addEventListener('input', function() {

            document.getElementById('similarity-value').textContent = Math.round(this.value * 100) + '%';

        });



        async function startProcessing() {

            // Show processing overlay

            document.getElementById('processing-overlay').classList.remove('hidden');



            // Google Drive import mode

            const driveUrl = document.getElementById('drive-folder-url').value.trim();

            if (!driveUrl) {

                alert('Please enter a Google Drive folder URL');

                document.getElementById('processing-overlay').classList.add('hidden');

                return;

            }



            if (!driveFolderVerified) {

                alert('Please click "Preview Folder" first to verify access');

                document.getElementById('processing-overlay').classList.add('hidden');

                return;

            }



            document.getElementById('processing-message').textContent = 'Connecting to Google Drive...';



            try {

                const response = await fetch('/import_from_drive', {

                    method: 'POST',

                    headers: { 'Content-Type': 'application/json' },

                    body: JSON.stringify({

                        folder_url: driveUrl,

                        quality_mode: qualityMode,

                        similarity_threshold: parseFloat(document.getElementById('similarity').value)

                    })

                });



                const data = await response.json();



                if (data.error) {

                    alert('Error: ' + data.error);

                    document.getElementById('processing-overlay').classList.add('hidden');

                    return;

                }



                jobId = data.job_id;

                pollStatus();



            } catch (error) {

                console.error('Error:', error);

                alert('Failed to import from Google Drive. Please try again.');

                document.getElementById('processing-overlay').classList.add('hidden');

            }

        }



        async function pollStatus() {

            try {

                const response = await fetch(`/status/${jobId}`);

                const data = await response.json();



                document.getElementById('processing-message').textContent = data.message;

                document.getElementById('progress-fill').style.width = `${data.progress}%`;

                document.getElementById('progress-percent').textContent = data.progress;



                // Show files checked count

                const filesCheckedEl = document.getElementById('files-checked');

                if (data.total_photos > 0) {

                    filesCheckedEl.textContent = `${data.photos_checked || 0} / ${data.total_photos} files checked`;

                } else {

                    filesCheckedEl.textContent = '';

                }



                if (data.status === 'review_pending') {

                    window.location.href = `/step3_review/${jobId}`;

                } else if (data.status === 'complete') {

                    window.location.href = `/step4_results/${jobId}`;

                } else if (data.status === 'error') {

                    alert('Error: ' + data.message);

                    document.getElementById('processing-overlay').classList.add('hidden');

                } else {

                    setTimeout(pollStatus, 1000);

                }



            } catch (error) {

                console.error('Poll error:', error);

                setTimeout(pollStatus, 2000);

            }

        }

    </script>
</body>
</html>