-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
1889 lines (1751 loc) · 127 KB
/
Copy pathadmin.html
File metadata and controls
1889 lines (1751 loc) · 127 KB
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
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
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Admin Dashboard | Kamal Optiks</title>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap"
rel="stylesheet">
<script>
// Immediate auth check
const token = localStorage.getItem('adminToken');
if (!token) {
window.location.href = '/admin-login.html';
}
</script>
<!-- Styles -->
<link rel="stylesheet" href="/src/css/style.css" />
</head>
<body class="bg-[#FAFAFA] text-primary" x-data="adminPage">
<div id="full-page-loader" class="fixed inset-0 z-[9999] flex items-center justify-center bg-white transition-opacity duration-500">
<div class="flex flex-col items-center gap-4">
<img src="/src/assets/kamla-optics-logo.png" alt="Loading..." class="w-32 animate-pulse">
</div>
</div>
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<aside
class="w-64 bg-[#111111] border-r border-neutral-900 flex-shrink-0 flex flex-col transition-all duration-300 z-20 absolute md:relative h-full"
:class="sidebarOpen ? 'translate-x-0' : '-translate-x-full md:translate-x-0'">
<div class="h-16 flex items-center px-6 border-b border-neutral-900 bg-black text-white">
<a href="#dashboard" @click.prevent="activeTab = 'dashboard'" class="flex items-center gap-2">
<img src="/src/assets/kamla-optics-logo.png" alt="Kamal Optiks Logo" class="h-6 object-contain" />
<span class="text-xs text-gray-400 uppercase tracking-widest ml-1 font-semibold">Admin</span>
</a>
<button @click="sidebarOpen = false"
class="ml-auto md:hidden text-gray-400 hover:text-white cursor-pointer p-1 rounded-lg hover:bg-neutral-900">
<i data-lucide="x" class="w-5 h-5"></i>
</button>
</div>
<div class="overflow-y-auto flex-1 p-4">
<nav class="space-y-1.5">
<a href="#dashboard" @click.prevent="activeTab = 'dashboard'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'dashboard' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="layout-dashboard"
class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i> Dashboard
</a>
<a href="#products" @click.prevent="activeTab = 'products'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'products' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="package" class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i>
Products
</a>
<a href="#categories" @click.prevent="activeTab = 'categories'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'categories' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="list" class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i>
Categories
</a>
<a href="#brands" @click.prevent="activeTab = 'brands'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'brands' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="tag" class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i> Brands
</a>
<a href="#orders" @click.prevent="activeTab = 'orders'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'orders' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="shopping-cart" class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i>
Orders
</a>
<a href="#settings" @click.prevent="activeTab = 'settings'"
class="flex items-center gap-3 px-4 py-3 rounded-xl font-medium transition-all duration-200 cursor-pointer group"
:class="activeTab === 'settings' ? 'bg-neutral-800 text-white shadow-sm' : 'hover:bg-neutral-900/50 hover:translate-x-1 text-gray-400 hover:text-white'">
<i data-lucide="settings" class="w-5 h-5 transition-transform duration-200 group-hover:scale-110"></i>
Settings
</a>
<a href="#" @click.prevent="logout()" class="flex items-center gap-3 px-4 py-3 mt-8 rounded-xl font-medium transition-all duration-200 text-red-400 hover:bg-red-500/10 hover:text-red-300">
<i data-lucide="log-out" class="w-5 h-5"></i>
<span>Logout</span>
</a>
</nav>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 flex flex-col h-screen overflow-hidden">
<!-- Header -->
<header class="h-16 bg-white border-b border-border flex items-center justify-between px-6 z-10 flex-shrink-0">
<div class="flex items-center">
<button @click="sidebarOpen = true"
class="p-2 mr-4 md:hidden text-gray-500 hover:text-black rounded-lg hover:bg-gray-100 cursor-pointer transition-colors">
<i data-lucide="menu" class="w-5 h-5"></i>
</button>
<h1 class="text-xl font-bold font-manrope capitalize text-gray-900 tracking-tight" x-text="activeTab"></h1>
</div>
<div class="flex items-center gap-4">
<button
class="w-9 h-9 rounded-full bg-gray-50 hover:bg-gray-100 hover:scale-105 active:scale-95 flex items-center justify-center text-gray-600 hover:text-black cursor-pointer transition-all duration-200 border border-gray-100">
<i data-lucide="bell" class="w-4.5 h-4.5"></i>
</button>
<div
class="w-9 h-9 rounded-full bg-black text-white hover:scale-105 active:scale-95 flex items-center justify-center font-bold text-sm cursor-pointer transition-all duration-200 shadow-sm border border-black/10">
AD
</div>
</div>
</header>
<!-- Content Area -->
<div class="flex-1 overflow-auto p-6 sm:p-8 bg-[#FAFAFA]">
<!-- Dashboard Tab -->
<div x-show="activeTab === 'dashboard'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0">
<!-- Statistics Grid (KPIs) -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5 mb-8">
<!-- KPI Card 1: Delivered Revenue -->
<div
@click="activeTab = 'orders'; ordersFilter = 'Delivered'"
class="bg-white border border-gray-100 p-6 rounded-2xl shadow-sm flex items-center justify-between group hover:scale-[1.02] hover:shadow-md hover:border-green-200 transition-all duration-200 cursor-pointer"
title="Click to view Delivered orders">
<div>
<p class="text-[10px] text-gray-400 font-bold uppercase tracking-wider">Delivered Revenue</p>
<h3 class="text-xl font-extrabold text-gray-900 mt-1"
x-text="'Rs. ' + (dashboardStats.revenue || 0).toLocaleString()"></h3>
<div class="flex items-center gap-1 mt-1 text-green-600 text-xs font-semibold">
<i data-lucide="check-circle" class="w-3.5 h-3.5"></i>
<span x-text="(dashboardStats.deliveredCount || 0) + ' order(s) delivered'"></span>
</div>
</div>
<div
class="w-12 h-12 bg-green-50 text-green-600 rounded-xl flex items-center justify-center border border-green-100/50 group-hover:bg-green-600 group-hover:text-white transition-colors">
<i data-lucide="dollar-sign" class="w-6 h-6"></i>
</div>
</div>
<!-- KPI Card 2: Total Orders -->
<div
@click="activeTab = 'orders'; ordersFilter = 'all'"
class="bg-white border border-gray-100 p-6 rounded-2xl shadow-sm flex items-center justify-between group hover:scale-[1.02] hover:shadow-md hover:border-blue-200 transition-all duration-200 cursor-pointer"
title="Click to view all orders">
<div>
<p class="text-[10px] text-gray-400 font-bold uppercase tracking-wider">Total Orders</p>
<h3 class="text-xl font-extrabold text-gray-900 mt-1" x-text="dashboardStats.ordersCount || 0"></h3>
<div class="flex items-center gap-1 mt-1 text-blue-600 text-xs font-semibold">
<i data-lucide="shopping-cart" class="w-3.5 h-3.5"></i>
<span x-text="(dashboardStats.pendingCount || 0) + ' pending order(s)'"></span>
</div>
</div>
<div
class="w-12 h-12 bg-blue-50 text-blue-600 rounded-xl flex items-center justify-center border border-blue-100/50 group-hover:bg-blue-600 group-hover:text-white transition-colors">
<i data-lucide="shopping-cart" class="w-5 h-5"></i>
</div>
</div>
<!-- KPI Card 3: Glasses Catalog -->
<div
@click="activeTab = 'products'"
class="bg-white border border-gray-100 p-6 rounded-2xl shadow-sm flex items-center justify-between group hover:scale-[1.02] hover:shadow-md hover:border-indigo-200 transition-all duration-200 cursor-pointer"
title="Click to manage catalog">
<div>
<p class="text-[10px] text-gray-400 font-bold uppercase tracking-wider">Eyewear Catalog</p>
<h3 class="text-xl font-extrabold text-gray-900 mt-1" x-text="dashboardStats.productsCount || 0"></h3>
<div class="flex items-center gap-1 mt-1 text-indigo-600 text-xs font-semibold">
<i data-lucide="package" class="w-3.5 h-3.5"></i>
<span>Frames & accessories</span>
</div>
</div>
<div
class="w-12 h-12 bg-indigo-50 text-indigo-600 rounded-xl flex items-center justify-center border border-indigo-100/50 group-hover:bg-indigo-600 group-hover:text-white transition-colors">
<i data-lucide="package" class="w-5 h-5"></i>
</div>
</div>
<!-- KPI Card 4: Low Stock Alert -->
<div
@click="activeTab = 'products'"
class="bg-white border border-gray-100 p-6 rounded-2xl shadow-sm flex items-center justify-between group hover:scale-[1.02] hover:shadow-md hover:border-red-200 transition-all duration-200 cursor-pointer"
title="Click to manage inventory">
<div>
<p class="text-[10px] text-gray-400 font-bold uppercase tracking-wider">Low Stock Frames</p>
<h3 class="text-xl font-extrabold text-gray-900 mt-1" x-text="dashboardStats.lowStockCount || 0"></h3>
<div class="flex items-center gap-1 mt-1 text-xs font-semibold"
:class="dashboardStats.lowStockCount > 0 ? 'text-red-500 animate-pulse' : 'text-gray-500'">
<i data-lucide="alert-circle" class="w-3.5 h-3.5"></i>
<span
x-text="dashboardStats.lowStockCount > 0 ? (dashboardStats.lowStockCount + ' frames need restock') : 'Inventory levels healthy'"></span>
</div>
</div>
<div class="w-12 h-12 rounded-xl flex items-center justify-center border group-hover:shadow transition-all"
:class="dashboardStats.lowStockCount > 0 ? 'bg-red-50 text-red-500 border-red-100/50 group-hover:bg-red-500 group-hover:text-white' : 'bg-gray-50 text-gray-400 border-gray-100'">
<i data-lucide="alert-circle" class="w-5 h-5"></i>
</div>
</div>
</div>
<!-- Full Width Recent Orders Container (Top Eyewear Models removed) -->
<div class="bg-white border border-gray-100 rounded-2xl shadow-sm overflow-hidden flex flex-col">
<div class="px-6 py-4.5 border-b border-gray-100 flex flex-wrap items-center justify-between gap-3 bg-gray-50/30">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-lg bg-black text-white flex items-center justify-center font-bold text-xs shadow-sm">
<i data-lucide="shopping-bag" class="w-4 h-4"></i>
</div>
<div>
<h3 class="text-sm font-bold text-gray-900 uppercase tracking-wider">Recent Orders</h3>
<p class="text-[11px] text-gray-500 mt-0.5">Latest customer purchases and order requests</p>
</div>
</div>
<div class="flex items-center gap-2">
<span class="text-xs bg-gray-100 text-gray-600 px-2.5 py-1 rounded-full font-medium"
x-text="(recentOrders ? recentOrders.length : 0) + ' latest order(s)'"></span>
<a href="#orders" @click.prevent="activeTab = 'orders'"
class="inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-bold text-white bg-black hover:bg-neutral-800 rounded-lg transition-colors shadow-sm cursor-pointer">
<span>View All Orders</span>
<i data-lucide="arrow-right" class="w-3.5 h-3.5"></i>
</a>
</div>
</div>
<!-- Table or Empty State -->
<div class="overflow-x-auto">
<table class="w-full text-left text-sm whitespace-nowrap" x-show="recentOrders && recentOrders.length > 0">
<thead class="bg-gray-50/75 text-gray-500 font-semibold text-xs border-b border-gray-100 uppercase tracking-wider">
<tr>
<th class="px-6 py-3.5">Order ID</th>
<th class="px-6 py-3.5">Date</th>
<th class="px-6 py-3.5">Customer</th>
<th class="px-6 py-3.5">Contact</th>
<th class="px-6 py-3.5">Items</th>
<th class="px-6 py-3.5">Total Amount</th>
<th class="px-6 py-3.5">Status</th>
<th class="px-6 py-3.5 text-right">Action</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<template x-for="order in recentOrders" :key="order.id">
<tr class="hover:bg-blue-50/30 transition-colors duration-150 cursor-pointer group"
@click="openOrderModal(order)">
<td class="px-6 py-4">
<span class="font-mono font-bold text-gray-900 group-hover:text-blue-600 transition-colors" x-text="order.id"></span>
</td>
<td class="px-6 py-4 text-xs text-gray-500" x-text="order.date || 'Recent'"></td>
<td class="px-6 py-4">
<p class="font-bold text-gray-800 leading-tight" x-text="order.customerName || 'Customer'"></p>
<p class="text-[11px] text-gray-400 mt-0.5" x-text="order.email || 'No email'"></p>
</td>
<td class="px-6 py-4 text-xs text-gray-600 font-medium" x-text="order.phone || '—'"></td>
<td class="px-6 py-4">
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-700"
x-text="(order.items ? order.items.length : 1) + ' item(s)'"></span>
</td>
<td class="px-6 py-4 font-bold text-gray-900"
x-text="'Rs. ' + (parseFloat(order.total) || 0).toLocaleString()"></td>
<td class="px-6 py-4">
<span
class="px-2.5 py-0.5 rounded-full text-[10px] font-bold tracking-wider inline-flex items-center border shadow-3xs"
:class="{
'bg-yellow-50 text-yellow-700 border-yellow-200': order.status === 'Pending',
'bg-blue-50 text-blue-700 border-blue-200': order.status === 'Processing',
'bg-indigo-50 text-indigo-700 border-indigo-200': order.status === 'Shipped',
'bg-green-50 text-green-700 border-green-200': order.status === 'Delivered',
'bg-red-50 text-red-700 border-red-200': order.status === 'Cancelled'
}" x-text="order.status"></span>
</td>
<td class="px-6 py-4 text-right">
<button type="button" @click.stop="openOrderModal(order)"
class="inline-flex items-center gap-1 px-2.5 py-1 text-xs font-semibold text-gray-700 bg-gray-100 hover:bg-black hover:text-white rounded-lg transition-colors">
<i data-lucide="eye" class="w-3.5 h-3.5"></i>
<span>Details</span>
</button>
</td>
</tr>
</template>
</tbody>
</table>
<!-- Empty State -->
<div x-show="!recentOrders || recentOrders.length === 0" class="py-14 px-6 text-center">
<div class="w-14 h-14 bg-gray-100 text-gray-400 rounded-2xl flex items-center justify-center mx-auto mb-3">
<i data-lucide="inbox" class="w-7 h-7"></i>
</div>
<h4 class="text-sm font-bold text-gray-800">No Orders Found</h4>
<p class="text-xs text-gray-400 mt-1 max-w-sm mx-auto">When new customer orders are placed, they will show up here automatically in real time.</p>
</div>
</div>
<!-- Footer Note -->
<div class="px-6 py-3.5 border-t border-gray-100 bg-gray-50/50 flex flex-wrap items-center justify-between gap-2 text-xs text-gray-500">
<p class="text-[11px] text-gray-500 font-medium">Click on any order row or "Details" to inspect customer prescription, order items, and manage fulfillment status.</p>
<a href="#orders" @click.prevent="activeTab = 'orders'" class="text-xs font-bold text-blue-600 hover:text-blue-800 transition-colors">
Open Orders Manager →
</a>
</div>
</div>
</div>
<!-- Products Tab -->
<div x-show="activeTab === 'products'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0"
style="display: none;">
<div class="flex flex-col sm:flex-row justify-between items-stretch sm:items-center gap-4 mb-6">
<div class="relative w-full sm:w-80">
<i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"></i>
<input type="text" x-model="searchQuery" placeholder="Search products by name or brand..."
class="w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 focus:outline-none focus:border-black focus:ring-1 focus:ring-black text-sm transition-all duration-200 bg-white">
</div>
<button @click="openModal()"
class="bg-black text-white px-5 py-2.5 rounded-xl text-sm font-medium hover:bg-gray-800 hover:-translate-y-0.5 active:translate-y-0 shadow-sm hover:shadow transition-all duration-200 cursor-pointer flex items-center justify-center gap-2 flex-shrink-0">
<i data-lucide="plus" class="w-4 h-4"></i> Add Product
</button>
</div>
<!-- Products Table Container -->
<div class="bg-white border border-gray-100 rounded-2xl shadow-sm overflow-hidden flex flex-col">
<div class="overflow-x-auto">
<table class="w-full text-left text-sm whitespace-nowrap">
<thead class="bg-gray-50/75 border-b border-gray-100 text-gray-500 font-medium">
<tr>
<th class="px-6 py-4.5 font-semibold">Product</th>
<th class="px-6 py-4.5 font-semibold">SKU</th>
<th class="px-6 py-4.5 font-semibold">Category</th>
<th class="px-6 py-4.5 font-semibold">Price</th>
<th class="px-6 py-4.5 font-semibold">Stock</th>
<th class="px-6 py-4.5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<template x-for="product in paginatedProducts" :key="product.id">
<tr class="hover:bg-gray-50/50 transition-colors duration-150">
<td class="px-6 py-4">
<div class="flex items-center gap-3.5">
<div
class="w-12 h-12 rounded-xl overflow-hidden bg-gray-50 border border-gray-100 flex-shrink-0 shadow-2xs">
<img :src="product.image || 'https://via.placeholder.com/150'"
class="w-full h-full object-cover">
</div>
<div>
<p class="font-bold text-gray-900 leading-tight" x-text="product.name"></p>
<p class="text-xs text-gray-400 mt-0.5 font-medium" x-text="product.brandName"></p>
</div>
</div>
</td>
<td class="px-6 py-4 text-gray-500 font-mono text-xs font-semibold" x-text="product.sku || 'N/A'">
</td>
<td class="px-6 py-4 text-gray-600 font-medium" x-text="product.categoryName"></td>
<td class="px-6 py-4">
<div class="flex flex-col">
<span class="font-bold text-gray-900"
x-text="'Rs. ' + (product.discountPrice || product.price)"></span>
<span x-show="product.discountPrice" class="text-xs text-gray-400 line-through mt-0.5"
x-text="'Rs. ' + product.price"></span>
</div>
</td>
<td class="px-6 py-4">
<span
class="px-3 py-1 rounded-full text-xs font-semibold tracking-wide inline-flex items-center"
:class="product.inStock && product.stockQuantity > 0 ? 'bg-green-50 text-green-700 border border-green-100' : 'bg-red-50 text-red-700 border border-red-100'"
x-text="(product.inStock && product.stockQuantity > 0) ? product.stockQuantity + ' in stock' : 'Out of stock'"></span>
</td>
<td class="px-6 py-4 text-right">
<div class="flex items-center justify-end gap-1">
<button @click="openModal(product)" :disabled="submittingId === product.id"
class="p-2 text-gray-400 hover:text-accent hover:bg-blue-50/50 rounded-xl transition-all duration-200 cursor-pointer hover:scale-105 active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed"
title="Edit Product">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="w-4 h-4">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
</svg>
</button>
<button @click="deleteProduct(product.id)" :disabled="submittingId === product.id"
class="p-2 text-gray-400 hover:text-red-500 hover:bg-red-50/50 rounded-xl transition-all duration-200 cursor-pointer hover:scale-105 active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed"
title="Delete Product">
<svg x-show="submittingId !== product.id" xmlns="http://www.w3.org/2000/svg" width="24"
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" class="w-4 h-4">
<path d="M3 6h18" />
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
<line x1="10" y1="11" x2="10" y2="17" />
<line x1="14" y1="11" x2="14" y2="17" />
</svg>
<i x-show="submittingId === product.id" data-lucide="loader-2"
class="w-4 h-4 animate-spin text-red-500"></i>
</button>
</div>
</td>
</tr>
</template>
<tr x-show="paginatedProducts.length === 0">
<td colspan="6" class="px-6 py-16 text-center text-gray-400 font-medium">
No products found matching your search.
</td>
</tr>
</tbody>
</table>
</div>
<!-- Pagination Controls -->
<div
class="border-t border-gray-100 px-6 py-4 flex flex-col sm:flex-row items-center justify-between gap-4 bg-gray-50/50">
<div class="text-sm text-gray-500 font-medium">
Showing <span class="text-gray-900 font-semibold"
x-text="filteredProducts.length === 0 ? 0 : ((page - 1) * itemsPerPage) + 1"></span> to
<span class="text-gray-900 font-semibold"
x-text="Math.min(page * itemsPerPage, filteredProducts.length)"></span> of
<span class="text-gray-900 font-semibold" x-text="filteredProducts.length"></span> products
</div>
<div class="flex items-center gap-2" x-show="totalPages > 1">
<button @click="page--" :disabled="page === 1"
class="p-2.5 border border-gray-200 bg-white rounded-xl hover:bg-gray-50 hover:text-black disabled:opacity-40 disabled:hover:bg-white disabled:hover:text-gray-400 disabled:cursor-not-allowed transition-all duration-200 cursor-pointer flex items-center justify-center shadow-3xs active:scale-95 disabled:active:scale-100">
<i data-lucide="chevron-left" class="w-4.5 h-4.5"></i>
</button>
<div class="flex items-center gap-1">
<template x-for="p in totalPages" :key="p">
<button @click="page = p"
class="w-9 h-9 rounded-xl text-sm font-semibold transition-all duration-200 cursor-pointer flex items-center justify-center active:scale-95"
:class="page === p ? 'bg-black text-white shadow-sm' : 'border border-gray-200 bg-white text-gray-600 hover:bg-gray-50 hover:text-black'"
x-text="p"></button>
</template>
</div>
<button @click="page++" :disabled="page === totalPages"
class="p-2.5 border border-gray-200 bg-white rounded-xl hover:bg-gray-50 hover:text-black disabled:opacity-40 disabled:hover:bg-white disabled:hover:text-gray-400 disabled:cursor-not-allowed transition-all duration-200 cursor-pointer flex items-center justify-center shadow-3xs active:scale-95 disabled:active:scale-100">
<i data-lucide="chevron-right" class="w-4.5 h-4.5"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Brands Tab -->
<div x-show="activeTab === 'brands'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0"
style="display: none;">
<div
class="bg-white rounded-2xl shadow-sm border border-gray-100/50 overflow-hidden relative z-10 flex flex-col min-h-[calc(100vh-140px)]">
<div
class="p-6 border-b border-gray-100 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 bg-gray-50/30">
<h3 class="font-bold text-gray-900 text-lg">Brands List</h3>
<button @click="openBrandModal()"
class="btn-primary py-2.5 px-4 rounded-xl flex items-center gap-2 text-sm shadow-sm hover:shadow-md transition-all cursor-pointer">
<i data-lucide="plus" class="w-4 h-4"></i> Add Brand
</button>
</div>
<div class="flex-1 overflow-x-auto">
<table class="w-full text-left border-collapse text-sm whitespace-nowrap">
<thead class="bg-gray-50/75 border-b border-gray-100 text-gray-500 font-medium">
<tr>
<th class="px-6 py-4.5 font-semibold">Name</th>
<th class="px-6 py-4.5 font-semibold">Slug</th>
<th class="px-6 py-4.5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<template x-for="brand in brands" :key="brand.id">
<tr class="hover:bg-gray-50/50 transition-colors duration-150">
<td class="px-6 py-4 font-bold text-gray-900" x-text="brand.name"></td>
<td class="px-6 py-4 text-gray-500 font-mono text-xs" x-text="brand.slug"></td>
<td class="px-6 py-4 text-right">
<div class="flex items-center justify-end gap-1">
<button @click="openBrandModal(brand)" :disabled="submittingId === 'brand_' + brand.id"
class="p-2 text-gray-400 hover:text-accent hover:bg-blue-50/50 rounded-xl transition-all duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
title="Edit Brand">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="w-4 h-4">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
</svg>
</button>
<button @click="deleteBrand(brand.id)" :disabled="submittingId === 'brand_' + brand.id"
class="p-2 text-gray-400 hover:text-red-500 hover:bg-red-50/50 rounded-xl transition-all duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
title="Delete Brand">
<svg x-show="submittingId !== 'brand_' + brand.id" xmlns="http://www.w3.org/2000/svg"
width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-4 h-4">
<path d="M3 6h18" />
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
<line x1="10" y1="11" x2="10" y2="17" />
<line x1="14" y1="11" x2="14" y2="17" />
</svg>
<i x-show="submittingId === 'brand_' + brand.id" data-lucide="loader-2"
class="w-4 h-4 animate-spin text-red-500"></i>
</button>
</div>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
</div>
<!-- Orders Tab -->
<!-- Categories Tab -->
<div x-show="activeTab === 'categories'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0"
style="display: none;">
<div
class="bg-white rounded-2xl shadow-sm border border-gray-100/50 overflow-hidden relative z-10 flex flex-col min-h-[calc(100vh-140px)]">
<div
class="p-6 border-b border-gray-100 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 bg-gray-50/30">
<h3 class="font-bold text-gray-900 text-lg">Categories List</h3>
<button @click="openCategoryModal()"
class="btn-primary py-2.5 px-4 rounded-xl flex items-center gap-2 text-sm shadow-sm hover:shadow-md transition-all cursor-pointer">
<i data-lucide="plus" class="w-4 h-4"></i> Add Category
</button>
</div>
<div class="flex-1 overflow-x-auto">
<table class="w-full text-left border-collapse text-sm whitespace-nowrap">
<thead class="bg-gray-50/75 border-b border-gray-100 text-gray-500 font-medium">
<tr>
<th class="px-6 py-4.5 font-semibold">Image</th>
<th class="px-6 py-4.5 font-semibold">Name</th>
<th class="px-6 py-4.5 font-semibold">Slug</th>
<th class="px-6 py-4.5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<template x-for="cat in categories" :key="cat.id">
<tr class="hover:bg-gray-50/50 transition-colors duration-150">
<td class="px-6 py-4">
<div
class="w-12 h-12 rounded-xl overflow-hidden bg-gray-50 border border-gray-100 flex-shrink-0 shadow-2xs">
<img :src="cat.image || 'https://via.placeholder.com/150'" class="w-full h-full object-cover">
</div>
</td>
<td class="px-6 py-4 font-bold text-gray-900" x-text="cat.name"></td>
<td class="px-6 py-4 text-gray-500 font-mono text-xs" x-text="cat.slug"></td>
<td class="px-6 py-4 text-right">
<div class="flex items-center justify-end gap-1">
<button @click="openCategoryModal(cat)" :disabled="submittingId === 'cat_' + cat.id"
class="p-2 text-gray-400 hover:text-accent hover:bg-blue-50/50 rounded-xl transition-all duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
title="Edit Category">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" class="w-4 h-4">
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
</svg>
</button>
<button @click="deleteCategory(cat.id)" :disabled="submittingId === 'cat_' + cat.id"
class="p-2 text-gray-400 hover:text-red-500 hover:bg-red-50/50 rounded-xl transition-all duration-200 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
title="Delete Category">
<svg x-show="submittingId !== 'cat_' + cat.id" xmlns="http://www.w3.org/2000/svg" width="24"
height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" class="w-4 h-4">
<path d="M3 6h18" />
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
<line x1="10" y1="11" x2="10" y2="17" />
<line x1="14" y1="11" x2="14" y2="17" />
</svg>
<i x-show="submittingId === 'cat_' + cat.id" data-lucide="loader-2"
class="w-4 h-4 animate-spin text-red-500"></i>
</button>
</div>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
</div>
<div x-show="activeTab === 'orders'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0"
style="display: none;">
<div class="flex flex-col md:flex-row justify-between items-stretch md:items-center gap-4 mb-6">
<!-- Search -->
<div class="relative w-full md:w-80">
<i data-lucide="search" class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"></i>
<input type="text" x-model="ordersSearchQuery" placeholder="Search orders by ID or customer..."
class="w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 text-sm transition-all duration-200 bg-white">
</div>
<!-- Filter Tabs -->
<div
class="flex flex-wrap items-center gap-1.5 bg-gray-100/50 p-1 rounded-xl border border-gray-200/50 self-start md:self-auto overflow-x-auto max-w-full">
<button @click="ordersFilter = 'all'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'all' ? 'bg-white text-black shadow-xs' : 'text-gray-500 hover:text-black'">All</button>
<button @click="ordersFilter = 'Pending'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'Pending' ? 'bg-yellow-500 text-white shadow-xs' : 'text-yellow-600 hover:bg-yellow-50/55'">Pending</button>
<button @click="ordersFilter = 'Processing'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'Processing' ? 'bg-blue-600 text-white shadow-xs' : 'text-blue-600 hover:bg-blue-50/50'">Processing</button>
<button @click="ordersFilter = 'Shipped'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'Shipped' ? 'bg-indigo-600 text-white shadow-xs' : 'text-indigo-600 hover:bg-indigo-50/50'">Shipped</button>
<button @click="ordersFilter = 'Delivered'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'Delivered' ? 'bg-green-600 text-white shadow-xs' : 'text-green-600 hover:bg-green-50/50'">Delivered</button>
<button @click="ordersFilter = 'Cancelled'"
class="px-3.5 py-1.5 rounded-lg text-xs font-semibold tracking-wide transition-all duration-150 cursor-pointer whitespace-nowrap"
:class="ordersFilter === 'Cancelled' ? 'bg-red-500 text-white shadow-xs' : 'text-red-500 hover:bg-red-50/50'">Cancelled</button>
</div>
</div>
<!-- Orders Table Container -->
<div class="bg-white border border-gray-100 rounded-2xl shadow-sm overflow-hidden flex flex-col">
<div class="overflow-x-auto">
<table class="w-full text-left text-sm whitespace-nowrap">
<thead class="bg-gray-50/75 border-b border-gray-100 text-gray-500 font-medium">
<tr>
<th class="px-6 py-4.5 font-semibold">Order ID</th>
<th class="px-6 py-4.5 font-semibold">Date</th>
<th class="px-6 py-4.5 font-semibold">Customer</th>
<th class="px-6 py-4.5 font-semibold">Total</th>
<th class="px-6 py-4.5 font-semibold">Status</th>
<th class="px-6 py-4.5 font-semibold text-right">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
<template x-for="order in paginatedOrders" :key="order.id">
<tr class="hover:bg-gray-50/50 transition-colors duration-150">
<td class="px-6 py-4">
<span class="font-bold text-gray-900 tracking-tight" x-text="order.id"></span>
</td>
<td class="px-6 py-4 text-gray-500 font-medium" x-text="order.date"></td>
<td class="px-6 py-4">
<div>
<p class="font-bold text-gray-900 leading-tight" x-text="order.customerName"></p>
<p class="text-xs text-gray-400 mt-0.5" x-text="order.email"></p>
</div>
</td>
<td class="px-6 py-4 font-bold text-gray-900" x-text="'Rs. ' + order.total.toLocaleString()"></td>
<td class="px-6 py-4">
<span
class="px-3 py-1 rounded-full text-xs font-semibold tracking-wide inline-flex items-center border"
:class="{
'bg-yellow-50 text-yellow-700 border-yellow-100': order.status === 'Pending',
'bg-blue-50 text-blue-700 border-blue-100': order.status === 'Processing',
'bg-indigo-50 text-indigo-700 border-indigo-100': order.status === 'Shipped',
'bg-green-50 text-green-700 border-green-100': order.status === 'Delivered',
'bg-red-50 text-red-700 border-red-100': order.status === 'Cancelled'
}" x-text="order.status"></span>
</td>
<td class="px-6 py-4 text-right flex items-center justify-end gap-2">
<button @click="openOrderModal(order)"
class="p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-xl transition-all duration-200 cursor-pointer hover:scale-105 active:scale-95 inline-flex items-center gap-1.5 font-medium text-xs border border-transparent hover:border-gray-200">
<i data-lucide="eye" class="w-4 h-4"></i> View Details
</button>
<button type="button" @click="printInvoice(order)"
class="p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-xl transition-all duration-200 cursor-pointer hover:scale-105 active:scale-95 inline-flex items-center gap-1.5 font-medium text-xs border border-transparent hover:border-gray-200" title="Print Invoice">
<i data-lucide="printer" class="w-4 h-4"></i> Print
</button>
<button type="button" @click="deleteOrder(order.id)"
class="p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-xl transition-all duration-200 cursor-pointer hover:scale-105 active:scale-95 inline-flex items-center gap-1.5 font-medium text-xs border border-transparent hover:border-red-200" title="Delete Order">
<i data-lucide="trash-2" class="w-4 h-4"></i> Delete
</button>
</td>
</tr>
</template>
<tr x-show="paginatedOrders.length === 0">
<td colspan="6" class="px-6 py-16 text-center text-gray-400 font-medium">
No orders found matching your criteria.
</td>
</tr>
</tbody>
</table>
</div>
<!-- Orders Pagination Controls -->
<div
class="border-t border-gray-100 px-6 py-4 flex flex-col sm:flex-row items-center justify-between gap-4 bg-gray-50/50">
<div class="text-sm text-gray-500 font-medium">
Showing <span class="text-gray-900 font-semibold"
x-text="filteredOrders.length === 0 ? 0 : ((ordersPage - 1) * ordersItemsPerPage) + 1"></span> to
<span class="text-gray-900 font-semibold"
x-text="Math.min(ordersPage * ordersItemsPerPage, filteredOrders.length)"></span> of
<span class="text-gray-900 font-semibold" x-text="filteredOrders.length"></span> orders
</div>
<div class="flex items-center gap-2" x-show="totalOrdersPages > 1">
<button @click="ordersPage--" :disabled="ordersPage === 1"
class="p-2.5 border border-gray-200 bg-white rounded-xl hover:bg-gray-50 hover:text-black disabled:opacity-40 disabled:hover:bg-white disabled:hover:text-gray-400 disabled:cursor-not-allowed transition-all duration-200 cursor-pointer flex items-center justify-center shadow-3xs active:scale-95 disabled:active:scale-100">
<i data-lucide="chevron-left" class="w-4.5 h-4.5"></i>
</button>
<div class="flex items-center gap-1">
<template x-for="p in totalOrdersPages" :key="p">
<button @click="ordersPage = p"
class="w-9 h-9 rounded-xl text-sm font-semibold transition-all duration-200 cursor-pointer flex items-center justify-center active:scale-95"
:class="ordersPage === p ? 'bg-black text-white shadow-sm' : 'border border-gray-200 bg-white text-gray-600 hover:bg-gray-50 hover:text-black'"
x-text="p"></button>
</template>
</div>
<button @click="ordersPage++" :disabled="ordersPage === totalOrdersPages"
class="p-2.5 border border-gray-200 bg-white rounded-xl hover:bg-gray-50 hover:text-black disabled:opacity-40 disabled:hover:bg-white disabled:hover:text-gray-400 disabled:cursor-not-allowed transition-all duration-200 cursor-pointer flex items-center justify-center shadow-3xs active:scale-95 disabled:active:scale-100">
<i data-lucide="chevron-right" class="w-4.5 h-4.5"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Other tabs placeholder -->
<!-- Settings Tab -->
<div x-show="activeTab === 'settings'" x-transition:enter="transition ease-out duration-250"
x-transition:enter-start="opacity-0 translate-y-3" x-transition:enter-end="opacity-100 translate-y-0"
style="display: none;">
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 p-6">
<h2 class="text-lg font-bold mb-4">Global Store Settings</h2>
<form @submit.prevent="saveSettings()" class="max-w-md">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Global Shipping Fee (Rs.)</label>
<input type="number" step="0.01" x-model="settings.global_shipping_fee" required
class="w-full px-4 py-2 border border-gray-200 rounded-xl focus:ring-2 focus:ring-black focus:border-black outline-none transition-all">
</div>
<button type="submit" class="bg-black text-white px-6 py-2 rounded-xl font-medium hover:bg-gray-800 transition-colors">
Save Settings
</button>
</form>
</div>
</div>
<div
x-show="activeTab !== 'products' && activeTab !== 'orders' && activeTab !== 'dashboard' && activeTab !== 'categories' && activeTab !== 'brands' && activeTab !== 'settings'"
style="display: none;">
<div class="bg-white border border-gray-100 shadow-sm rounded-2xl p-12 text-center max-w-lg mx-auto mt-8">
<div
class="w-16 h-16 bg-gray-50 rounded-full flex items-center justify-center mx-auto mb-4 border border-gray-100">
<i data-lucide="construction" class="w-8 h-8 text-gray-400"></i>
</div>
<h2 class="text-xl font-bold mb-2 text-gray-800">Under Construction</h2>
<p class="text-gray-500 text-sm">This section is not implemented in this demo panel, but is fully ready to
be connected to the backend endpoints.</p>
</div>
</div>
</div>
</main>
</div>
<!-- Add/Edit Product Modal -->
<div x-show="isModalOpen" class="fixed inset-0 z-[100] flex items-center justify-center overflow-hidden"
style="display: none;">
<div class="absolute inset-0 bg-black/50 backdrop-blur-xs transition-opacity" x-show="isModalOpen"
x-transition.opacity @click="closeModal()"></div>
<div
class="bg-white rounded-2xl w-full max-w-5xl max-h-[90vh] overflow-y-auto m-4 relative z-10 shadow-2xl flex flex-col border border-gray-100"
x-show="isModalOpen" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 scale-98 translate-y-3"
x-transition:enter-end="opacity-100 scale-100 translate-y-0" x-transition:leave="transition ease-in duration-200"
x-transition:leave-start="opacity-100 scale-100 translate-y-0"
x-transition:leave-end="opacity-0 scale-98 translate-y-3">
<div class="sticky top-0 bg-white border-b border-gray-100 px-6 py-4.5 flex items-center justify-between z-20">
<h2 class="text-lg font-bold font-manrope text-gray-900 tracking-tight"
x-text="editingProduct ? 'Edit Product Settings' : 'Create New Eyeglasses Product'"></h2>
<button @click="closeModal()"
class="p-2 text-gray-400 hover:text-black hover:bg-gray-50 rounded-full transition-colors cursor-pointer">
<i data-lucide="x" class="w-5 h-5"></i>
</button>
</div>
<form @submit.prevent="saveProduct" class="p-6 space-y-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Left Column: Details -->
<div class="space-y-4">
<div class="grid grid-cols-3 gap-4">
<div class="col-span-2">
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Product Name
*</label>
<input type="text" x-model="form.name" required
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all">
</div>
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">SKU *</label>
<input type="text" x-model="form.sku" required
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all">
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Category
*</label>
<select x-model="form.categoryId" required
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all cursor-pointer">
<option value="">Select...</option>
<template x-for="cat in categories" :key="cat.id">
<option :value="cat.id" x-text="cat.name"></option>
</template>
</select>
</div>
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Brand *</label>
<select x-model="form.brandId" required
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all cursor-pointer">
<option value="">Select...</option>
<template x-for="brand in brands" :key="brand.id">
<option :value="brand.id" x-text="brand.name"></option>
</template>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Regular Price
(Rs) *</label>
<input type="number" x-model.number="form.price" required min="0"
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all">
</div>
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Discount Price
(Rs)</label>
<input type="number" x-model.number="form.discountPrice" min="0" placeholder="Optional"
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all">
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5 whitespace-nowrap">Stock Quantity *</label>
<input type="number" x-model.number="form.stockQuantity" required min="0"
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all">
<label class="flex items-center gap-2 mt-3 cursor-pointer">
<input type="checkbox" x-model="form.inStock" class="w-4 h-4 rounded border-gray-300 text-black focus:ring-black accent-black">
<span class="text-xs font-semibold text-gray-600">Manually Mark as In Stock</span>
</label>
</div>
</div>
<!-- Custom Colors and Sizes with premium UI -->
<div class="bg-gray-50/70 p-5 rounded-2xl border border-gray-150/80 space-y-5">
<div>
<label class="block text-xs font-bold text-gray-600 uppercase tracking-wider mb-2">Custom Colors</label>
<div class="flex items-center gap-2 mb-3">
<input type="text" x-model="newColor" @keydown.enter.prevent="addColor" placeholder="e.g. Matte Black"
class="flex-1 border border-gray-200 rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all shadow-2xs">
<button type="button" @click="addColor"
class="bg-black text-white px-5 py-2.5 rounded-xl text-sm font-semibold hover:bg-gray-800 transition-all shadow-sm cursor-pointer hover:-translate-y-0.5 active:translate-y-0 flex-shrink-0">Add</button>
</div>
<div class="flex flex-wrap gap-2">
<template x-for="(col, idx) in form.colors" :key="idx">
<div class="flex items-center gap-2 bg-white p-2 rounded-xl border border-gray-200 shadow-3xs hover:border-black/20 transition-all">
<div class="w-4 h-4 rounded-full overflow-hidden border border-gray-200 shadow-inner relative" ><span class="absolute inset-0 rounded-full" :style="'background: ' + getColorHex(col.name)"></span></div>
<span class="text-xs font-bold text-gray-800 min-w-[60px]" x-text="col.name"></span>
<div class="h-4 w-px bg-gray-200 mx-1"></div>
<span class="text-[10px] font-semibold text-gray-400 uppercase tracking-wide">Qty</span>
<input type="number" x-model.number="col.qty" min="0" class="w-14 border border-gray-200 rounded-md px-1.5 py-0.5 text-xs focus:outline-none focus:border-black text-center font-semibold bg-gray-50">
<div class="h-4 w-px bg-gray-200 mx-1"></div>
<label class="cursor-pointer flex items-center justify-center relative group/img" title="Upload Image for this Color">
<input type="file" @change="handleColorImageUpload($event, idx)" accept="image/*" class="hidden">
<template x-if="col.image">
<div class="relative w-7 h-7">
<img :src="getImageUrl(col.image)" class="w-full h-full rounded-md object-cover border border-gray-200 shadow-sm">
<div class="absolute inset-0 bg-black/40 opacity-0 group-hover/img:opacity-100 rounded-md flex items-center justify-center transition-opacity">
<i data-lucide="edit-2" class="w-3 h-3 text-white"></i>
</div>
</div>
</template>
<template x-if="!col.image">
<div class="w-7 h-7 rounded-md border border-gray-200 border-dashed flex items-center justify-center text-gray-400 hover:text-black hover:border-black transition-colors bg-gray-50">
<i data-lucide="image" class="w-3.5 h-3.5"></i>
</div>
</template>
</label>
<button type="button" @click="removeColor(idx)" class="text-gray-400 hover:text-red-500 hover:bg-red-50 p-1.5 rounded-md transition-all cursor-pointer flex items-center justify-center ml-1" title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="w-3 h-3"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</div>
</template>
<p x-show="!form.colors || form.colors.length === 0" class="text-xs text-gray-400/80 italic pl-1">No custom colors added yet.</p>
</div>
</div>
<div class="h-px bg-gray-200/60 w-full"></div>
<div>
<label class="block text-xs font-bold text-gray-600 uppercase tracking-wider mb-2">Sizes (Optional)</label>
<div class="flex items-center gap-2 mb-3">
<input type="text" x-model="newSize" @keydown.enter.prevent="addSize" placeholder="e.g. 50-18-140"
class="flex-1 border border-gray-200 rounded-xl px-4 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all shadow-2xs">
<button type="button" @click="addSize"
class="bg-black text-white px-5 py-2.5 rounded-xl text-sm font-semibold hover:bg-gray-800 transition-all shadow-sm cursor-pointer hover:-translate-y-0.5 active:translate-y-0 flex-shrink-0">Add</button>
</div>
<div class="flex flex-wrap gap-2">
<template x-for="(sz, idx) in form.sizes" :key="idx">
<span class="inline-flex items-center gap-1.5 bg-white px-3 py-1.5 rounded-xl text-xs font-bold text-gray-800 border border-gray-200 shadow-3xs hover:border-red-200 transition-all">
<span x-text="sz"></span>
<button type="button" @click="removeSize(idx)" class="text-gray-400 hover:text-red-500 hover:bg-red-50 p-1 rounded-md transition-all cursor-pointer flex items-center justify-center" title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="w-3 h-3"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
</button>
</span>
</template>
<p x-show="!form.sizes || form.sizes.length === 0" class="text-xs text-gray-400/80 italic pl-1">No custom sizes added yet.</p>
</div>
</div>
</div>
<div>
<label
class="block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1.5">Description</label>
<textarea x-model="form.description" rows="3"
class="w-full border border-gray-200 rounded-xl px-3.5 py-2.5 text-sm focus:outline-none focus:border-black focus:ring-2 focus:ring-black/5 bg-white transition-all resize-none"></textarea>
</div>
<div class="mt-4">
<label
class="flex items-center gap-3 p-4 border border-gray-200 rounded-xl cursor-pointer hover:bg-gray-50 transition-colors">
<input type="checkbox" x-model="form.isTrending"
class="w-5 h-5 rounded border-gray-300 text-black focus:ring-black">
<div class="flex flex-col">
<span class="text-sm font-bold text-gray-900">Mark as Trending</span>
<span class="text-xs text-gray-500 mt-0.5">Show this product in the "Trending Now" section on the
homepage</span>
</div>
</label>
</div>
</div>
<!-- Right Column: Images -->
<div class="space-y-4">
<div class="flex justify-between items-end">
<label class="block text-xs font-semibold text-gray-500 uppercase tracking-wider">Product Images *</label>
<span class="text-xs text-gray-400 font-medium"
x-text="(form.images ? form.images.length : 0) + '/3 Allowed'"></span>
</div>
<div
class="border-2 border-dashed border-gray-200 hover:border-black/35 rounded-2xl p-6 flex flex-col items-center justify-center bg-gray-50/50 transition-all duration-300 relative cursor-pointer group min-h-[160px]"
@click="if((form.images ? form.images.length : 0) < 3) $refs.fileInput.click()"
:class="(form.images ? form.images.length : 0) < 3 ? 'hover:bg-gray-50' : 'cursor-not-allowed opacity-50'">
<input type="file" x-ref="fileInput" @change="handleImagesUpload" accept="image/*" multiple
class="hidden">
<div class="text-center">
<i data-lucide="upload-cloud"
class="w-10 h-10 text-gray-400 mx-auto mb-2 transition-colors duration-200"
:class="(form.images ? form.images.length : 0) < 3 ? 'group-hover:text-black group-hover:scale-105' : ''"></i>
<p class="text-sm font-semibold text-gray-700"
x-text="(form.images ? form.images.length : 0) >= 3 ? 'Maximum images reached' : 'Click to upload multiple images'">
</p>
<p class="text-xs text-gray-400 mt-1">PNG, JPG, WEBP up to 5MB (Max 3)</p>
</div>
</div>
<div class="grid grid-cols-3 gap-3" x-show="(form.images ? form.images.length : 0) > 0">
<template x-for="(img, idx) in form.images" :key="idx">
<div
class="aspect-square rounded-xl overflow-hidden bg-white border border-gray-100 shadow-2xs relative group">
<img :src="getImageUrl(img)" class="w-full h-full object-cover">
<div
class="absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center">
<button type="button" @click.stop="removeImage(idx)"
class="bg-red-500 text-white p-2 rounded-full hover:bg-red-600 transition-colors shadow-lg hover:scale-110 active:scale-95 cursor-pointer">
<i data-lucide="trash-2" class="w-4 h-4"></i>
</button>
</div>
</div>
</template>
</div>