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
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
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hamilton Christian School - Space Booking</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>
        .hidden {
            display: none;
        }
        
        .calendar-day {
            transition: all 0.2s ease;
        }
        
        .calendar-day:hover:not(.disabled):not(.booked) {
            background-color: #f0f9ff;
            cursor: pointer;
        }
        
        .booking-card {
            transition: all 0.3s ease;
        }
        
        .booking-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        
        #login {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(255, 255, 255, 0.9);
            z-index: 1000;
            overflow-y: auto;
        }
        
        .room-image {
            height: 200px;
            object-fit: cover;
        }
        
        @media (max-width: 768px) {
            .room-image {
                height: 150px;
            }
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Navigation Bar -->
    <nav class="bg-blue-800 text-white shadow-lg">
        <div class="container mx-auto px-4 py-3 flex justify-between items-center">
            <div class="flex items-center space-x-4">
                <a href="#" id="home-link" class="text-xl font-bold hover:text-blue-200 transition">HCS Booking</a>
                <a href="#" id="back-link" class="hidden hover:text-blue-200 transition">
                    <i class="fas fa-arrow-left mr-1"></i> Back
                </a>
            </div>
            <div id="logout-container" class="hidden">
                <button id="logout-btn" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded transition">
                    <i class="fas fa-sign-out-alt mr-1"></i> Logout
                </button>
            </div>
        </div>
    </nav>

    <!-- Main Content Area -->
    <main class="container mx-auto px-4 py-8">
        <!-- Homepage - Booking Area Selection -->
        <section id="homepage" class="page">
            <h1 class="text-3xl md:text-4xl font-bold text-gray-800 mb-8">Book a Space at Hamilton Christian School</h1>
            
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                <!-- Fields Card -->
                <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition">
                    <div class="bg-green-600 h-40 flex items-center justify-center">
                        <i class="fas fa-futbol text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Fields</h3>
                        <p class="text-gray-600 mb-4">Book our outdoor sports fields for games and practices.</p>
                        <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="fields">
                            View Fields <i class="fas fa-arrow-right ml-1"></i>
                        </button>
                    </div>
                </div>
                
                <!-- Classrooms Card -->
                <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition">
                    <div class="bg-blue-600 h-40 flex items-center justify-center">
                        <i class="fas fa-chalkboard text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Classrooms</h3>
                        <p class="text-gray-600 mb-4">Book classrooms for meetings, events, or study sessions.</p>
                        <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="classrooms">
                            View Classrooms <i class="fas fa-arrow-right ml-1"></i>
                        </button>
                    </div>
                </div>
                
                <!-- MPR/Library Card -->
                <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition">
                    <div class="bg-purple-600 h-40 flex items-center justify-center">
                        <i class="fas fa-book-open text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">MPR/Library</h3>
                        <p class="text-gray-600 mb-4">Book our Multi-Purpose Room or Library for larger events.</p>
                        <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="mpr-library">
                            View Spaces <i class="fas fa-arrow-right ml-1"></i>
                        </button>
                    </div>
                </div>
                
                <!-- Courts Card -->
                <div class="booking-card bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition">
                    <div class="bg-red-600 h-40 flex items-center justify-center">
                        <i class="fas fa-basketball-ball text-white text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">Courts</h3>
                        <p class="text-gray-600 mb-4">Book our basketball or tennis courts for games and practice.</p>
                        <button class="book-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-type="courts">
                            View Courts <i class="fas fa-arrow-right ml-1"></i>
                        </button>
                    </div>
                </div>
            </div>
        </section>

        <!-- Space Selection Pages -->
        <section id="space-selection" class="page hidden">
            <div class="flex justify-between items-center mb-8">
                <h2 id="space-title" class="text-2xl md:text-3xl font-bold text-gray-800"></h2>
                <div class="flex space-x-2">
                    <button id="prev-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition">
                        <i class="fas fa-chevron-left"></i>
                    </button>
                    <button id="next-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition">
                        <i class="fas fa-chevron-right"></i>
                    </button>
                </div>
            </div>
            
            <div id="space-content" class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <!-- Space items will be dynamically inserted here -->
            </div>
        </section>

        <!-- Room Details Page -->
        <section id="room-details" class="page hidden">
            <div class="flex justify-between items-center mb-6">
                <h2 id="room-title" class="text-2xl md:text-3xl font-bold text-gray-800"></h2>
                <div class="flex space-x-2">
                    <button id="room-prev-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition">
                        <i class="fas fa-chevron-left"></i>
                    </button>
                    <span id="room-current-month" class="px-3 py-1 font-medium"></span>
                    <button id="room-next-month" class="px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 transition">
                        <i class="fas fa-chevron-right"></i>
                    </button>
                </div>
            </div>
            
            <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                <div>
                    <div class="bg-white rounded-lg shadow-md overflow-hidden mb-6">
                        <img id="room-main-image" src="https://via.placeholder.com/800x400?text=Room+Image" alt="Room Image" class="w-full room-image">
                        <div class="p-6">
                            <h3 class="text-xl font-semibold mb-2" id="room-name"></h3>
                            <p class="text-gray-600 mb-4" id="room-description"></p>
                            <div class="grid grid-cols-2 gap-4 mb-4">
                                <div>
                                    <span class="block text-sm text-gray-500">Capacity</span>
                                    <span class="font-medium" id="room-capacity"></span>
                                </div>
                                <div>
                                    <span class="block text-sm text-gray-500">Type</span>
                                    <span class="font-medium" id="room-type"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-2 gap-4 mb-8">
                        <img src="https://via.placeholder.com/400x300?text=Inside+View" alt="Inside View" class="rounded shadow room-image">
                        <img src="https://via.placeholder.com/400x300?text=Outside+View" alt="Outside View" class="rounded shadow room-image">
                    </div>
                </div>
                
                <div>
                    <div class="bg-white rounded-lg shadow-md p-6 mb-6">
                        <h3 class="text-xl font-semibold mb-4">Availability Calendar</h3>
                        <div id="room-calendar" class="grid grid-cols-7 gap-1 mb-4">
                            <!-- Calendar days will be inserted here -->
                        </div>
                        
                        <div class="mb-6">
                            <h4 class="font-medium mb-2">Available Time Slots</h4>
                            <div id="time-slots" class="grid grid-cols-2 md:grid-cols-3 gap-2">
                                <!-- Time slots will be inserted here -->
                            </div>
                        </div>
                        
                        <div id="booking-form" class="hidden">
                            <h4 class="font-medium mb-2">Book This Room</h4>
                            <div class="space-y-4">
                                <div>
                                    <label class="block text-sm text-gray-600 mb-1">Selected Date</label>
                                    <input type="text" id="booking-date" class="w-full p-2 border rounded" readonly>
                                </div>
                                <div>
                                    <label class="block text-sm text-gray-600 mb-1">Time Slot</label>
                                    <input type="text" id="booking-time" class="w-full p-2 border rounded" readonly>
                                </div>
                                <div>
                                    <label for="booking-purpose" class="block text-sm text-gray-600 mb-1">Purpose</label>
                                    <input type="text" id="booking-purpose" class="w-full p-2 border rounded" placeholder="Meeting, Event, etc.">
                                </div>
                                <div class="flex space-x-4">
                                    <button id="confirm-booking" class="flex-1 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition">
                                        Confirm Booking
                                    </button>
                                    <button id="cancel-booking" class="flex-1 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300 transition">
                                        Cancel
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div id="my-bookings" class="bg-white rounded-lg shadow-md p-6 hidden">
                        <h3 class="text-xl font-semibold mb-4">My Bookings</h3>
                        <div id="bookings-list">
                            <!-- User's bookings will be inserted here -->
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Login Page (hidden by default) -->
    <section id="login" class="page hidden">
        <div class="bg-blue-800 text-white py-12">
            <div class="container mx-auto px-4">
                <h1 class="text-3xl md:text-4xl font-bold">Login to Your Account</h1>
                <p class="text-xl mt-2">Access your bookings and account details</p>
            </div>
        </div>

        <div class="container mx-auto px-4 py-12">
            <div class="max-w-md mx-auto bg-white p-8 rounded-lg shadow-md">
                <form id="login-form" class="space-y-6">
                    <div>
                        <label for="login-email" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
                        <input type="email" id="login-email" class="w-full p-3 border rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                    <div>
                        <label for="login-password" class="block text-sm font-medium text-gray-700 mb-1">Password</label>
                        <input type="password" id="login-password" class="w-full p-3 border rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                    </div>
                    <div class="flex items-center justify-between">
                        <div class="flex items-center">
                            <input type="checkbox" id="remember-me" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
                            <label for="remember-me" class="ml-2 block text-sm text-gray-700">Remember me</label>
                        </div>
                        <a href="#" class="text-sm text-blue-600 hover:text-blue-800">Forgot password?</a>
                    </div>
                    <div>
                        <button type="submit" class="w-full py-3 px-4 bg-blue-600 text-white rounded hover:bg-blue-700 transition duration-300">
                            Login
                        </button>
                    </div>
                    <div class="text-center">
                        <p class="text-sm text-gray-600">Don't have an account? <a href="#" class="text-blue-600 hover:text-blue-800">Create one</a></p>
                    </div>
                </form>
                
                <div class="mt-6">
                    <div class="relative">
                        <div class="absolute inset-0 flex items-center">
                            <div class="w-full border-t border-gray-300"></div>
                        </div>
                        <div class="relative flex justify-center text-sm">
                            <span class="px-2 bg-white text-gray-500">Or continue with</span>
                        </div>
                    </div>

                    <div class="mt-6 grid grid-cols-1 gap-3">
                        <button id="google-login" class="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 hover:bg-gray-50">
                            <i class="fab fa-google text-red-500 mr-2"></i> Sign in with Google
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Toast Notification -->
    <div id="toast" class="fixed bottom-4 right-4 bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg hidden">
        <div class="flex items-center">
            <i class="fas fa-check-circle mr-2"></i>
            <span id="toast-message"></span>
        </div>
    </div>

    <script>
        // State management
        const state = {
            currentUser: null,
            currentPage: 'homepage',
            currentSpaceType: null,
            currentRoom: null,
            currentMonth: new Date().getMonth(),
            currentYear: new Date().getFullYear(),
            bookings: JSON.parse(localStorage.getItem('bookings')) || [],
            selectedDate: null,
            selectedTime: null,
            loginRedirect: null
        };

        // DOM Elements
        const pages = document.querySelectorAll('.page');
        const homeLink = document.getElementById('home-link');
        const backLink = document.getElementById('back-link');
        const logoutContainer = document.getElementById('logout-container');
        const logoutBtn = document.getElementById('logout-btn');
        const bookBtns = document.querySelectorAll('.book-btn');
        const spaceSelectionPage = document.getElementById('space-selection');
        const spaceTitle = document.getElementById('space-title');
        const spaceContent = document.getElementById('space-content');
        const prevMonthBtn = document.getElementById('prev-month');
        const nextMonthBtn = document.getElementById('next-month');
        const roomDetailsPage = document.getElementById('room-details');
        const roomTitle = document.getElementById('room-title');
        const roomName = document.getElementById('room-name');
        const roomDescription = document.getElementById('room-description');
        const roomCapacity = document.getElementById('room-capacity');
        const roomType = document.getElementById('room-type');
        const roomMainImage = document.getElementById('room-main-image');
        const roomCalendar = document.getElementById('room-calendar');
        const roomCurrentMonth = document.getElementById('room-current-month');
        const roomPrevMonthBtn = document.getElementById('room-prev-month');
        const roomNextMonthBtn = document.getElementById('room-next-month');
        const timeSlots = document.getElementById('time-slots');
        const bookingForm = document.getElementById('booking-form');
        const bookingDate = document.getElementById('booking-date');
        const bookingTime = document.getElementById('booking-time');
        const bookingPurpose = document.getElementById('booking-purpose');
        const confirmBookingBtn = document.getElementById('confirm-booking');
        const cancelBookingBtn = document.getElementById('cancel-booking');
        const myBookingsSection = document.getElementById('my-bookings');
        const bookingsList = document.getElementById('bookings-list');
        const loginPage = document.getElementById('login');
        const loginForm = document.getElementById('login-form');
        const loginEmail = document.getElementById('login-email');
        const loginPassword = document.getElementById('login-password');
        const googleLoginBtn = document.getElementById('google-login');
        const toast = document.getElementById('toast');
        const toastMessage = document.getElementById('toast-message');

        // Initialize the app
        function init() {
            // Check if user is logged in from localStorage
            const savedUser = localStorage.getItem('currentUser');
            if (savedUser) {
                state.currentUser = JSON.parse(savedUser);
                logoutContainer.classList.remove('hidden');
            }

            // Set up event listeners
            homeLink.addEventListener('click', showHomepage);
            backLink.addEventListener('click', goBack);
            logoutBtn.addEventListener('click', handleLogout);
            
            bookBtns.forEach(btn => {
                btn.addEventListener('click', () => {
                    const spaceType = btn.getAttribute('data-type');
                    showSpaceSelection(spaceType);
                });
            });
            
            prevMonthBtn.addEventListener('click', () => {
                if (state.currentMonth === 0) {
                    state.currentMonth = 11;
                    state.currentYear--;
                } else {
                    state.currentMonth--;
                }
                renderSpaceSelection();
            });
            
            nextMonthBtn.addEventListener('click', () => {
                if (state.currentMonth === 11) {
                    state.currentMonth = 0;
                    state.currentYear++;
                } else {
                    state.currentMonth++;
                }
                renderSpaceSelection();
            });
            
            roomPrevMonthBtn.addEventListener('click', () => {
                if (state.currentMonth === 0) {
                    state.currentMonth = 11;
                    state.currentYear--;
                } else {
                    state.currentMonth--;
                }
                renderRoomDetails();
            });
            
            roomNextMonthBtn.addEventListener('click', () => {
                if (state.currentMonth === 11) {
                    state.currentMonth = 0;
                    state.currentYear++;
                } else {
                    state.currentMonth++;
                }
                renderRoomDetails();
            });
            
            confirmBookingBtn.addEventListener('click', handleConfirmBooking);
            cancelBookingBtn.addEventListener('click', () => {
                bookingForm.classList.add('hidden');
                state.selectedDate = null;
                state.selectedTime = null;
            });
            
            loginForm.addEventListener('submit', handleLogin);
            googleLoginBtn.addEventListener('click', handleGoogleLogin);
            
            // Show homepage by default
            showPage('homepage');
        }

        // Page navigation functions
        function showPage(pageId) {
            pages.forEach(page => {
                if (page.id === pageId) {
                    page.classList.remove('hidden');
                    state.currentPage = pageId;
                } else {
                    page.classList.add('hidden');
                }
            });
            
            // Update navigation buttons
            if (pageId === 'homepage') {
                backLink.classList.add('hidden');
            } else if (pageId === 'space-selection') {
                backLink.classList.remove('hidden');
            } else if (pageId === 'room-details') {
                backLink.classList.remove('hidden');
            }
            
            // Update logout button visibility
            if (state.currentUser) {
                logoutContainer.classList.remove('hidden');
            } else {
                logoutContainer.classList.add('hidden');
            }
        }

        function showHomepage(e) {
            if (e) e.preventDefault();
            showPage('homepage');
        }

        function showSpaceSelection(spaceType) {
            state.currentSpaceType = spaceType;
            
            // Set title based on space type
            let title = '';
            switch (spaceType) {
                case 'fields':
                    title = 'Sports Fields';
                    break;
                case 'classrooms':
                    title = 'Classrooms';
                    break;
                case 'mpr-library':
                    title = 'MPR & Library';
                    break;
                case 'courts':
                    title = 'Sports Courts';
                    break;
            }
            
            spaceTitle.textContent = title;
            renderSpaceSelection();
            showPage('space-selection');
        }

        function showRoomDetails(room) {
            state.currentRoom = room;
            roomTitle.textContent = room.name;
            roomName.textContent = room.name;
            roomDescription.textContent = room.description;
            roomCapacity.textContent = room.capacity;
            roomType.textContent = room.type;
            roomMainImage.src = room.image;
            
            renderRoomDetails();
            showPage('room-details');
        }

        function goBack(e) {
            if (e) e.preventDefault();
            
            if (state.currentPage === 'space-selection') {
                showHomepage();
            } else if (state.currentPage === 'room-details') {
                showSpaceSelection(state.currentSpaceType);
            }
        }

        // Render functions
        function renderSpaceSelection() {
            spaceContent.innerHTML = '';
            
            // Get spaces based on current space type
            const spaces = getSpacesForType(state.currentSpaceType);
            
            spaces.forEach(space => {
                const spaceElement = document.createElement('div');
                spaceElement.className = 'bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition cursor-pointer';
                spaceElement.innerHTML = `
                    <div class="h-40 bg-blue-100 flex items-center justify-center">
                        <i class="${space.icon} text-blue-600 text-6xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-semibold text-gray-800 mb-2">${space.name}</h3>
                        <p class="text-gray-600 mb-4">${space.description}</p>
                        <button class="view-space-btn w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition" data-id="${space.id}">
                            View Details <i class="fas fa-arrow-right ml-1"></i>
                        </button>
                    </div>
                `;
                
                spaceContent.appendChild(spaceElement);
            });
            
            // Add event listeners to view buttons
            document.querySelectorAll('.view-space-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const spaceId = btn.getAttribute('data-id');
                    const space = getSpaceById(spaceId);
                    showRoomDetails(space);
                });
            });
        }

        function renderRoomDetails() {
            // Update month display
            const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
            roomCurrentMonth.textContent = `${monthNames[state.currentMonth]} ${state.currentYear}`;
            
            // Render calendar
            renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id);
            
            // Show user's bookings if logged in
            if (state.currentUser) {
                myBookingsSection.classList.remove('hidden');
                renderUserBookings();
            } else {
                myBookingsSection.classList.add('hidden');
            }
            
            // Clear time slots and booking form
            timeSlots.innerHTML = '';
            bookingForm.classList.add('hidden');
        }

        function renderCalendar(container, year, month, roomId) {
            container.innerHTML = '';
            
            // Add day headers
            const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            dayNames.forEach(day => {
                const dayHeader = document.createElement('div');
                dayHeader.className = 'text-center font-medium text-sm py-1';
                dayHeader.textContent = day;
                container.appendChild(dayHeader);
            });
            
            // Get first day of month and total days
            const firstDay = new Date(year, month, 1).getDay();
            const daysInMonth = new Date(year, month + 1, 0).getDate();
            
            // Add empty cells for days before first day
            for (let i = 0; i < firstDay; i++) {
                const emptyCell = document.createElement('div');
                emptyCell.className = 'h-10';
                container.appendChild(emptyCell);
            }
            
            // Add day cells
            const today = new Date();
            today.setHours(0, 0, 0, 0);
            
            for (let day = 1; day <= daysInMonth; day++) {
                const date = new Date(year, month, day);
                const dayCell = document.createElement('div');
                dayCell.className = 'calendar-day text-center p-1 h-10 border rounded';
                
                // Check if date is in the past or less than 5 days ahead
                const minBookingDate = new Date();
                minBookingDate.setDate(minBookingDate.getDate() + 5);
                minBookingDate.setHours(0, 0, 0, 0);
                
                if (date < minBookingDate) {
                    dayCell.classList.add('disabled', 'bg-gray-100', 'text-gray-400');
                } else {
                    // Check if date is booked
                    const isBooked = state.bookings.some(booking => {
                        const bookingDate = new Date(booking.date);
                        return (
                            booking.roomId === roomId &&
                            bookingDate.getFullYear() === year &&
                            bookingDate.getMonth() === month &&
                            bookingDate.getDate() === day
                        );
                    });
                    
                    if (isBooked) {
                        dayCell.classList.add('booked', 'bg-red-100', 'text-red-800');
                    }
                }
                
                dayCell.textContent = day;
                
                // Add click event for selectable days
                if (!dayCell.classList.contains('disabled') && !dayCell.classList.contains('booked')) {
                    dayCell.addEventListener('click', () => handleDateSelect(year, month, day, roomId));
                }
                
                container.appendChild(dayCell);
            }
        }

        function handleDateSelect(year, month, day, roomId) {
            state.selectedDate = new Date(year, month, day);
            
            // Format date for display
            const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
            bookingDate.value = state.selectedDate.toLocaleDateString('en-US', options);
            
            // Generate time slots (9am to 5pm in 1-hour increments)
            timeSlots.innerHTML = '';
            const startHour = 9;
            const endHour = 17;
            
            for (let hour = startHour; hour < endHour; hour++) {
                const timeSlot = document.createElement('button');
                timeSlot.className = 'py-2 bg-green-100 text-green-800 rounded hover:bg-green-200 transition';
                timeSlot.textContent = `${hour}:00 - ${hour + 1}:00`;
                
                timeSlot.addEventListener('click', () => {
                    // Remove active class from all time slots
                    document.querySelectorAll('#time-slots button').forEach(btn => {
                        btn.classList.remove('bg-green-500', 'text-white');
                        btn.classList.add('bg-green-100', 'text-green-800');
                    });
                    
                    // Add active class to selected time slot
                    timeSlot.classList.remove('bg-green-100', 'text-green-800');
                    timeSlot.classList.add('bg-green-500', 'text-white');
                    
                    state.selectedTime = `${hour}:00 - ${hour + 1}:00`;
                    bookingTime.value = state.selectedTime;
                    
                    // Show booking form
                    bookingForm.classList.remove('hidden');
                });
                
                timeSlots.appendChild(timeSlot);
            }
        }

        function renderUserBookings() {
            if (!state.currentUser) return;
            
            const userBookings = state.bookings.filter(
                booking => booking.userId === state.currentUser.id && booking.roomId === state.currentRoom.id
            );
            
            if (userBookings.length === 0) {
                bookingsList.innerHTML = '<p class="text-gray-500">You have no bookings for this room.</p>';
                return;
            }
            
            bookingsList.innerHTML = '';
            
            userBookings.forEach(booking => {
                const bookingElement = document.createElement('div');
                bookingElement.className = 'border-b border-gray-200 py-4';
                bookingElement.innerHTML = `
                    <div class="flex justify-between items-start">
                        <div>
                            <h4 class="font-medium">${new Date(booking.date).toLocaleDateString()}</h4>
                            <p class="text-sm text-gray-600">${booking.time}</p>
                            <p class="text-sm mt-1">${booking.purpose}</p>
                        </div>
                        <div>
                            <button class="edit-booking-btn px-3 py-1 bg-blue-100 text-blue-600 rounded hover:bg-blue-200 transition text-sm mr-2" data-id="${booking.id}">
                                <i class="fas fa-edit mr-1"></i> Edit
                            </button>
                            <button class="cancel-booking-btn px-3 py-1 bg-red-100 text-red-600 rounded hover:bg-red-200 transition text-sm" data-id="${booking.id}">
                                <i class="fas fa-trash-alt mr-1"></i> Cancel
                            </button>
                        </div>
                    </div>
                `;
                
                bookingsList.appendChild(bookingElement);
            });
            
            // Add event listeners to edit and cancel buttons
            document.querySelectorAll('.edit-booking-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const bookingId = btn.getAttribute('data-id');
                    promptLoginIfNeeded(() => {
                        const booking = state.bookings.find(b => b.id === bookingId);
                        if (booking) {
                            editBooking(booking);
                        }
                    });
                });
            });
            
            document.querySelectorAll('.cancel-booking-btn').forEach(btn => {
                btn.addEventListener('click', () => {
                    const bookingId = btn.getAttribute('data-id');
                    promptLoginIfNeeded(() => {
                        cancelBooking(bookingId);
                    });
                });
            });
        }

        // Booking functions
        function handleConfirmBooking() {
            if (!state.currentUser) {
                showToast('Please login to make a booking');
                return;
            }
            
            if (!state.selectedDate || !state.selectedTime) {
                showToast('Please select a date and time');
                return;
            }
            
            const purpose = bookingPurpose.value.trim();
            if (!purpose) {
                showToast('Please enter a purpose for your booking');
                return;
            }
            
            // Create new booking
            const newBooking = {
                id: generateId(),
                userId: state.currentUser.id,
                roomId: state.currentRoom.id,
                date: state.selectedDate.toISOString(),
                time: state.selectedTime,
                purpose: purpose,
                createdAt: new Date().toISOString()
            };
            
            // Add to bookings array
            state.bookings.push(newBooking);
            saveBookings();
            
            // Reset form and show success message
            bookingForm.classList.add('hidden');
            bookingPurpose.value = '';
            state.selectedDate = null;
            state.selectedTime = null;
            
            showToast('Booking confirmed successfully!');
            
            // Refresh calendar and bookings list
            renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id);
            renderUserBookings();
        }

        function editBooking(booking) {
            // For simplicity, we'll just allow canceling and creating a new booking
            // In a real app, you would have a proper edit form
            state.selectedDate = new Date(booking.date);
            state.selectedTime = booking.time;
            bookingPurpose.value = booking.purpose;
            
            // Format date for display
            const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
            bookingDate.value = state.selectedDate.toLocaleDateString('en-US', options);
            bookingTime.value = state.selectedTime;
            
            // Show booking form
            bookingForm.classList.remove('hidden');
            
            // Scroll to form
            bookingForm.scrollIntoView({ behavior: 'smooth' });
        }

        function cancelBooking(bookingId) {
            if (confirm('Are you sure you want to cancel this booking?')) {
                state.bookings = state.bookings.filter(booking => booking.id !== bookingId);
                saveBookings();
                showToast('Booking canceled successfully');
                
                // Refresh calendar and bookings list
                renderCalendar(roomCalendar, state.currentYear, state.currentMonth, state.currentRoom.id);
                renderUserBookings();
            }
        }

        // Auth functions
        function handleLogin(e) {
            e.preventDefault();
            
            const email = loginEmail.value.trim();
            const password = loginPassword.value.trim();
            
            // Simple validation
            if (!email || !password) {
                showToast('Please enter both email and password');
                return;
            }
            
            // Check if it's a Gmail account
            if (!email.endsWith('@gmail.com')) {
                showToast('Please use a Gmail account to login');
                return;
            }
            
            // For demo purposes, any password works
            state.currentUser = {
                id: generateId(),
                email: email,
                name: email.split('@')[0]
            };
            
            // Save to localStorage if "Remember me" is checked
            if (document.getElementById('remember-me').checked) {
                localStorage.setItem('currentUser', JSON.stringify(state.currentUser));
            }
            
            // Hide login page
            loginPage.classList.add('hidden');
            
            // Show success message
            showToast('Login successful!');
            
            // Update UI
            logoutContainer.classList.remove('hidden');
            
            // If there was a redirect, go to that page
            if (state.loginRedirect) {
                state.loginRedirect();
                state.loginRedirect = null;
            } else {
                // Otherwise refresh current page
                if (state.currentPage === 'room-details') {
                    renderRoomDetails();
                }
            }
        }

        function handleGoogleLogin() {
            // Simulate Google login
            state.currentUser = {
                id: generateId(),
                email: 'demo@gmail.com',
                name: 'Demo User'
            };
            
            // Save to localStorage
            localStorage.setItem('currentUser', JSON.stringify(state.currentUser));
            
            // Hide login page
            loginPage.classList.add('hidden');
            
            // Show success message
            showToast('Google login successful!');
            
            // Update UI
            logoutContainer.classList.remove('hidden');
            
            // If there was a redirect, go to that page
            if (state.loginRedirect) {
                state.loginRedirect();
                state.loginRedirect = null;
            } else {
                // Otherwise refresh current page
                if (state.currentPage === 'room-details') {
                    renderRoomDetails();
                }
            }
        }

        function handleLogout() {
            if (confirm('Are you sure you want to log out?')) {
                state.currentUser = null;
                localStorage.removeItem('currentUser');
                logoutContainer.classList.add('hidden');
                showToast('Logout complete.');
                
                // If on room details page, refresh to update UI
                if (state.currentPage === 'room-details') {
                    renderRoomDetails();
                }
            }
        }

        function promptLoginIfNeeded(action) {
            if (!state.currentUser) {
                state.loginRedirect = action;
                loginPage.classList.remove('hidden');
            } else {
                action();
            }
        }

        // Helper functions
        function getSpacesForType(type) {
            switch (type) {
                case 'fields':
                    return [
                        { id: 'field1', name: 'Main Sports Field', description: 'Grass field suitable for soccer, rugby, and other field sports', icon: 'fas fa-futbol', capacity: '100 people', type: 'Outdoor Field', image: 'https://via.placeholder.com/800x400?text=Main+Sports+Field' },
                        { id: 'field2', name: 'Secondary Field', description: 'Smaller grass field for practice sessions', icon: 'fas fa-running', capacity: '50 people', type: 'Outdoor Field', image: 'https://via.placeholder.com/800x400?text=Secondary+Field' }
                    ];
                case 'classrooms':
                    return [
                        { id: 'b-block', name: 'B Block', description: 'Classrooms B1-B5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=B+Block' },
                        { id: 'c-block', name: 'C Block', description: 'Classrooms C1-C5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=C+Block' },
                        { id: 'd-block', name: 'D Block', description: 'Classrooms D1-D5', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=D+Block' },
                        { id: 'e-block', name: 'E Block', description: 'Classrooms E1-E3', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=E+Block' },
                        { id: 'f-block', name: 'F Block', description: 'F1 (Library), F2 (MPR), F3-F4', icon: 'fas fa-book', capacity: 'Varies', type: 'Mixed Use', image: 'https://via.placeholder.com/800x400?text=F+Block' },
                        { id: 'i-block', name: 'I Block', description: 'Upper and Down classrooms', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=I+Block' },
                        { id: 'j-block', name: 'J Block', description: 'Upper and Down classrooms', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=J+Block' },
                        { id: 's-block', name: 'S Block', description: 'Classrooms S1-S3', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=S+Block' },
                        { id: 't-block', name: 'T Block', description: 'Classrooms T1-T7', icon: 'fas fa-chalkboard-teacher', capacity: '25-30 students', type: 'Classroom Block', image: 'https://via.placeholder.com/800x400?text=T+Block' }
                    ];
                case 'mpr-library':
                    return [
                        { id: 'mpr', name: 'Multi-Purpose Room', description: 'Large space for events, presentations, and gatherings', icon: 'fas fa-users', capacity: '100 people', type: 'Event Space', image: 'https://via.placeholder.com/800x400?text=Multi-Purpose+Room' },
                        { id: 'library', name: 'Library', description: 'School library with study spaces', icon: 'fas fa-book-reader', capacity: '50 people', type: 'Study Space', image: 'https://via.placeholder.com/800x400?text=Library' }
                    ];
                case 'courts':
                    return [
                        { id: 'basketball1', name: 'Basketball Court 1', description: 'Main basketball court with bleachers', icon: 'fas fa-basketball-ball', capacity: '30 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Basketball+Court+1' },
                        { id: 'basketball2', name: 'Basketball Court 2', description: 'Secondary basketball court', icon: 'fas fa-basketball-ball', capacity: '30 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Basketball+Court+2' },
                        { id: 'tennis', name: 'Tennis Court', description: 'Outdoor tennis court', icon: 'fas fa-table-tennis', capacity: '4 people', type: 'Sports Court', image: 'https://via.placeholder.com/800x400?text=Tennis+Court' }
                    ];
                default:
                    return [];
            }
        }

        function getSpaceById(id) {
            const spaces = getSpacesForType(state.currentSpaceType);
            return spaces.find(space => space.id === id);
        }

        function saveBookings() {
            localStorage.setItem('bookings', JSON.stringify(state.bookings));
        }

        function generateId() {
            return Math.random().toString(36).substr(2, 9);
        }

        function showToast(message) {
            toastMessage.textContent = message;
            toast.classList.remove('hidden');
            
            setTimeout(() => {
                toast.classList.add('hidden');
            }, 3000);
        }

        // Initialize the app when DOM is loaded
        document.addEventListener('DOMContentLoaded', init);
    </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=davphi17/freespace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>