tailwind-rs-core 0.15.4

Core types and utilities for tailwind-rs
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
//! CSS generation system for tailwind-rs
//!
//! This module provides the core CSS generation functionality, converting
//! Tailwind class names into actual CSS rules.

use crate::error::{Result, TailwindError};
use crate::responsive::Breakpoint;
use std::collections::HashMap;

/// Represents a CSS rule with selector and properties
#[derive(Debug, Clone, PartialEq)]
pub struct CssRule {
    /// CSS selector (e.g., ".p-4", ".md:bg-blue-500")
    pub selector: String,
    /// CSS properties for this rule
    pub properties: Vec<CssProperty>,
    /// Media query for responsive rules
    pub media_query: Option<String>,
    /// CSS specificity score
    pub specificity: u32,
}

/// Represents a CSS property
#[derive(Debug, Clone, PartialEq)]
pub struct CssProperty {
    /// Property name (e.g., "padding", "background-color")
    pub name: String,
    /// Property value (e.g., "1rem", "#3b82f6")
    pub value: String,
    /// Whether the property is marked as !important
    pub important: bool,
}

/// CSS generator that converts Tailwind classes to CSS rules
#[derive(Debug, Clone)]
pub struct CssGenerator {
    /// Generated CSS rules
    rules: HashMap<String, CssRule>,
    /// Responsive breakpoints
    breakpoints: HashMap<Breakpoint, String>,
    /// Custom CSS properties
    custom_properties: HashMap<String, String>,
}

impl CssGenerator {
    /// Create a new CSS generator
    pub fn new() -> Self {
        let mut generator = Self {
            rules: HashMap::new(),
            breakpoints: HashMap::new(),
            custom_properties: HashMap::new(),
        };
        
        // Initialize default breakpoints
        generator.breakpoints.insert(Breakpoint::Sm, "(min-width: 640px)".to_string());
        generator.breakpoints.insert(Breakpoint::Md, "(min-width: 768px)".to_string());
        generator.breakpoints.insert(Breakpoint::Lg, "(min-width: 1024px)".to_string());
        generator.breakpoints.insert(Breakpoint::Xl, "(min-width: 1280px)".to_string());
        generator.breakpoints.insert(Breakpoint::Xl2, "(min-width: 1536px)".to_string());
        
        generator
    }

    /// Add a class to the generator
    pub fn add_class(&mut self, class: &str) -> Result<()> {
        let rule = self.class_to_css_rule(class)?;
        self.rules.insert(class.to_string(), rule);
        Ok(())
    }

    /// Add a responsive class
    pub fn add_responsive_class(&mut self, breakpoint: Breakpoint, class: &str) -> Result<()> {
        let mut rule = self.class_to_css_rule(class)?;
        rule.selector = format!("{}{}", breakpoint.prefix(), class);
        rule.media_query = self.breakpoints.get(&breakpoint).cloned();
        rule.specificity = 20; // Higher specificity for responsive rules
        
        let responsive_class = format!("{}:{}", breakpoint.prefix().trim_end_matches(':'), class);
        self.rules.insert(responsive_class, rule);
        Ok(())
    }

    /// Add a custom CSS property
    pub fn add_custom_property(&mut self, name: &str, value: &str) {
        self.custom_properties.insert(name.to_string(), value.to_string());
    }

    /// Generate CSS from all added classes
    pub fn generate_css(&self) -> String {
        let mut css = String::new();
        
        // Add custom properties
        if !self.custom_properties.is_empty() {
            css.push_str(":root {\n");
            for (name, value) in &self.custom_properties {
                css.push_str(&format!("  --{}: {};\n", name, value));
            }
            css.push_str("}\n\n");
        }
        
        // Group rules by media query
        let mut base_rules = Vec::new();
        let mut responsive_rules: HashMap<String, Vec<&CssRule>> = HashMap::new();
        
        for rule in self.rules.values() {
            if let Some(ref media_query) = rule.media_query {
                responsive_rules.entry(media_query.clone()).or_default().push(rule);
            } else {
                base_rules.push(rule);
            }
        }
        
        // Generate base rules
        for rule in base_rules {
            css.push_str(&self.rule_to_css(rule));
        }
        
        // Generate responsive rules
        for (media_query, rules) in responsive_rules {
            css.push_str(&format!("@media {} {{\n", media_query));
            for rule in rules {
                css.push_str(&format!("  {}\n", self.rule_to_css(rule)));
            }
            css.push_str("}\n\n");
        }
        
        css
    }

    /// Generate minified CSS
    pub fn generate_minified_css(&self) -> String {
        let css = self.generate_css();
        self.minify_css(&css)
    }

    /// Get all generated rules
    pub fn get_rules(&self) -> &HashMap<String, CssRule> {
        &self.rules
    }

    /// Get the number of generated rules
    pub fn rule_count(&self) -> usize {
        self.rules.len()
    }

    /// Remove a CSS rule by selector
    pub fn remove_rule(&mut self, selector: &str) -> Option<CssRule> {
        self.rules.remove(selector)
    }

    /// Update a CSS rule
    pub fn update_rule(&mut self, selector: &str, rule: CssRule) {
        self.rules.insert(selector.to_string(), rule);
    }

    /// Parse variants from a class name and return (variants, base_class)
    fn parse_variants(&self, class: &str) -> (Vec<String>, String) {
        let mut variants = Vec::new();
        let mut remaining = class.to_string();
        
        // Parse variants in order of specificity (most specific first)
        let variant_patterns = [
            ("dark:", "dark"),
            ("hover:", "hover"),
            ("focus:", "focus"),
            ("active:", "active"),
            ("visited:", "visited"),
            ("disabled:", "disabled"),
            ("group-hover:", "group-hover"),
            ("group-focus:", "group-focus"),
            ("group-active:", "group-active"),
            ("group-disabled:", "group-disabled"),
            ("peer-hover:", "peer-hover"),
            ("peer-focus:", "peer-focus"),
            ("peer-active:", "peer-active"),
            ("peer-disabled:", "peer-disabled"),
            ("first:", "first"),
            ("last:", "last"),
            ("odd:", "odd"),
            ("even:", "even"),
            ("sm:", "sm"),
            ("md:", "md"),
            ("lg:", "lg"),
            ("xl:", "xl"),
            ("2xl:", "2xl"),
        ];
        
        for (prefix, variant) in variant_patterns {
            if remaining.starts_with(prefix) {
                variants.push(variant.to_string());
                remaining = remaining.strip_prefix(prefix).unwrap_or(&remaining).to_string();
                break; // Only parse one variant at a time for now
            }
        }
        
        (variants, remaining)
    }

    /// Convert a class name to a CSS rule
    fn class_to_css_rule(&self, class: &str) -> Result<CssRule> {
        let (variants, base_class) = self.parse_variants(class);
        let properties = self.class_to_properties(class)?;
        
        // Build selector with variants
        let mut selector = String::new();
        for variant in &variants {
            match variant.as_str() {
                "dark" => selector.push_str(".dark "),
                "hover" => selector.push_str(":hover"),
                "focus" => selector.push_str(":focus"),
                "active" => selector.push_str(":active"),
                "visited" => selector.push_str(":visited"),
                "disabled" => selector.push_str(":disabled"),
                "group-hover" => selector.push_str(".group:hover "),
                "group-focus" => selector.push_str(".group:focus "),
                "group-active" => selector.push_str(".group:active "),
                "group-disabled" => selector.push_str(".group:disabled "),
                "peer-hover" => selector.push_str(".peer:hover "),
                "peer-focus" => selector.push_str(".peer:focus "),
                "peer-active" => selector.push_str(".peer:active "),
                "peer-disabled" => selector.push_str(".peer:disabled "),
                "first" => selector.push_str(":first-child"),
                "last" => selector.push_str(":last-child"),
                "odd" => selector.push_str(":nth-child(odd)"),
                "even" => selector.push_str(":nth-child(even)"),
                _ => {} // Responsive variants handled separately
            }
        }
        
        // Add the base class
        selector.push_str(&format!(".{}", base_class));
        
        // Determine media query for responsive variants
        let media_query = variants.iter()
            .find(|v| matches!(v.as_str(), "sm" | "md" | "lg" | "xl" | "2xl"))
            .and_then(|variant| {
                match variant.as_str() {
                    "sm" => Some("(min-width: 640px)"),
                    "md" => Some("(min-width: 768px)"),
                    "lg" => Some("(min-width: 1024px)"),
                    "xl" => Some("(min-width: 1280px)"),
                    "2xl" => Some("(min-width: 1536px)"),
                    _ => None,
                }
            })
            .map(|s| s.to_string());
        
        // Determine specificity based on variants
        let specificity = 10 + (variants.len() as u32 * 10);
        
        Ok(CssRule {
            selector,
            properties,
            media_query,
            specificity,
        })
    }

    /// Convert a class name to CSS properties
    fn class_to_properties(&self, class: &str) -> Result<Vec<CssProperty>> {
        // First, parse variants and get the base class
        let (_variants, base_class) = self.parse_variants(class);
        
        // Try to parse the base class using comprehensive patterns
        if let Some(properties) = self.parse_spacing_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_color_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_typography_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_layout_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_flexbox_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_grid_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_border_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_effects_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_transform_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_animation_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_interactivity_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_sizing_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_background_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_filter_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_transition_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_text_shadow_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_mask_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_logical_properties_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_enhanced_backdrop_filter_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_modern_css_features_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_device_variant_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_css_nesting_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_advanced_plugin_system_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_enhanced_validation_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_advanced_performance_optimization_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_container_query_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_color_function_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_performance_optimization_class(&base_class) {
            return Ok(properties);
        }
        
        if let Some(properties) = self.parse_advanced_animation_class(&base_class) {
            return Ok(properties);
        }
        
        // Fallback to hardcoded classes for backwards compatibility
        match base_class.as_str() {
            // Display utilities
            "block" => Ok(vec![CssProperty { name: "display".to_string(), value: "block".to_string(), important: false }]),
            "inline" => Ok(vec![CssProperty { name: "display".to_string(), value: "inline".to_string(), important: false }]),
            "flex" => Ok(vec![CssProperty { name: "display".to_string(), value: "flex".to_string(), important: false }]),
            "grid" => Ok(vec![CssProperty { name: "display".to_string(), value: "grid".to_string(), important: false }]),
            "hidden" => Ok(vec![CssProperty { name: "display".to_string(), value: "none".to_string(), important: false }]),
            
            _ => Err(TailwindError::class_generation(format!("Unknown class: {}", class))),
        }
    }
    
