File size: 33,450 Bytes
928619c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Product Comparison Tool</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        .radar-chart-container {
            position: relative;
            height: 300px;
            width: 100%;
        }
        .priority-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #3b82f6;
            cursor: pointer;
        }
        .priority-slider::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #3b82f6;
            cursor: pointer;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <header class="text-center mb-10">
            <h1 class="text-4xl font-bold text-blue-600 mb-2">Amazon Review Analyzer</h1>
            <p class="text-gray-600 text-lg">Compare products based on customer feedback analysis</p>
        </header>

        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Left Column - Input Section -->
            <div class="bg-white p-6 rounded-lg shadow-md lg:col-span-1">
                <h2 class="text-xl font-semibold mb-4 text-gray-800">Product Selection</h2>
                
                <div class="mb-6">
                    <label class="block text-gray-700 mb-2">Product A</label>
                    <select id="productA" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
                        <option value="product1">Wireless Earbuds X200</option>
                        <option value="product2">Smart Watch Pro</option>
                        <option value="product3">Bluetooth Speaker Z5</option>
                    </select>
                </div>
                
                <div class="mb-6">
                    <label class="block text-gray-700 mb-2">Product B</label>
                    <select id="productB" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
                        <option value="product2">Smart Watch Pro</option>
                        <option value="product1">Wireless Earbuds X200</option>
                        <option value="product3">Bluetooth Speaker Z5</option>
                    </select>
                </div>
                
                <button id="compareBtn" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition duration-200">
                    Compare Products
                </button>
                
                <div class="mt-8">
                    <h2 class="text-xl font-semibold mb-4 text-gray-800">Set Your Priorities</h2>
                    <p class="text-sm text-gray-500 mb-4">Adjust the sliders to reflect what matters most to you (total must be 100%)</p>
                    
                    <div class="space-y-4">
                        <div>
                            <label class="block text-gray-700 mb-1">Price</label>
                            <input type="range" min="0" max="100" value="20" class="w-full priority-slider" id="pricePriority">
                            <div class="flex justify-between text-xs text-gray-500">
                                <span>0%</span>
                                <span id="priceValue">20%</span>
                                <span>100%</span>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-gray-700 mb-1">Durability</label>
                            <input type="range" min="0" max="100" value="20" class="w-full priority-slider" id="durabilityPriority">
                            <div class="flex justify-between text-xs text-gray-500">
                                <span>0%</span>
                                <span id="durabilityValue">20%</span>
                                <span>100%</span>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-gray-700 mb-1">Features</label>
                            <input type="range" min="0" max="100" value="20" class="w-full priority-slider" id="featuresPriority">
                            <div class="flex justify-between text-xs text-gray-500">
                                <span>0%</span>
                                <span id="featuresValue">20%</span>
                                <span>100%</span>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-gray-700 mb-1">Usability</label>
                            <input type="range" min="0" max="100" value="20" class="w-full priority-slider" id="usabilityPriority">
                            <div class="flex justify-between text-xs text-gray-500">
                                <span>0%</span>
                                <span id="usabilityValue">20%</span>
                                <span>100%</span>
                            </div>
                        </div>
                        
                        <div>
                            <label class="block text-gray-700 mb-1">Customer Service</label>
                            <input type="range" min="0" max="100" value="20" class="w-full priority-slider" id="servicePriority">
                            <div class="flex justify-between text-xs text-gray-500">
                                <span>0%</span>
                                <span id="serviceValue">20%</span>
                                <span>100%</span>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mt-4 p-3 bg-blue-50 rounded-md">
                        <p class="text-sm text-blue-800">Total: <span id="totalPriority">100</span>%</p>
                    </div>
                </div>
            </div>
            
            <!-- Right Column - Results Section -->
            <div class="bg-white p-6 rounded-lg shadow-md lg:col-span-2">
                <div id="resultsSection" class="hidden">
                    <h2 class="text-2xl font-semibold mb-6 text-gray-800">Comparison Results</h2>
                    
                    <!-- Recommendation Banner -->
                    <div id="recommendationBanner" class="mb-8 p-4 rounded-md bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200">
                        <div class="flex items-center">
                            <div class="mr-4 p-2 bg-blue-100 rounded-full">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                                </svg>
                            </div>
                            <div>
                                <h3 class="font-bold text-lg text-blue-800" id="recommendationTitle">Our Recommendation</h3>
                                <p class="text-gray-700" id="recommendationText"></p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Radar Chart -->
                    <div class="mb-8">
                        <h3 class="text-lg font-medium text-gray-800 mb-4">Category Comparison</h3>
                        <div class="radar-chart-container">
                            <canvas id="radarChart"></canvas>
                        </div>
                    </div>
                    
                    <!-- Scores Table -->
                    <div class="mb-8 overflow-x-auto">
                        <h3 class="text-lg font-medium text-gray-800 mb-4">Detailed Scores</h3>
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Weight</th>
                                    <th id="productAName" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product A</th>
                                    <th id="productBName" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product B</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Price</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="weightPrice">20</span>%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productAPrice">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productBPrice">0</span>/100</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Durability</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="weightDurability">20</span>%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productADurability">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productBDurability">0</span>/100</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Features</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="weightFeatures">20</span>%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productAFeatures">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productBFeatures">0</span>/100</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Usability</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="weightUsability">20</span>%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productAUsability">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productBUsability">0</span>/100</td>
                                </tr>
                                <tr>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Customer Service</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="weightService">20</span>%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productAService">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"><span id="productBService">0</span>/100</td>
                                </tr>
                                <tr class="bg-blue-50 border-t-2 border-blue-200">
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-blue-800">Overall Score</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-blue-800">100%</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-blue-800"><span id="productAOverall">0</span>/100</td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-bold text-blue-800"><span id="productBOverall">0</span>/100</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <!-- Review Snippets -->
                    <div>
                        <h3 class="text-lg font-medium text-gray-800 mb-4">Sample Review Highlights</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="font-medium text-blue-600 mb-2" id="productAName2">Product A</h4>
                                <div class="space-y-3">
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Price:</p>
                                        <p class="text-gray-600 italic" id="productAPriceReview">"Great value for money compared to competitors."</p>
                                    </div>
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Durability:</p>
                                        <p class="text-gray-600 italic" id="productADurabilityReview">"Held up well after 6 months of daily use."</p>
                                    </div>
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Features:</p>
                                        <p class="text-gray-600 italic" id="productAFeaturesReview">"Has all the features I need but some are hard to find."</p>
                                    </div>
                                </div>
                            </div>
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="font-medium text-blue-600 mb-2" id="productBName2">Product B</h4>
                                <div class="space-y-3">
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Price:</p>
                                        <p class="text-gray-600 italic" id="productBPriceReview">"A bit expensive but you get what you pay for."</p>
                                    </div>
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Durability:</p>
                                        <p class="text-gray-600 italic" id="productBDurabilityReview">"Screen scratched within the first month."</p>
                                    </div>
                                    <div class="text-sm">
                                        <p class="font-medium text-gray-700">Features:</p>
                                        <p class="text-gray-600 italic" id="productBFeaturesReview">"Innovative features that competitors don't have."</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Empty State -->
                <div id="emptyState" class="text-center py-12">
                    <svg xmlns="http://www.w3.org/2000/svg" class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    <h3 class="mt-2 text-lg font-medium text-gray-900">No comparison yet</h3>
                    <p class="mt-1 text-gray-500">Select two products and click "Compare Products" to see results.</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Mock data for products
        const products = {
            product1: {
                name: "Wireless Earbuds X200",
                scores: {
                    price: 85,
                    durability: 70,
                    features: 75,
                    usability: 80,
                    service: 65
                },
                reviews: {
                    price: "Great value for money compared to competitors.",
                    durability: "Held up well after 6 months of daily use.",
                    features: "Has all the features I need but some are hard to find.",
                    usability: "Very comfortable and easy to pair with devices.",
                    service: "Had to contact support once, response was slow."
                }
            },
            product2: {
                name: "Smart Watch Pro",
                scores: {
                    price: 60,
                    durability: 65,
                    features: 90,
                    usability: 85,
                    service: 80
                },
                reviews: {
                    price: "A bit expensive but you get what you pay for.",
                    durability: "Screen scratched within the first month.",
                    features: "Innovative features that competitors don't have.",
                    usability: "Interface is intuitive and responsive.",
                    service: "Excellent warranty service when I had an issue."
                }
            },
            product3: {
                name: "Bluetooth Speaker Z5",
                scores: {
                    price: 75,
                    durability: 85,
                    features: 70,
                    usability: 75,
                    service: 70
                },
                reviews: {
                    price: "Mid-range price with premium sound quality.",
                    durability: "Built like a tank - survived multiple drops.",
                    features: "Basic features but does them very well.",
                    usability: "Simple controls but the app could be better.",
                    service: "Average response time for customer inquiries."
                }
            }
        };

        // DOM elements
        const compareBtn = document.getElementById('compareBtn');
        const resultsSection = document.getElementById('resultsSection');
        const emptyState = document.getElementById('emptyState');
        const recommendationText = document.getElementById('recommendationText');
        const recommendationTitle = document.getElementById('recommendationTitle');
        const recommendationBanner = document.getElementById('recommendationBanner');
        
        // Slider elements
        const sliders = [
            { element: document.getElementById('pricePriority'), value: document.getElementById('priceValue'), weight: document.getElementById('weightPrice') },
            { element: document.getElementById('durabilityPriority'), value: document.getElementById('durabilityValue'), weight: document.getElementById('weightDurability') },
            { element: document.getElementById('featuresPriority'), value: document.getElementById('featuresValue'), weight: document.getElementById('weightFeatures') },
            { element: document.getElementById('usabilityPriority'), value: document.getElementById('usabilityValue'), weight: document.getElementById('weightUsability') },
            { element: document.getElementById('servicePriority'), value: document.getElementById('serviceValue'), weight: document.getElementById('weightService') }
        ];
        
        const totalPriority = document.getElementById('totalPriority');
        
        // Product score elements
        const productElements = {
            productA: {
                name: [document.getElementById('productAName'), document.getElementById('productAName2')],
                price: document.getElementById('productAPrice'),
                durability: document.getElementById('productADurability'),
                features: document.getElementById('productAFeatures'),
                usability: document.getElementById('productAUsability'),
                service: document.getElementById('productAService'),
                overall: document.getElementById('productAOverall'),
                reviews: {
                    price: document.getElementById('productAPriceReview'),
                    durability: document.getElementById('productADurabilityReview'),
                    features: document.getElementById('productAFeaturesReview'),
                    usability: document.getElementById('productAUsabilityReview'),
                    service: document.getElementById('productAServiceReview')
                }
            },
            productB: {
                name: [document.getElementById('productBName'), document.getElementById('productBName2')],
                price: document.getElementById('productBPrice'),
                durability: document.getElementById('productBDurability'),
                features: document.getElementById('productBFeatures'),
                usability: document.getElementById('productBUsability'),
                service: document.getElementById('productBService'),
                overall: document.getElementById('productBOverall'),
                reviews: {
                    price: document.getElementById('productBPriceReview'),
                    durability: document.getElementById('productBDurabilityReview'),
                    features: document.getElementById('productBFeaturesReview'),
                    usability: document.getElementById('productBUsabilityReview'),
                    service: document.getElementById('productBServiceReview')
                }
            }
        };
        
        // Radar chart
        let radarChart = null;
        
        // Initialize slider values
        function initializeSliders() {
            sliders.forEach(slider => {
                slider.value.textContent = slider.element.value + '%';
                slider.weight.textContent = slider.element.value;
                
                slider.element.addEventListener('input', () => {
                    updateSliders();
                });
            });
            
            updateSliders();
        }
        
        // Update slider values and ensure they sum to 100
        function updateSliders() {
            const total = sliders.reduce((sum, slider) => sum + parseInt(slider.element.value), 0);
            
            if (total !== 100) {
                // Adjust the first slider to make the total 100
                const difference = 100 - total;
                const firstSliderValue = parseInt(sliders[0].element.value) + difference;
                sliders[0].element.value = firstSliderValue;
                sliders[0].value.textContent = firstSliderValue + '%';
                sliders[0].weight.textContent = firstSliderValue;
            }
            
            // Update all value displays
            sliders.forEach(slider => {
                slider.value.textContent = slider.element.value + '%';
                slider.weight.textContent = slider.element.value;
            });
            
            totalPriority.textContent = sliders.reduce((sum, slider) => sum + parseInt(slider.element.value), 0);
        }
        
        // Compare products
        function compareProducts() {
            const productAId = document.getElementById('productA').value;
            const productBId = document.getElementById('productB').value;
            
            if (productAId === productBId) {
                alert("Please select two different products to compare.");
                return;
            }
            
            const productA = products[productAId];
            const productB = products[productBId];
            
            // Update product names
            productElements.productA.name.forEach(el => el.textContent = productA.name);
            productElements.productB.name.forEach(el => el.textContent = productB.name);
            
            // Update scores
            updateProductScores('productA', productA);
            updateProductScores('productB', productB);
            
            // Calculate weighted scores
            const weights = {
                price: parseInt(sliders[0].element.value) / 100,
                durability: parseInt(sliders[1].element.value) / 100,
                features: parseInt(sliders[2].element.value) / 100,
                usability: parseInt(sliders[3].element.value) / 100,
                service: parseInt(sliders[4].element.value) / 100
            };
            
            const overallA = calculateOverallScore(productA.scores, weights);
            const overallB = calculateOverallScore(productB.scores, weights);
            
            productElements.productA.overall.textContent = overallA.toFixed(1);
            productElements.productB.overall.textContent = overallB.toFixed(1);
            
            // Update recommendation
            updateRecommendation(productA.name, productB.name, overallA, overallB);
            
            // Update radar chart
            updateRadarChart(productA, productB);
            
            // Show results
            emptyState.classList.add('hidden');
            resultsSection.classList.remove('hidden');
        }
        
        // Update individual product scores
        function updateProductScores(productKey, productData) {
            const elements = productElements[productKey];
            
            elements.price.textContent = productData.scores.price;
            elements.durability.textContent = productData.scores.durability;
            elements.features.textContent = productData.scores.features;
            elements.usability.textContent = productData.scores.usability;
            elements.service.textContent = productData.scores.service;
            
            // Update review snippets
            elements.reviews.price.textContent = `"${productData.reviews.price}"`;
            elements.reviews.durability.textContent = `"${productData.reviews.durability}"`;
            elements.reviews.features.textContent = `"${productData.reviews.features}"`;
            elements.reviews.usability.textContent = `"${productData.reviews.usability}"`;
            elements.reviews.service.textContent = `"${productData.reviews.service}"`;
        }
        
        // Calculate overall score
        function calculateOverallScore(scores, weights) {
            return (
                scores.price * weights.price +
                scores.durability * weights.durability +
                scores.features * weights.features +
                scores.usability * weights.usability +
                scores.service * weights.service
            );
        }
        
        // Update recommendation
        function updateRecommendation(nameA, nameB, scoreA, scoreB) {
            if (scoreA > scoreB) {
                recommendationTitle.textContent = `We recommend ${nameA}`;
                recommendationText.textContent = `Based on your priorities, ${nameA} scored higher (${scoreA.toFixed(1)} vs ${scoreB.toFixed(1)}) with better performance in key categories.`;
                recommendationBanner.className = "mb-8 p-4 rounded-md bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200";
            } else if (scoreB > scoreA) {
                recommendationTitle.textContent = `We recommend ${nameB}`;
                recommendationText.textContent = `Based on your priorities, ${nameB} scored higher (${scoreB.toFixed(1)} vs ${scoreA.toFixed(1)}) with better performance in key categories.`;
                recommendationBanner.className = "mb-8 p-4 rounded-md bg-gradient-to-r from-green-50 to-teal-50 border border-green-200";
            } else {
                recommendationTitle.textContent = "Both products are equally good";
                recommendationText.textContent = `Both ${nameA} and ${nameB} scored ${scoreA.toFixed(1)} based on your priorities. Consider other factors like brand preference or design.`;
                recommendationBanner.className = "mb-8 p-4 rounded-md bg-gradient-to-r from-purple-50 to-pink-50 border border-purple-200";
            }
        }
        
        // Update radar chart
        function updateRadarChart(productA, productB) {
            const ctx = document.getElementById('radarChart').getContext('2d');
            
            const data = {
                labels: ['Price', 'Durability', 'Features', 'Usability', 'Customer Service'],
                datasets: [
                    {
                        label: productA.name,
                        data: [
                            productA.scores.price,
                            productA.scores.durability,
                            productA.scores.features,
                            productA.scores.usability,
                            productA.scores.service
                        ],
                        backgroundColor: 'rgba(59, 130, 246, 0.2)',
                        borderColor: 'rgba(59, 130, 246, 1)',
                        borderWidth: 2,
                        pointBackgroundColor: 'rgba(59, 130, 246, 1)'
                    },
                    {
                        label: productB.name,
                        data: [
                            productB.scores.price,
                            productB.scores.durability,
                            productB.scores.features,
                            productB.scores.usability,
                            productB.scores.service
                        ],
                        backgroundColor: 'rgba(16, 185, 129, 0.2)',
                        borderColor: 'rgba(16, 185, 129, 1)',
                        borderWidth: 2,
                        pointBackgroundColor: 'rgba(16, 185, 129, 1)'
                    }
                ]
            };
            
            const config = {
                type: 'radar',
                data: data,
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        r: {
                            angleLines: {
                                display: true
                            },
                            suggestedMin: 0,
                            suggestedMax: 100,
                            ticks: {
                                stepSize: 20
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            position: 'top',
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return context.dataset.label + ': ' + context.raw + '/100';
                                }
                            }
                        }
                    }
                }
            };
            
            if (radarChart) {
                radarChart.destroy();
            }
            
            radarChart = new Chart(ctx, config);
        }
        
        // Event listeners
        compareBtn.addEventListener('click', compareProducts);
        
        // Initialize
        initializeSliders();
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=apamplona2011/amazoncomparisontool" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>