File size: 33,524 Bytes
01f7128
 
 
dad761f
22c7e1a
dad761f
22c7e1a
 
dad761f
22c7e1a
 
 
c510759
22c7e1a
c510759
 
22c7e1a
 
 
c510759
 
22c7e1a
c510759
 
 
 
 
 
22c7e1a
64b31b0
 
22c7e1a
7f7d4e8
 
 
c510759
 
22c7e1a
7f7d4e8
 
 
965802c
7f7d4e8
 
 
 
 
22c7e1a
7f7d4e8
965802c
7f7d4e8
 
c510759
 
90c1673
7f7d4e8
c510759
 
 
 
 
 
 
 
07a58d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c510759
 
 
 
356df69
 
 
c510759
 
22c7e1a
c510759
356df69
 
c510759
 
22c7e1a
 
 
 
c510759
22c7e1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2927271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c510759
22c7e1a
 
 
 
 
 
b815d2a
006f8f9
b815d2a
 
006f8f9
 
 
 
 
 
 
 
b815d2a
006f8f9
 
 
 
 
 
b815d2a
006f8f9
 
 
 
 
 
 
 
 
 
 
 
 
b815d2a
006f8f9
0fe423f
 
 
 
 
 
ab036c1
4b33a3a
ab036c1
 
b10f111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa861e6
 
 
 
 
 
 
22c7e1a
dad761f
 
22c7e1a
 
dd8d73b
 
 
 
01f7128
22c7e1a
 
 
 
7f7d4e8
 
 
22c7e1a
fa861e6
 
 
ecc63f2
 
 
2d9a321
 
 
22c7e1a
fa861e6
 
 
35bcc12
 
456fb21
5911ba2
 
 
85c4a46
4cb9c24
85c4a46
22c7e1a
 
 
 
dad761f
22c7e1a
456fb21
 
 
 
 
 
 
 
 
b12f34f
456fb21
574fabb
456fb21
 
 
 
 
22c7e1a
 
1ff9da7
c70bb17
 
 
 
 
 
9262c5d
c70bb17
 
 
 
 
 
 
2927271
 
 
 
7c185ea
60579d5
2927271
 
60579d5
b10f111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2927271
 
 
 
 
60579d5
7c185ea
2927271
22c7e1a
 
 
 
 
 
423a4e7
b36d1ac
85c4a46
 
b36d1ac
22c7e1a
423a4e7
 
 
22c7e1a
85c4a46
 
a0d5227
85c4a46
a0d5227
85c4a46
 
 
423a4e7
 
85c4a46
 
423a4e7
 
 
 
85c4a46
 
5b607ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
070ae9d
85c4a46
 
1fb91bb
423a4e7
 
 
 
85c4a46
423a4e7
8de243f
 
 
9262c5d
 
8de243f
9262c5d
 
 
 
 
 
8de243f
9262c5d
ddb0e12
9262c5d
 
 
423a4e7
9262c5d
 
cf6db7d
 
 
9262c5d
 
 
 
85c4a46
cf6db7d
 
9262c5d
 
 
 
 
b10f111
 
9262c5d
 
 
b10f111
 
9262c5d
22c7e1a
8de243f
9262c5d
 
 
ba38de0
67d2793
ba38de0
 
 
 
 
 
 
 
 
 
 
 
 
9262c5d
22c7e1a
 
7a42b14
9262c5d
22c7e1a
 
 
 
 
9262c5d
22c7e1a
 
 
 
 
 
9262c5d
 
 
 
 
 
 
 
 
 
 
 
 
 
22c7e1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4aca512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574fabb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4aca512
22c7e1a
 
 
 
