Spaces:
Running

File size: 30,778 Bytes
903ada2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SweetRing - Sistema de Gestão</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">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        donutPink: '#FF9BAA',
                        donutPurple: '#B399D4',
                        donutBlue: '#89CFF0',
                        donutGreen: '#A7E8BD',
                        donutYellow: '#FFEE93'
                    }
                }
            }
        }
    </script>
    <style>
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
            animation: fadeIn 0.5s;
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
        .donut-chart {
            position: relative;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: conic-gradient(
                #FF9BAA 0% 25%,
                #B399D4 25% 50%,
                #89CFF0 50% 75%,
                #A7E8BD 75% 100%
            );
        }
        .chart-center {
            position: absolute;
            width: 70%;
            height: 70%;
            background: white;
            border-radius: 50%;
            top: 15%;
            left: 15%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: #7E6B8F;
        }
    </style>
</head>
<body class="bg-gray-100 font-sans">
    <div class="container mx-auto px-4 py-8 max-w-6xl">
        <!-- Header -->
        <header class="bg-white rounded-xl shadow-md p-6 mb-8 flex flex-col md:flex-row items-center justify-between">
            <div class="flex items-center mb-4 md:mb-0">
                <div class="w-16 h-16 rounded-full bg-gradient-to-r from-donutPink to-donutPurple flex items-center justify-center text-white text-2xl mr-4 overflow-hidden">
                    <img src="https://images.unsplash.com/photo-1551024506-0ecc3ec5ee1f?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=200&q=80" alt="Donut" class="w-full h-full object-cover">
                </div>
                <div>
                    <h1 class="text-3xl font-bold text-gray-800">Donu</h1>
                    <p class="text-donutPurple">Controle de qualidade</p>
                </div>
            </div>
            <div class="flex items-center space-x-4">
                <div class="bg-donutYellow rounded-full p-3 text-center">
                    <p class="text-sm font-semibold">Pontos Hoje</p>
                    <p class="text-2xl font-bold" id="todayPoints">0</p>
                </div>
                <div class="bg-donutGreen rounded-full p-3 text-center">
                    <p class="text-sm font-semibold">Pontos Mês</p>
                    <p class="text-2xl font-bold" id="monthPoints">0</p>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <!-- Tabs -->
            <div class="flex border-b border-gray-200">
                <button class="tab-btn py-4 px-6 font-medium text-gray-500 hover:text-donutPurple hover:bg-gray-50 active" data-tab="sales">
                    <i class="fas fa-chart-line mr-2"></i>Vendas
                </button>
                <button class="tab-btn py-4 px-6 font-medium text-gray-500 hover:text-donutPurple hover:bg-gray-50" data-tab="ingredients">
                    <i class="fas fa-utensils mr-2"></i>Insumos
                </button>
                <button class="tab-btn py-4 px-6 font-medium text-gray-500 hover:text-donutPurple hover:bg-gray-50" data-tab="reports">
                    <i class="fas fa-file-alt mr-2"></i>Relatórios
                </button>
            </div>

            <!-- Tab Contents -->
            <div class="p-6">
                <!-- Sales Tab -->
                <div id="sales" class="tab-content active">
                    <div class="flex flex-col md:flex-row justify-between mb-6">
                        <h2 class="text-2xl font-bold text-gray-800 mb-4 md:mb-0">Controle de Vendas</h2>
                        <div class="flex space-x-2">
                            <select id="salesPeriod" class="border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-donutPurple">
                                <option value="daily">Diário</option>
                                <option value="weekly">Semanal</option>
                                <option value="monthly">Mensal</option>
                            </select>
                            <button id="addSaleBtn" class="bg-donutPurple text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                                <i class="fas fa-plus mr-2"></i>Nova Venda
                            </button>
                        </div>
                    </div>

                    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
                        <div class="bg-donutPink bg-opacity-10 p-6 rounded-xl">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Total Vendido</h3>
                            <p class="text-3xl font-bold text-donutPink">R$ <span id="totalSales">0,00</span></p>
                            <p class="text-sm text-gray-500 mt-1"><span id="salesCount">0</span> vendas realizadas</p>
                        </div>
                        <div class="bg-donutBlue bg-opacity-10 p-6 rounded-xl">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Meta do Dia</h3>
                            <p class="text-3xl font-bold text-donutBlue">R$ <span id="dailyGoal">1.500,00</span></p>
                            <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                                <div class="bg-donutBlue h-2.5 rounded-full" style="width: 45%"></div>
                            </div>
                            <p class="text-sm text-gray-500 mt-1">45% alcançado</p>
                        </div>
                        <div class="bg-donutGreen bg-opacity-10 p-6 rounded-xl flex flex-col items-center justify-center">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Distribuição</h3>
                            <div class="donut-chart">
                                <div class="chart-center">
                                    <span>100%</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="overflow-x-auto">
                        <table class="min-w-full bg-white rounded-lg overflow-hidden">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Data/Hora</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Produto</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Quantidade</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Valor</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Pontos</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ações</th>
                                </tr>
                            </thead>
                            <tbody id="salesTableBody" class="divide-y divide-gray-200">
                                <!-- Sales data will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                </div>

                <!-- Ingredients Tab -->
                <div id="ingredients" class="tab-content">
                    <div class="flex flex-col md:flex-row justify-between mb-6">
                        <h2 class="text-2xl font-bold text-gray-800 mb-4 md:mb-0">Controle de Insumos</h2>
                        <div class="flex space-x-2">
                            <button id="addIngredientBtn" class="bg-donutPurple text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                                <i class="fas fa-plus mr-2"></i>Adicionar Insumo
                            </button>
                        </div>
                    </div>

                    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
                        <div class="bg-donutYellow bg-opacity-10 p-6 rounded-xl">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Gasto Semanal</h3>
                            <p class="text-3xl font-bold text-donutYellow">R$ <span id="weeklySpending">0,00</span></p>
                            <p class="text-sm text-gray-500 mt-1"><span id="ingredientsCount">0</span> insumos registrados</p>
                        </div>
                        <div class="bg-donutBlue bg-opacity-10 p-6 rounded-xl">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Orçamento</h3>
                            <p class="text-3xl font-bold text-donutBlue">R$ <span id="ingredientBudget">2.000,00</span></p>
                            <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                                <div class="bg-donutBlue h-2.5 rounded-full" style="width: 15%"></div>
                            </div>
                            <p class="text-sm text-gray-500 mt-1">15% utilizado</p>
                        </div>
                        <div class="bg-donutPink bg-opacity-10 p-6 rounded-xl">
                            <h3 class="text-lg font-semibold text-gray-700 mb-2">Estoque Crítico</h3>
                            <p class="text-3xl font-bold text-donutPink"><span id="criticalItems">3</span></p>
                            <p class="text-sm text-gray-500 mt-1">itens com baixo estoque</p>
                        </div>
                    </div>

                    <div class="overflow-x-auto">
                        <table class="min-w-full bg-white rounded-lg overflow-hidden">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Insumo</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Quantidade</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Unidade</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Custo Unitário</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fornecedor</th>
                                    <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ações</th>
                                </tr>
                            </thead>
                            <tbody id="ingredientsTableBody" class="divide-y divide-gray-200">
                                <!-- Ingredients data will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                </div>

                <!-- Reports Tab -->
                <div id="reports" class="tab-content">
                    <h2 class="text-2xl font-bold text-gray-800 mb-6">Relatórios</h2>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-8">
                        <div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
                            <h3 class="text-lg font-semibold text-gray-700 mb-4">Relatório de Vendas</h3>
                            <div class="space-y-4">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">Período</label>
                                    <select class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple">
                                        <option>Últimos 7 dias</option>
                                        <option>Últimos 30 dias</option>
                                        <option>Este mês</option>
                                        <option>Mês passado</option>
                                        <option>Personalizado</option>
                                    </select>
                                </div>
                                <button class="w-full bg-donutPurple text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                                    <i class="fas fa-file-pdf mr-2"></i>Gerar Relatório
                                </button>
                            </div>
                        </div>
                        
                        <div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
                            <h3 class="text-lg font-semibold text-gray-700 mb-4">Relatório de Insumos</h3>
                            <div class="space-y-4">
                                <div>
                                    <label class="block text-sm font-medium text-gray-700 mb-1">Semana</label>
                                    <select class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple">
                                        <option>Esta semana</option>
                                        <option>Semana passada</option>
                                        <option>Últimas 4 semanas</option>
                                        <option>Personalizado</option>
                                    </select>
                                </div>
                                <button class="w-full bg-donutPink text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                                    <i class="fas fa-file-excel mr-2"></i>Gerar Relatório
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white border border-gray-200 rounded-xl p-6 shadow-sm">
                        <h3 class="text-lg font-semibold text-gray-700 mb-4">Análise de Desempenho</h3>
                        <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="text-sm font-medium text-gray-500 mb-2">Vendas Mensais</h4>
                                <p class="text-2xl font-bold text-donutPurple">R$ 42.560,00</p>
                                <p class="text-sm text-green-500"><i class="fas fa-arrow-up mr-1"></i>12% vs mês anterior</p>
                            </div>
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="text-sm font-medium text-gray-500 mb-2">Custo Insumos</h4>
                                <p class="text-2xl font-bold text-donutPink">R$ 8.240,00</p>
                                <p class="text-sm text-red-500"><i class="fas fa-arrow-up mr-1"></i>5% vs mês anterior</p>
                            </div>
                            <div class="border border-gray-200 rounded-lg p-4">
                                <h4 class="text-sm font-medium text-gray-500 mb-2">Lucro Líquido</h4>
                                <p class="text-2xl font-bold text-donutGreen">R$ 34.320,00</p>
                                <p class="text-sm text-green-500"><i class="fas fa-arrow-up mr-1"></i>15% vs mês anterior</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modals -->
    <!-- Add Sale Modal -->
    <div id="addSaleModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-xl p-6 w-full max-w-md">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold text-gray-800">Registrar Nova Venda</h3>
                <button id="closeSaleModal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <form id="saleForm" class="space-y-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Produto</label>
                    <select class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                        <option value="">Selecione um produto</option>
                        <option>Donut Tradicional</option>
                        <option>Donut Recheado</option>
                        <option>Donut Gourmet</option>
                        <option>Donut Especial</option>
                        <option>Combo Familiar</option>
                        <option>Bebidas</option>
                    </select>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Quantidade</label>
                    <input type="number" min="1" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Valor Unitário</label>
                    <input type="number" step="0.01" min="0" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Método de Pagamento</label>
                    <select class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                        <option value="">Selecione</option>
                        <option>Dinheiro</option>
                        <option>Cartão de Débito</option>
                        <option>Cartão de Crédito</option>
                        <option>PIX</option>
                    </select>
                </div>
                <div class="pt-2">
                    <button type="submit" class="w-full bg-donutPurple text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                        Registrar Venda
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Add Ingredient Modal -->
    <div id="addIngredientModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-xl p-6 w-full max-w-md">
            <div class="flex justify-between items-center mb-4">
                <h3 class="text-xl font-bold text-gray-800">Adicionar Insumo</h3>
                <button id="closeIngredientModal" class="text-gray-500 hover:text-gray-700">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <form id="ingredientForm" class="space-y-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Nome do Insumo</label>
                    <input type="text" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Quantidade</label>
                        <input type="number" min="0" step="0.01" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Unidade</label>
                        <select class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                            <option value="">Selecione</option>
                            <option>kg</option>
                            <option>g</option>
                            <option>L</option>
                            <option>ml</option>
                            <option>un</option>
                            <option>cx</option>
                        </select>
                    </div>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Custo Unitário</label>
                    <input type="number" step="0.01" min="0" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Fornecedor</label>
                    <input type="text" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Data da Compra</label>
                    <input type="date" class="border rounded-lg px-4 py-2 w-full focus:outline-none focus:ring-2 focus:ring-donutPurple" required>
                </div>
                <div class="pt-2">
                    <button type="submit" class="w-full bg-donutPurple text-white px-4 py-2 rounded-lg hover:bg-opacity-90 transition">
                        Adicionar Insumo
                    </button>
                </div>
            </form>
        </div>
    </div>

    <script>
        // Tab functionality
        document.addEventListener('DOMContentLoaded', function() {
            const tabButtons = document.querySelectorAll('.tab-btn');
            const tabContents = document.querySelectorAll('.tab-content');
            
            tabButtons.forEach(button => {
                button.addEventListener('click', () => {
                    const tabId = button.getAttribute('data-tab');
                    
                    // Remove active class from all buttons and contents
                    tabButtons.forEach(btn => btn.classList.remove('active'));
                    tabContents.forEach(content => content.classList.remove('active'));
                    
                    // Add active class to clicked button and corresponding content
                    button.classList.add('active');
                    document.getElementById(tabId).classList.add('active');
                });
            });
            
            // Modal functionality
            const addSaleBtn = document.getElementById('addSaleBtn');
            const addSaleModal = document.getElementById('addSaleModal');
            const closeSaleModal = document.getElementById('closeSaleModal');
            
            const addIngredientBtn = document.getElementById('addIngredientBtn');
            const addIngredientModal = document.getElementById('addIngredientModal');
            const closeIngredientModal = document.getElementById('closeIngredientModal');
            
            addSaleBtn.addEventListener('click', () => {
                addSaleModal.classList.remove('hidden');
            });
            
            closeSaleModal.addEventListener('click', () => {
                addSaleModal.classList.add('hidden');
            });
            
            addIngredientBtn.addEventListener('click', () => {
                addIngredientModal.classList.remove('hidden');
            });
            
            closeIngredientModal.addEventListener('click', () => {
                addIngredientModal.classList.add('hidden');
            });
            
            // Close modals when clicking outside
            window.addEventListener('click', (e) => {
                if (e.target === addSaleModal) {
                    addSaleModal.classList.add('hidden');
                }
                if (e.target === addIngredientModal) {
                    addIngredientModal.classList.add('hidden');
                }
            });
            
            // Empty data arrays to start fresh
            const salesData = [];
            const ingredientsData = [];
            
            // Populate sales table
            const salesTableBody = document.getElementById('salesTableBody');
            let totalSales = 0;
            let totalPoints = 0;
            
            salesData.forEach(sale => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${sale.date}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${sale.product}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${sale.quantity}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">R$ ${sale.value.toFixed(2)}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${sale.points}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                        <button class="text-donutPurple hover:text-donutPink mr-2">
                            <i class="fas fa-edit"></i>
                        </button>
                        <button class="text-red-500 hover:text-red-700">
                            <i class="fas fa-trash"></i>
                        </button>
                    </td>
                `;
                salesTableBody.appendChild(row);
                
                totalSales += sale.value;
                totalPoints += sale.points;
            });
            
            document.getElementById('totalSales').textContent = '0,00';
            document.getElementById('salesCount').textContent = '0';
            document.getElementById('todayPoints').textContent = '0';
            document.getElementById('monthPoints').textContent = '0';
            
            // Populate ingredients table
            const ingredientsTableBody = document.getElementById('ingredientsTableBody');
            let weeklySpending = 0;
            
            ingredientsData.forEach(ingredient => {
                const totalCost = ingredient.quantity * ingredient.unitCost;
                weeklySpending += totalCost;
                
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${ingredient.name}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 ${ingredient.quantity < 10 ? 'text-red-500 font-bold' : ''}">${ingredient.quantity}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${ingredient.unit}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">R$ ${ingredient.unitCost.toFixed(2)}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">R$ ${totalCost.toFixed(2)}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${ingredient.supplier}</td>
                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                        <button class="text-donutPurple hover:text-donutPink mr-2">
                            <i class="fas fa-edit"></i>
                        </button>
                        <button class="text-red-500 hover:text-red-700">
                            <i class="fas fa-trash"></i>
                        </button>
                    </td>
                `;
                ingredientsTableBody.appendChild(row);
            });
            
            document.getElementById('weeklySpending').textContent = '0,00';
            document.getElementById('ingredientsCount').textContent = '0';
            document.getElementById('criticalItems').textContent = '0';
            
            // Form submissions
            document.getElementById('saleForm').addEventListener('submit', function(e) {
                e.preventDefault();
                alert('Venda registrada com sucesso!');
                this.reset();
                addSaleModal.classList.add('hidden');
            });
            
            document.getElementById('ingredientForm').addEventListener('submit', function(e) {
                e.preventDefault();
                alert('Insumo adicionado com sucesso!');
                this.reset();
                addIngredientModal.classList.add('hidden');
            });
        });
    </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=brunosda/teste" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>