File size: 33,133 Bytes
a726fb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Corbeil-Essonnes 2025 - Cartographie Socio-Écologique</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/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: calc(100vh - 80px);
            width: 100%;
            z-index: 1;
        }
        .leaflet-control-layers-toggle {
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%234CAF50"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><circle cx="12" cy="12" r="5"/></svg>') !important;
        }
        .custom-popup .leaflet-popup-content-wrapper {
            background: #f8fafc;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        .custom-popup .leaflet-popup-tip {
            background: #f8fafc;
        }
        .legend {
            background: white;
            padding: 10px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .legend i {
            width: 18px;
            height: 18px;
            float: left;
            margin-right: 8px;
            opacity: 0.7;
        }
        .sidebar {
            transition: all 0.3s ease;
        }
        .sidebar.collapsed {
            transform: translateX(-90%);
        }
        .chart-container {
            height: 200px;
            width: 100%;
        }
        .pulse {
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        .chat-modal {
            display: none;
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 350px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.2);
            z-index: 1000;
        }
        .chat-header {
            background: #4CAF50;
            color: white;
            padding: 15px;
            border-top-left-radius: 12px;
            border-top-right-radius: 12px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .chat-body {
            padding: 15px;
            height: 300px;
            overflow-y: auto;
        }
        .chat-input {
            display: flex;
            padding: 10px;
            border-top: 1px solid #eee;
        }
        .event-badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
            margin-right: 5px;
        }
    </style>
</head>
<body class="bg-green-50 font-sans">
    <!-- Header -->
    <header class="bg-green-700 text-white shadow-lg">
        <div class="container mx-auto px-4 py-4 flex justify-between items-center">
            <div class="flex items-center space-x-4">
                <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Corbeil-Essonnes_logo.svg/1200px-Corbeil-Essonnes_logo.svg.png" alt="Logo Corbeil-Essonnes" class="h-12">
                <div>
                    <h1 class="text-2xl font-bold">Corbeil-Essonnes 2025</h1>
                    <p class="text-green-100">Cartographie Socio-Écologique Interactive</p>
                </div>
            </div>
            <div class="flex items-center space-x-4">
                <button id="toggle-sidebar" class="bg-green-600 hover:bg-green-500 px-4 py-2 rounded-lg flex items-center">
                    <i class="fas fa-layer-group mr-2"></i> Couches
                </button>
                <button class="bg-green-600 hover:bg-green-500 px-4 py-2 rounded-lg flex items-center">
                    <i class="fas fa-download mr-2"></i> Exporter
                </button>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <div class="flex">
        <!-- Sidebar -->
        <div id="sidebar" class="sidebar w-80 bg-white shadow-lg h-screen fixed z-20">
            <div class="p-4 border-b border-gray-200 flex justify-between items-center bg-green-600 text-white">
                <h2 class="text-xl font-semibold">Couches Cartographiques</h2>
                <button id="collapse-sidebar" class="text-white">
                    <i class="fas fa-chevron-left"></i>
                </button>
            </div>
            <div class="p-4 space-y-4">
                <div class="space-y-2">
                    <h3 class="font-medium text-green-800">Environnement</h3>
                    <div class="space-y-2">
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" checked data-layer="espaces-verts">
                            <span>Espaces Verts</span>
                        </label>
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" checked data-layer="biodiversite">
                            <span>Zones de Biodiversité</span>
                        </label>
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" data-layer="pollution">
                            <span>Niveaux de Pollution</span>
                        </label>
                    </div>
                </div>
                
                <div class="space-y-2">
                    <h3 class="font-medium text-green-800">Social</h3>
                    <div class="space-y-2">
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" data-layer="densite">
                            <span>Densité de Population</span>
                        </label>
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" data-layer="revenus">
                            <span>Revenus Médians</span>
                        </label>
                    </div>
                </div>
                
                <div class="space-y-2">
                    <h3 class="font-medium text-green-800">Activités</h3>
                    <div class="space-y-2">
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" checked data-layer="evenements">
                            <span>Événements Écologiques</span>
                        </label>
                        <label class="flex items-center space-x-2">
                            <input type="checkbox" class="form-checkbox text-green-600" checked data-layer="associations">
                            <span>Associations Locales</span>
                        </label>
                    </div>
                </div>
            </div>
            
            <div class="p-4 border-t border-gray-200">
                <h3 class="font-medium text-green-800 mb-2">Indicateurs Clés</h3>
                <div class="bg-green-50 rounded-lg p-3 mb-3">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-green-700">Qualité de l'Air</span>
                        <span class="text-green-600 font-bold">78/100</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div class="bg-green-500 h-2 rounded-full" style="width: 78%"></div>
                    </div>
                </div>
                <div class="bg-green-50 rounded-lg p-3 mb-3">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-green-700">Accès aux Espaces Verts</span>
                        <span class="text-green-600 font-bold">92%</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div class="bg-green-500 h-2 rounded-full" style="width: 92%"></div>
                    </div>
                </div>
                <div class="bg-green-50 rounded-lg p-3">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-green-700">Engagement Citoyen</span>
                        <span class="text-green-600 font-bold">42 événements/mois</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div class="bg-green-500 h-2 rounded-full" style="width: 65%"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Map Container -->
        <div class="flex-1 ml-80">
            <div id="map"></div>
            
            <!-- Floating Info Panel -->
            <div class="absolute bottom-4 right-4 bg-white rounded-lg shadow-xl z-10 w-80 overflow-hidden">
                <div class="bg-green-600 text-white p-3 flex justify-between items-center">
                    <h3 class="font-semibold">Zone Sélectionnée</h3>
                    <button id="close-info" class="text-white hover:text-green-200">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                <div id="info-content" class="p-4">
                    <div class="text-center py-8 text-gray-500">
                        <i class="fas fa-map-marker-alt text-3xl mb-2 text-green-500"></i>
                        <p>Cliquez sur la carte pour voir les détails d'une zone</p>
                    </div>
                </div>
            </div>
            
            <!-- Legend -->
            <div class="absolute bottom-4 left-80 ml-4 bg-white rounded-lg shadow-lg z-10 p-4 legend">
                <h4 class="font-medium mb-2 text-green-800">Légende</h4>
                <div class="space-y-2">
                    <div><i style="background: #4CAF50"></i> Espaces Verts</div>
                    <div><i style="background: #8BC34A"></i> Biodiversité</div>
                    <div><i style="background: #FFC107"></i> Événements</div>
                    <div><i style="background: #9C27B0"></i> Associations</div>
                    <div><i style="background: #FF9800"></i> Pollution Modérée</div>
                    <div><i style="background: #F44336"></i> Pollution Élevée</div>
                </div>
            </div>
        </div>
    </div>

    <!-- Floating Action Button -->
    <div class="fixed bottom-6 right-6 z-10">
        <button id="fab" class="bg-green-600 hover:bg-green-500 text-white rounded-full w-14 h-14 flex items-center justify-center shadow-lg pulse">
            <i class="fas fa-leaf text-xl"></i>
        </button>
    </div>

    <!-- Chat Modal -->
    <div id="chat-modal" class="chat-modal">
        <div class="chat-header">
            <h3 id="chat-title">Chat avec l'organisation</h3>
            <button id="close-chat" class="text-white">
                <i class="fas fa-times"></i>
            </button>
        </div>
        <div id="chat-body" class="chat-body">
            <div class="text-center text-gray-500 py-10">
                <i class="fas fa-comments text-3xl mb-2"></i>
                <p>Connectez-vous avec l'organisation</p>
            </div>
        </div>
        <div class="chat-input">
            <input type="text" id="chat-message" placeholder="Tapez votre message..." class="flex-1 border rounded-l-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-green-500">
            <button id="send-message" class="bg-green-500 text-white px-4 py-2 rounded-r-lg hover:bg-green-600">
                <i class="fas fa-paper-plane"></i>
            </button>
        </div>
    </div>

    <script>
        // Initialize the map
        const map = L.map('map').setView([48.6139, 2.4820], 13);
        
        // Add base layer
        L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
            attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
            maxZoom: 19
        }).addTo(map);
        
        // Add Corbeil-Essonnes overlay
        const corbeilOverlay = L.imageOverlay(
            'https://upload.wikimedia.org/wikipedia/commons/2/24/91174-Corbeil-Essonnes-Sols.png', 
            [[48.5900, 2.4500], [48.6300, 2.5100]], 
            { opacity: 0.7 }
        ).addTo(map);
        
        // Sample data for ecological zones
        const greenSpaces = [
            { lat: 48.615, lng: 2.475, name: "Parc des Tarterêts", area: "5.2 ha", biodiversity: "Élevée", facilities: "Aire de jeux, Sentiers" },
            { lat: 48.618, lng: 2.488, name: "Jardin de la Nacelle", area: "1.8 ha", biodiversity: "Moyenne", facilities: "Bassin, Bancs" },
            { lat: 48.605, lng: 2.470, name: "Bois des Templiers", area: "12.5 ha", biodiversity: "Très élevée", facilities: "Sentiers, Observatoire" }
        ];
        
        // Add markers for green spaces
        greenSpaces.forEach(space => {
            const marker = L.marker([space.lat, space.lng], {
                icon: L.divIcon({
                    className: 'custom-marker',
                    html: `<div class="bg-green-500 text-white rounded-full w-8 h-8 flex items-center justify-center shadow-lg"><i class="fas fa-tree"></i></div>`,
                    iconSize: [24, 24]
                })
            }).addTo(map);
            
            marker.bindPopup(`
                <div class="custom-popup">
                    <h3 class="font-bold text-lg text-green-700">${space.name}</h3>
                    <p class="text-sm text-gray-600">${space.area} - Biodiversité: ${space.biodiversity}</p>
                    <p class="text-sm mt-2"><span class="font-medium">Équipements:</span> ${space.facilities}</p>
                    <div class="mt-3 flex justify-between text-xs">
                        <span class="bg-green-100 text-green-800 px-2 py-1 rounded">Espace Vert</span>
                        <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded">Accès Libre</span>
                    </div>
                </div>
            `);
        });
        
        // Sample pollution data
        const pollutionZones = [
            { lat: 48.612, lng: 2.492, level: "Modérée", sources: "Trafic routier", value: 45 },
            { lat: 48.608, lng: 2.478, level: "Élevée", sources: "Industrie, Trafic", value: 68 }
        ];
        
        pollutionZones.forEach(zone => {
            const color = zone.level === "Élevée" ? "#F44336" : "#FF9800";
            const marker = L.circleMarker([zone.lat, zone.lng], {
                radius: 10,
                color: color,
                fillColor: color,
                fillOpacity: 0.7
            }).addTo(map);
            
            marker.bindPopup(`
                <div class="custom-popup">
                    <h3 class="font-bold text-lg">Niveau de Pollution: ${zone.level}</h3>
                    <p class="text-sm text-gray-600 mt-1">Indice: ${zone.value}/100</p>
                    <p class="text-sm"><span class="font-medium">Sources:</span> ${zone.sources}</p>
                    <div class="mt-3">
                        <div class="flex justify-between text-xs mb-1">
                            <span>0</span>
                            <span>25</span>
                            <span>50</span>
                            <span>75</span>
                            <span>100</span>
                        </div>
                        <div class="w-full bg-gray-200 rounded-full h-2">
                            <div class="bg-gradient-to-r from-green-500 via-yellow-500 to-red-500 h-2 rounded-full" style="width: ${zone.value}%"></div>
                        </div>
                    </div>
                </div>
            `);
        });
        
        // Social-ecological activities and events
        const activities = [
            { 
                lat: 48.616, 
                lng: 2.480, 
                title: "Atelier de Jardinage Urbain", 
                org: "Vert l'Avenir", 
                date: "15/06/2025", 
                time: "14h-17h", 
                desc: "Apprenez les techniques de jardinage écologique en ville et repartez avec vos propres plants.", 
                type: "atelier",
                contact: "[email protected]",
                participants: 24
            },
            { 
                lat: 48.610, 
                lng: 2.485, 
                title: "Nettoyage Citoyen de la Seine", 
                org: "Essonnes Propre", 
                date: "22/06/2025", 
                time: "10h-13h", 
                desc: "Rejoignez-nous pour nettoyer les berges de la Seine et sensibiliser à la pollution plastique.", 
                type: "collectif",
                contact: "[email protected]",
                participants: 56
            },
            { 
                lat: 48.613, 
                lng: 2.476, 
                title: "Marché de Producteurs Locaux", 
                org: "Terroirs Essonniens", 
                date: "Tous les samedis", 
                time: "8h-13h", 
                desc: "Découvrez des produits locaux, bio et de saison directement des producteurs de la région.", 
                type: "marche",
                contact: "[email protected]",
                participants: 120
            },
            { 
                lat: 48.619, 
                lng: 2.483, 
                title: "Conférence sur la Transition Énergétique", 
                org: "Énergie Citoyenne", 
                date: "28/06/2025", 
                time: "18h30-20h30", 
                desc: "Échangez avec des experts sur les solutions énergétiques locales et durables.", 
                type: "conference",
                contact: "[email protected]",
                participants: 80
            },
            { 
                lat: 48.607, 
                lng: 2.472, 
                title: "Atelier de Réparation Vélo", 
                org: "Cyclo Écolo", 
                date: "Tous les mercredis", 
                time: "16h-19h", 
                desc: "Apprenez à réparer votre vélo avec nos mécaniciens bénévoles et prolongez sa durée de vie.", 
                type: "atelier",
                contact: "[email protected]",
                participants: 15
            }
        ];
        
        // Add markers for activities
        activities.forEach(activity => {
            let iconColor, iconClass;
            if (activity.type === "atelier") {
                iconColor = "#FFC107";
                iconClass = "fa-seedling";
            } else if (activity.type === "collectif") {
                iconColor = "#2196F3";
                iconClass = "fa-users";
            } else if (activity.type === "marche") {
                iconColor = "#4CAF50";
                iconClass = "fa-shopping-basket";
            } else {
                iconColor = "#9C27B0";
                iconClass = "fa-chalkboard-teacher";
            }
            
            const marker = L.marker([activity.lat, activity.lng], {
                icon: L.divIcon({
                    className: 'custom-marker',
                    html: `<div class="bg-white border-2 border-[${iconColor}] text-[${iconColor}] rounded-full w-8 h-8 flex items-center justify-center shadow-lg"><i class="fas ${iconClass}"></i></div>`,
                    iconSize: [24, 24]
                })
            }).addTo(map);
            
            const typeBadge = activity.type === "atelier" ? "Atelier" : 
                            activity.type === "collectif" ? "Action collective" : 
                            activity.type === "marche" ? "Marché" : "Conférence";
            
            const badgeColor = activity.type === "atelier" ? "bg-yellow-100 text-yellow-800" : 
                             activity.type === "collectif" ? "bg-blue-100 text-blue-800" : 
                             activity.type === "marche" ? "bg-green-100 text-green-800" : "bg-purple-100 text-purple-800";
            
            marker.bindPopup(`
                <div class="custom-popup">
                    <div class="flex justify-between items-start">
                        <h3 class="font-bold text-lg">${activity.title}</h3>
                        <span class="${badgeColor} event-badge">${typeBadge}</span>
                    </div>
                    <p class="text-sm text-gray-600 mt-1">Organisé par <span class="font-medium">${activity.org}</span></p>
                    
                    <div class="mt-3">
                        <p class="text-sm"><i class="fas fa-calendar-day text-green-500 mr-2"></i> ${activity.date} • ${activity.time}</p>
                        <p class="text-sm mt-2"><i class="fas fa-users text-green-500 mr-2"></i> ${activity.participants} participants attendus</p>
                    </div>
                    
                    <p class="text-sm mt-3">${activity.desc}</p>
                    
                    <div class="mt-4 flex justify-between">
                        <button class="chat-button bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded text-sm flex items-center" 
                                data-org="${activity.org}" data-contact="${activity.contact}">
                            <i class="fas fa-comment-dots mr-2"></i> Contacter
                        </button>
                        <button class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded text-sm flex items-center">
                            <i class="fas fa-calendar-plus mr-2"></i> S'inscrire
                        </button>
                    </div>
                </div>
            `);
        });
        
        // Local associations
        const associations = [
            { 
                lat: 48.614, 
                lng: 2.479, 
                name: "Les Jardins Partagés", 
                mission: "Promouvoir l'agriculture urbaine et les circuits courts", 
                contact: "[email protected]",
                members: 45,
                founded: 2021
            },
            { 
                lat: 48.611, 
                lng: 2.481, 
                name: "Énergie Citoyenne", 
                mission: "Développer les énergies renouvelables locales", 
                contact: "[email protected]",
                members: 32,
                founded: 2019
            },
            { 
                lat: 48.617, 
                lng: 2.486, 
                name: "Zéro Déchet Essonne", 
                mission: "Sensibiliser à la réduction des déchets", 
                contact: "[email protected]",
                members: 78,
                founded: 2020
            }
        ];
        
        // Add markers for associations
        associations.forEach(asso => {
            const marker = L.marker([asso.lat, asso.lng], {
                icon: L.divIcon({
                    className: 'custom-marker',
                    html: `<div class="bg-purple-500 text-white rounded-full w-8 h-8 flex items-center justify-center shadow-lg"><i class="fas fa-hands-helping"></i></div>`,
                    iconSize: [24, 24]
                })
            }).addTo(map);
            
            marker.bindPopup(`
                <div class="custom-popup">
                    <h3 class="font-bold text-lg">${asso.name}</h3>
                    <p class="text-sm text-gray-600 mt-1">${asso.members} membres • Créée en ${asso.founded}</p>
                    
                    <p class="text-sm mt-3">${asso.mission}</p>
                    
                    <div class="mt-4">
                        <button class="chat-button bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded text-sm flex items-center w-full justify-center" 
                                data-org="${asso.name}" data-contact="${asso.contact}">
                            <i class="fas fa-comment-dots mr-2"></i> Contacter l'association
                        </button>
                    </div>
                </div>
            `);
        });
        
        // Handle map clicks
        map.on('click', function(e) {
            const infoContent = document.getElementById('info-content');
            infoContent.innerHTML = `
                <div>
                    <h4 class="font-semibold text-green-700 mb-2">Zone: ${e.latlng.lat.toFixed(4)}, ${e.latlng.lng.toFixed(4)}</h4>
                    <div class="grid grid-cols-2 gap-4 mb-4">
                        <div class="bg-green-50 p-3 rounded-lg">
                            <p class="text-xs text-green-600">Qualité de l'Air</p>
                            <p class="text-xl font-bold text-green-700">72/100</p>
                        </div>
                        <div class="bg-green-50 p-3 rounded-lg">
                            <p class="text-xs text-green-600">Activités Proches</p>
                            <p class="text-xl font-bold text-green-700">3</p>
                        </div>
                    </div>
                    <div class="mb-4">
                        <p class="text-sm font-medium text-gray-700 mb-1">Détails:</p>
                        <ul class="text-sm text-gray-600 space-y-1">
                            <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i> Zone résidentielle</li>
                            <li class="flex items-center"><i class="fas fa-check-circle text-green-500 mr-2"></i> Accès transports à 300m</li>
                            <li class="flex items-center"><i class="fas fa-exclamation-triangle text-yellow-500 mr-2"></i> Pollution sonore modérée</li>
                        </ul>
                    </div>
                    <div class="chart-container">
                        <canvas id="zone-chart"></canvas>
                    </div>
                </div>
            `;
            
            setTimeout(() => {
                const ctx = document.getElementById('zone-chart');
                if (ctx) {
                    ctx.innerHTML = `
                        <div class="text-center py-8 text-gray-400">
                            <i class="fas fa-chart-line text-3xl mb-2"></i>
                            <p>Graphique des indicateurs</p>
                        </div>
                    `;
                }
            }, 100);
        });
        
        // Sidebar toggle
        const sidebar = document.getElementById('sidebar');
        const toggleSidebar = document.getElementById('toggle-sidebar');
        const collapseSidebar = document.getElementById('collapse-sidebar');
        
        toggleSidebar.addEventListener('click', () => {
            sidebar.classList.remove('collapsed');
        });
        
        collapseSidebar.addEventListener('click', () => {
            sidebar.classList.add('collapsed');
        });
        
        // Close info panel
        document.getElementById('close-info').addEventListener('click', () => {
            document.getElementById('info-content').innerHTML = `
                <div class="text-center py-8 text-gray-500">
                    <i class="fas fa-map-marker-alt text-3xl mb-2 text-green-500"></i>
                    <p>Cliquez sur la carte pour voir les détails d'une zone</p>
                </div>
            `;
        });
        
        // FAB action
        document.getElementById('fab').addEventListener('click', () => {
            alert("Bienvenue sur la cartographie socio-écologique de Corbeil-Essonnes 2025!\n\nExplorez les différentes couches pour découvrir les initiatives écologiques et les données sociales de notre ville.");
        });
        
        // Layer controls
        document.querySelectorAll('input[type="checkbox"][data-layer]').forEach(checkbox => {
            checkbox.addEventListener('change', function() {
                const layer = this.dataset.layer;
                console.log(`Layer ${layer} ${this.checked ? 'shown' : 'hidden'}`);
            });
        });
        
        // Chat functionality
        let currentChatOrg = "";
        let currentChatContact = "";
        
        // Open chat when clicking contact buttons
        document.addEventListener('click', function(e) {
            if (e.target.classList.contains('chat-button') || e.target.closest('.chat-button')) {
                const button = e.target.classList.contains('chat-button') ? e.target : e.target.closest('.chat-button');
                currentChatOrg = button.dataset.org;
                currentChatContact = button.dataset.contact;
                
                document.getElementById('chat-title').textContent = `Chat avec ${currentChatOrg}`;
                document.getElementById('chat-body').innerHTML = `
                    <div class="text-sm text-gray-500 mb-4">
                        <p>Vous allez contacter: <span class="font-medium">${currentChatOrg}</span></p>
                        <p>Email: <span class="font-medium">${currentChatContact}</span></p>
                    </div>
                    <div class="bg-green-50 p-3 rounded-lg mb-3">
                        <p class="text-sm font-medium text-green-700">Bonjour, je souhaiterais obtenir plus d'informations sur vos activités.</p>
                        <p class="text-xs text-gray-500 text-right mt-1">Aujourd'hui, ${new Date().toLocaleTimeString()}</p>
                    </div>
                `;
                
                document.getElementById('chat-modal').style.display = 'block';
            }
        });
        
        // Close chat
        document.getElementById('close-chat').addEventListener('click', function() {
            document.getElementById('chat-modal').style.display = 'none';
        });
        
        // Send message
        document.getElementById('send-message').addEventListener('click', function() {
            const messageInput = document.getElementById('chat-message');
            const message = messageInput.value.trim();
            
            if (message) {
                const chatBody = document.getElementById('chat-body');
                chatBody.innerHTML += `
                    <div class="bg-blue-50 p-3 rounded-lg mb-3 ml-8">
                        <p class="text-sm font-medium text-blue-700">${message}</p>
                        <p class="text-xs text-gray-500 text-right mt-1">Maintenant</p>
                    </div>
                    <div class="bg-green-50 p-3 rounded-lg mb-3">
                        <p class="text-sm font-medium text-green-700">Merci pour votre message! Nous vous répondrons bientôt par email à propos de: "${message}"</p>
                        <p class="text-xs text-gray-500 text-right mt-1">Maintenant</p>
                    </div>
                `;
                messageInput.value = '';
                chatBody.scrollTop = chatBody.scrollHeight;
                
                // In a real app, this would send the message to the organization
                console.log(`Message to ${currentChatContact}: ${message}`);
            }
        });
        
        // Allow pressing Enter to send message
        document.getElementById('chat-message').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                document.getElementById('send-message').click();
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=Ko0ol/test1ce" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html>