File size: 40,928 Bytes
f84861c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d3e5ed
 
 
 
 
 
 
 
 
 
f84861c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d3e5ed
f84861c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d3e5ed
 
 
 
 
 
 
 
 
 
f84861c
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cotizador REDRING</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, #1e3a8a 0%, #2563eb 100%);
        }
        .service-card {
            transition: all 0.3s ease;
        }
        .service-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .result-card {
            animation: fadeIn 0.5s ease-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        input[type="range"] {
            -webkit-appearance: none;
            height: 8px;
            background: #e2e8f0;
            border-radius: 5px;
        }
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            height: 20px;
            width: 20px;
            border-radius: 50%;
            background: #2563eb;
            cursor: pointer;
            box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
        }
        .tab-content {
            display: none;
        }
        .tab-content.active {
            display: block;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="gradient-bg text-white py-8 shadow-lg">
        <div class="container mx-auto px-4">
            <div class="flex items-center justify-between">
                <div>
                    <h1 class="text-3xl md:text-4xl font-bold">Cotizador REDRING</h1>
                    <p class="mt-2 text-blue-100">Herramienta interna para cotización de servicios</p>
                </div>
                <div class="hidden md:block">
                    <i class="fas fa-calculator text-4xl opacity-70"></i>
                </div>
            </div>
        </div>
    </div>

    <div class="container mx-auto px-4 py-8">
        <!-- Service Selection Tabs -->
        <div class="bg-white rounded-lg shadow-md mb-8 overflow-hidden">
            <div class="flex border-b">
                <button class="tab-btn py-4 px-6 font-medium text-gray-700 hover:text-blue-600 focus:outline-none border-b-2 border-blue-600 text-blue-600" data-tab="maquila">
                    <i class="fas fa-users-cog mr-2"></i>Maquila de Nómina
                </button>
                <button class="tab-btn py-4 px-6 font-medium text-gray-700 hover:text-blue-600 focus:outline-none" data-tab="renta">
                    <i class="fas fa-laptop-code mr-2"></i>Renta de Software
                </button>
            </div>
            
            <!-- Maquila de Nómina Tab -->
            <div id="maquila" class="tab-content active p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Cotización de Maquila de Nómina</h2>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Input Form -->
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold text-gray-700 mb-4">Parámetros de cotización</h3>
                        
                        <div id="employeeRanges">
                            <div class="mb-6 range-group">
                                <div class="flex justify-between items-center mb-2">
                                    <label class="block text-gray-700 font-medium">Rango de empleados</label>
                                    <button type="button" class="remove-range text-red-500 hover:text-red-700 text-sm">
                                        <i class="fas fa-times mr-1"></i>Eliminar
                                    </button>
                                </div>
                                <div class="grid grid-cols-2 gap-4 mb-2">
                                    <div>
                                        <label class="block text-gray-600 text-sm mb-1">Desde</label>
                                        <input type="number" min="1" class="min-employees w-full px-3 py-2 border border-gray-300 rounded-md" value="1">
                                    </div>
                                    <div>
                                        <label class="block text-gray-600 text-sm mb-1">Hasta</label>
                                        <input type="number" min="1" class="max-employees w-full px-3 py-2 border border-gray-300 rounded-md" value="10">
                                    </div>
                                </div>
                                <div class="mb-4">
                                    <label class="block text-gray-700 font-medium mb-2">Tipo de periodo</label>
                                    <select class="period-type w-full px-4 py-2 border border-gray-300 rounded-md">
                                        <option value="mensual">Mensual</option>
                                        <option value="quincenal">Quincenal/Catorcenal</option>
                                        <option value="semanal">Semanal</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <button type="button" id="addRange" class="w-full bg-gray-200 hover:bg-gray-300 text-gray-800 py-2 px-4 rounded-md mb-6">
                            <i class="fas fa-plus mr-2"></i>Agregar otro rango
                        </button>
                        
                        <div class="mb-6">
                            <label class="block text-gray-700 font-medium mb-2">Tipo de servicio</label>
                            <div class="space-y-2">
                                <label class="flex items-center">
                                    <input type="radio" name="serviceType" value="hibrido" class="mr-2" checked>
                                    <span>Híbrido (Cliente sube incidencias en RR 2.0)</span>
                                </label>
                                <label class="flex items-center">
                                    <input type="radio" name="serviceType" value="total" class="mr-2">
                                    <span>Gestión Total</span>
                                </label>
                            </div>
                        </div>
                        
                        <div class="mb-6" id="periodTypeContainer">
                            <label class="block text-gray-700 font-medium mb-2">Tipo de periodo</label>
                            <select id="periodType" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <option value="mensual">Mensual</option>
                                <option value="quincenal">Quincenal/Catorcenal</option>
                                <option value="semanal">Semanal</option>
                            </select>
                        </div>
                        
                        <div class="mb-6 relative">
                            <label class="block text-gray-700 font-medium mb-2">
                                ¿Usa layout de RR 2.0?
                                <span class="tooltip ml-1 text-blue-500 cursor-pointer">
                                    <i class="fas fa-info-circle"></i>
                                    <span class="tooltip-text hidden absolute z-10 w-64 bg-gray-800 text-white text-xs rounded p-2">
                                        Marque esta opción si el cliente ya utiliza nuestro formato estándar para subir incidencias
                                    </span>
                                </span>
                            </label>
                            <div class="flex items-center">
                                <input type="checkbox" id="useLayout" class="mr-2 h-5 w-5 text-blue-600">
                                <span>Sí, el cliente usa el layout de RR 2.0</span>
                            </div>
                        </div>
                        
                        <button id="calculateMaquila" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-md transition duration-300">
                            <i class="fas fa-calculator mr-2"></i>Calcular Cotización
                        </button>
                    </div>
                    
                    <!-- Results Placeholder -->
                    <div id="maquilaResults" class="result-card bg-white p-6 rounded-lg shadow-sm border border-gray-200 hidden">
                        <h3 class="text-xl font-semibold text-gray-700 mb-4">Resultados de cotización</h3>
                        <div class="space-y-4">
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Número de empleados:</span>
                                <span id="resultEmployees" class="font-medium"></span>
                            </div>
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Tipo de servicio:</span>
                                <span id="resultServiceType" class="font-medium"></span>
                            </div>
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Tipo de periodo:</span>
                                <span id="resultPeriodType" class="font-medium"></span>
                            </div>
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Usa layout RR 2.0:</span>
                                <span id="resultLayout" class="font-medium"></span>
                            </div>
                            <div id="resultDetails" class="space-y-3 mt-4"></div>
                            <div class="bg-blue-50 p-4 rounded-md mt-4">
                                <div class="flex justify-between items-center">
                                    <span class="text-lg font-bold text-gray-700">Precio mensual:</span>
                                    <span id="resultMonthlyPrice" class="text-2xl font-bold text-blue-600"></span>
                                </div>
                                <div class="flex justify-between mt-2">
                                    <span class="text-gray-600">Facturación anual:</span>
                                    <span id="resultAnnual" class="font-medium"></span>
                                </div>
                            </div>
                            <div class="bg-green-50 p-4 rounded-md">
                                <div class="flex justify-between items-center">
                                    <span class="text-lg font-bold text-gray-700">Con descuento (25%):</span>
                                    <span id="resultDiscountPrice" class="text-2xl font-bold text-green-600"></span>
                                </div>
                                <div class="flex justify-between mt-2">
                                    <span class="text-gray-600">Facturación anual con descuento:</span>
                                    <span id="resultAnnualDiscount" class="font-medium"></span>
                                </div>
                            </div>
                        </div>
                        
                        <button id="newMaquilaQuote" class="w-full mt-6 bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold py-2 px-4 rounded-md transition duration-300">
                            <i class="fas fa-redo mr-2"></i>Nueva cotización
                        </button>
                    </div>
                </div>
                
                <!-- Pricing Table -->
                <div class="mt-12">
                    <h3 class="text-xl font-semibold text-gray-700 mb-4">Tabla de referencia de precios</h3>
                    <div class="overflow-x-auto">
                        <table class="min-w-full bg-white border border-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="px-6 py-3 border-b border-gray-200 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Rango</th>
                                    <th class="px-6 py-3 border-b border-gray-200 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Empleados</th>
                                    <th colspan="2" class="px-6 py-3 border-b border-gray-200 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Híbrido</th>
                                    <th colspan="3" class="px-6 py-3 border-b border-gray-200 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Gestión Total</th>
                                    <th colspan="2" class="px-6 py-3 border-b border-gray-200 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Renta</th>
                                </tr>
                                <tr>
                                    <th></th>
                                    <th></th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">P. mensual</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">Fact. anual</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">Mensual</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">Qnal/Cator.</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">Semanal</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">P. mensual</th>
                                    <th class="px-6 py-2 border-b border-gray-200 text-xs font-medium text-gray-500 uppercase tracking-wider">Fact. anual</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <!-- Rows will be populated by JavaScript -->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- Renta de Software Tab -->
            <div id="renta" class="tab-content p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Cotización de Renta de Software</h2>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <!-- Input Form -->
                    <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
                        <h3 class="text-xl font-semibold text-gray-700 mb-4">Parámetros de cotización</h3>
                        
                        <div class="mb-6">
                            <label class="block text-gray-700 font-medium mb-2">Número de empleados</label>
                            <input type="range" id="employeeRangeRenta" min="1" max="5500" value="10" class="w-full mb-2">
                            <div class="flex justify-between">
                                <span>1</span>
                                <span id="employeeValueRenta" class="font-bold">10</span>
                                <span>5500+</span>
                            </div>
                        </div>
                        
                        <div class="mb-6">
                            <label class="block text-gray-700 font-medium mb-2">Tipo de cotización</label>
                            <div class="space-y-2">
                                <label class="flex items-center">
                                    <input type="radio" name="rentaType" value="unico" class="mr-2" checked>
                                    <span>Un precio para todos los tipos de periodo</span>
                                </label>
                                <label class="flex items-center">
                                    <input type="radio" name="rentaType" value="diferente" class="mr-2">
                                    <span>Diferentes precios por tipo de periodo</span>
                                </label>
                            </div>
                        </div>
                        
                        <div class="mb-6" id="periodTypeRentaContainer">
                            <label class="block text-gray-700 font-medium mb-2">Tipo de periodo</label>
                            <select id="periodTypeRenta" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <option value="mensual">Mensual</option>
                                <option value="quincenal">Quincenal/Catorcenal</option>
                                <option value="semanal">Semanal</option>
                            </select>
                        </div>
                        
                        <button id="calculateRenta" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-md transition duration-300">
                            <i class="fas fa-calculator mr-2"></i>Calcular Cotización
                        </button>
                    </div>
                    
                    <!-- Results Placeholder -->
                    <div id="rentaResults" class="result-card bg-white p-6 rounded-lg shadow-sm border border-gray-200 hidden">
                        <h3 class="text-xl font-semibold text-gray-700 mb-4">Resultados de cotización</h3>
                        <div class="space-y-4">
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Número de empleados:</span>
                                <span id="resultEmployeesRenta" class="font-medium"></span>
                            </div>
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Tipo de cotización:</span>
                                <span id="resultRentaType" class="font-medium"></span>
                            </div>
                            <div class="flex justify-between py-2 border-b border-gray-200">
                                <span class="text-gray-600">Tipo de periodo:</span>
                                <span id="resultPeriodTypeRenta" class="font-medium"></span>
                            </div>
                            <div class="bg-blue-50 p-4 rounded-md mt-4">
                                <div class="flex justify-between items-center">
                                    <span class="text-lg font-bold text-gray-700">Precio mensual:</span>
                                    <span id="resultMonthlyPriceRenta" class="text-2xl font-bold text-blue-600"></span>
                                </div>
                                <div class="flex justify-between mt-2">
                                    <span class="text-gray-600">Facturación anual:</span>
                                    <span id="resultAnnualRenta" class="font-medium"></span>
                                </div>
                            </div>
                        </div>
                        
                        <button id="newRentaQuote" class="w-full mt-6 bg-gray-200 hover:bg-gray-300 text-gray-800 font-bold py-2 px-4 rounded-md transition duration-300">
                            <i class="fas fa-redo mr-2"></i>Nueva cotización
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <footer class="bg-gray-800 text-white py-6">
        <div class="container mx-auto px-4 text-center">
            <p>© 2023 REDRING - Herramienta interna de cotización</p>
            <p class="text-gray-400 text-sm mt-2">Para rangos superiores a 5,500 empleados, consultar con Gerencias Comercial y Operaciones</p>
        </div>
    </footer>

    <script>
        // Pricing data
        const pricingData = [
            { min: 1, max: 10, hibrido: 525, totalMensual: 700, totalQuincenal: 770, totalSemanal: 840, renta: 99 },
            { min: 11, max: 30, hibrido: 488, totalMensual: 650, totalQuincenal: 715, totalSemanal: 780, renta: 94 },
            { min: 31, max: 70, hibrido: 450, totalMensual: 600, totalQuincenal: 660, totalSemanal: 720, renta: 89 },
            { min: 71, max: 150, hibrido: 413, totalMensual: 550, totalQuincenal: 605, totalSemanal: 660, renta: 84 },
            { min: 151, max: 300, hibrido: 375, totalMensual: 500, totalQuincenal: 550, totalSemanal: 600, renta: 79 },
            { min: 301, max: 600, hibrido: 338, totalMensual: 450, totalQuincenal: 495, totalSemanal: 540, renta: 74 },
            { min: 601, max: 1200, hibrido: 300, totalMensual: 400, totalQuincenal: 440, totalSemanal: 480, renta: 69 },
            { min: 1201, max: 2200, hibrido: 263, totalMensual: 350, totalQuincenal: 385, totalSemanal: 420, renta: 64 },
            { min: 2201, max: 3300, hibrido: 225, totalMensual: 300, totalQuincenal: 330, totalSemanal: 360, renta: 59 },
            { min: 3301, max: 4400, hibrido: 188, totalMensual: 250, totalQuincenal: 275, totalSemanal: 300, renta: 54 },
            { min: 4401, max: 5500, hibrido: 150, totalMensual: 200, totalQuincenal: 220, totalSemanal: 240, renta: 49 },
            { min: 5501, max: null, hibrido: null, totalMensual: null, totalQuincenal: null, totalSemanal: null, renta: null }
        ];

        // Tab functionality
        document.querySelectorAll('.tab-btn').forEach(btn => {
            btn.addEventListener('click', () => {
                // Remove active class from all tabs and buttons
                document.querySelectorAll('.tab-btn').forEach(tb => {
                    tb.classList.remove('border-blue-600', 'text-blue-600');
                    tb.classList.add('text-gray-700');
                });
                
                document.querySelectorAll('.tab-content').forEach(content => {
                    content.classList.remove('active');
                });
                
                // Add active class to clicked tab
                btn.classList.add('border-blue-600', 'text-blue-600');
                btn.classList.remove('text-gray-700');
                
                const tabId = btn.getAttribute('data-tab');
                document.getElementById(tabId).classList.add('active');
            });
        });

        // Employee range input for Maquila
        const employeeRange = document.getElementById('employeeRange');
        const employeeValue = document.getElementById('employeeValue');
        
        employeeRange.addEventListener('input', () => {
            employeeValue.textContent = employeeRange.value;
        });

        // Employee range input for Renta
        const employeeRangeRenta = document.getElementById('employeeRangeRenta');
        const employeeValueRenta = document.getElementById('employeeValueRenta');
        
        employeeRangeRenta.addEventListener('input', () => {
            employeeValueRenta.textContent = employeeRangeRenta.value;
        });

        // Show/hide period type based on service type for Maquila
        document.querySelectorAll('input[name="serviceType"]').forEach(radio => {
            radio.addEventListener('change', () => {
                const useLayout = document.getElementById('useLayout').checked;
                const serviceType = document.querySelector('input[name="serviceType"]:checked').value;
                
                if (serviceType === 'total' && !useLayout) {
                    document.getElementById('periodTypeContainer').classList.remove('hidden');
                } else {
                    document.getElementById('periodTypeContainer').classList.add('hidden');
                }
            });
        });

        document.getElementById('useLayout').addEventListener('change', function() {
            const serviceType = document.querySelector('input[name="serviceType"]:checked').value;
            
            if (serviceType === 'total' && !this.checked) {
                document.getElementById('periodTypeContainer').classList.remove('hidden');
            } else {
                document.getElementById('periodTypeContainer').classList.add('hidden');
            }
        });

        // Show/hide period type based on renta type
        document.querySelectorAll('input[name="rentaType"]').forEach(radio => {
            radio.addEventListener('change', () => {
                const rentaType = document.querySelector('input[name="rentaType"]:checked').value;
                
                if (rentaType === 'diferente') {
                    document.getElementById('periodTypeRentaContainer').classList.remove('hidden');
                } else {
                    document.getElementById('periodTypeRentaContainer').classList.add('hidden');
                }
            });
        });

        // Add new range
        document.getElementById('addRange').addEventListener('click', () => {
            const rangeGroup = document.querySelector('.range-group').cloneNode(true);
            rangeGroup.querySelector('.min-employees').value = '';
            rangeGroup.querySelector('.max-employees').value = '';
            document.getElementById('employeeRanges').appendChild(rangeGroup);
            addRemoveListeners();
        });

        // Remove range
        function addRemoveListeners() {
            document.querySelectorAll('.remove-range').forEach(btn => {
                btn.addEventListener('click', function() {
                    if (document.querySelectorAll('.range-group').length > 1) {
                        this.closest('.range-group').remove();
                    } else {
                        alert('Debe haber al menos un rango de empleados');
                    }
                });
            });
        }

        // Calculate Maquila with multiple ranges
        document.getElementById('calculateMaquila').addEventListener('click', () => {
            const serviceType = document.querySelector('input[name="serviceType"]:checked').value;
            const useLayout = document.getElementById('useLayout').checked;
            
            const ranges = document.querySelectorAll('.range-group');
            let totalPrice = 0;
            let totalAnnual = 0;
            let resultsHTML = '';
            
            ranges.forEach(range => {
                const minEmployees = parseInt(range.querySelector('.min-employees').value) || 0;
                const maxEmployees = parseInt(range.querySelector('.max-employees').value) || 0;
                const periodType = range.querySelector('.period-type').value;
                
                if (minEmployees === 0 || maxEmployees === 0 || minEmployees > maxEmployees) {
                    alert('Por favor ingrese rangos válidos');
                    return;
                }
                
                const avgEmployees = Math.floor((minEmployees + maxEmployees) / 2);
                
                // Find the pricing tier
                let tier = pricingData.find(t => 
                    (t.max === null && avgEmployees >= t.min) || 
                    (avgEmployees >= t.min && avgEmployees <= t.max)
                );
                
                if (!tier) {
                    alert(`Para más de 5,500 empleados, consultar con Gerencias Comercial y Operaciones`);
                    return;
                }
                
                // Calculate price
                let price;
                let annual;
                let description;
                
                if (serviceType === 'hibrido') {
                    price = tier.hibrido * avgEmployees;
                    annual = price * 10;
                    description = "Híbrido";
                } else { // total
                    if (useLayout) {
                        price = tier.totalMensual * avgEmployees;
                        description = "Gestión Total (con layout RR 2.0)";
                    } else {
                        if (periodType === 'mensual') {
                            price = tier.totalMensual * avgEmployees;
                        } else if (periodType === 'quincenal') {
                            price = tier.totalQuincenal * avgEmployees;
                        } else { // semanal
                            price = tier.totalSemanal * avgEmployees;
                        }
                        description = `Gestión Total (${periodType})`;
                    }
                    annual = price * (periodType === 'mensual' ? 10 : (periodType === 'quincenal' ? 24 : 52));
                }
                
                totalPrice += price;
                totalAnnual += annual;
                
                // Add to results details
                resultsHTML += `
                    <div class="mb-4 p-3 bg-gray-50 rounded-md">
                        <div class="flex justify-between py-1">
                            <span class="text-gray-600">Empleados:</span>
                            <span class="font-medium">${minEmployees} - ${maxEmployees}</span>
                        </div>
                        <div class="flex justify-between py-1">
                            <span class="text-gray-600">Tipo de periodo:</span>
                            <span class="font-medium">${periodType.charAt(0).toUpperCase() + periodType.slice(1)}</span>
                        </div>
                        <div class="flex justify-between py-1">
                            <span class="text-gray-600">Precio mensual:</span>
                            <span class="font-medium">${price.toLocaleString()}</span>
                        </div>
                        <div class="flex justify-between py-1">
                            <span class="text-gray-600">Facturación anual:</span>
                            <span class="font-medium">${annual.toLocaleString()}</span>
                        </div>
                    </div>
                `;
            });
            
            // Calculate discount
            const discountPrice = totalPrice * 0.75;
            const annualDiscount = totalAnnual * 0.75;
            
            // Display results
            document.getElementById('resultEmployees').textContent = ranges.length > 1 ? `${ranges.length} rangos de empleados` : `${ranges[0].querySelector('.min-employees').value} - ${ranges[0].querySelector('.max-employees').value}`;
            document.getElementById('resultServiceType').textContent = serviceType === 'hibrido' ? 'Híbrido' : 'Gestión Total';
            document.getElementById('resultPeriodType').textContent = ranges.length > 1 ? 'Múltiples periodos' : ranges[0].querySelector('.period-type').value.charAt(0).toUpperCase() + ranges[0].querySelector('.period-type').value.slice(1);
            document.getElementById('resultLayout').textContent = useLayout ? "Sí" : "No";
            
            // Add details to results
            document.getElementById('resultDetails').innerHTML = resultsHTML;
            
            // Show totals
            document.getElementById('resultMonthlyPrice').textContent = `${totalPrice.toLocaleString()}`;
            document.getElementById('resultAnnual').textContent = `${totalAnnual.toLocaleString()}`;
            document.getElementById('resultDiscountPrice').textContent = `${discountPrice.toLocaleString()}`;
            document.getElementById('resultAnnualDiscount').textContent = `${annualDiscount.toLocaleString()}`;
            
            // Show results
            document.getElementById('maquilaResults').classList.remove('hidden');
        });

        // Calculate Renta
        document.getElementById('calculateRenta').addEventListener('click', () => {
            const employees = parseInt(employeeRangeRenta.value);
            const rentaType = document.querySelector('input[name="rentaType"]:checked').value;
            const periodType = document.getElementById('periodTypeRenta').value;
            
            // Find the pricing tier
            let tier = pricingData.find(t => 
                (t.max === null && employees >= t.min) || 
                (employees >= t.min && employees <= t.max)
            );
            
            if (!tier) {
                alert("Para más de 5,500 empleados, consultar con Gerencias Comercial y Operaciones");
                return;
            }
            
            // Calculate price
            let price;
            let annual;
            let description;
            
            if (rentaType === 'unico') {
                price = tier.renta * employees;
                description = "Precio único para todos los periodos";
            } else { // diferente
                price = tier.renta * employees;
                description = `Precio para periodo ${periodType}`;
            }
            
            annual = price * (periodType === 'mensual' ? 10 : (periodType === 'quincenal' ? 24 : 52));
            
            // Display results
            document.getElementById('resultEmployeesRenta').textContent = employees;
            document.getElementById('resultRentaType').textContent = description;
            document.getElementById('resultPeriodTypeRenta').textContent = periodType.charAt(0).toUpperCase() + periodType.slice(1);
            document.getElementById('resultMonthlyPriceRenta').textContent = `$${price.toLocaleString()}`;
            document.getElementById('resultAnnualRenta').textContent = `$${annual.toLocaleString()}`;
            
            // Show results
            document.getElementById('rentaResults').classList.remove('hidden');
        });

        // New quote buttons
        document.getElementById('newMaquilaQuote').addEventListener('click', () => {
            document.getElementById('maquilaResults').classList.add('hidden');
        });

        document.getElementById('newRentaQuote').addEventListener('click', () => {
            document.getElementById('rentaResults').classList.add('hidden');
        });

        // Populate pricing table
        function populatePricingTable() {
            const tbody = document.querySelector('tbody');
            tbody.innerHTML = '';
            
            pricingData.forEach((tier, index) => {
                const row = document.createElement('tr');
                row.className = index % 2 === 0 ? 'bg-white' : 'bg-gray-50';
                
                // Rango
                const rangeCell = document.createElement('td');
                rangeCell.className = 'px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900';
                rangeCell.textContent = index + 1;
                row.appendChild(rangeCell);
                
                // Empleados
                const employeesCell = document.createElement('td');
                employeesCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                if (tier.max === null) {
                    employeesCell.textContent = `>${tier.min}`;
                } else {
                    employeesCell.textContent = `${tier.min} - ${tier.max}`;
                }
                row.appendChild(employeesCell);
                
                // Híbrido
                const hibridoPriceCell = document.createElement('td');
                hibridoPriceCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                hibridoPriceCell.textContent = tier.hibrido ? `$${tier.hibrido}` : 'Consultar';
                row.appendChild(hibridoPriceCell);
                
                const hibridoAnnualCell = document.createElement('td');
                hibridoAnnualCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                if (tier.hibrido) {
                    const avgEmployees = tier.max ? Math.floor((tier.min + tier.max) / 2) : tier.min;
                    hibridoAnnualCell.textContent = `$${(tier.hibrido * avgEmployees * 10).toLocaleString()}`;
                } else {
                    hibridoAnnualCell.textContent = 'Consultar';
                }
                row.appendChild(hibridoAnnualCell);
                
                // Gestión Total
                const totalMensualCell = document.createElement('td');
                totalMensualCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                totalMensualCell.textContent = tier.totalMensual ? `$${tier.totalMensual}` : 'Consultar';
                row.appendChild(totalMensualCell);
                
                const totalQuincenalCell = document.createElement('td');
                totalQuincenalCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                totalQuincenalCell.textContent = tier.totalQuincenal ? `$${tier.totalQuincenal}` : 'Consultar';
                row.appendChild(totalQuincenalCell);
                
                const totalSemanalCell = document.createElement('td');
                totalSemanalCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                totalSemanalCell.textContent = tier.totalSemanal ? `$${tier.totalSemanal}` : 'Consultar';
                row.appendChild(totalSemanalCell);
                
                // Renta
                const rentaPriceCell = document.createElement('td');
                rentaPriceCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                rentaPriceCell.textContent = tier.renta ? `$${tier.renta}` : 'Consultar';
                row.appendChild(rentaPriceCell);
                
                const rentaAnnualCell = document.createElement('td');
                rentaAnnualCell.className = 'px-6 py-4 whitespace-nowrap text-sm text-gray-500';
                if (tier.renta) {
                    const avgEmployees = tier.max ? Math.floor((tier.min + tier.max) / 2) : tier.min;
                    rentaAnnualCell.textContent = `$${(tier.renta * avgEmployees * 10).toLocaleString()}`;
                } else {
                    rentaAnnualCell.textContent = 'Consultar';
                }
                row.appendChild(rentaAnnualCell);
                
                tbody.appendChild(row);
            });
        }

        // Tooltip functionality
        document.querySelectorAll('.tooltip').forEach(el => {
            el.addEventListener('mouseover', () => {
                el.querySelector('.tooltip-text').classList.remove('hidden');
            });
            el.addEventListener('mouseout', () => {
                el.querySelector('.tooltip-text').classList.add('hidden');
            });
        });

        // Initialize
        document.addEventListener('DOMContentLoaded', () => {
            populatePricingTable();
            addRemoveListeners();
            
            // Hide period type initially for Maquila
            document.getElementById('periodTypeContainer').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=MyNameIsToby/apps-redring" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>