    /// Parse spacing classes (padding, margin, etc.)
    fn parse_spacing_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        let spacing_map = [
            ("0", "0px"), ("px", "1px"), ("0.5", "0.125rem"), ("1", "0.25rem"),
            ("1.5", "0.375rem"), ("2", "0.5rem"), ("2.5", "0.625rem"), ("3", "0.75rem"),
            ("3.5", "0.875rem"), ("4", "1rem"), ("5", "1.25rem"), ("6", "1.5rem"),
            ("7", "1.75rem"), ("8", "2rem"), ("9", "2.25rem"), ("10", "2.5rem"),
            ("11", "2.75rem"), ("12", "3rem"), ("14", "3.5rem"), ("16", "4rem"),
            ("20", "5rem"), ("24", "6rem"), ("28", "7rem"), ("32", "8rem"),
            ("36", "9rem"), ("40", "10rem"), ("44", "11rem"), ("48", "12rem"),
            ("52", "13rem"), ("56", "14rem"), ("60", "15rem"), ("64", "16rem"),
            ("72", "18rem"), ("80", "20rem"), ("96", "24rem"),
        ];
        
        // Parse padding classes
        if class.starts_with("p-") {
            let value = &class[2..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "padding".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        // Parse margin classes
        if class.starts_with("m-") {
            let value = &class[2..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "margin".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        // Parse padding top/bottom/left/right
        if class.starts_with("pt-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "padding-top".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("pb-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "padding-bottom".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("pl-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "padding-left".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("pr-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "padding-right".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        // Parse padding x/y (horizontal/vertical)
        if class.starts_with("px-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![
                    CssProperty { 
                        name: "padding-left".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    },
                    CssProperty { 
                        name: "padding-right".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    }
                ]);
            }
        }
        
        if class.starts_with("py-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![
                    CssProperty { 
                        name: "padding-top".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    },
                    CssProperty { 
                        name: "padding-bottom".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    }
                ]);
            }
        }
        
        // Parse margin top/bottom/left/right
        if class.starts_with("mt-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "margin-top".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("mb-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "margin-bottom".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("ml-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "margin-left".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        if class.starts_with("mr-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![CssProperty { 
                    name: "margin-right".to_string(), 
                    value: css_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        // Parse margin x/y (horizontal/vertical)
        if class.starts_with("mx-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![
                    CssProperty { 
                        name: "margin-left".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    },
                    CssProperty { 
                        name: "margin-right".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    }
                ]);
            }
        }
        
        if class.starts_with("my-") {
            let value = &class[3..];
            if let Some((_, css_value)) = spacing_map.iter().find(|(k, _)| *k == value) {
                return Some(vec![
                    CssProperty { 
                        name: "margin-top".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    },
                    CssProperty { 
                        name: "margin-bottom".to_string(), 
                        value: css_value.to_string(), 
                        important: false 
                    }
                ]);
            }
        }
        
        None
    }
    
    /// Parse color classes (background, text, border colors)
    fn parse_color_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        let color_map = [
            // Grays
            ("gray-50", "#f9fafb"), ("gray-100", "#f3f4f6"), ("gray-200", "#e5e7eb"), 
            ("gray-300", "#d1d5db"), ("gray-400", "#9ca3af"), ("gray-500", "#6b7280"),
            ("gray-600", "#4b5563"), ("gray-700", "#374151"), ("gray-800", "#1f2937"), ("gray-900", "#111827"),
            ("gray-950", "#030712"),
            
            // Zinc colors
            ("zinc-50", "#fafafa"), ("zinc-100", "#f4f4f5"), ("zinc-200", "#e4e4e7"), 
            ("zinc-300", "#d4d4d8"), ("zinc-400", "#a1a1aa"), ("zinc-500", "#71717a"),
            ("zinc-600", "#52525b"), ("zinc-700", "#3f3f46"), ("zinc-800", "#27272a"), ("zinc-900", "#18181b"),
            ("zinc-950", "#09090b"),
            
            // Blues
            ("blue-50", "#eff6ff"), ("blue-100", "#dbeafe"), ("blue-200", "#bfdbfe"), 
            ("blue-300", "#93c5fd"), ("blue-400", "#60a5fa"), ("blue-500", "#3b82f6"),
            ("blue-600", "#2563eb"), ("blue-700", "#1d4ed8"), ("blue-800", "#1e40af"), ("blue-900", "#1e3a8a"),
            ("blue-950", "#172554"),
            
            // Teal colors
            ("teal-50", "#f0fdfa"), ("teal-100", "#ccfbf1"), ("teal-200", "#99f6e4"), 
            ("teal-300", "#5eead4"), ("teal-400", "#2dd4bf"), ("teal-500", "#14b8a6"),
            ("teal-600", "#0d9488"), ("teal-700", "#0f766e"), ("teal-800", "#115e59"), ("teal-900", "#134e4a"),
            ("teal-950", "#042f2e"),
            
            // Emerald colors
            ("emerald-50", "#ecfdf5"), ("emerald-100", "#d1fae5"), ("emerald-200", "#a7f3d0"), 
            ("emerald-300", "#6ee7b7"), ("emerald-400", "#34d399"), ("emerald-500", "#10b981"),
            ("emerald-600", "#059669"), ("emerald-700", "#047857"), ("emerald-800", "#065f46"), ("emerald-900", "#064e3b"),
            ("emerald-950", "#022c22"),
            
            // Reds
            ("red-50", "#fef2f2"), ("red-100", "#fee2e2"), ("red-200", "#fecaca"), 
            ("red-300", "#fca5a5"), ("red-400", "#f87171"), ("red-500", "#ef4444"),
            ("red-600", "#dc2626"), ("red-700", "#b91c1c"), ("red-800", "#991b1b"), ("red-900", "#7f1d1d"),
            ("red-950", "#450a0a"),
            
            // Greens
            ("green-50", "#f0fdf4"), ("green-100", "#dcfce7"), ("green-200", "#bbf7d0"), 
            ("green-300", "#86efac"), ("green-400", "#4ade80"), ("green-500", "#22c55e"),
            ("green-600", "#16a34a"), ("green-700", "#15803d"), ("green-800", "#166534"), ("green-900", "#14532d"),
            ("green-950", "#052e16"),
            
            // Yellows
            ("yellow-50", "#fefce8"), ("yellow-100", "#fef3c7"), ("yellow-200", "#fde68a"), 
            ("yellow-300", "#fcd34d"), ("yellow-400", "#fbbf24"), ("yellow-500", "#f59e0b"),
            ("yellow-600", "#d97706"), ("yellow-700", "#b45309"), ("yellow-800", "#92400e"), ("yellow-900", "#78350f"),
            ("yellow-950", "#451a03"),
            
            // Purples
            ("purple-50", "#faf5ff"), ("purple-100", "#f3e8ff"), ("purple-200", "#e9d5ff"), 
            ("purple-300", "#d8b4fe"), ("purple-400", "#c084fc"), ("purple-500", "#a855f7"),
            ("purple-600", "#9333ea"), ("purple-700", "#7c3aed"), ("purple-800", "#6b21a8"), ("purple-900", "#581c87"),
            ("purple-950", "#3b0764"),
            
            // Special colors
            ("white", "#ffffff"), ("black", "#000000"), ("transparent", "transparent"),
        ];
        
        // Parse background colors
        if class.starts_with("bg-") {
            let color = &class[3..];
            
            // Check for opacity modifier (e.g., bg-blue-500/50)
            if let Some(slash_pos) = color.find('/') {
                let base_color = &color[..slash_pos];
                let opacity_str = &color[slash_pos + 1..];
                
                if let Some((_, hex_value)) = color_map.iter().find(|(k, _)| *k == base_color) {
                    if let Ok(opacity) = opacity_str.parse::<f32>() {
                        let rgba_value = self.hex_to_rgba(hex_value, opacity / 100.0);
                        return Some(vec![CssProperty { 
                            name: "background-color".to_string(), 
                            value: rgba_value, 
                            important: false 
                        }]);
                    }
                }
            } else {
                // No opacity modifier
                if let Some((_, hex_value)) = color_map.iter().find(|(k, _)| *k == color) {
                    return Some(vec![CssProperty { 
                        name: "background-color".to_string(), 
                        value: hex_value.to_string(), 
                        important: false 
                    }]);
                }
            }
        }
        
        // Parse text colors
        if class.starts_with("text-") {
            let color = &class[5..];
            
            // Check for opacity modifier (e.g., text-blue-500/50)
            if let Some(slash_pos) = color.find('/') {
                let base_color = &color[..slash_pos];
                let opacity_str = &color[slash_pos + 1..];
                
                if let Some((_, hex_value)) = color_map.iter().find(|(k, _)| *k == base_color) {
                    if let Ok(opacity) = opacity_str.parse::<f32>() {
                        let rgba_value = self.hex_to_rgba(hex_value, opacity / 100.0);
                        return Some(vec![CssProperty { 
                            name: "color".to_string(), 
                            value: rgba_value, 
                            important: false 
                        }]);
                    }
                }
            } else {
                // No opacity modifier
                if let Some((_, hex_value)) = color_map.iter().find(|(k, _)| *k == color) {
                    return Some(vec![CssProperty { 
                        name: "color".to_string(), 
                        value: hex_value.to_string(), 
                        important: false 
                    }]);
                }
            }
        }
        
        // Parse border colors
        if class.starts_with("border-") {
            let color = &class[7..];
            if let Some((_, hex_value)) = color_map.iter().find(|(k, _)| *k == color) {
                return Some(vec![CssProperty { 
                    name: "border-color".to_string(), 
                    value: hex_value.to_string(), 
                    important: false 
                }]);
            }
        }
        
