Spaces:
Running

File size: 69,139 Bytes
0d7d06a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Rutas a Pie por España | GR Organizer</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        #map { height: 500px; }
        #detail-map { height: 300px; }
        .route-card:hover { transform: translateY(-5px); }
        .elevation-chart { height: 200px; background: #f8fafc; }
        .custom-popup .leaflet-popup-content-wrapper {
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .gradient-bg {
            background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
        }
        .stage-list {
            max-height: 400px;
            overflow-y: auto;
        }
        .stage-item:hover {
            background-color: #f0f9ff;
        }
        .hidden {
            display: none;
        }
        .tab-active {
            border-bottom: 3px solid #3b82f6;
            color: #3b82f6;
            font-weight: 600;
        }
    </style>
</head>
<body class="bg-gray-50">
    <header class="gradient-bg text-white shadow-lg">
        <div class="container mx-auto px-4 py-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="flex items-center mb-4 md:mb-0">
                    <i class="fas fa-hiking text-3xl mr-3"></i>
                    <h1 class="text-3xl font-bold">GR España</h1>
                </div>
                <nav class="flex space-x-6">
                    <a href="#" class="hover:text-blue-200 font-medium nav-link" data-page="home">Inicio</a>
                    <a href="#" class="hover:text-blue-200 font-medium nav-link" data-page="routes">Rutas</a>
                    <a href="#" class="hover:text-blue-200 font-medium nav-link" data-page="planner">Planificador</a>
                    <a href="#" class="hover:text-blue-200 font-medium nav-link" data-page="community">Comunidad</a>
                </nav>
                <div class="mt-4 md:mt-0">
                    <button class="bg-white text-blue-600 px-4 py-2 rounded-full font-semibold hover:bg-blue-50 transition">
                        <i class="fas fa-user mr-2"></i>Iniciar sesión
                    </button>
                </div>
            </div>
        </div>
    </header>

    <!-- Página de Inicio -->
    <main id="home-page" class="container mx-auto px-4 py-8">
        <section class="mb-12">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div id="map" class="w-full"></div>
                <div class="p-6">
                    <div class="flex flex-wrap justify-between items-center mb-6">
                        <h2 class="text-2xl font-bold text-gray-800">Explora las rutas GR de España</h2>
                        <div class="flex space-x-2 mt-4 md:mt-0">
                            <button id="filter-all" class="px-4 py-2 bg-blue-600 text-white rounded-full text-sm font-medium">Todas</button>
                            <button id="filter-north" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-full text-sm font-medium hover:bg-gray-300">Norte</button>
                            <button id="filter-center" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-full text-sm font-medium hover:bg-gray-300">Centro</button>
                            <button id="filter-south" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-full text-sm font-medium hover:bg-gray-300">Sur</button>
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6" id="routes-grid">
                        <!-- Rutas se cargarán dinámicamente -->
                    </div>
                </div>
            </div>
        </section>

        <section class="mb-12">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <h2 class="text-2xl font-bold text-gray-800 mb-6">Consejos para senderistas</h2>
                    
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                        <div class="border-l-4 border-blue-500 pl-4 py-2">
                            <h3 class="font-semibold text-lg text-gray-800 mb-2">Equipamiento esencial</h3>
                            <p class="text-gray-600">Lleva calzado adecuado, ropa técnica, bastones, mapa y brújula, además de protección solar y suficiente agua.</p>
                        </div>
                        
                        <div class="border-l-4 border-green-500 pl-4 py-2">
                            <h3 class="font-semibold text-lg text-gray-800 mb-2">Temporadas recomendadas</h3>
                            <p class="text-gray-600">Primavera y otoño son las mejores épocas. En verano evita las horas centrales del día, especialmente en el sur.</p>
                        </div>
                        
                        <div class="border-l-4 border-purple-500 pl-4 py-2">
                            <h3 class="font-semibold text-lg text-gray-800 mb-2">Respeto al medio ambiente</h3>
                            <p class="text-gray-600">No dejes basura, sigue los senderos marcados y respeta la fauna y flora local. "No dejes nada más que huellas".</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Página de Detalles de Ruta -->
    <main id="route-detail-page" class="container mx-auto px-4 py-8 hidden">
        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="p-6">
                <button id="back-to-routes" class="mb-4 flex items-center text-blue-600 hover:text-blue-800">
                    <i class="fas fa-arrow-left mr-2"></i> Volver a todas las rutas
                </button>
                
                <div class="flex flex-col md:flex-row gap-6 mb-6">
                    <div class="md:w-2/3">
                        <h2 id="route-title" class="text-3xl font-bold text-gray-800 mb-2"></h2>
                        <div class="flex items-center mb-4">
                            <span id="route-region" class="px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm mr-3"></span>
                            <span id="route-distance" class="text-gray-600"><i class="fas fa-route mr-1"></i></span>
                            <span id="route-duration" class="text-gray-600 ml-3"><i class="fas fa-clock mr-1"></i></span>
                        </div>
                        <p id="route-description" class="text-gray-700 mb-6"></p>
                        
                        <div id="detail-map" class="w-full rounded-lg mb-6"></div>
                    </div>
                    
                    <div class="md:w-1/3">
                        <div class="bg-gray-50 p-4 rounded-lg shadow-sm mb-6">
                            <h3 class="font-semibold text-lg text-gray-800 mb-4">Datos técnicos</h3>
                            <div class="space-y-3">
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Distancia total</span>
                                    <span id="tech-distance" class="font-medium"></span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Desnivel positivo</span>
                                    <span id="tech-ascent" class="font-medium"></span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Desnivel negativo</span>
                                    <span id="tech-descent" class="font-medium"></span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Altitud máxima</span>
                                    <span id="tech-max-alt" class="font-medium"></span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Dificultad</span>
                                    <span id="tech-difficulty" class="font-medium"></span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-600">Época recomendada</span>
                                    <span id="tech-season" class="font-medium"></span>
                                </div>
                            </div>
                        </div>
                        
                        <div class="bg-gray-50 p-4 rounded-lg shadow-sm">
                            <h3 class="font-semibold text-lg text-gray-800 mb-4">Descargas</h3>
                            <div class="space-y-2">
                                <a href="#" class="flex items-center text-blue-600 hover:text-blue-800">
                                    <i class="fas fa-file-pdf mr-2"></i> Guía completa en PDF
                                </a>
                                <a href="#" class="flex items-center text-blue-600 hover:text-blue-800">
                                    <i class="fas fa-map mr-2"></i> Mapa detallado (GPX)
                                </a>
                                <a href="#" class="flex items-center text-blue-600 hover:text-blue-800">
                                    <i class="fas fa-book mr-2"></i> Guía de alojamientos
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="mb-6">
                    <div class="flex border-b border-gray-200">
                        <button class="tab-button py-2 px-4 mr-2 tab-active" data-tab="stages">Etapas</button>
                        <button class="tab-button py-2 px-4 mr-2" data-tab="gallery">Galería</button>
                        <button class="tab-button py-2 px-4 mr-2" data-tab="tips">Consejos</button>
                        <button class="tab-button py-2 px-4" data-tab="reviews">Opiniones</button>
                    </div>
                    
                    <div id="stages-tab" class="tab-content pt-4">
                        <div class="stage-list bg-white rounded-lg border border-gray-200">
                            <!-- Etapas se cargarán dinámicamente -->
                        </div>
                    </div>
                    
                    <div id="gallery-tab" class="tab-content pt-4 hidden">
                        <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                            <div class="bg-gray-200 h-40 rounded-lg flex items-center justify-center">
                                <i class="fas fa-image text-gray-400 text-3xl"></i>
                            </div>
                            <div class="bg-gray-200 h-40 rounded-lg flex items-center justify-center">
                                <i class="fas fa-image text-gray-400 text-3xl"></i>
                            </div>
                            <div class="bg-gray-200 h-40 rounded-lg flex items-center justify-center">
                                <i class="fas fa-image text-gray-400 text-3xl"></i>
                            </div>
                            <div class="bg-gray-200 h-40 rounded-lg flex items-center justify-center">
                                <i class="fas fa-image text-gray-400 text-3xl"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div id="tips-tab" class="tab-content pt-4 hidden">
                        <div class="bg-blue-50 p-4 rounded-lg mb-4">
                            <h4 class="font-semibold text-blue-800 mb-2"><i class="fas fa-info-circle mr-2"></i>Equipamiento recomendado</h4>
                            <p class="text-gray-700">Para esta ruta se recomienda llevar calzado de montaña con buena suela, bastones telescópicos, ropa técnica por capas y protección solar. En algunas etapas es necesario llevar agua suficiente ya que no hay fuentes.</p>
                        </div>
                        <div class="bg-green-50 p-4 rounded-lg mb-4">
                            <h4 class="font-semibold text-green-800 mb-2"><i class="fas fa-utensils mr-2"></i>Avituallamiento</h4>
                            <p class="text-gray-700">Las etapas 3, 7 y 12 no pasan por ningún pueblo con servicios. Es necesario llevar comida suficiente para todo el día. En las demás etapas suele haber al menos un bar o restaurante a mitad de camino.</p>
                        </div>
                        <div class="bg-yellow-50 p-4 rounded-lg">
                            <h4 class="font-semibold text-yellow-800 mb-2"><i class="fas fa-exclamation-triangle mr-2"></i>Precauciones</h4>
                            <p class="text-gray-700">En las etapas de alta montaña (5, 6 y 11) puede haber nieve hasta bien entrada la primavera. Consulta el estado de la ruta antes de salir. Evita estas etapas con mal tiempo ya que la visibilidad puede ser muy reducida.</p>
                        </div>
                    </div>
                    
                    <div id="reviews-tab" class="tab-content pt-4 hidden">
                        <div class="space-y-4">
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-10 h-10 rounded-full bg-gray-300 mr-3"></div>
                                    <div>
                                        <h4 class="font-semibold">Juan Pérez</h4>
                                        <div class="flex text-yellow-400 text-sm">
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star-half-alt"></i>
                                        </div>
                                    </div>
                                </div>
                                <p class="text-gray-700">Hice esta ruta el pasado mes de mayo y fue una experiencia increíble. Los paisajes son espectaculares, especialmente en las etapas de los Pirineos. La señalización es buena en general, aunque en algún tramo hay que estar atento.</p>
                            </div>
                            
                            <div class="bg-white p-4 rounded-lg shadow-sm">
                                <div class="flex items-center mb-2">
                                    <div class="w-10 h-10 rounded-full bg-gray-300 mr-3"></div>
                                    <div>
                                        <h4 class="font-semibold">María Gómez</h4>
                                        <div class="flex text-yellow-400 text-sm">
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="fas fa-star"></i>
                                            <i class="far fa-star"></i>
                                        </div>
                                    </div>
                                </div>
                                <p class="text-gray-700">Ruta muy completa con variedad de paisajes. Recomiendo hacerla en primavera u otoño porque en verano hace mucho calor en algunas etapas. Los albergues están bien pero conviene reservar con antelación.</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-sm">
                    <h3 class="text-xl font-bold text-gray-800 mb-4">Planificar esta ruta</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-semibold text-gray-700 mb-3">Selecciona etapas</h4>
                            <div class="stage-list bg-gray-50 rounded-lg border border-gray-200 p-4 max-h-60 overflow-y-auto">
                                <!-- Etapas para planificación se cargarán dinámicamente -->
                            </div>
                        </div>
                        <div>
                            <h4 class="font-semibold text-gray-700 mb-3">Detalles de tu plan</h4>
                            <div class="bg-blue-50 p-4 rounded-lg mb-4">
                                <div class="flex justify-between mb-2">
                                    <span class="text-gray-700">Etapas seleccionadas:</span>
                                    <span id="selected-stages" class="font-medium">0</span>
                                </div>
                                <div class="flex justify-between mb-2">
                                    <span class="text-gray-700">Distancia total:</span>
                                    <span id="selected-distance" class="font-medium">0 km</span>
                                </div>
                                <div class="flex justify-between">
                                    <span class="text-gray-700">Días estimados:</span>
                                    <span id="selected-days" class="font-medium">0</span>
                                </div>
                            </div>
                            
                            <div class="mb-4">
                                <label class="block text-gray-700 mb-2">Fecha de inicio</label>
                                <input type="date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                            </div>
                            
                            <button class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
                                <i class="fas fa-calendar-plus mr-2"></i>Crear planificación
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- Página de Planificador -->
    <main id="planner-page" class="container mx-auto px-4 py-8 hidden">
        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Planifica tu ruta</h2>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-lg font-semibold mb-4 text-gray-700">Configuración de la ruta</h3>
                        
                        <div class="space-y-4">
                            <div>
                                <label class="block text-gray-700 mb-2">Ruta GR</label>
                                <select id="route-select" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                    <option value="">Selecciona una ruta GR</option>
                                    <!-- Opciones se cargarán dinámicamente -->
                                </select>
                            </div>
                            
                            <div class="grid grid-cols-2 gap-4">
                                <div>
                                    <label class="block text-gray-700 mb-2">Fecha inicio</label>
                                    <input type="date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                </div>
                                <div>
                                    <label class="block text-gray-700 mb-2">Fecha fin</label>
                                    <input type="date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                                </div>
                            </div>
                            
                            <div>
                                <label class="block text-gray-700 mb-2">Nivel de dificultad</label>
                                <div class="flex space-x-4">
                                    <label class="inline-flex items-center">
                                        <input type="radio" name="difficulty" class="h-4 w-4 text-blue-600" value="easy" checked>
                                        <span class="ml-2 text-gray-700">Fácil</span>
                                    </label>
                                    <label class="inline-flex items-center">
                                        <input type="radio" name="difficulty" class="h-4 w-4 text-blue-600" value="moderate">
                                        <span class="ml-2 text-gray-700">Moderado</span>
                                    </label>
                                    <label class="inline-flex items-center">
                                        <input type="radio" name="difficulty" class="h-4 w-4 text-blue-600" value="hard">
                                        <span class="ml-2 text-gray-700">Difícil</span>
                                    </label>
                                </div>
                            </div>
                            
                            <div>
                                <label class="block text-gray-700 mb-2">Alojamiento preferido</label>
                                <div class="flex flex-wrap gap-2">
                                    <span class="px-3 py-1 bg-blue-100 text-blue-800 rounded-full text-sm cursor-pointer accommodation-tag">Refugios</span>
                                    <span class="px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm cursor-pointer accommodation-tag">Campings</span>
                                    <span class="px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm cursor-pointer accommodation-tag">Hoteles</span>
                                    <span class="px-3 py-1 bg-yellow-100 text-yellow-800 rounded-full text-sm cursor-pointer accommodation-tag">Albergues</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-lg font-semibold mb-4 text-gray-700">Perfil de elevación</h3>
                        <div class="elevation-chart rounded-lg border border-gray-200 p-4 mb-6">
                            <!-- Aquí iría el gráfico de elevación -->
                            <div class="flex items-end h-full space-x-1">
                                <div class="w-8 bg-blue-400 rounded-t" style="height: 30%;"></div>
                                <div class="w-8 bg-blue-500 rounded-t" style="height: 50%;"></div>
                                <div class="w-8 bg-blue-600 rounded-t" style="height: 80%;"></div>
                                <div class="w-8 bg-blue-700 rounded-t" style="height: 100%;"></div>
                                <div class="w-8 bg-blue-600 rounded-t" style="height: 75%;"></div>
                                <div class="w-8 bg-blue-500 rounded-t" style="height: 60%;"></div>
                                <div class="w-8 bg-blue-400 rounded-t" style="height: 40%;"></div>
                            </div>
                        </div>
                        
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-medium text-gray-700 mb-2">Resumen de la ruta</h4>
                            <div class="grid grid-cols-3 gap-4 text-center">
                                <div class="bg-white p-3 rounded-lg shadow-sm">
                                    <div class="text-gray-500 text-sm">Distancia</div>
                                    <div id="plan-distance" class="font-bold text-blue-600">0 km</div>
                                </div>
                                <div class="bg-white p-3 rounded-lg shadow-sm">
                                    <div class="text-gray-500 text-sm">Desnivel +</div>
                                    <div id="plan-ascent" class="font-bold text-green-600">0 m</div>
                                </div>
                                <div class="bg-white p-3 rounded-lg shadow-sm">
                                    <div class="text-gray-500 text-sm">Días</div>
                                    <div id="plan-days" class="font-bold text-purple-600">0</div>
                                </div>
                            </div>
                        </div>
                        
                        <button id="save-plan" class="w-full mt-6 bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300">
                            <i class="fas fa-save mr-2"></i>Guardar planificación
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="bg-white rounded-xl shadow-md overflow-hidden mt-8">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Tus planificaciones guardadas</h2>
                
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nombre</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ruta</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fechas</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Dificultad</th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Acciones</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Pirineos 2023</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">GR-11</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">15/06 - 30/06</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <span class="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">Moderado</span>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <button class="text-blue-600 hover:text-blue-900 mr-3"><i class="fas fa-eye"></i></button>
                                    <button class="text-green-600 hover:text-green-900 mr-3"><i class="fas fa-download"></i></button>
                                    <button class="text-red-600 hover:text-red-900"><i class="fas fa-trash-alt"></i></button>
                                </td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Mediterráneo Otoño</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">GR-92</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">10/09 - 20/09</td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <span class="px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-xs">Fácil</span>
                                </td>
                                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                    <button class="text-blue-600 hover:text-blue-900 mr-3"><i class="fas fa-eye"></i></button>
                                    <button class="text-green-600 hover:text-green-900 mr-3"><i class="fas fa-download"></i></button>
                                    <button class="text-red-600 hover:text-red-900"><i class="fas fa-trash-alt"></i></button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </main>

    <!-- Página de Comunidad -->
    <main id="community-page" class="container mx-auto px-4 py-8 hidden">
        <div class="bg-white rounded-xl shadow-md overflow-hidden">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Comunidad de senderistas</h2>
                
                <div class="mb-8">
                    <div class="flex items-center mb-4">
                        <div class="flex-1">
                            <input type="text" placeholder="Buscar en la comunidad..." class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                        </div>
                        <button class="ml-2 bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
                            <i class="fas fa-search"></i>
                        </button>
                    </div>
                    
                    <div class="flex space-x-4 overflow-x-auto pb-2">
                        <button class="px-4 py-2 bg-blue-100 text-blue-800 rounded-full text-sm font-medium whitespace-nowrap">Todos</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">GR-11</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">GR-7</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">GR-10</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">GR-1</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">GR-92</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">Fotos</button>
                        <button class="px-4 py-2 bg-gray-100 text-gray-800 rounded-full text-sm font-medium whitespace-nowrap">Preguntas</button>
                    </div>
                </div>
                
                <div class="space-y-6">
                    <div class="bg-white rounded-lg shadow-md p-6">
                        <div class="flex items-start mb-4">
                            <div class="w-12 h-12 rounded-full bg-gray-300 mr-4"></div>
                            <div>
                                <h3 class="font-semibold">Carlos Martínez</h3>
                                <p class="text-gray-500 text-sm">Hace 2 días · GR-11</p>
                            </div>
                        </div>
                        <p class="text-gray-700 mb-4">¡Acabo de completar la etapa 12 del GR-11! Los paisajes son absolutamente impresionantes, especialmente el paso por el Parque Nacional de Ordesa. La subida fue dura pero la vista desde el collado lo vale todo. ¿Alguien más lo ha hecho recientemente?</p>
                        <div class="flex items-center text-gray-500 text-sm">
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-heart mr-1"></i> 24
                            </button>
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-comment mr-1"></i> 8
                            </button>
                            <button class="flex items-center hover:text-blue-600">
                                <i class="far fa-share-square mr-1"></i> Compartir
                            </button>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-lg shadow-md p-6">
                        <div class="flex items-start mb-4">
                            <div class="w-12 h-12 rounded-full bg-gray-300 mr-4"></div>
                            <div>
                                <h3 class="font-semibold">Ana López</h3>
                                <p class="text-gray-500 text-sm">Hace 1 semana · GR-7</p>
                            </div>
                        </div>
                        <p class="text-gray-700 mb-4">Comparto algunas fotos de mi recorrido por el GR-7 en Castellón. La primavera es sin duda la mejor época para hacer esta parte de la ruta, con todos los almendros en flor. La etapa entre Xert y Sant Mateu es especialmente bonita.</p>
                        <div class="grid grid-cols-2 md:grid-cols-4 gap-2 mb-4">
                            <div class="bg-gray-200 h-32 rounded-lg"></div>
                            <div class="bg-gray-200 h-32 rounded-lg"></div>
                            <div class="bg-gray-200 h-32 rounded-lg"></div>
                            <div class="bg-gray-200 h-32 rounded-lg"></div>
                        </div>
                        <div class="flex items-center text-gray-500 text-sm">
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-heart mr-1"></i> 42
                            </button>
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-comment mr-1"></i> 15
                            </button>
                            <button class="flex items-center hover:text-blue-600">
                                <i class="far fa-share-square mr-1"></i> Compartir
                            </button>
                        </div>
                    </div>
                    
                    <div class="bg-white rounded-lg shadow-md p-6">
                        <div class="flex items-start mb-4">
                            <div class="w-12 h-12 rounded-full bg-gray-300 mr-4"></div>
                            <div>
                                <h3 class="font-semibold">Javier Ruiz</h3>
                                <p class="text-gray-500 text-sm">Hace 3 semanas · Pregunta</p>
                            </div>
                        </div>
                        <p class="text-gray-700 mb-4">Estoy planeando hacer el GR-10 el próximo mes de octubre. ¿Alguien puede recomendarme alojamientos económicos en la zona de Sierra de Aracena? Preferiblemente que no estén muy lejos del camino. ¡Gracias!</p>
                        <div class="flex items-center text-gray-500 text-sm">
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-heart mr-1"></i> 5
                            </button>
                            <button class="flex items-center mr-4 hover:text-blue-600">
                                <i class="far fa-comment mr-1"></i> 7
                            </button>
                            <button class="flex items-center hover:text-blue-600">
                                <i class="far fa-share-square mr-1"></i> Compartir
                            </button>
                        </div>
                    </div>
                </div>
                
                <div class="mt-8 bg-white rounded-lg shadow-md p-6">
                    <h3 class="text-lg font-semibold mb-4">Crea una nueva publicación</h3>
                    <textarea class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 mb-4" rows="3" placeholder="Comparte tus experiencias, fotos o preguntas con la comunidad..."></textarea>
                    <div class="flex justify-between items-center">
                        <div class="flex space-x-2">
                            <button class="p-2 text-gray-500 hover:text-blue-600">
                                <i class="fas fa-camera"></i>
                            </button>
                            <button class="p-2 text-gray-500 hover:text-blue-600">
                                <i class="fas fa-map-marked-alt"></i>
                            </button>
                            <button class="p-2 text-gray-500 hover:text-blue-600">
                                <i class="fas fa-tag"></i>
                            </button>
                        </div>
                        <button class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
                            Publicar
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <footer class="bg-gray-800 text-white py-12">
        <div class="container mx-auto px-4">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
                <div>
                    <h3 class="text-xl font-bold mb-4">GR España</h3>
                    <p class="text-gray-400">La mejor manera de planificar y disfrutar de los senderos de Gran Recorrido en España.</p>
                    <div class="flex space-x-4 mt-4">
                        <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-facebook-f"></i></a>
                        <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter"></i></a>
                        <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-instagram"></i></a>
                        <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-youtube"></i></a>
                    </div>
                </div>
                
                <div>
                    <h4 class="font-semibold mb-4">Rutas populares</h4>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-gray-400 hover:text-white">GR-11 Pirineos</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">GR-7 Mediterráneo</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">GR-10 Sierras del Sur</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">GR-1 Sendero Histórico</a></li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="font-semibold mb-4">Recursos</h4>
                    <ul class="space-y-2">
                        <li><a href="#" class="text-gray-400 hover:text-white">Mapas descargables</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">Guías de etapas</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">Alojamientos</a></li>
                        <li><a href="#" class="text-gray-400 hover:text-white">Foro de la comunidad</a></li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="font-semibold mb-4">Contacto</h4>
                    <ul class="space-y-2">
                        <li class="flex items-center text-gray-400"><i class="fas fa-envelope mr-2"></i> info@grespana.com</li>
                        <li class="flex items-center text-gray-400"><i class="fas fa-phone mr-2"></i> +34 123 456 789</li>
                        <li class="flex items-center text-gray-400"><i class="fas fa-map-marker-alt mr-2"></i> Madrid, España</li>
                    </ul>
                </div>
            </div>
            
            <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
                <p>© 2023 GR España. Todos los derechos reservados.</p>
            </div>
        </div>
    </footer>

    <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
    <script>
        // Datos de las rutas GR
        const grRoutes = [
            {
                id: "gr11",
                name: "GR-11: Pirineos",
                shortDesc: "800 km a través de los Pirineos desde el Atlántico hasta el Mediterráneo.",
                fullDesc: "El GR-11, también conocido como Senda Pirenaica, es una de las rutas de Gran Recorrido más espectaculares de España. Recorre todo el Pirineo de oeste a este, desde el Cabo Higuer (en el mar Cantábrico) hasta el Cap de Creus (en el Mediterráneo). La ruta ofrece una gran variedad de paisajes: desde verdes valles atlánticos hasta las áridas sierras mediterráneas, pasando por los impresionantes paisajes de alta montaña del Pirineo central. El GR-11 está dividido en 45 etapas de entre 15 y 25 km, con un desnivel acumulado positivo total de unos 40,000 metros. La mejor época para realizarlo es entre junio y septiembre, aunque algunas etapas de alta montaña pueden tener nieve hasta bien entrado el verano.",
                region: "norte",
                stages: 45,
                distance: "800 km",
                duration: "6-8 semanas",
                difficulty: "Difícil",
                season: "Junio a Septiembre",
                icon: "fa-mountain",
                color: "from-blue-400 to-green-400",
                coords: [42.6036, 0.7369],
                techDetails: {
                    distance: "800 km",
                    ascent: "40,000 m",
                    descent: "39,500 m",
                    maxAlt: "2,500 m",
                    difficulty: "Alta",
                    season: "Junio-Septiembre"
                },
                stagesDetails: [
                    {number: 1, from: "Cabo Higuer", to: "Bera", distance: "18 km", ascent: "800 m", descent: "400 m", time: "5-6 h"},
                    {number: 2, from: "Bera", to: "Elizondo", distance: "22 km", ascent: "950 m", descent: "900 m", time: "6-7 h"},
                    {number: 3, from: "Elizondo", to: "Puerto de Urkiaga", distance: "20 km", ascent: "1,200 m", descent: "500 m", time: "6-7 h"},
                    {number: 4, from: "Puerto de Urkiaga", to: "Burguete", distance: "17 km", ascent: "600 m", descent: "1,000 m", time: "5 h"},
                    {number: 5, from: "Burguete", to: "Isaba", distance: "24 km", ascent: "1,100 m", descent: "1,050 m", time: "7-8 h"},
                    {number: 6, from: "Isaba", to: "Refugio de Belagua", distance: "14 km", ascent: "1,000 m", descent: "400 m", time: "4-5 h"},
                    {number: 7, from: "Refugio de Belagua", to: "Candanchú", distance: "21 km", ascent: "900 m", descent: "1,300 m", time: "6-7 h"},
                    {number: 8, from: "Candanchú", to: "Sallent de Gállego", distance: "19 km", ascent: "1,000 m", descent: "1,100 m", time: "6 h"},
                    {number: 9, from: "Sallent de Gállego", to: "Refugio de Respomuso", distance: "16 km", ascent: "1,400 m", descent: "500 m", time: "5-6 h"},
                    {number: 10, from: "Refugio de Respomuso", to: "Baños de Panticosa", distance: "15 km", ascent: "600 m", descent: "1,500 m", time: "4-5 h"}
                ]
            },
            {
                id: "gr7",
                name: "GR-7: Mediterráneo",
                shortDesc: "1,300 km desde Tarifa hasta Andorra a través del este peninsular.",
                fullDesc: "El GR-7 es uno de los senderos de Gran Recorrido más largos de España, formando parte del sendero europeo E-4. Comienza en Tarifa (Cádiz), el punto más meridional de Europa continental, y recorre todo el este peninsular hasta llegar a Andorra. La ruta atraviesa numerosos espacios naturales protegidos como el Parque Natural de los Alcornocales, Sierra Nevada, los Puertos de Tortosa-Beceite o el Parque Natural del Cadí-Moixeró. El GR-7 está dividido en 62 etapas de entre 15 y 25 km, con un desnivel acumulado positivo total de unos 35,000 metros. La diversidad de paisajes y climas hace que sea una ruta muy variada, aunque las condiciones más duras se encuentran en las etapas de montaña del norte.",
                region: "este",
                stages: 62,
                distance: "1,300 km",
                duration: "8-10 semanas",
                icon: "fa-sun",
                color: "from-yellow-400 to-orange-400",
                coords: [39.4699, -0.3763],
                difficulty: "Moderado",
                season: "Todo el año (según zona)",
                techDetails: {
                    distance: "1,300 km",
                    ascent: "35,000 m",
                    descent: "34,500 m",
                    maxAlt: "3,400 m",
                    difficulty: "Media",
                    season: "Todo el año (según zona)"
                },
                stagesDetails: [
                    {number: 1, from: "Tarifa", to: "Facinas", distance: "22 km", ascent: "500 m", descent: "400 m", time: "5-6 h"},
                    {number: 2, from: "Facinas", to: "Alcalá de los Gazules", distance: "20 km", ascent: "800 m", descent: "600 m", time: "6 h"},
                    {number: 3, from: "Alcalá de los Gazules", to: "Ubrique", distance: "24 km", ascent: "1,100 m", descent: "900 m", time: "7 h"},
                    {number: 4, from: "Ubrique", to: "Grazalema", distance: "18 km", ascent: "1,000 m", descent: "600 m", time: "5-6 h"},
                    {number: 5, from: "Grazalema", to: "Ronda", distance: "21 km", ascent: "800 m", descent: "900 m", time: "6 h"},
                    {number: 6, from: "Ronda", to: "El Burgo", distance: "23 km", ascent: "900 m", descent: "800 m", time: "6-7 h"},
                    {number: 7, from: "El Burgo", to: "Yunquera", distance: "19 km", ascent: "1,100 m", descent: "900 m", time: "6 h"},
                    {number: 8, from: "Yunquera", to: "Alozaina", distance: "16 km", ascent: "600 m", descent: "1,000 m", time: "4-5 h"},
                    {number: 9, from: "Alozaina", to: "Alora", distance: "20 km", ascent: "700 m", descent: "1,100 m", time: "5-6 h"},
                    {number: 10, from: "Alora", to: "Almogía", distance: "18 km", ascent: "900 m", descent: "600 m", time: "5 h"}
                ]
            },
            {
                id: "gr10",
                name: "GR-10: Sierras del Sur",
                shortDesc: "500 km por las sierras de Andalucía y Extremadura.",
                fullDesc: "El GR-10 recorre las principales sierras del sur de España, desde la Sierra de Grazalema en Cádiz hasta la Sierra de Aracena en Huelva, adentrándose también en Extremadura. Es una ruta que combina paisajes mediterráneos con dehesas y bosques de castaños, ofreciendo una gran diversidad natural y cultural. La ruta está dividida en 28 etapas de entre 15 y 25 km, con un desnivel acumulado positivo total de unos 15,000 metros. A diferencia de otras rutas GR, el GR-10 no es lineal sino que forma una especie de círculo, lo que permite comenzar y terminar en el mismo punto. La mejor época para realizarlo es en primavera y otoño, ya que los veranos pueden ser muy calurosos en algunas zonas.",
                region: "sur",
                stages: 28,
                distance: "500 km",
                duration: "4-5 semanas",
                icon: "fa-tree",
                color: "from-purple-400 to-pink-400",
                coords: [37.5443, -4.7278],
                difficulty: "Moderado",
                season: "Primavera y Otoño",
                techDetails: {
                    distance: "500 km",
                    ascent: "15,000 m",
                    descent: "15,000 m",
                    maxAlt: "1,600 m",
                    difficulty: "Media",
                    season: "Marzo-Junio y Septiembre-Noviembre"
                },
                stagesDetails: [
                    {number: 1, from: "Grazalema", to: "Villaluenga del Rosario", distance: "15 km", ascent: "700 m", descent: "600 m", time: "4-5 h"},
                    {number: 2, from: "Villaluenga del Rosario", to: "Benaocaz", distance: "12 km", ascent: "500 m", descent: "400 m", time: "3-4 h"},
                    {number: 3, from: "Benaocaz", to: "Ubrique", distance: "14 km", ascent: "600 m", descent: "700 m", time: "4 h"},
                    {number: 4, from: "Ubrique", to: "El Bosque", distance: "18 km", ascent: "800 m", descent: "900 m", time: "5-6 h"},
                    {number: 5, from: "El Bosque", to: "Prado del Rey", distance: "16 km", ascent: "700 m", descent: "600 m", time: "4-5 h"},
                    {number: 6, from: "Prado del Rey", to: "Zahara de la Sierra", distance: "20 km", ascent: "900 m", descent: "800 m", time: "6 h"},
                    {number: 7, from: "Zahara de la Sierra", to: "Algodonales", distance: "17 km", ascent: "600 m", descent: "900 m", time: "4-5 h"},
                    {number: 8, from: "Algodonales", to: "Olvera", distance: "19 km", ascent: "800 m", descent: "700 m", time: "5-6 h"},
                    {number: 9, from: "Olvera", to: "Coripe", distance: "22 km", ascent: "900 m", descent: "1,000 m", time: "6-7 h"},
                    {number: 10, from: "Coripe", to: "Montellano", distance: "15 km", ascent: "500 m", descent: "700 m", time: "4 h"}
                ]
            },
            {
                id: "gr1",
                name: "GR-1: Sendero Histórico",
                shortDesc: "1,200 km desde Ampurias hasta Finisterre, siguiendo caminos históricos.",
                fullDesc: "El GR-1 o Sendero Histórico recorre el norte de España desde Ampurias (Girona) hasta Finisterre (A Coruña), siguiendo antiguos caminos históricos como el Camino de Santiago primitivo o las calzadas romanas. La ruta atraviesa paisajes muy variados: desde la costa mediterránea hasta las montañas de los Picos de Europa, pasando por las llanuras de Castilla y León. El GR-1 está dividido en 53 etapas de entre 15 y 25 km, con un desnivel acumulado positivo total de unos 25,000 metros. Es una ruta ideal para aquellos que buscan combinar naturaleza con patrimonio histórico, ya que pasa por numerosos pueblos medievales, monasterios y yacimientos arqueológicos.",
                region: "norte",
                stages: 53,
                distance: "1,200 km",
                duration: "7-9 semanas",
                icon: "fa-landmark",
                color: "from-indigo-400 to-purple-400",
                coords: [42.6453, -2.9291],
                difficulty: "Moderado",
                season: "Mayo a Octubre",
                techDetails: {
                    distance: "1,200 km",
                    ascent: "25,000 m",
                    descent: "24,500 m",
                    maxAlt: "1,800 m",
                    difficulty: "Media",
                    season: "Mayo-Octubre"
                },
                stagesDetails: [
                    {number: 1, from: "Ampurias", to: "Sant Pere Pescador", distance: "16 km", ascent: "200 m", descent: "200 m", time: "4 h"},
                    {number: 2, from: "Sant Pere Pescador", to: "Báscara", distance: "20 km", ascent: "300 m", descent: "300 m", time: "5 h"},
                    {number: 3, from: "Báscara", to: "Sant Martí d'Empúries", distance: "18 km", ascent: "400 m", descent: "400 m", time: "4-5 h"},
                    {number: 4, from: "Sant Martí d'Empúries", to: "Besalú", distance: "22 km", ascent: "500 m", descent: "400 m", time: "5-6 h"},
                    {number: 5, from: "Besalú", to: "Olot", distance: "19 km", ascent: "600 m", descent: "500 m", time: "5 h"},
                    {number: 6, from: "Olot", to: "Sant Pau de Segúries", distance: "21 km", ascent: "800 m", descent: "600 m", time: "6 h"},
                    {number: 7, from: "Sant Pau de Segúries", to: "Camprodon", distance: "17 km", ascent: "700 m", descent: "800 m", time: "5 h"},
                    {number: 8, from: "Camprodon", to: "Ribes de Freser", distance: "23 km", ascent: "1,100 m", descent: "900 m", time: "7 h"},
                    {number: 9, from: "Ribes de Freser", to: "Toses", distance: "18 km", ascent: "1,000 m", descent: "600 m", time: "5-6 h"},
                    {number: 10, from: "Toses", to: "Gombrèn", distance: "20 km", ascent: "800 m", descent: "1,000 m", time: "6 h"}
                ]
            },
            {
                id: "gr92",
                name: "GR-92: Senderos del Mediterráneo",
                shortDesc: "583 km por la costa mediterránea desde Portbou hasta Ulldecona.",
                fullDesc: "El GR-92 recorre toda la costa mediterránea española desde Portbou (Girona) hasta Ulldecona (Tarragona), aunque su trazado completo llega hasta Cádiz. Es una ruta ideal para aquellos que quieren combinar senderismo con playas y calas espectaculares. La parte catalana del GR-92 está dividida en 35 etapas de entre 10 y 20 km, con un desnivel acumulado positivo total de unos 12,000 metros. La ruta alterna tramos por la costa con excursiones al interior, pasando por parques naturales como el Cap de Creus, el Montseny o el Delta del Ebro. La mejor época para realizarla es primavera y otoño, evitando los meses de mayor afluencia turística.",
                region: "este",
                stages: 35,
                distance: "583 km",
                duration: "5-6 semanas",
                icon: "fa-umbrella-beach",
                color: "from-blue-400 to-cyan-400",
                coords: [41.3851, 2.1734],
                difficulty: "Fácil",
                season: "Primavera y Otoño",
                techDetails: {
                    distance: "583 km",
                    ascent: "12,000 m",
                    descent: "12,000 m",
                    maxAlt: "800 m",
                    difficulty: "Baja",
                    season: "Abril-Junio y Septiembre-Octubre"
                },
                stagesDetails: [
                    {number: 1, from: "Portbou", to: "Llançà", distance: "15 km", ascent: "500 m", descent: "500 m", time: "4 h"},
                    {number: 2, from: "Llançà", to: "Cadaqués", distance: "18 km", ascent: "600 m", descent: "600 m", time: "5 h"},
                    {number: 3, from: "Cadaqués", to: "Roses", distance: "16 km", ascent: "500 m", descent: "500 m", time: "4-5 h"},
                    {number: 4, from: "Roses", to: "L'Escala", distance: "20 km", ascent: "400 m", descent: "400 m", time: "5 h"},
                    {number: 5, from: "L'Escala", to: "Torroella de Montgrí", distance: "12 km", ascent: "300 m", descent: "300 m", time: "3 h"},
                    {number: 6, from: "Torroella de Montgrí", to: "Pals", distance: "14 km", ascent: "200 m", descent: "200 m", time: "3-4 h"},
                    {number: 7, from: "Pals", to: "Palafrugell", distance: "10 km", ascent: "100 m", descent: "100 m", time: "2-3 h"},
                    {number: 8, from: "Palafrugell", to: "Calella de Palafrugell", distance: "8 km", ascent: "150 m", descent: "150 m", time: "2 h"},
                    {number: 9, from: "Calella de Palafrugell", to: "Tamariu", distance: "6 km", ascent: "200 m", descent: "200 m", time: "1.5 h"},
                    {number: 10, from: "Tamariu", to: "Begur", distance: "12 km", ascent: "300 m", descent: "300 m", time: "3 h"}
                ]
            }
        ];

        // Variables globales
        let map;
        let detailMap;
        let currentRoute = null;
        let routeLayer = null;

        // Inicializar la aplicación
        document.addEventListener('DOMContentLoaded', function() {
            initMap();
            loadRoutes();
            setupEventListeners();
            populateRouteSelect();
        });

        // Inicializar el mapa principal
        function initMap() {
            map = L.map('map').setView([40.4168, -3.7038], 6);
            
            L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
            }).addTo(map);
            
            // Añadir marcadores para rutas GR importantes
            grRoutes.forEach(route => {
                const marker = L.marker(route.coords).addTo(map);
                marker.getElement().classList.add(`route-${route.region}`);
                
                marker.bindPopup(`
                    <div class="custom-popup">
                        <h3 class="font-bold text-lg mb-2">${route.name}</h3>
                        <div class="flex items-center mb-2">
                            <i class="fas ${route.icon} text-blue-500 mr-2"></i>
                            <span>${route.distance}</span>
                        </div>
                        <div class="flex items-center mb-2">
                            <i class="fas fa-route text-green-500 mr-2"></i>
                            <span>${route.stages} etapas</span>
                        </div>
                        <button class="mt-2 w-full bg-blue-500 hover:bg-blue-600 text-white py-1 px-3 rounded text-sm route-detail-btn" data-route="${route.id}">
                            Ver detalles
                        </button>
                    </div>
                `);
            });
        }

        // Cargar las rutas en el grid
        function loadRoutes() {
            const routesGrid = document.getElementById('routes-grid');
            routesGrid.innerHTML = '';
            
            grRoutes.forEach(route => {
                const routeCard = document.createElement('div');
                routeCard.className = 'route-card bg-white border border-gray-200 rounded-lg overflow-hidden shadow-sm hover:shadow-md transition duration-300';
                routeCard.innerHTML = `
                    <div class="h-48 bg-gradient-to-r ${route.color} flex items-center justify-center">
                        <i class="fas ${route.icon} text-white text-6xl opacity-70"></i>
                    </div>
                    <div class="p-5">
                        <h3 class="text-xl font-bold mb-2">${route.name}</h3>
                        <p class="text-gray-600 mb-4">${route.shortDesc}</p>
                        <div class="flex justify-between items-center">
                            <span class="text-sm text-gray-500"><i class="fas fa-route mr-1"></i> ${route.stages} etapas</span>
                            <button class="text-blue-600 font-medium hover:text-blue-800 route-detail-btn" data-route="${route.id}">Ver ruta</button>
                        </div>
                    </div>
                `;
                
                routesGrid.appendChild(routeCard);
            });
        }

        // Configurar event listeners
        function setupEventListeners() {
            // Navegación entre páginas
            document.querySelectorAll('.nav-link').forEach(link => {
                link.addEventListener('click', function(e) {
                    e.preventDefault();
                    const page = this.getAttribute('data-page');
                    showPage(page);
                });
            });
            
            // Botón para volver a rutas desde detalle
            document.getElementById('back-to-routes').addEventListener('click', function() {
                showPage('home');
            });
            
            // Filtros de región
            document.getElementById('filter-all').addEventListener('click', () => {
                document.querySelectorAll('.leaflet-marker-icon').forEach(marker => {
                    marker.style.display = 'block';
                });
                updateActiveFilter('filter-all');
            });
            
            document.getElementById('filter-north').addEventListener('click', () => {
                document.querySelectorAll('.leaflet-marker-icon').forEach(marker => {
                    marker.style.display = marker.classList.contains('route-north') ? 'block' : 'none';
                });
                updateActiveFilter('filter-north');
            });
            
            document.getElementById('filter-center').addEventListener('click', () => {
                document.querySelectorAll('.leaflet-marker-icon').forEach(marker => {
                    marker.style.display = 'none'; // No hay rutas en el centro en este ejemplo
                });
                updateActiveFilter('filter-center');
            });
            
            document.getElementById('filter-south').addEventListener('click', () => {
                document.querySelectorAll('.leaflet-marker-icon').forEach(marker => {
                    marker.style.display = marker.classList.contains('route-south') ? 'block' : 'none';
                });
                updateActiveFilter('filter-south');
            });
            
            // Delegación de eventos para botones de detalle
            document.addEventListener('click', function(e) {
                if (e.target.classList.contains('route-detail-btn')) {
                    const routeId = e.target.getAttribute('data-route');
                    showRouteDetail(routeId);
                }
                
                // Tabs en página de detalle
                if (e.target.classList.contains('tab-button')) {
                    const tab = e.target.getAttribute('data-tab');
                    showTab(tab);
                }
                
                // Tags de alojamiento
                if (e.target.classList.contains('accommodation-tag')) {
                    e.target.classList.toggle('bg-blue-100');
                    e.target.classList.toggle('bg-blue-600');
                    e.target.classList.toggle('text-blue-800');
                    e.target.classList.toggle('text-white');
                }
            });
            
            // Cambio en selección de ruta en planificador
            document.getElementById('route-select').addEventListener('change', function() {
                const routeId = this.value;
                if (routeId) {
                    const route = grRoutes.find(r => r.id === routeId);
                    updatePlanSummary(route);
                } else {
                    resetPlanSummary();
                }
            });
            
            // Guardar planificación
            document.getElementById('save-plan').addEventListener('click', function() {
                alert('Planificación guardada correctamente');
            });
        }

        // Mostrar página específica
        function showPage(page) {
            document.getElementById('home-page').classList.add('hidden');
            document.getElementById('route-detail-page').classList.add('hidden');
            document.getElementById('planner-page').classList.add('hidden');
            document.getElementById('community-page').classList.add('hidden');
            
            document.getElementById(`${page}-page`).classList.remove('hidden');
            
            // Ajustar mapa cuando se muestra la página de inicio
            if (page === 'home') {
                setTimeout(() => {
                    map.invalidateSize();
                }, 100);
            }
        }

        // Actualizar filtro activo
        function updateActiveFilter(activeId) {
            document.querySelectorAll('[id^="filter-"]').forEach(btn => {
                if (btn.id === activeId) {
                    btn.classList.remove('bg-gray-200', 'text-gray-700');
                    btn.classList.add('bg-blue-600', 'text-white');
                } else {
                    btn.classList.remove('bg-blue-600', 'text-white');
                    btn.classList.add('bg-gray-200', 'text-gray-700');
                }
            });
        }

        // Mostrar detalles de una ruta
        function showRouteDetail(routeId) {
            currentRoute = grRoutes.find(route => route.id === routeId);
            
            // Actualizar información básica
            document.getElementById('route-title').textContent = currentRoute.name;
            document.getElementById('route-description').textContent = currentRoute.fullDesc;
            document.getElementById('route-region').textContent = currentRoute.region === 'norte' ? 'Norte' : 
                                                               currentRoute.region === 'este' ? 'Este' : 'Sur';
            document.getElementById('route-distance').innerHTML = `<i class="fas fa-route mr-1"></i> ${currentRoute.distance}`;
            document.getElementById('route-duration').innerHTML = `<i class="fas fa-clock mr-1"></i> ${currentRoute.duration}`;
            
            // Actualizar detalles técnicos
            document.getElementById('tech-distance').textContent = currentRoute.techDetails.distance;
            document.getElementById('tech-ascent').textContent = currentRoute.techDetails.ascent;
            document.getElementById('tech-descent').textContent = currentRoute.techDetails.descent;
            document.getElementById('tech-max-alt').textContent = currentRoute.techDetails.maxAlt;
            document.getElementById('tech-difficulty').textContent = currentRoute.techDetails.difficulty;
            document.getElementById('tech-season').textContent = currentRoute.techDetails.season;
            
            // Inicializar mapa de detalle
            if (detailMap) {
                detailMap.remove();
            }
            
            detailMap = L.map('detail-map').setView(currentRoute.coords, 10);
            L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
            }).addTo(detailMap);
            
            // Añadir marcador de la ruta
            L.marker(currentRoute.coords).addTo(detailMap)
                .bindPopup(currentRoute.name);
            
            // Aquí normalmente cargaríamos el trazado real de la ruta
            // Por simplicidad, mostramos un círculo alrededor del marcador
            if (routeLayer) {
                detailMap.removeLayer(routeLayer);
            }
            routeLayer = L.circle(currentRoute.coords, {
                color: '#3b82f6',
                fillColor: '#3b82f6',
                fillOpacity: 0.2,
                radius: 15000
            }).addTo(detailMap);
            
            // Cargar etapas
            loadStages(currentRoute);
            
            // Mostrar página de detalle
            showPage('route-detail');
        }

        // Cargar etapas de la ruta
        function loadStages(route) {
            const stagesList = document.querySelectorAll('.stage-list');
            
            stagesList.forEach(list => {
                list.innerHTML = '';
                
                route.stagesDetails.forEach(stage => {
                    const stageItem = document.createElement('div');
                    stageItem.className = 'stage-item p-4 border-b border-gray-200 last:border-b-0 hover:bg-blue-50 cursor-pointer transition';
                    
                    if (list.id === 'planning-stages') {
                        stageItem.innerHTML = `
                            <div class="flex items-center">
                                <input type="checkbox" class="mr-3 stage-check
</html>