File size: 30,503 Bytes
cc2bcdb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Citrus Classification System</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
        }
        .citrus-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .citrus-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .grade-A {
            border-left: 5px solid #10B981;
        }
        .grade-B {
            border-left: 5px solid #F59E0B;
        }
        .grade-C {
            border-left: 5px solid #EF4444;
        }
        .slider-thumb::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            cursor: pointer;
        }
        #sizeSlider::-webkit-slider-thumb {
            background: #3B82F6;
        }
        #colorSlider::-webkit-slider-thumb {
            background: #F59E0B;
        }
        #smoothnessSlider::-webkit-slider-thumb {
            background: #10B981;
        }
        #photoPreview {
            max-height: 300px;
            object-fit: contain;
        }
        .dropzone {
            border: 2px dashed #cbd5e0;
            transition: all 0.3s;
        }
        .dropzone.active {
            border-color: #3b82f6;
            background-color: #ebf4ff;
        }
        .analysis-progress {
            height: 6px;
            background-color: #e5e7eb;
        }
        .analysis-progress-bar {
            height: 100%;
            background-color: #3b82f6;
            transition: width 0.3s ease;
        }
    </style>
</head>
<body class="gradient-bg min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="text-center mb-12">
            <h1 class="text-4xl font-bold text-gray-800 mb-2">
                <i class="fas fa-lemon text-yellow-400 mr-2"></i>
                Citrus Classification System
            </h1>
            <p class="text-lg text-gray-600 max-w-2xl mx-auto">
                Analyze citrus fruits through manual input or photo analysis for quality grading
            </p>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Input Panel -->
            <div class="bg-white rounded-xl shadow-lg p-6 lg:col-span-1">
                <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                    <i class="fas fa-sliders-h text-blue-500 mr-2"></i>
                    Classification Parameters
                </h2>
                
                <!-- Tab Navigation -->
                <div class="flex border-b mb-6">
                    <button id="manualTab" class="flex-1 py-2 px-4 font-medium text-blue-600 border-b-2 border-blue-500">
                        <i class="fas fa-keyboard mr-2"></i>Manual Input
                    </button>
                    <button id="photoTab" class="flex-1 py-2 px-4 font-medium text-gray-500">
                        <i class="fas fa-camera mr-2"></i>Photo Analysis
                    </button>
                </div>
                
                <!-- Manual Input Section -->
                <div id="manualInputSection">
                    <!-- Size Input -->
                    <div class="mb-6">
                        <label for="sizeSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
                            <i class="fas fa-ruler-vertical text-blue-400 mr-2"></i>
                            Size (Diameter in cm)
                        </label>
                        <input type="range" id="sizeSlider" min="5" max="10" step="0.1" value="7.5" 
                               class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>5 cm</span>
                            <span id="sizeValue">7.5 cm</span>
                            <span>10 cm</span>
                        </div>
                    </div>
                    
                    <!-- Color Input -->
                    <div class="mb-6">
                        <label for="colorSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
                            <i class="fas fa-palette text-yellow-400 mr-2"></i>
                            Color (Green to Orange)
                        </label>
                        <input type="range" id="colorSlider" min="0" max="100" value="50" 
                               class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>Green</span>
                            <span id="colorValue">50%</span>
                            <span>Orange</span>
                        </div>
                    </div>
                    
                    <!-- Smoothness Input -->
                    <div class="mb-8">
                        <label for="smoothnessSlider" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
                            <i class="fas fa-hand-paper text-green-400 mr-2"></i>
                            Skin Smoothness
                        </label>
                        <input type="range" id="smoothnessSlider" min="0" max="100" value="50" 
                               class="w-full h-2 bg-gray-200 rounded-lg slider-thumb">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>Rough</span>
                            <span id="smoothnessValue">50%</span>
                            <span>Smooth</span>
                        </div>
                    </div>
                </div>
                
                <!-- Photo Analysis Section -->
                <div id="photoAnalysisSection" class="hidden">
                    <div class="mb-4">
                        <div id="dropzone" class="dropzone rounded-lg p-6 text-center cursor-pointer">
                            <div class="flex flex-col items-center justify-center py-8">
                                <i class="fas fa-cloud-upload-alt text-3xl text-gray-400 mb-2"></i>
                                <p class="text-sm text-gray-600 mb-1">Drag & drop citrus photo here</p>
                                <p class="text-xs text-gray-500">or click to browse files</p>
                            </div>
                            <input type="file" id="photoInput" accept="image/*" class="hidden">
                        </div>
                    </div>
                    
                    <div id="photoPreviewContainer" class="hidden mb-4">
                        <div class="relative">
                            <img id="photoPreview" src="#" alt="Preview" class="w-full rounded-lg">
                            <button id="removePhotoBtn" class="absolute top-2 right-2 bg-white rounded-full p-2 shadow-md hover:bg-gray-100">
                                <i class="fas fa-times text-gray-600"></i>
                            </button>
                        </div>
                    </div>
                    
                    <div id="analysisProgress" class="hidden">
                        <div class="flex justify-between text-sm text-gray-600 mb-1">
                            <span>Analyzing image...</span>
                            <span id="progressPercent">0%</span>
                        </div>
                        <div class="analysis-progress rounded-full overflow-hidden">
                            <div id="progressBar" class="analysis-progress-bar" style="width: 0%"></div>
                        </div>
                    </div>
                    
                    <div id="analysisResults" class="hidden">
                        <div class="bg-gray-50 rounded-lg p-4 mb-4">
                            <h4 class="font-medium text-gray-700 mb-2">Photo Analysis Results</h4>
                            <div class="grid grid-cols-3 gap-2 text-sm">
                                <div>
                                    <p class="text-gray-500">Size</p>
                                    <p id="photoSize" class="font-medium">-</p>
                                </div>
                                <div>
                                    <p class="text-gray-500">Color</p>
                                    <p id="photoColor" class="font-medium">-</p>
                                </div>
                                <div>
                                    <p class="text-gray-500">Smoothness</p>
                                    <p id="photoSmoothness" class="font-medium">-</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Classify Button -->
                <button id="classifyBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white font-medium py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center">
                    <i class="fas fa-cogs mr-2"></i>
                    Classify Citrus
                </button>
            </div>
            
            <!-- Results Panel -->
            <div class="bg-white rounded-xl shadow-lg p-6 lg:col-span-2">
                <h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
                    <i class="fas fa-chart-bar text-purple-500 mr-2"></i>
                    Classification Results
                </h2>
                
                <!-- Grade Standards -->
                <div class="mb-8">
                    <h3 class="text-lg font-medium text-gray-700 mb-3">Grading Standards</h3>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="bg-gray-50 p-4 rounded-lg grade-A">
                            <h4 class="font-semibold text-green-600 flex items-center">
                                <i class="fas fa-star mr-2"></i> Grade A (Premium)
                            </h4>
                            <ul class="text-sm text-gray-600 mt-2 space-y-1">
                                <li><i class="fas fa-check-circle text-green-400 mr-1"></i> Size: 8-10 cm</li>
                                <li><i class="fas fa-check-circle text-green-400 mr-1"></i> Color: 70-100% orange</li>
                                <li><i class="fas fa-check-circle text-green-400 mr-1"></i> Smoothness: 80-100%</li>
                            </ul>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg grade-B">
                            <h4 class="font-semibold text-yellow-600 flex items-center">
                                <i class="fas fa-star-half-alt mr-2"></i> Grade B (Standard)
                            </h4>
                            <ul class="text-sm text-gray-600 mt-2 space-y-1">
                                <li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Size: 6-8 cm</li>
                                <li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Color: 30-70% orange</li>
                                <li><i class="fas fa-check-circle text-yellow-400 mr-1"></i> Smoothness: 50-80%</li>
                            </ul>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg grade-C">
                            <h4 class="font-semibold text-red-600 flex items-center">
                                <i class="far fa-star mr-2"></i> Grade C (Utility)
                            </h4>
                            <ul class="text-sm text-gray-600 mt-2 space-y-1">
                                <li><i class="fas fa-check-circle text-red-400 mr-1"></i> Size: 5-6 cm</li>
                                <li><i class="fas fa-check-circle text-red-400 mr-1"></i> Color: 0-30% orange</li>
                                <li><i class="fas fa-check-circle text-red-400 mr-1"></i> Smoothness: 0-50%</li>
                            </ul>
                        </div>
                    </div>
                </div>
                
                <!-- Results Display -->
                <div id="resultsContainer" class="hidden">
                    <h3 class="text-lg font-medium text-gray-700 mb-3">Current Classification</h3>
                    <div class="bg-gray-50 rounded-lg p-6">
                        <div class="flex flex-col md:flex-row items-center justify-between">
                            <div class="flex items-center mb-4 md:mb-0">
                                <div id="citrusVisual" class="w-20 h-20 rounded-full bg-orange-300 border-4 border-orange-200 mr-4"></div>
                                <div>
                                    <h4 id="gradeTitle" class="text-xl font-semibold"></h4>
                                    <p id="gradeDescription" class="text-sm text-gray-600"></p>
                                </div>
                            </div>
                            <div id="gradeBadge" class="px-4 py-2 rounded-full text-white font-medium text-lg"></div>
                        </div>
                        
                        <div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">
                            <div class="bg-white p-3 rounded-lg shadow-sm">
                                <p class="text-xs text-gray-500">Size</p>
                                <p id="resultSize" class="font-medium"></p>
                                <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                                    <div id="sizeBar" class="h-2 rounded-full bg-blue-500"></div>
                                </div>
                            </div>
                            <div class="bg-white p-3 rounded-lg shadow-sm">
                                <p class="text-xs text-gray-500">Color</p>
                                <p id="resultColor" class="font-medium"></p>
                                <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                                    <div id="colorBar" class="h-2 rounded-full bg-yellow-500"></div>
                                </div>
                            </div>
                            <div class="bg-white p-3 rounded-lg shadow-sm">
                                <p class="text-xs text-gray-500">Smoothness</p>
                                <p id="resultSmoothness" class="font-medium"></p>
                                <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                                    <div id="smoothnessBar" class="h-2 rounded-full bg-green-500"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- MATLAB-style Visualization -->
                <div id="matlabViz" class="mt-8 hidden">
                    <h3 class="text-lg font-medium text-gray-700 mb-3">Classification Visualization</h3>
                    <div class="bg-gray-800 rounded-lg p-4">
                        <div class="flex items-center text-green-400 font-mono text-sm mb-2">
                            <span class="mr-2">>></span>
                            <span>Citrus Classification Algorithm Output:</span>
                        </div>
                        <div id="matlabOutput" class="bg-black text-green-400 p-3 rounded font-mono text-sm overflow-x-auto"></div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- Footer -->
        <footer class="mt-12 text-center text-gray-500 text-sm">
            <p>© 2023 Citrus Classification System | Designed with MATLAB-inspired interface</p>
        </footer>
    </div>

    <script>
        // Update slider values in real-time
        document.getElementById('sizeSlider').addEventListener('input', function() {
            document.getElementById('sizeValue').textContent = this.value + ' cm';
        });
        
        document.getElementById('colorSlider').addEventListener('input', function() {
            document.getElementById('colorValue').textContent = this.value + '%';
        });
        
        document.getElementById('smoothnessSlider').addEventListener('input', function() {
            document.getElementById('smoothnessValue').textContent = this.value + '%';
        });
        
        // Tab switching
        document.getElementById('manualTab').addEventListener('click', function() {
            document.getElementById('manualInputSection').classList.remove('hidden');
            document.getElementById('photoAnalysisSection').classList.add('hidden');
            this.classList.add('text-blue-600', 'border-blue-500');
            this.classList.remove('text-gray-500');
            document.getElementById('photoTab').classList.add('text-gray-500');
            document.getElementById('photoTab').classList.remove('text-blue-600', 'border-blue-500');
        });
        
        document.getElementById('photoTab').addEventListener('click', function() {
            document.getElementById('manualInputSection').classList.add('hidden');
            document.getElementById('photoAnalysisSection').classList.remove('hidden');
            this.classList.add('text-blue-600', 'border-blue-500');
            this.classList.remove('text-gray-500');
            document.getElementById('manualTab').classList.add('text-gray-500');
            document.getElementById('manualTab').classList.remove('text-blue-600', 'border-blue-500');
        });
        
        // Photo upload functionality
        const dropzone = document.getElementById('dropzone');
        const photoInput = document.getElementById('photoInput');
        const photoPreview = document.getElementById('photoPreview');
        const photoPreviewContainer = document.getElementById('photoPreviewContainer');
        const removePhotoBtn = document.getElementById('removePhotoBtn');
        const analysisProgress = document.getElementById('analysisProgress');
        const analysisResults = document.getElementById('analysisResults');
        
        // Handle drag and drop events
        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropzone.addEventListener(eventName, preventDefaults, false);
        });
        
        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }
        
        ['dragenter', 'dragover'].forEach(eventName => {
            dropzone.addEventListener(eventName, highlight, false);
        });
        
        ['dragleave', 'drop'].forEach(eventName => {
            dropzone.addEventListener(eventName, unhighlight, false);
        });
        
        function highlight() {
            dropzone.classList.add('active');
        }
        
        function unhighlight() {
            dropzone.classList.remove('active');
        }
        
        // Handle dropped files
        dropzone.addEventListener('drop', handleDrop, false);
        
        function handleDrop(e) {
            const dt = e.dataTransfer;
            const files = dt.files;
            handleFiles(files);
        }
        
        // Handle clicked files
        photoInput.addEventListener('change', function() {
            handleFiles(this.files);
        });
        
        dropzone.addEventListener('click', function() {
            photoInput.click();
        });
        
        // Remove photo
        removePhotoBtn.addEventListener('click', function(e) {
            e.stopPropagation();
            photoPreview.src = '#';
            photoPreviewContainer.classList.add('hidden');
            analysisProgress.classList.add('hidden');
            analysisResults.classList.add('hidden');
        });
        
        function handleFiles(files) {
            if (files.length > 0) {
                const file = files[0];
                if (file.type.match('image.*')) {
                    const reader = new FileReader();
                    
                    reader.onload = function(e) {
                        photoPreview.src = e.target.result;
                        photoPreviewContainer.classList.remove('hidden');
                        analyzeImage(file);
                    }
                    
                    reader.readAsDataURL(file);
                }
            }
        }
        
        // Simulate image analysis
        function analyzeImage(file) {
            analysisProgress.classList.remove('hidden');
            analysisResults.classList.add('hidden');
            
            let progress = 0;
            const progressInterval = setInterval(() => {
                progress += Math.random() * 10;
                if (progress > 100) progress = 100;
                
                document.getElementById('progressBar').style.width = `${progress}%`;
                document.getElementById('progressPercent').textContent = `${Math.floor(progress)}%`;
                
                if (progress === 100) {
                    clearInterval(progressInterval);
                    setTimeout(() => {
                        // Simulate analysis results
                        const simulatedSize = (5 + Math.random() * 5).toFixed(1);
                        const simulatedColor = Math.floor(Math.random() * 100);
                        const simulatedSmoothness = Math.floor(Math.random() * 100);
                        
                        document.getElementById('photoSize').textContent = `${simulatedSize} cm`;
                        document.getElementById('photoColor').textContent = `${simulatedColor}% orange`;
                        document.getElementById('photoSmoothness').textContent = `${simulatedSmoothness}% smooth`;
                        
                        // Update sliders with analyzed values
                        document.getElementById('sizeSlider').value = simulatedSize;
                        document.getElementById('colorSlider').value = simulatedColor;
                        document.getElementById('smoothnessSlider').value = simulatedSmoothness;
                        
                        document.getElementById('sizeValue').textContent = `${simulatedSize} cm`;
                        document.getElementById('colorValue').textContent = `${simulatedColor}%`;
                        document.getElementById('smoothnessValue').textContent = `${simulatedSmoothness}%`;
                        
                        analysisProgress.classList.add('hidden');
                        analysisResults.classList.remove('hidden');
                    }, 500);
                }
            }, 100);
        }
        
        // Classification function
        document.getElementById('classifyBtn').addEventListener('click', function() {
            // Get input values
            const size = parseFloat(document.getElementById('sizeSlider').value);
            const color = parseInt(document.getElementById('colorSlider').value);
            const smoothness = parseInt(document.getElementById('smoothnessSlider').value);
            
            // Determine grade
            let grade, title, description, badgeClass;
            
            if ((size >= 8 && size <= 10) && (color >= 70 && color <= 100) && (smoothness >= 80 && smoothness <= 100)) {
                grade = 'A';
                title = 'Premium Quality Citrus';
                description = 'Excellent size, color, and texture. Ideal for fresh consumption.';
                badgeClass = 'bg-green-500';
            } 
            else if ((size >= 6 && size < 8) && (color >= 30 && color < 70) && (smoothness >= 50 && smoothness < 80)) {
                grade = 'B';
                title = 'Standard Quality Citrus';
                description = 'Good quality, suitable for both fresh consumption and processing.';
                badgeClass = 'bg-yellow-500';
            } 
            else if ((size >= 5 && size < 6) && (color >= 0 && color < 30) && (smoothness >= 0 && smoothness < 50)) {
                grade = 'C';
                title = 'Utility Grade Citrus';
                description = 'Best suited for processing into juices or other products.';
                badgeClass = 'bg-red-500';
            }
            else {
                grade = 'B';
                title = 'Standard Quality Citrus (Mixed Characteristics)';
                description = 'Some characteristics meet premium standards while others are utility grade.';
                badgeClass = 'bg-yellow-500';
            }
            
            // Update citrus visual
            const citrusVisual = document.getElementById('citrusVisual');
            const colorValue = color / 100;
            const orangeHue = 30 + (colorValue * 30); // Range from 30 (greenish) to 60 (orange)
            citrusVisual.style.backgroundColor = `hsl(${orangeHue}, 100%, ${70 - (smoothness/100 * 20)}%)`;
            
            // Update results
            document.getElementById('gradeTitle').textContent = title;
            document.getElementById('gradeDescription').textContent = description;
            document.getElementById('gradeBadge').textContent = `Grade ${grade}`;
            document.getElementById('gradeBadge').className = `px-4 py-2 rounded-full text-white font-medium text-lg ${badgeClass}`;
            
            // Update metric displays
            document.getElementById('resultSize').textContent = `${size.toFixed(1)} cm`;
            document.getElementById('resultColor').textContent = `${color}% orange`;
            document.getElementById('resultSmoothness').textContent = `${smoothness}% smooth`;
            
            // Update progress bars
            document.getElementById('sizeBar').style.width = `${((size - 5) / 5) * 100}%`;
            document.getElementById('colorBar').style.width = `${color}%`;
            document.getElementById('smoothnessBar').style.width = `${smoothness}%`;
            
            // Show results
            document.getElementById('resultsContainer').classList.remove('hidden');
            
            // Generate MATLAB-style output
            generateMatlabOutput(size, color, smoothness, grade);
            document.getElementById('matlabViz').classList.remove('hidden');
        });
        
        function generateMatlabOutput(size, color, smoothness, grade) {
            const output = document.getElementById('matlabOutput');
            output.innerHTML = `
                <div>>> citrus_features = [${size.toFixed(1)}, ${color}, ${smoothness}];</div>
                <div>>> grade = classifyCitrus(citrus_features);</div>
                <div class="mt-2">Processing feature vector...</div>
                <div>Size component: ${size.toFixed(1)} cm → ${getSizeCategory(size)}</div>
                <div>Color component: ${color}% orange → ${getColorCategory(color)}</div>
                <div>Smoothness component: ${smoothness}% → ${getSmoothnessCategory(smoothness)}</div>
                <div class="mt-2 font-bold">Classification result: Grade ${grade}</div>
                <div class="mt-1">Confidence: ${calculateConfidence(size, color, smoothness, grade).toFixed(1)}%</div>
            `;
        }
        
        function getSizeCategory(size) {
            if (size >= 8) return 'Premium range';
            if (size >= 6) return 'Standard range';
            return 'Utility range';
        }
        
        function getColorCategory(color) {
            if (color >= 70) return 'Premium color';
            if (color >= 30) return 'Standard color';
            return 'Utility color';
        }
        
        function getSmoothnessCategory(smoothness) {
            if (smoothness >= 80) return 'Premium texture';
            if (smoothness >= 50) return 'Standard texture';
            return 'Utility texture';
        }
        
        function calculateConfidence(size, color, smoothness, grade) {
            // Simple confidence calculation based on how close features are to grade center
            let sizeScore, colorScore, smoothnessScore;
            
            if (grade === 'A') {
                sizeScore = Math.min(100, Math.max(0, (size - 8) / 2 * 100));
                colorScore = Math.min(100, Math.max(0, (color - 70) / 30 * 100));
                smoothnessScore = Math.min(100, Math.max(0, (smoothness - 80) / 20 * 100));
            } 
            else if (grade === 'B') {
                sizeScore = 100 - Math.abs(size - 7) / 1 * 100;
                colorScore = 100 - Math.abs(color - 50) / 20 * 100;
                smoothnessScore = 100 - Math.abs(smoothness - 65) / 15 * 100;
            } 
            else {
                sizeScore = Math.min(100, Math.max(0, (6 - size) / 1 * 100));
                colorScore = Math.min(100, Math.max(0, (30 - color) / 30 * 100));
                smoothnessScore = Math.min(100, Math.max(0, (50 - smoothness) / 50 * 100));
            }
            
            return (sizeScore + colorScore + smoothnessScore) / 3;
        }
    </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=ccookie/orange" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>