        None
    }
    
    /// Convert hex color to RGBA with opacity
    fn hex_to_rgba(&self, hex: &str, opacity: f32) -> String {
        // Remove # if present
        let hex = hex.trim_start_matches('#');
        
        // Parse hex to RGB
        if hex.len() == 6 {
            if let (Ok(r), Ok(g), Ok(b)) = (
                u8::from_str_radix(&hex[0..2], 16),
                u8::from_str_radix(&hex[2..4], 16),
                u8::from_str_radix(&hex[4..6], 16),
            ) {
                return format!("rgba({}, {}, {}, {})", r, g, b, opacity);
            }
        }
        
        // Fallback to original hex if parsing fails
        format!("{}", hex)
    }
    
    /// Parse typography classes
    fn parse_typography_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            // Font sizes
            "text-xs" => Some(vec![CssProperty { name: "font-size".to_string(), value: "0.75rem".to_string(), important: false }]),
            "text-sm" => Some(vec![CssProperty { name: "font-size".to_string(), value: "0.875rem".to_string(), important: false }]),
            "text-base" => Some(vec![CssProperty { name: "font-size".to_string(), value: "1rem".to_string(), important: false }]),
            "text-lg" => Some(vec![CssProperty { name: "font-size".to_string(), value: "1.125rem".to_string(), important: false }]),
            "text-xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "1.25rem".to_string(), important: false }]),
            "text-2xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "1.5rem".to_string(), important: false }]),
            "text-3xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "1.875rem".to_string(), important: false }]),
            "text-4xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "2.25rem".to_string(), important: false }]),
            "text-5xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "3rem".to_string(), important: false }]),
            "text-6xl" => Some(vec![CssProperty { name: "font-size".to_string(), value: "3.75rem".to_string(), important: false }]),
            
            // Font weights
            "font-thin" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "100".to_string(), important: false }]),
            "font-extralight" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "200".to_string(), important: false }]),
            "font-light" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "300".to_string(), important: false }]),
            "font-normal" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "400".to_string(), important: false }]),
            "font-medium" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "500".to_string(), important: false }]),
            "font-semibold" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "600".to_string(), important: false }]),
            "font-bold" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "700".to_string(), important: false }]),
            "font-extrabold" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "800".to_string(), important: false }]),
            "font-black" => Some(vec![CssProperty { name: "font-weight".to_string(), value: "900".to_string(), important: false }]),
            
            // Text alignment
            "text-left" => Some(vec![CssProperty { name: "text-align".to_string(), value: "left".to_string(), important: false }]),
            "text-center" => Some(vec![CssProperty { name: "text-align".to_string(), value: "center".to_string(), important: false }]),
            "text-right" => Some(vec![CssProperty { name: "text-align".to_string(), value: "right".to_string(), important: false }]),
            "text-justify" => Some(vec![CssProperty { name: "text-align".to_string(), value: "justify".to_string(), important: false }]),
            
            // Letter spacing (tracking)
            "tracking-tighter" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "-0.05em".to_string(), important: false }]),
            "tracking-tight" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "-0.025em".to_string(), important: false }]),
            "tracking-normal" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "0em".to_string(), important: false }]),
            "tracking-wide" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "0.025em".to_string(), important: false }]),
            "tracking-wider" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "0.05em".to_string(), important: false }]),
            "tracking-widest" => Some(vec![CssProperty { name: "letter-spacing".to_string(), value: "0.1em".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse layout classes
    fn parse_layout_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "block" => Some(vec![CssProperty { name: "display".to_string(), value: "block".to_string(), important: false }]),
            "inline" => Some(vec![CssProperty { name: "display".to_string(), value: "inline".to_string(), important: false }]),
            "inline-block" => Some(vec![CssProperty { name: "display".to_string(), value: "inline-block".to_string(), important: false }]),
            "flex" => Some(vec![CssProperty { name: "display".to_string(), value: "flex".to_string(), important: false }]),
            "inline-flex" => Some(vec![CssProperty { name: "display".to_string(), value: "inline-flex".to_string(), important: false }]),
            "grid" => Some(vec![CssProperty { name: "display".to_string(), value: "grid".to_string(), important: false }]),
            "inline-grid" => Some(vec![CssProperty { name: "display".to_string(), value: "inline-grid".to_string(), important: false }]),
            "hidden" => Some(vec![CssProperty { name: "display".to_string(), value: "none".to_string(), important: false }]),
            
            // Position
            "static" => Some(vec![CssProperty { name: "position".to_string(), value: "static".to_string(), important: false }]),
            "fixed" => Some(vec![CssProperty { name: "position".to_string(), value: "fixed".to_string(), important: false }]),
            "absolute" => Some(vec![CssProperty { name: "position".to_string(), value: "absolute".to_string(), important: false }]),
            "relative" => Some(vec![CssProperty { name: "position".to_string(), value: "relative".to_string(), important: false }]),
            "sticky" => Some(vec![CssProperty { name: "position".to_string(), value: "sticky".to_string(), important: false }]),
            
            // Positioning utilities
            "inset-0" => Some(vec![CssProperty { name: "top".to_string(), value: "0px".to_string(), important: false }, CssProperty { name: "right".to_string(), value: "0px".to_string(), important: false }, CssProperty { name: "bottom".to_string(), value: "0px".to_string(), important: false }, CssProperty { name: "left".to_string(), value: "0px".to_string(), important: false }]),
            "inset-x-0" => Some(vec![CssProperty { name: "left".to_string(), value: "0px".to_string(), important: false }, CssProperty { name: "right".to_string(), value: "0px".to_string(), important: false }]),
            "inset-y-0" => Some(vec![CssProperty { name: "top".to_string(), value: "0px".to_string(), important: false }, CssProperty { name: "bottom".to_string(), value: "0px".to_string(), important: false }]),
            "top-0" => Some(vec![CssProperty { name: "top".to_string(), value: "0px".to_string(), important: false }]),
            "right-0" => Some(vec![CssProperty { name: "right".to_string(), value: "0px".to_string(), important: false }]),
            "bottom-0" => Some(vec![CssProperty { name: "bottom".to_string(), value: "0px".to_string(), important: false }]),
            "left-0" => Some(vec![CssProperty { name: "left".to_string(), value: "0px".to_string(), important: false }]),
            
            // Negative positioning
            "-inset-x-4" => Some(vec![CssProperty { name: "left".to_string(), value: "-1rem".to_string(), important: false }, CssProperty { name: "right".to_string(), value: "-1rem".to_string(), important: false }]),
            "-inset-y-6" => Some(vec![CssProperty { name: "top".to_string(), value: "-1.5rem".to_string(), important: false }, CssProperty { name: "bottom".to_string(), value: "-1.5rem".to_string(), important: false }]),
            
            // Z-index utilities
            "z-0" => Some(vec![CssProperty { name: "z-index".to_string(), value: "0".to_string(), important: false }]),
            "z-10" => Some(vec![CssProperty { name: "z-index".to_string(), value: "10".to_string(), important: false }]),
            "z-20" => Some(vec![CssProperty { name: "z-index".to_string(), value: "20".to_string(), important: false }]),
            "z-30" => Some(vec![CssProperty { name: "z-index".to_string(), value: "30".to_string(), important: false }]),
            "z-40" => Some(vec![CssProperty { name: "z-index".to_string(), value: "40".to_string(), important: false }]),
            "z-50" => Some(vec![CssProperty { name: "z-index".to_string(), value: "50".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse flexbox classes
    fn parse_flexbox_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "flex-row" => Some(vec![CssProperty { name: "flex-direction".to_string(), value: "row".to_string(), important: false }]),
            "flex-row-reverse" => Some(vec![CssProperty { name: "flex-direction".to_string(), value: "row-reverse".to_string(), important: false }]),
            "flex-col" => Some(vec![CssProperty { name: "flex-direction".to_string(), value: "column".to_string(), important: false }]),
            "flex-col-reverse" => Some(vec![CssProperty { name: "flex-direction".to_string(), value: "column-reverse".to_string(), important: false }]),
            
            "flex-wrap" => Some(vec![CssProperty { name: "flex-wrap".to_string(), value: "wrap".to_string(), important: false }]),
            "flex-wrap-reverse" => Some(vec![CssProperty { name: "flex-wrap".to_string(), value: "wrap-reverse".to_string(), important: false }]),
            "flex-nowrap" => Some(vec![CssProperty { name: "flex-wrap".to_string(), value: "nowrap".to_string(), important: false }]),
            
            "justify-start" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "flex-start".to_string(), important: false }]),
            "justify-end" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "flex-end".to_string(), important: false }]),
            "justify-center" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "center".to_string(), important: false }]),
            "justify-between" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "space-between".to_string(), important: false }]),
            "justify-around" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "space-around".to_string(), important: false }]),
            "justify-evenly" => Some(vec![CssProperty { name: "justify-content".to_string(), value: "space-evenly".to_string(), important: false }]),
            
            "items-start" => Some(vec![CssProperty { name: "align-items".to_string(), value: "flex-start".to_string(), important: false }]),
            "items-end" => Some(vec![CssProperty { name: "align-items".to_string(), value: "flex-end".to_string(), important: false }]),
            "items-center" => Some(vec![CssProperty { name: "align-items".to_string(), value: "center".to_string(), important: false }]),
            "items-baseline" => Some(vec![CssProperty { name: "align-items".to_string(), value: "baseline".to_string(), important: false }]),
            "items-stretch" => Some(vec![CssProperty { name: "align-items".to_string(), value: "stretch".to_string(), important: false }]),
            
            // Order utilities
            "order-first" => Some(vec![CssProperty { name: "order".to_string(), value: "-1".to_string(), important: false }]),
            "order-last" => Some(vec![CssProperty { name: "order".to_string(), value: "9999".to_string(), important: false }]),
            "order-none" => Some(vec![CssProperty { name: "order".to_string(), value: "0".to_string(), important: false }]),
            "order-1" => Some(vec![CssProperty { name: "order".to_string(), value: "1".to_string(), important: false }]),
            "order-2" => Some(vec![CssProperty { name: "order".to_string(), value: "2".to_string(), important: false }]),
            "order-3" => Some(vec![CssProperty { name: "order".to_string(), value: "3".to_string(), important: false }]),
            "order-4" => Some(vec![CssProperty { name: "order".to_string(), value: "4".to_string(), important: false }]),
            "order-5" => Some(vec![CssProperty { name: "order".to_string(), value: "5".to_string(), important: false }]),
            "order-6" => Some(vec![CssProperty { name: "order".to_string(), value: "6".to_string(), important: false }]),
            "order-7" => Some(vec![CssProperty { name: "order".to_string(), value: "7".to_string(), important: false }]),
            "order-8" => Some(vec![CssProperty { name: "order".to_string(), value: "8".to_string(), important: false }]),
            "order-9" => Some(vec![CssProperty { name: "order".to_string(), value: "9".to_string(), important: false }]),
            "order-10" => Some(vec![CssProperty { name: "order".to_string(), value: "10".to_string(), important: false }]),
            "order-11" => Some(vec![CssProperty { name: "order".to_string(), value: "11".to_string(), important: false }]),
            "order-12" => Some(vec![CssProperty { name: "order".to_string(), value: "12".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse grid classes
    fn parse_grid_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "grid-cols-1" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(1, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-2" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(2, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-3" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(3, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-4" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(4, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-5" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(5, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-6" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(6, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-cols-12" => Some(vec![CssProperty { name: "grid-template-columns".to_string(), value: "repeat(12, minmax(0, 1fr))".to_string(), important: false }]),
            
            "grid-rows-1" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(1, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-rows-2" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(2, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-rows-3" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(3, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-rows-4" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(4, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-rows-5" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(5, minmax(0, 1fr))".to_string(), important: false }]),
            "grid-rows-6" => Some(vec![CssProperty { name: "grid-template-rows".to_string(), value: "repeat(6, minmax(0, 1fr))".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse border classes
    fn parse_border_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "border" => Some(vec![CssProperty { name: "border-width".to_string(), value: "1px".to_string(), important: false }]),
            "border-0" => Some(vec![CssProperty { name: "border-width".to_string(), value: "0px".to_string(), important: false }]),
            "border-2" => Some(vec![CssProperty { name: "border-width".to_string(), value: "2px".to_string(), important: false }]),
            "border-4" => Some(vec![CssProperty { name: "border-width".to_string(), value: "4px".to_string(), important: false }]),
            "border-8" => Some(vec![CssProperty { name: "border-width".to_string(), value: "8px".to_string(), important: false }]),
            
            "rounded" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0.25rem".to_string(), important: false }]),
            "rounded-sm" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0.125rem".to_string(), important: false }]),
            "rounded-md" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0.375rem".to_string(), important: false }]),
            "rounded-lg" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0.5rem".to_string(), important: false }]),
            "rounded-xl" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0.75rem".to_string(), important: false }]),
            "rounded-2xl" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "1rem".to_string(), important: false }]),
            "rounded-3xl" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "1.5rem".to_string(), important: false }]),
            "rounded-full" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "9999px".to_string(), important: false }]),
            "rounded-none" => Some(vec![CssProperty { name: "border-radius".to_string(), value: "0px".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse effects classes (shadows, etc.)
    fn parse_effects_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "shadow-sm" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 1px 2px 0 rgb(0 0 0 / 0.05)".to_string(), important: false }]),
            "shadow" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)".to_string(), important: false }]),
            "shadow-md" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)".to_string(), important: false }]),
            "shadow-lg" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)".to_string(), important: false }]),
            "shadow-xl" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)".to_string(), important: false }]),
            "shadow-2xl" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 25px 50px -12px rgb(0 0 0 / 0.25)".to_string(), important: false }]),
            "shadow-none" => Some(vec![CssProperty { name: "box-shadow".to_string(), value: "0 0 #0000".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse transform classes
    fn parse_transform_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "transform" => Some(vec![CssProperty { name: "transform".to_string(), value: "translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))".to_string(), important: false }]),
            "scale-0" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(0)".to_string(), important: false }]),
            "scale-50" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(0.5)".to_string(), important: false }]),
            "scale-75" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(0.75)".to_string(), important: false }]),
            "scale-90" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(0.9)".to_string(), important: false }]),
            "scale-95" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(0.95)".to_string(), important: false }]),
            "scale-100" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(1)".to_string(), important: false }]),
            "scale-105" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(1.05)".to_string(), important: false }]),
            "scale-110" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(1.1)".to_string(), important: false }]),
            "scale-125" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(1.25)".to_string(), important: false }]),
            "scale-150" => Some(vec![CssProperty { name: "transform".to_string(), value: "scale(1.5)".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse animation classes
    fn parse_animation_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "animate-none" => Some(vec![CssProperty { name: "animation".to_string(), value: "none".to_string(), important: false }]),
            "animate-spin" => Some(vec![CssProperty { name: "animation".to_string(), value: "spin 1s linear infinite".to_string(), important: false }]),
            "animate-ping" => Some(vec![CssProperty { name: "animation".to_string(), value: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite".to_string(), important: false }]),
            "animate-pulse" => Some(vec![CssProperty { name: "animation".to_string(), value: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite".to_string(), important: false }]),
            "animate-bounce" => Some(vec![CssProperty { name: "animation".to_string(), value: "bounce 1s infinite".to_string(), important: false }]),
            
            _ => None,
        }
    }
    
    /// Parse interactivity classes
    fn parse_interactivity_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        match class {
            "cursor-auto" => Some(vec![CssProperty { name: "cursor".to_string(), value: "auto".to_string(), important: false }]),
            "cursor-default" => Some(vec![CssProperty { name: "cursor".to_string(), value: "default".to_string(), important: false }]),
            "cursor-pointer" => Some(vec![CssProperty { name: "cursor".to_string(), value: "pointer".to_string(), important: false }]),
            "cursor-wait" => Some(vec![CssProperty { name: "cursor".to_string(), value: "wait".to_string(), important: false }]),
            "cursor-text" => Some(vec![CssProperty { name: "cursor".to_string(), value: "text".to_string(), important: false }]),
            "cursor-move" => Some(vec![CssProperty { name: "cursor".to_string(), value: "move".to_string(), important: false }]),
            "cursor-help" => Some(vec![CssProperty { name: "cursor".to_string(), value: "help".to_string(), important: false }]),
            "cursor-not-allowed" => Some(vec![CssProperty { name: "cursor".to_string(), value: "not-allowed".to_string(), important: false }]),
            
            "select-none" => Some(vec![CssProperty { name: "user-select".to_string(), value: "none".to_string(), important: false }]),
            "select-text" => Some(vec![CssProperty { name: "user-select".to_string(), value: "text".to_string(), important: false }]),
            "select-all" => Some(vec![CssProperty { name: "user-select".to_string(), value: "all".to_string(), important: false }]),
            "select-auto" => Some(vec![CssProperty { name: "user-select".to_string(), value: "auto".to_string(), important: false }]),
            
            _ => None,
        }
    }

    /// Convert a CSS rule to CSS string
    fn rule_to_css(&self, rule: &CssRule) -> String {
        let mut css = format!("{} {{\n", rule.selector);
        for property in &rule.properties {
            let important = if property.important { " !important" } else { "" };
            css.push_str(&format!("  {}: {}{};\n", property.name, property.value, important));
        }
        css.push_str("}\n");
        css
    }

    /// Minify CSS by removing unnecessary whitespace
    fn minify_css(&self, css: &str) -> String {
        css.lines()
            .map(|line| line.trim())
            .filter(|line| !line.is_empty())
            .collect::<Vec<&str>>()
            .join("")
            .replace(" {", "{")
            .replace("} ", "}")
            .replace("; ", ";")
            .replace(" ", "")
    }
}

impl Default for CssGenerator {
    fn default() -> Self {
        Self::new()
    }
}

/// Configuration for comprehensive CSS generation
#[derive(Debug, Clone)]
pub struct CssGenerationConfig {
    /// Include color palettes
    pub include_colors: bool,
    /// Include spacing utilities
    pub include_spacing: bool,
    /// Include typography utilities
    pub include_typography: bool,
    /// Include layout utilities
    pub include_layout: bool,
    /// Include flexbox utilities
    pub include_flexbox: bool,
    /// Include grid utilities
    pub include_grid: bool,
    /// Include border utilities
    pub include_borders: bool,
    /// Include effects utilities
    pub include_effects: bool,
    /// Include transform utilities
    pub include_transforms: bool,
    /// Include animation utilities
    pub include_animations: bool,
    /// Include interactivity utilities
    pub include_interactivity: bool,
    /// Include sizing utilities
    pub include_sizing: bool,
    /// Include background utilities
    pub include_backgrounds: bool,
    /// Include filter utilities
    pub include_filters: bool,
    /// Include transition utilities
    pub include_transitions: bool,
    /// Include text shadow utilities
    pub include_text_shadow: bool,
    /// Include mask utilities
    pub include_mask: bool,
    /// Include logical properties
    pub include_logical_properties: bool,
    /// Include enhanced backdrop filters
    pub include_enhanced_backdrop_filters: bool,
    /// Include modern CSS features
    pub include_modern_css_features: bool,
    /// Include device variants
    pub include_device_variants: bool,
    /// Include CSS nesting
    pub include_css_nesting: bool,
    /// Include advanced plugin system
    pub include_advanced_plugin_system: bool,
    /// Include enhanced validation
    pub include_enhanced_validation: bool,
    /// Include advanced performance optimization
    pub include_advanced_performance_optimization: bool,
    /// Include container queries
    pub include_container_queries: bool,
    /// Include color functions
    pub include_color_functions: bool,
    /// Include performance optimization
    pub include_performance_optimization: bool,
    /// Include advanced animations
    pub include_advanced_animations: bool,
    /// Color palettes to include
    pub color_palettes: Vec<String>,
    /// Generate responsive variants
    pub include_responsive: bool,
    /// Generate dark mode variants
    pub include_dark_mode: bool,
}

impl Default for CssGenerationConfig {
    fn default() -> Self {
        Self {
            include_colors: true,
            include_spacing: true,
            include_typography: true,
            include_layout: true,
            include_flexbox: true,
            include_grid: true,
            include_borders: true,
            include_effects: true,
            include_transforms: true,
            include_animations: true,
            include_interactivity: true,
            include_sizing: true,
            include_backgrounds: true,
            include_filters: true,
            include_transitions: true,
            include_text_shadow: true,
            include_mask: true,
            include_logical_properties: true,
            include_enhanced_backdrop_filters: true,
            include_modern_css_features: true,
            include_device_variants: true,
            include_css_nesting: true,
            include_advanced_plugin_system: true,
            include_enhanced_validation: true,
            include_advanced_performance_optimization: true,
            include_container_queries: true,
            include_color_functions: true,
            include_performance_optimization: true,
            include_advanced_animations: true,
            color_palettes: vec![
                "gray".to_string(),
                "blue".to_string(),
                "red".to_string(),
                "green".to_string(),
                "yellow".to_string(),
                "purple".to_string(),
            ],
            include_responsive: true,
            include_dark_mode: true,
        }
    }
}

impl CssGenerator {
    /// Generate comprehensive CSS with all Tailwind utilities
    pub fn generate_comprehensive_css(&mut self, config: &CssGenerationConfig) -> Result<String> {
        // Generate spacing utilities
        if config.include_spacing {
            self.generate_spacing_utilities()?;
        }
        
        // Generate color utilities
        if config.include_colors {
            self.generate_color_utilities(&config.color_palettes)?;
        }
        
        // Generate typography utilities
        if config.include_typography {
            self.generate_typography_utilities()?;
        }
        
        // Generate layout utilities
        if config.include_layout {
            self.generate_layout_utilities()?;
        }
        
        // Generate flexbox utilities
        if config.include_flexbox {
            self.generate_flexbox_utilities()?;
        }
        
        // Generate grid utilities
        if config.include_grid {
            self.generate_grid_utilities()?;
        }
        
        // Generate border utilities
        if config.include_borders {
            self.generate_border_utilities()?;
        }
        
        // Generate effects utilities
        if config.include_effects {
            self.generate_effects_utilities()?;
        }
        
        // Generate transform utilities
        if config.include_transforms {
            self.generate_transform_utilities()?;
        }
        
        // Generate animation utilities
        if config.include_animations {
            self.generate_animation_utilities()?;
        }
        
        // Generate interactivity utilities
        if config.include_interactivity {
            self.generate_interactivity_utilities()?;
        }
        
        // Generate sizing utilities
        if config.include_sizing {
            self.generate_sizing_utilities()?;
        }
        
        // Generate background utilities
        if config.include_backgrounds {
            self.generate_background_utilities()?;
        }
        
        // Generate filter utilities
        if config.include_filters {
            self.generate_filter_utilities()?;
        }
        
        // Generate transition utilities
        if config.include_transitions {
            self.generate_transition_utilities()?;
        }
        
        // Generate text shadow utilities
        if config.include_text_shadow {
            self.generate_text_shadow_utilities()?;
        }
        
        // Generate mask utilities
        if config.include_mask {
            self.generate_mask_utilities()?;
        }
        
        // Generate logical properties utilities
        if config.include_logical_properties {
            self.generate_logical_properties_utilities()?;
        }
        
        // Generate enhanced backdrop filter utilities
        if config.include_enhanced_backdrop_filters {
            self.generate_enhanced_backdrop_filter_utilities()?;
        }
        
        // Generate modern CSS features utilities
        if config.include_modern_css_features {
            self.generate_modern_css_features_utilities()?;
        }
        
        // Generate device variant utilities
        if config.include_device_variants {
            self.generate_device_variant_utilities()?;
        }
        
        // Generate CSS nesting utilities
        if config.include_css_nesting {
            self.generate_css_nesting_utilities()?;
        }
        
        // Generate advanced plugin system utilities
        if config.include_advanced_plugin_system {
            self.generate_advanced_plugin_system_utilities()?;
        }
        
        // Generate enhanced validation utilities
        if config.include_enhanced_validation {
            self.generate_enhanced_validation_utilities()?;
        }
        
        // Generate advanced performance optimization utilities
        if config.include_advanced_performance_optimization {
            self.generate_advanced_performance_optimization_utilities()?;
        }
        
        // Generate container query utilities
        if config.include_container_queries {
            self.generate_container_query_utilities()?;
        }
        
        // Generate color function utilities
        if config.include_color_functions {
            self.generate_color_function_utilities()?;
        }
        
        // Generate performance optimization utilities
        if config.include_performance_optimization {
            self.generate_performance_optimization_utilities()?;
        }
        
        // Generate advanced animation utilities
        if config.include_advanced_animations {
            self.generate_advanced_animation_utilities()?;
        }
        
        // Generate responsive variants
        if config.include_responsive {
            self.generate_responsive_variants()?;
        }
        
        // Generate dark mode variants
        if config.include_dark_mode {
            self.generate_dark_mode_variants()?;
        }
        
        Ok(self.generate_css())
    }
    
    /// Generate spacing utilities (padding, margin, etc.)
    pub fn generate_spacing_utilities(&mut self) -> Result<()> {
        let spacing_values = [
            "0", "px", "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "5", "6", "7", "8", "9", "10",
            "11", "12", "14", "16", "20", "24", "28", "32", "36", "40", "44", "48", "52", "56", "60", "64",
            "72", "80", "96"
        ];
        
        for value in &spacing_values {
            // Padding
            self.add_class(&format!("p-{}", value))?;
            self.add_class(&format!("pt-{}", value))?;
            self.add_class(&format!("pr-{}", value))?;
            self.add_class(&format!("pb-{}", value))?;
            self.add_class(&format!("pl-{}", value))?;
            self.add_class(&format!("px-{}", value))?;
            self.add_class(&format!("py-{}", value))?;
            
            // Margin
            self.add_class(&format!("m-{}", value))?;
            self.add_class(&format!("mt-{}", value))?;
            self.add_class(&format!("mr-{}", value))?;
            self.add_class(&format!("mb-{}", value))?;
            self.add_class(&format!("ml-{}", value))?;
            self.add_class(&format!("mx-{}", value))?;
            self.add_class(&format!("my-{}", value))?;
        }
        
        Ok(())
    }
    
    /// Generate color utilities for specified palettes
    pub fn generate_color_utilities(&mut self, palettes: &[String]) -> Result<()> {
        let color_shades = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
        
        for palette in palettes {
            for shade in &color_shades {
                // Background colors
                self.add_class(&format!("bg-{}-{}", palette, shade))?;
                // Text colors
                self.add_class(&format!("text-{}-{}", palette, shade))?;
                // Border colors
                self.add_class(&format!("border-{}-{}", palette, shade))?;
            }
        }
        
        // Special colors
        self.add_class("bg-white")?;
        self.add_class("bg-black")?;
        self.add_class("bg-transparent")?;
        self.add_class("text-white")?;
        self.add_class("text-black")?;
        self.add_class("text-transparent")?;
        
        Ok(())
    }
    
    /// Generate typography utilities
    pub fn generate_typography_utilities(&mut self) -> Result<()> {
        // Font sizes
        let font_sizes = ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl"];
        for size in &font_sizes {
            self.add_class(&format!("text-{}", size))?;
        }
        
        // Font weights
        let font_weights = ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"];
        for weight in &font_weights {
            self.add_class(&format!("font-{}", weight))?;
        }
        
        // Text alignment
        let alignments = ["left", "center", "right", "justify"];
        for alignment in &alignments {
            self.add_class(&format!("text-{}", alignment))?;
        }
        
        Ok(())
    }
    
    /// Generate layout utilities
    pub fn generate_layout_utilities(&mut self) -> Result<()> {
        let displays = ["block", "inline", "inline-block", "flex", "inline-flex", "grid", "inline-grid", "hidden"];
        for display in &displays {
            self.add_class(display)?;
        }
        
        let positions = ["static", "fixed", "absolute", "relative", "sticky"];
        for position in &positions {
            self.add_class(position)?;
        }
        
        Ok(())
    }
    
    /// Generate flexbox utilities
    pub fn generate_flexbox_utilities(&mut self) -> Result<()> {
        let flex_directions = ["flex-row", "flex-row-reverse", "flex-col", "flex-col-reverse"];
        for direction in &flex_directions {
            self.add_class(direction)?;
        }
        
        let flex_wraps = ["flex-wrap", "flex-wrap-reverse", "flex-nowrap"];
        for wrap in &flex_wraps {
            self.add_class(wrap)?;
        }
        
        let justify_contents = ["justify-start", "justify-end", "justify-center", "justify-between", "justify-around", "justify-evenly"];
        for justify in &justify_contents {
            self.add_class(justify)?;
        }
        
        let align_items = ["items-start", "items-end", "items-center", "items-baseline", "items-stretch"];
        for align in &align_items {
            self.add_class(align)?;
        }
        
        Ok(())
    }
    
    /// Generate grid utilities
    pub fn generate_grid_utilities(&mut self) -> Result<()> {
        let grid_cols = ["1", "2", "3", "4", "5", "6", "12"];
        for cols in &grid_cols {
            self.add_class(&format!("grid-cols-{}", cols))?;
        }
        
        let grid_rows = ["1", "2", "3", "4", "5", "6"];
        for rows in &grid_rows {
            self.add_class(&format!("grid-rows-{}", rows))?;
        }
        
        Ok(())
    }
    
    /// Generate border utilities
    pub fn generate_border_utilities(&mut self) -> Result<()> {
        let border_widths = ["0", "2", "4", "8"];
        for width in &border_widths {
            self.add_class(&format!("border-{}", width))?;
        }
        
        let border_radius = ["none", "sm", "md", "lg", "xl", "2xl", "3xl", "full"];
        for radius in &border_radius {
            self.add_class(&format!("rounded-{}", radius))?;
        }
        
        Ok(())
    }
    
    /// Generate effects utilities
    pub fn generate_effects_utilities(&mut self) -> Result<()> {
        let shadows = ["none", "sm", "md", "lg", "xl", "2xl"];
        for shadow in &shadows {
            self.add_class(&format!("shadow-{}", shadow))?;
        }
        
        Ok(())
    }
    
    /// Generate transform utilities
    pub fn generate_transform_utilities(&mut self) -> Result<()> {
        self.add_class("transform")?;
        
        let scales = ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150"];
        for scale in &scales {
            self.add_class(&format!("scale-{}", scale))?;
        }
        
        Ok(())
    }
    
    /// Generate animation utilities
    pub fn generate_animation_utilities(&mut self) -> Result<()> {
        let animations = ["none", "spin", "ping", "pulse", "bounce"];
        for animation in &animations {
            self.add_class(&format!("animate-{}", animation))?;
        }
        
        Ok(())
    }
    
    /// Generate interactivity utilities
    pub fn generate_interactivity_utilities(&mut self) -> Result<()> {
        let cursors = ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed"];
        for cursor in &cursors {
            self.add_class(&format!("cursor-{}", cursor))?;
        }
        
        let selects = ["none", "text", "all", "auto"];
        for select in &selects {
            self.add_class(&format!("select-{}", select))?;
        }
        
        Ok(())
    }
    
    /// Generate responsive variants
    pub fn generate_responsive_variants(&mut self) -> Result<()> {
        let breakpoints = [Breakpoint::Sm, Breakpoint::Md, Breakpoint::Lg, Breakpoint::Xl, Breakpoint::Xl2];
        let common_classes = ["p-4", "m-4", "bg-blue-500", "text-white", "flex", "grid"];
        
        for breakpoint in &breakpoints {
            for class in &common_classes {
                self.add_responsive_class(*breakpoint, class)?;
            }
        }
        
        Ok(())
    }
    
    /// Generate dark mode variants
    pub fn generate_dark_mode_variants(&mut self) -> Result<()> {
        // This would require dark mode support in the CSS generator
        // For now, we'll add some basic dark mode classes
        let dark_classes = ["dark:bg-gray-800", "dark:text-white", "dark:border-gray-600"];
        
        for class in &dark_classes {
            // Parse dark mode classes and add them
            if let Some(actual_class) = class.strip_prefix("dark:") {
                self.add_class(actual_class)?;
            }
        }
        
        Ok(())
    }
    
    /// Generate sizing utilities (width, height, min/max dimensions)
    pub fn generate_sizing_utilities(&mut self) -> Result<()> {
        let sizing_values = [
            "0", "px", "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "5", "6", "7", "8", "9", "10",
            "11", "12", "14", "16", "20", "24", "28", "32", "36", "40", "44", "48", "52", "56", "60", "64",
            "72", "80", "96", "auto", "full", "screen", "min", "max", "fit"
        ];
        
        for value in &sizing_values {
            // Width utilities
            self.add_class(&format!("w-{}", value))?;
            self.add_class(&format!("min-w-{}", value))?;
            self.add_class(&format!("max-w-{}", value))?;
            
            // Height utilities
            self.add_class(&format!("h-{}", value))?;
            self.add_class(&format!("min-h-{}", value))?;
            self.add_class(&format!("max-h-{}", value))?;
        }
        
        // Special sizing utilities
        let special_sizing = [
            "w-screen", "h-screen", "w-full", "h-full", "w-auto", "h-auto",
            "w-fit", "h-fit", "w-max", "h-max", "w-min", "h-min",
            "w-1/2", "w-1/3", "w-2/3", "w-1/4", "w-3/4", "w-1/5", "w-2/5", "w-3/5", "w-4/5",
            "h-1/2", "h-1/3", "h-2/3", "h-1/4", "h-3/4", "h-1/5", "h-2/5", "h-3/5", "h-4/5",
        ];
        
        for class in &special_sizing {
            self.add_class(class)?;
        }
        
        Ok(())
    }
    
    /// Generate background utilities (images, gradients, attachments)
    pub fn generate_background_utilities(&mut self) -> Result<()> {
        // Background size utilities
        let background_sizes = ["auto", "cover", "contain"];
        for size in &background_sizes {
            self.add_class(&format!("bg-{}", size))?;
        }
        
        // Background position utilities
        let background_positions = [
            "bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"
        ];
        for position in &background_positions {
            self.add_class(&format!("bg-{}", position))?;
        }
        
        // Background repeat utilities
        let background_repeats = ["no-repeat", "repeat", "repeat-x", "repeat-y", "round", "space"];
        for repeat in &background_repeats {
            self.add_class(&format!("bg-{}", repeat))?;
        }
        
        // Background attachment utilities
        let background_attachments = ["fixed", "local", "scroll"];
        for attachment in &background_attachments {
            self.add_class(&format!("bg-{}", attachment))?;
        }
        
        // Background clip utilities
        let background_clips = ["border", "padding", "content", "text"];
        for clip in &background_clips {
            self.add_class(&format!("bg-clip-{}", clip))?;
        }
        
        // Background origin utilities
        let background_origins = ["border", "padding", "content"];
        for origin in &background_origins {
            self.add_class(&format!("bg-origin-{}", origin))?;
        }
        
        Ok(())
    }
    
    /// Generate filter utilities (blur, brightness, contrast, etc.)
    pub fn generate_filter_utilities(&mut self) -> Result<()> {
        // Blur utilities
        let blur_values = ["none", "sm", "0", "1", "2", "3", "xl", "2xl", "3xl"];
        for blur in &blur_values {
            self.add_class(&format!("blur-{}", blur))?;
        }
        
        // Brightness utilities
        let brightness_values = ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"];
        for brightness in &brightness_values {
            self.add_class(&format!("brightness-{}", brightness))?;
        }
        
        // Contrast utilities
        let contrast_values = ["0", "50", "75", "100", "125", "150", "200"];
        for contrast in &contrast_values {
            self.add_class(&format!("contrast-{}", contrast))?;
        }
        
        // Grayscale utilities
        let grayscale_values = ["0", "100"];
        for grayscale in &grayscale_values {
            self.add_class(&format!("grayscale-{}", grayscale))?;
        }
        
        // Hue rotate utilities
        let hue_rotate_values = ["0", "15", "30", "60", "90", "180"];
        for hue_rotate in &hue_rotate_values {
            self.add_class(&format!("hue-rotate-{}", hue_rotate))?;
        }
        
        // Invert utilities
        let invert_values = ["0", "100"];
        for invert in &invert_values {
            self.add_class(&format!("invert-{}", invert))?;
        }
        
        // Saturate utilities
        let saturate_values = ["0", "50", "100", "150", "200"];
        for saturate in &saturate_values {
            self.add_class(&format!("saturate-{}", saturate))?;
        }
        
        // Sepia utilities
        let sepia_values = ["0", "100"];
        for sepia in &sepia_values {
            self.add_class(&format!("sepia-{}", sepia))?;
        }
        
        // Drop shadow utilities
        let drop_shadow_values = ["none", "sm", "0", "1", "2", "3", "xl", "2xl", "3xl"];
        for drop_shadow in &drop_shadow_values {
            self.add_class(&format!("drop-shadow-{}", drop_shadow))?;
        }
        
        Ok(())
    }
    
    /// Generate transition utilities (properties, duration, timing)
    pub fn generate_transition_utilities(&mut self) -> Result<()> {
        // Transition property utilities
        let transition_properties = ["none", "all", "colors", "opacity", "shadow", "transform"];
        for property in &transition_properties {
            self.add_class(&format!("transition-{}", property))?;
        }
        
        // Transition duration utilities
        let transition_durations = ["75", "100", "150", "200", "300", "500", "700", "1000"];
        for duration in &transition_durations {
            self.add_class(&format!("duration-{}", duration))?;
        }
        
        // Transition timing function utilities
        let transition_timing = ["linear", "in", "out", "in-out"];
        for timing in &transition_timing {
            self.add_class(&format!("ease-{}", timing))?;
        }
        
        // Transition delay utilities
        let transition_delays = ["75", "100", "150", "200", "300", "500", "700", "1000"];
        for delay in &transition_delays {
            self.add_class(&format!("delay-{}", delay))?;
        }
        
        Ok(())
    }
    
    /// Generate text shadow utilities
    pub fn generate_text_shadow_utilities(&mut self) -> Result<()> {
        let text_shadow_values = ["none", "sm", "0", "1", "2", "3", "xl", "2xl", "3xl"];
        for shadow in &text_shadow_values {
            self.add_class(&format!("text-shadow-{}", shadow))?;
        }
        
        Ok(())
    }
    
    /// Generate mask utilities
    pub fn generate_mask_utilities(&mut self) -> Result<()> {
        // Mask size utilities
        let mask_sizes = ["auto", "contain", "cover"];
        for size in &mask_sizes {
            self.add_class(&format!("mask-{}", size))?;
        }
        
        // Mask position utilities
        let mask_positions = [
            "bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"
        ];
        for position in &mask_positions {
            self.add_class(&format!("mask-{}", position))?;
        }
        
        // Mask repeat utilities
        let mask_repeats = ["no-repeat", "repeat", "repeat-x", "repeat-y", "round", "space"];
        for repeat in &mask_repeats {
            self.add_class(&format!("mask-{}", repeat))?;
        }
        
        // Mask origin utilities
        let mask_origins = ["border", "padding", "content"];
        for origin in &mask_origins {
            self.add_class(&format!("mask-origin-{}", origin))?;
        }
        
        // Mask clip utilities
        let mask_clips = ["border", "padding", "content", "text"];
        for clip in &mask_clips {
            self.add_class(&format!("mask-clip-{}", clip))?;
        }
        
        Ok(())
    }
    
    /// Generate logical properties utilities
    pub fn generate_logical_properties_utilities(&mut self) -> Result<()> {
        // Logical border utilities
        let logical_borders = ["border-inline", "border-block", "border-inline-start", "border-inline-end", "border-block-start", "border-block-end"];
        for border in &logical_borders {
            self.add_class(border)?;
        }
        
        // Logical margin utilities
        let logical_margins = ["m-inline", "m-block", "m-inline-start", "m-inline-end", "m-block-start", "m-block-end"];
        for margin in &logical_margins {
            self.add_class(margin)?;
        }
        
        // Logical padding utilities
        let logical_paddings = ["p-inline", "p-block", "p-inline-start", "p-inline-end", "p-block-start", "p-block-end"];
        for padding in &logical_paddings {
            self.add_class(padding)?;
        }
        
        // Logical text alignment utilities
        let logical_text_alignments = ["text-inline-start", "text-inline-end", "text-block-start", "text-block-end"];
        for alignment in &logical_text_alignments {
            self.add_class(alignment)?;
        }
        
        Ok(())
    }
    
    /// Generate enhanced backdrop filter utilities
    pub fn generate_enhanced_backdrop_filter_utilities(&mut self) -> Result<()> {
        // Backdrop blur utilities
        let backdrop_blur_values = ["none", "sm", "0", "1", "2", "3", "xl", "2xl", "3xl"];
        for blur in &backdrop_blur_values {
            self.add_class(&format!("backdrop-blur-{}", blur))?;
        }
        
        // Backdrop brightness utilities
        let backdrop_brightness_values = ["0", "50", "75", "90", "95", "100", "105", "110", "125", "150", "200"];
        for brightness in &backdrop_brightness_values {
            self.add_class(&format!("backdrop-brightness-{}", brightness))?;
        }
        
        // Backdrop contrast utilities
        let backdrop_contrast_values = ["0", "50", "75", "100", "125", "150", "200"];
        for contrast in &backdrop_contrast_values {
            self.add_class(&format!("backdrop-contrast-{}", contrast))?;
        }
        
        // Backdrop grayscale utilities
        let backdrop_grayscale_values = ["0", "100"];
        for grayscale in &backdrop_grayscale_values {
            self.add_class(&format!("backdrop-grayscale-{}", grayscale))?;
        }
        
        // Backdrop hue rotate utilities
        let backdrop_hue_rotate_values = ["0", "15", "30", "60", "90", "180"];
        for hue_rotate in &backdrop_hue_rotate_values {
            self.add_class(&format!("backdrop-hue-rotate-{}", hue_rotate))?;
        }
        
        // Backdrop invert utilities
        let backdrop_invert_values = ["0", "100"];
        for invert in &backdrop_invert_values {
            self.add_class(&format!("backdrop-invert-{}", invert))?;
        }
        
        // Backdrop opacity utilities
        let backdrop_opacity_values = ["0", "5", "10", "20", "25", "30", "40", "50", "60", "70", "75", "80", "90", "95", "100"];
        for opacity in &backdrop_opacity_values {
            self.add_class(&format!("backdrop-opacity-{}", opacity))?;
        }
        
        // Backdrop saturate utilities
        let backdrop_saturate_values = ["0", "50", "100", "150", "200"];
        for saturate in &backdrop_saturate_values {
            self.add_class(&format!("backdrop-saturate-{}", saturate))?;
        }
        
        // Backdrop sepia utilities
        let backdrop_sepia_values = ["0", "100"];
        for sepia in &backdrop_sepia_values {
            self.add_class(&format!("backdrop-sepia-{}", sepia))?;
        }
        
        Ok(())
    }
    
    /// Generate modern CSS features utilities
    pub fn generate_modern_css_features_utilities(&mut self) -> Result<()> {
        // Cascade layer utilities
        let cascade_layers = ["base", "components", "utilities"];
        for layer in &cascade_layers {
            self.add_class(&format!("layer-{}", layer))?;
        }
        
        // Custom property utilities
        let custom_properties = ["primary", "secondary", "accent", "neutral", "base-100", "base-200", "base-300"];
        for property in &custom_properties {
            self.add_class(&format!("--{}", property))?;
        }
        
        // Container query utilities
        let container_queries = ["@container", "@container-sm", "@container-md", "@container-lg", "@container-xl"];
        for query in &container_queries {
            self.add_class(query)?;
        }
        
        // CSS nesting utilities
        let nesting_utilities = ["&", "&:hover", "&:focus", "&:active", "&:disabled"];
        for nesting in &nesting_utilities {
            self.add_class(nesting)?;
        }
        
        Ok(())
    }
    
    /// Generate device variant utilities
    pub fn generate_device_variant_utilities(&mut self) -> Result<()> {
        // Device-specific utilities
        let device_variants = [
            "mobile", "tablet", "desktop", "touch", "no-touch", "hover", "no-hover",
            "pointer-coarse", "pointer-fine", "pointer-none", "any-pointer-coarse", "any-pointer-fine", "any-pointer-none"
        ];
        
        for device in &device_variants {
            self.add_class(&format!("{}:", device))?;
        }
        
        Ok(())
    }
    
    /// Generate CSS nesting utilities
    pub fn generate_css_nesting_utilities(&mut self) -> Result<()> {
        // CSS nesting selectors
        let nesting_selectors = [
            "&", "&:hover", "&:focus", "&:active", "&:disabled", "&:checked", "&:indeterminate",
            "&:default", "&:required", "&:valid", "&:invalid", "&:in-range", "&:out-of-range",
            "&:placeholder-shown", "&:autofill", "&:read-only", "&:before", "&:after",
            "&:first-letter", "&:first-line", "&:marker", "&:selection", "&:file",
            "&:backdrop", "&:placeholder", "&:any-link", "&:link", "&:visited", "&:target",
            "&:scope", "&:current", "&:past", "&:future", "&:playing", "&:paused",
            "&:seeking", "&:buffering", "&:stalled", "&:muted", "&:volume-locked"
        ];
        
        for selector in &nesting_selectors {
            self.add_class(selector)?;
        }
        
        Ok(())
    }
    
    /// Generate advanced plugin system utilities
    pub fn generate_advanced_plugin_system_utilities(&mut self) -> Result<()> {
        // Plugin type utilities
        let plugin_types = ["utility", "component", "base", "variant"];
        for plugin_type in &plugin_types {
            self.add_class(&format!("plugin-{}", plugin_type))?;
        }
        
        // Plugin priority utilities
        let plugin_priorities = ["low", "normal", "high", "critical"];
        for priority in &plugin_priorities {
            self.add_class(&format!("plugin-priority-{}", priority))?;
        }
        
        // Plugin lifecycle utilities
        let plugin_lifecycles = ["initialize", "execute", "cleanup", "validate"];
        for lifecycle in &plugin_lifecycles {
            self.add_class(&format!("plugin-{}", lifecycle))?;
        }
        
        // Plugin composition utilities
        let plugin_compositions = ["merge", "extend", "override", "prepend", "append"];
        for composition in &plugin_compositions {
            self.add_class(&format!("plugin-{}", composition))?;
        }
        
        Ok(())
    }
    
    /// Generate enhanced validation utilities
    pub fn generate_enhanced_validation_utilities(&mut self) -> Result<()> {
        // Validation state utilities
        let validation_states = ["valid", "invalid", "pending", "required", "optional"];
        for state in &validation_states {
            self.add_class(&format!("validation-{}", state))?;
        }
        
        // Validation rule utilities
        let validation_rules = ["required", "pattern", "length", "range", "custom"];
        for rule in &validation_rules {
            self.add_class(&format!("validation-rule-{}", rule))?;
        }
        
        // Validation error utilities
        let validation_errors = ["error", "warning", "info", "success"];
        for error in &validation_errors {
            self.add_class(&format!("validation-{}", error))?;
        }
        
        Ok(())
    }
    
    /// Generate advanced performance optimization utilities
    pub fn generate_advanced_performance_optimization_utilities(&mut self) -> Result<()> {
        // Performance optimization utilities
        let performance_optimizations = [
            "will-change-auto", "will-change-scroll", "will-change-contents", "will-change-transform",
            "contain-none", "contain-strict", "contain-content", "contain-layout", "contain-paint", "contain-size",
            "isolation-auto", "isolation-isolate",
            "backface-visibility-visible", "backface-visibility-hidden",
            "perspective-none", "perspective-1000", "perspective-1500", "perspective-2000", "perspective-2500", "perspective-3000",
            "transform-gpu", "transform-cpu", "transform-3d", "transform-2d"
        ];
        
        for optimization in &performance_optimizations {
            self.add_class(optimization)?;
        }
        
        Ok(())
    }
    
    /// Generate container query utilities
    pub fn generate_container_query_utilities(&mut self) -> Result<()> {
        // Container query utilities
        let container_queries = [
            "@container", "@container-sm", "@container-md", "@container-lg", "@container-xl", "@container-2xl",
            "container-type-size", "container-type-inline-size", "container-type-normal",
            "container-name", "container-query"
        ];
        
        for query in &container_queries {
            self.add_class(query)?;
        }
        
        Ok(())
    }
    
    /// Generate color function utilities
    pub fn generate_color_function_utilities(&mut self) -> Result<()> {
        // Color function utilities
        let color_functions = [
            "rgb", "rgba", "hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch",
            "color-mix", "color-contrast", "color-scheme", "color-adjust"
        ];
        
        for function in &color_functions {
            self.add_class(&format!("color-{}", function))?;
        }
        
        Ok(())
    }
    
    /// Generate performance optimization utilities
    pub fn generate_performance_optimization_utilities(&mut self) -> Result<()> {
        // Performance optimization utilities
        let performance_utilities = [
            "optimize-speed", "optimize-quality", "optimize-auto",
            "will-change-auto", "will-change-scroll", "will-change-contents", "will-change-transform",
            "contain-none", "contain-strict", "contain-content", "contain-layout", "contain-paint", "contain-size"
        ];
        
        for utility in &performance_utilities {
            self.add_class(utility)?;
        }
        
        Ok(())
    }
    
    /// Generate advanced animation utilities
    pub fn generate_advanced_animation_utilities(&mut self) -> Result<()> {
        // Advanced animation utilities
        let advanced_animations = [
            "animate-bounce", "animate-ping", "animate-pulse", "animate-spin",
            "animate-ping-slow", "animate-ping-fast", "animate-pulse-slow", "animate-pulse-fast",
            "animate-spin-slow", "animate-spin-fast", "animate-bounce-slow", "animate-bounce-fast",
            "animate-fade-in", "animate-fade-out", "animate-slide-in", "animate-slide-out",
            "animate-zoom-in", "animate-zoom-out", "animate-rotate-in", "animate-rotate-out",
            "animate-scale-in", "animate-scale-out", "animate-flip-in", "animate-flip-out"
        ];
        
        for animation in &advanced_animations {
            self.add_class(animation)?;
        }
        
        Ok(())
    }
    
    /// Parse sizing classes (width, height, min/max dimensions)
    fn parse_sizing_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        // Width utilities
        if class.starts_with("w-") {
            let value = &class[2..];
            return Some(vec![CssProperty { 
                name: "width".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        // Height utilities
        if class.starts_with("h-") {
            let value = &class[2..];
            return Some(vec![CssProperty { 
                name: "height".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        // Min width utilities
        if class.starts_with("min-w-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "min-width".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        // Max width utilities
        if class.starts_with("max-w-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "max-width".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        // Min height utilities
        if class.starts_with("min-h-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "min-height".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        // Max height utilities
        if class.starts_with("max-h-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "max-height".to_string(), 
                value: self.parse_sizing_value(value), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse sizing values
    fn parse_sizing_value(&self, value: &str) -> String {
        match value {
            "0" => "0px".to_string(),
            "px" => "1px".to_string(),
            "auto" => "auto".to_string(),
            "full" => "100%".to_string(),
            "screen" => "100vh".to_string(),
            "min" => "min-content".to_string(),
            "max" => "max-content".to_string(),
            "fit" => "fit-content".to_string(),
            "1/2" => "50%".to_string(),
            "1/3" => "33.333333%".to_string(),
            "2/3" => "66.666667%".to_string(),
            "1/4" => "25%".to_string(),
            "3/4" => "75%".to_string(),
            "1/5" => "20%".to_string(),
            "2/5" => "40%".to_string(),
            "3/5" => "60%".to_string(),
            "4/5" => "80%".to_string(),
            _ => {
                // Handle numeric values
                if let Ok(num) = value.parse::<f64>() {
                    if num < 1.0 {
                        format!("{}rem", num * 0.25)
                    } else {
                        format!("{}rem", num * 0.25)
                    }
                } else {
                    value.to_string()
                }
            }
        }
    }
    
    /// Parse background classes
    fn parse_background_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("bg-") {
            let value = &class[3..];
            return Some(vec![CssProperty { 
                name: "background-size".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("bg-clip-") {
            let value = &class[8..];
            return Some(vec![CssProperty { 
                name: "background-clip".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("bg-origin-") {
            let value = &class[10..];
            return Some(vec![CssProperty { 
                name: "background-origin".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse filter classes
    fn parse_filter_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("blur-") {
            let value = &class[5..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("blur({})", self.parse_blur_value(value)), 
                important: false 
            }]);
        }
        
        if class.starts_with("brightness-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("brightness({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("contrast-") {
            let value = &class[9..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("contrast({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("grayscale-") {
            let value = &class[10..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("grayscale({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("hue-rotate-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("hue-rotate({}deg)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("invert-") {
            let value = &class[7..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("invert({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("saturate-") {
            let value = &class[9..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("saturate({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("sepia-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("sepia({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("drop-shadow-") {
            let value = &class[12..];
            return Some(vec![CssProperty { 
                name: "filter".to_string(), 
                value: format!("drop-shadow({})", self.parse_drop_shadow_value(value)), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse blur values
    fn parse_blur_value(&self, value: &str) -> String {
        match value {
            "none" => "0px".to_string(),
            "sm" => "4px".to_string(),
            "0" => "0px".to_string(),
            "1" => "4px".to_string(),
            "2" => "8px".to_string(),
            "3" => "12px".to_string(),
            "xl" => "24px".to_string(),
            "2xl" => "40px".to_string(),
            "3xl" => "64px".to_string(),
            _ => format!("{}px", value),
        }
    }
    
    /// Parse drop shadow values
    fn parse_drop_shadow_value(&self, value: &str) -> String {
        match value {
            "none" => "0 0 #0000".to_string(),
            "sm" => "0 1px 2px 0 rgb(0 0 0 / 0.05)".to_string(),
            "0" => "0 0 #0000".to_string(),
            "1" => "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)".to_string(),
            "2" => "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)".to_string(),
            "3" => "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)".to_string(),
            "xl" => "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)".to_string(),
            "2xl" => "0 25px 50px -12px rgb(0 0 0 / 0.25)".to_string(),
            "3xl" => "0 35px 60px -12px rgb(0 0 0 / 0.3)".to_string(),
            _ => format!("0 0 #0000"),
        }
    }
    
    /// Parse transition classes
    fn parse_transition_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("transition-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "transition-property".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("duration-") {
            let value = &class[9..];
            return Some(vec![CssProperty { 
                name: "transition-duration".to_string(), 
                value: format!("{}ms", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("ease-") {
            let value = &class[5..];
            return Some(vec![CssProperty { 
                name: "transition-timing-function".to_string(), 
                value: self.parse_ease_value(value), 
                important: false 
            }]);
        }
        
        if class.starts_with("delay-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "transition-delay".to_string(), 
                value: format!("{}ms", value), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse ease values
    fn parse_ease_value(&self, value: &str) -> String {
        match value {
            "linear" => "linear".to_string(),
            "in" => "cubic-bezier(0.4, 0, 1, 1)".to_string(),
            "out" => "cubic-bezier(0, 0, 0.2, 1)".to_string(),
            "in-out" => "cubic-bezier(0.4, 0, 0.2, 1)".to_string(),
            _ => value.to_string(),
        }
    }
    
    /// Parse text shadow classes
    fn parse_text_shadow_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("text-shadow-") {
            let value = &class[12..];
            return Some(vec![CssProperty { 
                name: "text-shadow".to_string(), 
                value: self.parse_text_shadow_value(value), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse text shadow values
    fn parse_text_shadow_value(&self, value: &str) -> String {
        match value {
            "none" => "none".to_string(),
            "sm" => "0 1px 2px rgb(0 0 0 / 0.05)".to_string(),
            "0" => "none".to_string(),
            "1" => "0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px rgb(0 0 0 / 0.1)".to_string(),
            "2" => "0 4px 6px rgb(0 0 0 / 0.1), 0 2px 4px rgb(0 0 0 / 0.1)".to_string(),
            "3" => "0 10px 15px rgb(0 0 0 / 0.1), 0 4px 6px rgb(0 0 0 / 0.1)".to_string(),
            "xl" => "0 20px 25px rgb(0 0 0 / 0.1), 0 8px 10px rgb(0 0 0 / 0.1)".to_string(),
            "2xl" => "0 25px 50px rgb(0 0 0 / 0.25)".to_string(),
            "3xl" => "0 35px 60px rgb(0 0 0 / 0.3)".to_string(),
            _ => "none".to_string(),
        }
    }
    
    /// Parse mask classes
    fn parse_mask_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("mask-") {
            let value = &class[5..];
            return Some(vec![CssProperty { 
                name: "mask-size".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("mask-origin-") {
            let value = &class[12..];
            return Some(vec![CssProperty { 
                name: "mask-origin".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("mask-clip-") {
            let value = &class[10..];
            return Some(vec![CssProperty { 
                name: "mask-clip".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse logical properties classes
    fn parse_logical_properties_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("border-inline") {
            return Some(vec![CssProperty { 
                name: "border-inline".to_string(), 
                value: "1px solid".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("border-block") {
            return Some(vec![CssProperty { 
                name: "border-block".to_string(), 
                value: "1px solid".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("m-inline") {
            return Some(vec![CssProperty { 
                name: "margin-inline".to_string(), 
                value: "0.25rem".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("m-block") {
            return Some(vec![CssProperty { 
                name: "margin-block".to_string(), 
                value: "0.25rem".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("p-inline") {
            return Some(vec![CssProperty { 
                name: "padding-inline".to_string(), 
                value: "0.25rem".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("p-block") {
            return Some(vec![CssProperty { 
                name: "padding-block".to_string(), 
                value: "0.25rem".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("text-inline-start") {
            return Some(vec![CssProperty { 
                name: "text-align".to_string(), 
                value: "start".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("text-inline-end") {
            return Some(vec![CssProperty { 
                name: "text-align".to_string(), 
                value: "end".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("text-block-start") {
            return Some(vec![CssProperty { 
                name: "text-align".to_string(), 
                value: "start".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("text-block-end") {
            return Some(vec![CssProperty { 
                name: "text-align".to_string(), 
                value: "end".to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse enhanced backdrop filter classes
    fn parse_enhanced_backdrop_filter_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("backdrop-blur-") {
            let value = &class[14..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("blur({})", self.parse_blur_value(value)), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-brightness-") {
            let value = &class[19..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("brightness({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-contrast-") {
            let value = &class[17..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("contrast({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-grayscale-") {
            let value = &class[18..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("grayscale({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-hue-rotate-") {
            let value = &class[19..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("hue-rotate({}deg)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-invert-") {
            let value = &class[16..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("invert({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-opacity-") {
            let value = &class[17..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("opacity({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-saturate-") {
            let value = &class[18..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("saturate({}%)", value), 
                important: false 
            }]);
        }
        
        if class.starts_with("backdrop-sepia-") {
            let value = &class[15..];
            return Some(vec![CssProperty { 
                name: "backdrop-filter".to_string(), 
                value: format!("sepia({}%)", value), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse modern CSS features classes
    fn parse_modern_css_features_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("layer-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "layer".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("--") {
            let value = &class[2..];
            return Some(vec![CssProperty { 
                name: "custom-property".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("@container") {
            return Some(vec![CssProperty { 
                name: "container-query".to_string(), 
                value: "true".to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse device variant classes
    fn parse_device_variant_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.ends_with(":") {
            let device = &class[..class.len()-1];
            return Some(vec![CssProperty { 
                name: "device-variant".to_string(), 
                value: device.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse CSS nesting classes
    fn parse_css_nesting_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("&") {
            return Some(vec![CssProperty { 
                name: "nesting-selector".to_string(), 
                value: class.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse advanced plugin system classes
    fn parse_advanced_plugin_system_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("plugin-") {
            let value = &class[7..];
            return Some(vec![CssProperty { 
                name: "plugin-type".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("plugin-priority-") {
            let value = &class[16..];
            return Some(vec![CssProperty { 
                name: "plugin-priority".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse enhanced validation classes
    fn parse_enhanced_validation_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("validation-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "validation-state".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("validation-rule-") {
            let value = &class[15..];
            return Some(vec![CssProperty { 
                name: "validation-rule".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse advanced performance optimization classes
    fn parse_advanced_performance_optimization_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("will-change-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "will-change".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("contain-") {
            let value = &class[8..];
            return Some(vec![CssProperty { 
                name: "contain".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("isolation-") {
            let value = &class[10..];
            return Some(vec![CssProperty { 
                name: "isolation".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("backface-visibility-") {
            let value = &class[19..];
            return Some(vec![CssProperty { 
                name: "backface-visibility".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("perspective-") {
            let value = &class[12..];
            return Some(vec![CssProperty { 
                name: "perspective".to_string(), 
                value: self.parse_perspective_value(value), 
                important: false 
            }]);
        }
        
        if class.starts_with("transform-") {
            let value = &class[10..];
            return Some(vec![CssProperty { 
                name: "transform".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse perspective values
    fn parse_perspective_value(&self, value: &str) -> String {
        match value {
            "none" => "none".to_string(),
            "1000" => "1000px".to_string(),
            "1500" => "1500px".to_string(),
            "2000" => "2000px".to_string(),
            "2500" => "2500px".to_string(),
            "3000" => "3000px".to_string(),
            _ => format!("{}px", value),
        }
    }
    
    /// Parse container query classes
    fn parse_container_query_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("@container") {
            return Some(vec![CssProperty { 
                name: "container-query".to_string(), 
                value: "true".to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("container-type-") {
            let value = &class[15..];
            return Some(vec![CssProperty { 
                name: "container-type".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("container-name") {
            return Some(vec![CssProperty { 
                name: "container-name".to_string(), 
                value: "true".to_string(), 
                important: false 
            }]);
        }
        
        if class == "container-query" {
            return Some(vec![CssProperty { 
                name: "container-query".to_string(), 
                value: "true".to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse color function classes
    fn parse_color_function_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("color-") {
            let value = &class[6..];
            return Some(vec![CssProperty { 
                name: "color-function".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse performance optimization classes
    fn parse_performance_optimization_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("optimize-") {
            let value = &class[9..];
            return Some(vec![CssProperty { 
                name: "optimization".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("will-change-") {
            let value = &class[11..];
            return Some(vec![CssProperty { 
                name: "will-change".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        if class.starts_with("contain-") {
            let value = &class[8..];
            return Some(vec![CssProperty { 
                name: "contain".to_string(), 
                value: value.to_string(), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse advanced animation classes
    fn parse_advanced_animation_class(&self, class: &str) -> Option<Vec<CssProperty>> {
        if class.starts_with("animate-") {
            let value = &class[7..];
            return Some(vec![CssProperty { 
                name: "animation".to_string(), 
                value: self.parse_animation_value(value), 
                important: false 
            }]);
        }
        
        None
    }
    
    /// Parse animation values
    fn parse_animation_value(&self, value: &str) -> String {
        match value {
            "bounce" => "bounce 1s infinite".to_string(),
            "ping" => "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite".to_string(),
            "pulse" => "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite".to_string(),
            "spin" => "spin 1s linear infinite".to_string(),
            "ping-slow" => "ping 2s cubic-bezier(0, 0, 0.2, 1) infinite".to_string(),
            "ping-fast" => "ping 0.5s cubic-bezier(0, 0, 0.2, 1) infinite".to_string(),
            "pulse-slow" => "pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite".to_string(),
            "pulse-fast" => "pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite".to_string(),
            "spin-slow" => "spin 2s linear infinite".to_string(),
            "spin-fast" => "spin 0.5s linear infinite".to_string(),
            "bounce-slow" => "bounce 2s infinite".to_string(),
            "bounce-fast" => "bounce 0.5s infinite".to_string(),
            "fade-in" => "fadeIn 0.5s ease-in".to_string(),
            "fade-out" => "fadeOut 0.5s ease-out".to_string(),
            "slide-in" => "slideIn 0.5s ease-in".to_string(),
            "slide-out" => "slideOut 0.5s ease-out".to_string(),
            "zoom-in" => "zoomIn 0.5s ease-in".to_string(),
            "zoom-out" => "zoomOut 0.5s ease-out".to_string(),
            "rotate-in" => "rotateIn 0.5s ease-in".to_string(),
            "rotate-out" => "rotateOut 0.5s ease-out".to_string(),
            "scale-in" => "scaleIn 0.5s ease-in".to_string(),
            "scale-out" => "scaleOut 0.5s ease-out".to_string(),
            "flip-in" => "flipIn 0.5s ease-in".to_string(),
            "flip-out" => "flipOut 0.5s ease-out".to_string(),
            _ => value.to_string(),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_css_generator_creation() {
        let generator = CssGenerator::new();
        assert_eq!(generator.rule_count(), 0);
        assert!(!generator.breakpoints.is_empty());
    }

    #[test]
    fn test_add_class() {
        let mut generator = CssGenerator::new();
        generator.add_class("p-4").unwrap();
        
        assert_eq!(generator.rule_count(), 1);
        let rules = generator.get_rules();
        assert!(rules.contains_key("p-4"));
    }

    #[test]
    fn test_generate_css() {
        let mut generator = CssGenerator::new();
        generator.add_class("p-4").unwrap();
        generator.add_class("bg-blue-500").unwrap();
        
        let css = generator.generate_css();
        assert!(css.contains(".p-4"));
        assert!(css.contains("padding: 1rem"));
        assert!(css.contains(".bg-blue-500"));
        assert!(css.contains("background-color: #3b82f6"));
    }

    #[test]
    fn test_responsive_class() {
        let mut generator = CssGenerator::new();
        generator.add_responsive_class(Breakpoint::Md, "p-4").unwrap();
        
        let css = generator.generate_css();
        assert!(css.contains("@media (min-width: 768px)"));
        assert!(css.contains("md:p-4"));
    }

    #[test]
    fn test_custom_properties() {
        let mut generator = CssGenerator::new();
        generator.add_custom_property("primary-color", "#3b82f6");
        
        let css = generator.generate_css();
        assert!(css.contains(":root"));
        assert!(css.contains("--primary-color: #3b82f6"));
    }

    #[test]
    fn test_minified_css() {
        let mut generator = CssGenerator::new();
        generator.add_class("p-4").unwrap();
        
        let minified = generator.generate_minified_css();
        assert!(!minified.contains('\n'));
        assert!(!minified.contains(' '));
    }

    #[test]
    fn test_unknown_class() {
        let mut generator = CssGenerator::new();
        let result = generator.add_class("unknown-class");
        assert!(result.is_err());
    }
}