dad761f
22c7e1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928

       

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cart</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
      body {
            font-family: Arial, sans-serif;
            background-color: #f3f4f6;
            color: #333;
        }
        .cart-container {
            max-width: 768px;
            margin: 30px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
            transition: box-shadow 0.3s ease-in-out;
        }
        .cart-container:hover {
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        }
        

        .cart-item {
            display: flex;                  /* Flexbox layout for the cart item */
            align-items: flex-start;         /* Ensure the image and content align at the top */
            justify-content: space-between;  /* Spread image and content across the container */
            border-bottom: 1px solid #e0e0e0;
            padding: 15px 0;
        }

        .image-wrapper {
            width: 80px;                    /* Width of the image container */
            height: 140px !important;                   /* Height of the image container */
            display: flex;                  /* Flex container for image */
            align-items: flex-start;        /* Align the image at the top */
            justify-content: center;        /* Center image horizontally if it has space */
        }

        .cart-item img {
            width: 100%;                    /* Fill the image container */
            height: auto !important;                   /* Maintain aspect ratio */
            object-fit: contain;            /* Ensure the full image is visible */
            border-radius: 8px;             /* Optional: rounded corners */
            transition: transform 0.3s;
        }


        .cart-item img:hover {
            transform: scale(1.05);
        }
        .cart-item-title {
            font-size: 1.1rem;
            font-weight: 600;
        }
        .checkout-button {
           background-color: #0FAA39; /* Green background */
           color: #fff; /* White text */
           padding: 12px;
           border-radius: 8px;
           border: none;
           width: 100%;
           font-size: 1.2rem;
           cursor: pointer;
           transition: background-color 0.3s, color 0.3s;
       }

       .checkout-button:hover {
           background-color: #0FAA39; /* Keep the background green on hover */
           color: #fff; /* Keep the text white on hover */
       }

        .add-back-button {
            padding: 6px 20px;
            font-size: 0.9rem;
            border-radius: 20px;
            border: 1px solid #fff;
            background-color: #fff;
            color: #0FAA39;
            cursor: pointer;
            transition: background-color 0.3s, color 0.3s;
        }
        .add-back-button:hover {
            background-color: #fff;
            color: #0FAA39;
        }
        
        .cart-item-details {
            flex: 1;
            margin-left: 15px;
        }
       
        .cart-item-quantity {
            display: flex;
            align-items: center;
            margin-top: 5px;
        }
        .cart-item-quantity button {
            width: 30px;
            height: 30px;
            border: none;
            background-color: #f0f0f0;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
        }
        .cart-item-quantity input {
            width: 40px;
            text-align: center;
            border: none;
            background-color: #f8f9fa;
            font-size: 1rem;
            margin: 0 5px;
        }
        .cart-summary {
    text-align: left;
    margin-top: 15px;
    padding: 20px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.bill-details {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two-column layout */
    grid-gap: 10px;
    margin-bottom: 10px;
}

.bill-details .label {
    font-weight: 600;
    font-size: 1rem;
}

.bill-details .amount {
    text-align: right;
    font-weight: 600;
    font-size: 1rem;
}

.dotted-line {
    border-bottom: 2px dotted #ccc;
    margin: 15px 0;
}

.total-bill {
    display: grid;
    grid-template-columns: 1fr 1fr;
    font-weight: 600;
    font-size: 1.2rem;
    margin-top: 10px;
}

.total-bill .label {
    font-size: 1.1rem;
}

.total-bill .amount {
    text-align: right;
    font-size: 1.1rem;
    color: #0FAA39; /* Green color for total */
}

.checkout-button {
    background-color: #0FAA39;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    border: none;
    width: 100%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

      
        .suggestion-section {
            margin-top: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 10px;
        }
       .suggestion-item {
    display: flex;
    align-items: center; /* Vertically align image and text */
    justify-content: space-between; /* Space between the image/text and the button */
    padding: 10px 0;
}

.suggestion-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    margin-right: 10px; /* Spacing between the image and the text */
}

.suggestion-item div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1; /* Allow the text to take up the available space */
}

.suggestion-item button {
    padding: 5px 15px;
    font-size: 0.9rem;
    border-radius: 5px;
    border: 2px solid #0FAA39;
    color: #0FAA39;
    background-color: #fff;
    font-weight: 600;
    height: 44px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    margin-left: auto; /* Push button to the right */
}

       .suggestion-item button:hover {
           background-color: #0FAA39; /* Change background to green on hover */
           color: #fff; /* Change text color to white on hover */
           border-color: #0FAA39; /* Keep the border green */
       }


        

        .remove-icon {
            border: none;
            background: none;
            color: red;
            font-size: 1.2rem;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="cart-container">
            <div style="text-align: right;">
                <a href="/menu" style="text-decoration: none; font-size: 1.5rem; color: #007bff;">&times;</a>
            </div>

             <h4 class="mb-4 fw-bold">Your Cart</h4>

            <!-- Cart Items -->
            {% for item in cart_items %}
            <div class="cart-item">
                <div class="image-wrapper">
                    <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
               </div>
                <div class="cart-item-details">
                    <div class="cart-item-title">
                        {{ item.Name }}
                    </div> 
                    <div class="cart-item-addons">
                        <small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
                    </div>
                    <div class="cart-item-instructions">
                        <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
                    </div>
                    <div class="cart-item-quantity mt-2">
                        <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
                        <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
                        <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
                    </div>
                </div>
               <div class="cart-item-actions">
                    <div>
                      <button class="remove-icon" onclick="removeItemFromCart('{{ item.Name }}')">🗑️</button>
                    </div>
                    <div class="text-primary">
                        $<span class="base-price">{{ item.Price__c }}</span> 
                    </div>
                </div>
            </div>
            {% else %}
            <p class="text-center">Your cart is empty.</p>
            {% endfor %}

            <!-- Suggestions Section -->
            {% if suggestions %}
            <div class="suggestion-section">
                <h5>Complete Your Meal</h5>
                {% for suggestion in suggestions %}
                <div class="suggestion-item">
                    <img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
                    <div>
                        <div>{{ suggestion.Name }}</div>
                        <div class="text-muted">${{ suggestion.Price__c }}</div>
                    </div>
                    <button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">Add</button>
                </div>
                {% endfor %}
            </div>
            {% endif %}

            <!-- Subtotal -->
            <div class="cart-summary">
               
                {% if coupons %}
                    <div class="coupon-selection">
                        <label>
                            <input type="checkbox" id="couponCheckbox" onchange="toggleCouponDropdown()">
                            Apply Coupon Code
                        </label>
                        <select id="couponDropdown" class="form-select mt-2" disabled onchange="calculateDiscount()">
                            <option value="">Select a coupon</option>
                            {% for coupon in coupons %}
                                <option value="{{ coupon }}">{{ coupon }}</option>
                           {% endfor %}
                        </select>
                    </div>
                {% endif %}
                <div class="bill-details">
                    <div class="label">Cart Total</div>
                    <div class="amount">${{ subtotal }}</div>
                    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cart</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
      body {
            font-family: Arial, sans-serif;
            background-color: #f3f4f6;
            color: #333;
        }
        .cart-container {
            max-width: 768px;
            margin: 30px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 12px;
            box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
            transition: box-shadow 0.3s ease-in-out;
        }
        .cart-container:hover {
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        }
        
        .cart-item {
            display: flex;                  /* Flexbox layout for the cart item */
            align-items: flex-start;         /* Ensure the image and content align at the top */
            justify-content: space-between;  /* Spread image and content across the container */
            border-bottom: 1px solid #e0e0e0;
            padding: 15px 0;
        }
        .image-wrapper {
            width: 80px;                    /* Width of the image container */
            height: 140px !important;                   /* Height of the image container */
            display: flex;                  /* Flex container for image */
            align-items: flex-start;        /* Align the image at the top */
            justify-content: center;        /* Center image horizontally if it has space */
        }
        .cart-item img {
            width: 100%;                    /* Fill the image container */
            height: auto !important;                   /* Maintain aspect ratio */
            object-fit: contain;            /* Ensure the full image is visible */
            border-radius: 8px;             /* Optional: rounded corners */
            transition: transform 0.3s;
        }
        .cart-item img:hover {
            transform: scale(1.05);
        }
        .cart-item-title {
            font-size: 1.1rem;
            font-weight: 600;
        }
        .checkout-button {
           background-color: #0FAA39; /* Green background */
           color: #fff; /* White text */
           padding: 12px;
           border-radius: 8px;
           border: none;
           width: 100%;
           font-size: 1.2rem;
           cursor: pointer;
           transition: background-color 0.3s, color 0.3s;
       }
       .checkout-button:hover {
           background-color: #0FAA39; /* Keep the background green on hover */
           color: #fff; /* Keep the text white on hover */
       }
        .add-back-button {
            padding: 6px 20px;
            font-size: 0.9rem;
            border-radius: 20px;
            border: 1px solid #fff;
            background-color: #fff;
            color: #0FAA39;
            cursor: pointer;
            transition: background-color 0.3s, color 0.3s;
        }
        .add-back-button:hover {
            background-color: #fff;
            color: #0FAA39;
        }
        
        .cart-item-details {
            flex: 1;
            margin-left: 15px;
        }
       
        .cart-item-quantity {
            display: flex;
            align-items: center;
            margin-top: 5px;
        }
        .cart-item-quantity button {
            width: 30px;
            height: 30px;
            border: none;
            background-color: #f0f0f0;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
        }
        .cart-item-quantity input {
            width: 40px;
            text-align: center;
            border: none;
            background-color: #f8f9fa;
            font-size: 1rem;
            margin: 0 5px;
        }
        .cart-summary {
    text-align: left;
    margin-top: 15px;
    padding: 20px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}
.bill-details {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two-column layout */
    grid-gap: 10px;
    margin-bottom: 10px;
}
.bill-details .label {
    font-weight: 600;
    font-size: 1rem;
}
.bill-details .amount {
    text-align: right;
    font-weight: 600;
    font-size: 1rem;
}
.dotted-line {
    border-bottom: 2px dotted #ccc;
    margin: 15px 0;
}
.total-bill {
    display: grid;
    grid-template-columns: 1fr 1fr;
    font-weight: 600;
    font-size: 1.2rem;
    margin-top: 10px;
}
.total-bill .label {
    font-size: 1.1rem;
}
.total-bill .amount {
    text-align: right;
    font-size: 1.1rem;
    color: #0FAA39; /* Green color for total */
}
.checkout-button {
    background-color: #0FAA39;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    border: none;
    width: 100%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}
      
        .suggestion-section {
            margin-top: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 10px;
        }
       .suggestion-item {
    display: flex;
    align-items: center; /* Vertically align image and text */
    justify-content: space-between; /* Space between the image/text and the button */
    padding: 10px 0;
}
.suggestion-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    margin-right: 10px; /* Spacing between the image and the text */
}
.suggestion-item div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1; /* Allow the text to take up the available space */
}
.suggestion-item button {
    padding: 5px 15px;
    font-size: 0.9rem;
    border-radius: 5px;
    border: 2px solid #0FAA39;
    color: #0FAA39;
    background-color: #fff;
    font-weight: 600;
    height: 44px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    margin-left: auto; /* Push button to the right */
}
       .suggestion-item button:hover {
           background-color: #0FAA39; /* Change background to green on hover */
           color: #fff; /* Change text color to white on hover */
           border-color: #0FAA39; /* Keep the border green */
       }
        
        .remove-icon {
            border: none;
            background: none;
            color: red;
            font-size: 1.2rem;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="cart-container">
            <div style="text-align: right;">
                <a href="/menu" style="text-decoration: none; font-size: 1.5rem; color: #007bff;">&times;</a>
            </div>

             <h4 class="mb-4 fw-bold">Your Cart</h4>

            <!-- Cart Items -->
            {% for item in cart_items %}
            <div class="cart-item">
                <div class="image-wrapper">
                    <img src="{{ item.Image1__c }}" alt="{{ item.Name }}" onerror="this.src='/static/placeholder.jpg';">
               </div>
                <div class="cart-item-details">
                    <div class="cart-item-title">
                        {{ item.Name }}
                    </div> 
                    <div class="cart-item-addons">
                        <small class="text-muted">Add-ons: {{ item.Add_Ons__c }}</small>
                    </div>
                    <div class="cart-item-instructions">
                        <small class="text-muted">Instructions: {{ item.Instructions__c or "None" }}</small>
                    </div>
                    <div class="cart-item-quantity mt-2">
                        <button onclick="updateQuantity('decrease', '{{ item.Name }}', '{{ customer_email }}')">-</button>
                        <input type="text" value="{{ item.Quantity__c|int }}" readonly data-item-name="{{ item.Name }}">
                        <button onclick="updateQuantity('increase', '{{ item.Name }}', '{{ customer_email }}')">+</button>
                    </div>
                </div>
               <div class="cart-item-actions">
                    <div>
                      <button class="remove-icon" onclick="removeItemFromCart('{{ item.Name }}')">🗑️</button>
                    </div>
                    <div class="text-primary">
                        $<span class="base-price">{{ item.Price__c }}</span> 
                    </div>
                </div>
            </div>
            {% else %}
            <p class="text-center">Your cart is empty.</p>
            {% endfor %}

            <!-- Suggestions Section -->
            {% if suggestions %}
            <div class="suggestion-section">
                <h5>Complete Your Meal</h5>
                {% for suggestion in suggestions %}
                <div class="suggestion-item">
                    <img src="{{ suggestion.Image1__c }}" alt="{{ suggestion.Name }}" onerror="this.src='/static/placeholder.jpg';">
                    <div>
                        <div>{{ suggestion.Name }}</div>
                        <div class="text-muted">${{ suggestion.Price__c }}</div>
                    </div>
                    <button class="add-back-button" onclick="addToCartSuggestion('{{ suggestion.Name }}', '{{ suggestion.Price__c }}', '{{ suggestion.Image1__c }}', '{{ suggestion.Id }}')">Add</button>
                </div>
                {% endfor %}
            </div>
            {% endif %}

            <!-- Subtotal -->
            <div class="cart-summary">
               
                {% if coupons %}
                    <div class="coupon-selection">
                        <label>
                            <input type="checkbox" id="couponCheckbox" onchange="toggleCouponDropdown()">
                            Apply Coupon Code
                        </label>
                        <select id="couponDropdown" class="form-select mt-2" disabled onchange="calculateDiscount()">
                            <option value="">Select a coupon</option>
                            {% for coupon in coupons %}
                                <option value="{{ coupon }}">{{ coupon }}</option>
                           {% endfor %}
                        </select>
                    </div>
                {% endif %}
                <div class="bill-details">
                    <div class="label">Cart Total</div>
                    <div class="amount">${{ subtotal }}</div>
                    <div class="label">Discount</div>
                    <div class="amount" id="discountText">-${{ discount }}</div>


                    
                    
                </div>

                <div class="dotted-line"></div>

                <div class="total-bill">
                     <div class="label">To Pay</div>
                     <div class="amount" id="totalBillText">${{ subtotal }}</div>
                </div>
                <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
            </div>
        </div>
    </div>

                    <div class="amount" id="discountText">-${{ discount }}</div>


                    
                    
                </div>

                <div class="dotted-line"></div>

                <div class="total-bill">
                     <div class="label">To Pay</div>
                     <div class="amount" id="totalBillText">${{ subtotal }}</div>
                </div>
                <button class="checkout-button" onclick="proceedToOrder()">Proceed to Order</button>
            </div>
        </div>
    </div>

    <script>
        // Example function to handle the increase/decrease button clicks
        function updateQuantity(action, itemName, customerEmail) {
            let quantityInput = document.querySelector(`input[data-item-name="${itemName}"]`);
            let quantity = parseInt(quantityInput.value);
            // Update quantity based on action
            if (action === 'increase') {
                quantity++;
            } else if (action === 'decrease' && quantity > 1) {
                quantity--;
            }

            // Validate quantity
            if (isNaN(quantity) || quantity < 1) {
                alert("Invalid quantity!");
                return;
            }

            // Send updated quantity to the server
            fetch('/cart/update_quantity', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ email: customerEmail, item_name: itemName, quantity: quantity })
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    // Update the item price and quantity in the UI
                    quantityInput.value = quantity;
                    let itemElement = quantityInput.closest(".cart-item"); // Locate the parent cart item
                    if (itemElement) {
                        let basePriceElement = itemElement.querySelector(".base-price");
                        let addonsPriceElement = itemElement.querySelector(".addons-price");

                        // Update the base price
                        if (basePriceElement) {
                            basePriceElement.innerText = data.new_item_price.toFixed(2); // Assuming backend sends this
                        }

                        // Update add-ons price if needed (optional)
                        if (addonsPriceElement && data.addons_price !== undefined) {
                            addonsPriceElement.innerText = data.addons_price.toFixed(2);
                        }
                    } else {
                        console.error(`Parent cart item element not found for item: ${itemName}`);
                    }
                    location.reload();

                    // Recalculate subtotal dynamically
                    
                } else {
                    alert("Error updating quantity: " + data.error);
                }
            })
            .catch(err => console.error("Error:", err));
        }
        function toggleCouponDropdown() {
            let couponCheckbox = document.getElementById('couponCheckbox');
            let couponDropdown = document.getElementById('couponDropdown');

            // Enable or disable the dropdown based on checkbox status
            couponDropdown.disabled = !couponCheckbox.checked;

            // If unchecked, reset discount and total
            if (!couponCheckbox.checked) {
                document.getElementById("discountText").innerText = `Discount: $0`;
                document.getElementById("totalBillText").innerText = `Total Bill: ${{ subtotal }}`;
            }
        }

        function calculateDiscount() {
            let couponCheckbox = document.getElementById('couponCheckbox');
            let couponDropdown = document.getElementById('couponDropdown');
            let subtotal = parseFloat("{{ subtotal }}");

            // If checkbox is selected
            if (couponCheckbox.checked) {
                let selectedCoupon = couponDropdown.value.trim();
                if (!selectedCoupon || selectedCoupon.toLowerCase() === "none") {
                    alert("Please select a valid coupon.");
                    document.getElementById("discountText").innerText = `Discount: $0`;
                    document.getElementById("totalBillText").innerText = `Total Bill: $${subtotal.toFixed(2)}`;
                    return;
                }

                

                // Apply 10% discount
                let discount = subtotal * 0.10;
                let total = subtotal - discount;

                // Update UI
                document.getElementById("discountText").innerText = `$${discount.toFixed(2)}`;
                document.getElementById("totalBillText").innerText = `$${total.toFixed(2)}`;

            } else {
                // If checkbox is not selected, reset discount
                document.getElementById("discountText").innerText = `$0`;
                document.getElementById("totalBillText").innerText = `$${subtotal.toFixed(2)}`;
            }
        }

        function proceedToOrder() {
            let couponCheckbox = document.getElementById('couponCheckbox');
            let couponDropdown = document.getElementById('couponDropdown');
            let selectedCoupon = ""; // Default to empty coupon

            if (couponCheckbox && couponCheckbox.checked) {
                if (couponDropdown) {
                    selectedCoupon = couponDropdown.value.trim();
                
                    // Prevent checkout if no coupon is selected
                    if (!selectedCoupon) {
                        alert("Please select a valid coupon before proceeding.");
                        return;
                    }
                } else {
                    alert("Error: Coupon dropdown not found.");
                    return;
                }
            }
            fetch('/checkout', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ selectedCoupon: selectedCoupon })
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert(data.message);
                    window.location.href = '/order';
                } else {
                    alert(data.error || data.message);
                }
            })
            .catch(err => console.error('Error during checkout:', err));
        }

        function calculateSubtotal() {
            let subtotal = 0;
            document.querySelectorAll('.cart-item').forEach(item => {
                const quantity = parseInt(item.querySelector('input').value);
                const basePrice = parseFloat(item.querySelector('.base-price').innerText.replace('$', '')); // Base Price
                const addonsPrice = parseFloat(item.querySelector('.addons-price').innerText.replace('$', '')) || 0; // Add-ons Price
                subtotal += (basePrice * quantity) + addonsPrice; // Include add-ons price in subtotal
            });

            // Update the subtotal in the HTML
            document.querySelector('.cart-summary p').innerText = `Subtotal: $${subtotal.toFixed(2)}`;
            return subtotal;
        }
        function addSuggestion(itemId) {
            fetch(`/cart/add_suggestion/${itemId}`, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({})
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert('Item added to cart!');
                    location.reload();
                } else {
                    alert(data.error);
                }
            })
            .catch(err => console.error('Error adding suggestion:', err));
        }
        function removeItemFromCart(itemName) {
            fetch(`/cart/remove/${encodeURIComponent(itemName)}`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                }
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert(data.message);
                    location.reload(); // Reload the page to update the cart
                } else {
                    alert(data.message);
                }
            })
            .catch(err => console.error('Error removing item:', err));
        }
        function addToCart(itemName, customerEmail) {
            fetch(`/cart/add_item`, {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({
                    email: customerEmail,
                    item_name: itemName.trim(), //Ensure the item name is trimmed
                    quantity: 0 // DEFAULT QUANTITY PASSED HERE
                })
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert("Item added/updated successfully.");
                    location.reload(); // Reload the page to update the cart
                } else {
                    alert(data.error || "Failed to add item to cart.");
                }
            })
            .catch(err => console.error("Error adding item to cart:", err));
        }
        function addSuggestion(itemId) {
            fetch(`/cart/add_suggestion/${itemId}`, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({})
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert('Item added to cart!');
                    location.reload();
                } else {
                    alert(data.error);
                }
            })
            .catch(err => console.error('Error adding suggestion:', err));
        }
        function addToCartSuggestion(itemName, itemPrice, itemImage, itemId) {
            const customerEmail = "{{ customer_email }}"; // Get customer email from session

            // Create the data object to send to the server
            const data = {
                item_name: itemName,
                item_price: itemPrice,
                item_image: itemImage,
                item_id: itemId,
                addons: [], // Default to empty, you can adjust if needed
                instructions: "", // Default to empty, you can adjust if needed
                customer_email: customerEmail
            };

            // Send the data to the backend via a POST request
            fetch('/cart/add_suggestion_to_cart', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(data)
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    alert('Item added to cart!');
                    location.reload(); // Reload to update the cart view
                } else {
                    alert('Error adding item to cart: ' + data.error);
                }
            })
            .catch(err => console.error('Error adding item:', err));
        }


        
        
    </script>

</body>
</html>