File size: 26,802 Bytes
3efee68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard - Free Sites 4 You</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/lucide@latest"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <style>
        body { font-family: 'Inter', sans-serif; }
        .gradient-bg { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
        .sidebar-active { background-color: rgba(255,255,255,0.1); border-left: 4px solid white; }
    </style>
</head>
<body class="bg-gray-100">
    <!-- Admin Check -->
    <script>
        if (!sessionStorage.getItem('adminLoggedIn')) {
            window.location.href = 'login.html';
        }
    </script>

    <div class="flex h-screen overflow-hidden">
        <!-- Sidebar -->
        <div class="w-64 gradient-bg text-white flex flex-col">
            <div class="p-6 border-b border-purple-500">
                <div class="flex items-center">
                    <i data-lucide="shield" class="w-8 h-8 mr-2"></i>
                    <span class="text-xl font-bold">Admin Panel</span>
                </div>
                <p class="text-sm text-purple-200 mt-1" id="adminEmailDisplay"></p>
            </div>
            
            <nav class="flex-1 py-4">
                <button onclick="showSection('sites')" id="navSites" class="w-full flex items-center px-6 py-3 hover:bg-white/10 transition sidebar-active">
                    <i data-lucide="globe" class="w-5 h-5 mr-3"></i>
                    Manage Sites
                </button>
                <button onclick="showSection('ads')" id="navAds" class="w-full flex items-center px-6 py-3 hover:bg-white/10 transition">
                    <i data-lucide="megaphone" class="w-5 h-5 mr-3"></i>
                    Manage Ads
                </button>
                <button onclick="showSection('subscribers')" id="navSubscribers" class="w-full flex items-center px-6 py-3 hover:bg-white/10 transition">
                    <i data-lucide="users" class="w-5 h-5 mr-3"></i>
                    Subscribers <span id="subscriberCount" class="ml-auto bg-purple-500 text-xs px-2 py-1 rounded-full hidden">0</span>
                </button>
                <button onclick="showSection('stats')" id="navStats" class="w-full flex items-center px-6 py-3 hover:bg-white/10 transition">
                    <i data-lucide="bar-chart-2" class="w-5 h-5 mr-3"></i>
                    Statistics
                </button>
            </nav>

            <div class="p-4 border-t border-purple-500">
                <button onclick="logout()" class="w-full flex items-center px-4 py-2 bg-red-500 hover:bg-red-600 rounded-lg transition">
                    <i data-lucide="log-out" class="w-5 h-5 mr-2"></i>
                    Logout
                </button>
            </div>
        </div>

        <!-- Main Content -->
        <div class="flex-1 overflow-y-auto">
            <!-- Header -->
            <div class="bg-white shadow-sm p-6 flex justify-between items-center">
                <h1 class="text-2xl font-bold text-gray-800">Dashboard</h1>
                <div class="flex items-center space-x-4">
                    <a href="index.html" target="_blank" class="text-purple-600 hover:text-purple-800 flex items-center">
                        <i data-lucide="external-link" class="w-4 h-4 mr-1"></i>
                        View Site
                    </a>
                </div>
            </div>

            <!-- Sites Management Section -->
            <div id="sectionSites" class="p-6">
                <div class="bg-white rounded-lg shadow-lg p-6 mb-6">
                    <h2 class="text-xl font-bold mb-4 flex items-center">
                        <i data-lucide="plus-circle" class="w-6 h-6 mr-2 text-green-500"></i>
                        Add New Site
                    </h2>
                    <form id="addSiteForm" class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Site Name</label>
                            <input type="text" id="siteName" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Category</label>
                            <select id="siteCategory" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                                <option value="ai">AI Tools</option>
                                <option value="design">Design</option>
                                <option value="audio">Audio/Music</option>
                                <option value="gaming">Gaming</option>
                                <option value="commerce">E-Commerce</option>
                                <option value="sports">Sports</option>
                                <option value="productivity">Productivity</option>
                            </select>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">URL</label>
                            <input type="url" id="siteUrl" required placeholder="https://example.com" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Replaces (Paid Tool)</label>
                            <input type="text" id="siteReplaces" placeholder="e.g., Canva, ChatGPT" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                        </div>
                        <div class="md:col-span-2">
                            <label class="block text-sm font-medium text-gray-700 mb-1">Description</label>
                            <textarea id="siteDescription" rows="2" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none"></textarea>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Image URL (optional)</label>
                            <input type="url" id="siteImage" placeholder="http://static.photos/tech/640x360/1" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Affiliate Link (optional)</label>
                            <input type="url" id="siteAffiliate" placeholder="https://affiliate-link.com" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                        </div>
                        <div class="md:col-span-2">
                            <button type="submit" class="bg-purple-600 text-white px-6 py-2 rounded-lg hover:bg-purple-700 transition flex items-center">
                                <i data-lucide="save" class="w-4 h-4 mr-2"></i>
                                Add Site
                            </button>
                        </div>
                    </form>
                </div>

                <div class="bg-white rounded-lg shadow-lg p-6">
                    <h2 class="text-xl font-bold mb-4">Existing Sites</h2>
                    <div id="sitesList" class="space-y-4">
                        <!-- Sites will be listed here -->
                    </div>
                </div>
            </div>

            <!-- Ads Management Section -->
            <div id="sectionAds" class="p-6 hidden">
                <div class="bg-white rounded-lg shadow-lg p-6 mb-6">
                    <h2 class="text-xl font-bold mb-4 flex items-center">
                        <i data-lucide="megaphone" class="w-6 h-6 mr-2 text-orange-500"></i>
                        Add New Advertisement
                    </h2>
                    <form id="addAdForm" class="space-y-4">
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Ad Title</label>
                                <input type="text" id="adTitle" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Advertiser Name</label>
                                <input type="text" id="adAdvertiser" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                            </div>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Ad Content / HTML</label>
                            <textarea id="adContent" rows="3" required placeholder="<a href='...'><img src='...'></a>" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none font-mono text-sm"></textarea>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Ad Position</label>
                            <select id="adPosition" class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                                <option value="top">Top Banner</option>
                                <option value="sidebar1">Sidebar 1</option>
                                <option value="sidebar2">Sidebar 2</option>
                                <option value="bottom">Bottom Banner</option>
                            </select>
                        </div>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">Start Date</label>
                                <input type="date" id="adStartDate" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                            </div>
                            <div>
                                <label class="block text-sm font-medium text-gray-700 mb-1">End Date</label>
                                <input type="date" id="adEndDate" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                            </div>
                        </div>
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Price Tier</label>
                            <div class="grid grid-cols-3 gap-2 mb-2">
                                <label class="flex items-center p-2 border rounded cursor-pointer hover:bg-gray-50">
                                    <input type="radio" name="adPriceTier" value="5" class="mr-2" onchange="setAdPrice(5)">
                                    <span class="text-sm">1 Week<br><strong>$5</strong></span>
                                </label>
                                <label class="flex items-center p-2 border rounded cursor-pointer hover:bg-gray-50">
                                    <input type="radio" name="adPriceTier" value="10" class="mr-2" onchange="setAdPrice(10)">
                                    <span class="text-sm">3 Weeks<br><strong>$10</strong></span>
                                </label>
                                <label class="flex items-center p-2 border-2 border-orange-400 bg-orange-50 rounded cursor-pointer">
                                    <input type="radio" name="adPriceTier" value="15" class="mr-2" onchange="setAdPrice(15)" checked>
                                    <span class="text-sm">1 Month<br><strong>$15</strong></span>
                                </label>
                            </div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">Custom Price ($)</label>
                            <input type="number" id="adPrice" step="0.01" value="15" required class="w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-purple-600 outline-none">
                            <p class="text-xs text-gray-500 mt-1">Standard pricing: $5/week, $10/3weeks, $15/month</p>
                        </div>
                        <button type="submit" class="bg-orange-500 text-white px-6 py-2 rounded-lg hover:bg-orange-600 transition flex items-center">
                            <i data-lucide="plus" class="w-4 h-4 mr-2"></i>
                            Add Advertisement
                        </button>
                    </form>
                </div>

                <div class="bg-white rounded-lg shadow-lg p-6">
                    <h2 class="text-xl font-bold mb-4">Active Advertisements</h2>
                    <div id="adsList" class="space-y-4">
                        <!-- Ads will be listed here -->
                    </div>
                </div>
            </div>

            <!-- Subscribers Section -->
            <div id="sectionSubscribers" class="p-6 hidden">
                <div class="bg-white rounded-lg shadow-lg p-6">
                    <h2 class="text-xl font-bold mb-4 flex items-center">
                        <i data-lucide="mail" class="w-6 h-6 mr-2 text-indigo-500"></i>
                        Email Subscribers
                    </h2>
                    <div class="mb-4 p-4 bg-indigo-50 rounded-lg">
                        <p class="text-sm text-indigo-800">
                            <i data-lucide="info" class="w-4 h-4 inline-block mr-1"></i>
                            Total subscribers collected through the website signup form.
                        </p>
                    </div>
                    <div id="subscribersList" class="space-y-4">
                        <!-- Subscribers will be listed here -->
                    </div>
                    <div id="noSubscribers" class="text-center py-8 text-gray-500 hidden">
                        <i data-lucide="inbox" class="w-12 h-12 mx-auto mb-2 text-gray-300"></i>
                        <p>No subscribers yet.</p>
                    </div>
                </div>
            </div>

            <!-- Statistics Section -->
            <div id="sectionStats" class="p-6 hidden">
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
                    <div class="bg-white rounded-lg shadow-lg p-6 text-center">
                        <i data-lucide="globe" class="w-12 h-12 text-purple-600 mx-auto mb-2"></i>
                        <h3 class="text-3xl font-bold text-gray-800" id="totalSites">0</h3>
                        <p class="text-gray-600">Total Sites</p>
                    </div>
                    <div class="bg-white rounded-lg shadow-lg p-6 text-center">
                        <i data-lucide="megaphone" class="w-12 h-12 text-orange-500 mx-auto mb-2"></i>
                        <h3 class="text-3xl font-bold text-gray-800" id="totalAds">0</h3>
                        <p class="text-gray-600">Active Ads</p>
                    </div>
                    <div class="bg-white rounded-lg shadow-lg p-6 text-center">
                        <i data-lucide="dollar-sign" class="w-12 h-12 text-green-500 mx-auto mb-2"></i>
                        <h3 class="text-3xl font-bold text-gray-800" id="totalRevenue">$0</h3>
                        <p class="text-gray-600">Total Revenue</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Initialize data
        let sites = JSON.parse(localStorage.getItem('sites')) || [];
        let ads = JSON.parse(localStorage.getItem('ads')) || [];

        // Set default admin email
        document.getElementById('adminEmailDisplay').textContent = sessionStorage.getItem('adminEmail') || 'levytmwale@gmail.com';

        function showSection(section) {
            // Hide all sections
            document.getElementById('sectionSites').classList.add('hidden');
            document.getElementById('sectionAds').classList.add('hidden');
            document.getElementById('sectionSubscribers').classList.add('hidden');
            document.getElementById('sectionStats').classList.add('hidden');
            
            // Remove active classes
            document.getElementById('navSites').classList.remove('sidebar-active');
            document.getElementById('navAds').classList.remove('sidebar-active');
            document.getElementById('navSubscribers').classList.remove('sidebar-active');
            document.getElementById('navStats').classList.remove('sidebar-active');
            
            // Show selected section
            document.getElementById('section' + section.charAt(0).toUpperCase() + section.slice(1)).classList.remove('hidden');
            document.getElementById('nav' + section.charAt(0).toUpperCase() + section.slice(1)).classList.add('sidebar-active');
            
            if (section === 'stats') updateStats();
            if (section === 'subscribers') renderSubscribers();
        }

        function setAdPrice(amount) {
            document.getElementById('adPrice').value = amount;
        }

        function renderSubscribers() {
            const subscribers = JSON.parse(localStorage.getItem('subscribers') || '[]');
            const container = document.getElementById('subscribersList');
            const noDataMsg = document.getElementById('noSubscribers');
            const countBadge = document.getElementById('subscriberCount');
            
            countBadge.textContent = subscribers.length;
            if (subscribers.length > 0) {
                countBadge.classList.remove('hidden');
            }
            
            if (subscribers.length === 0) {
                container.innerHTML = '';
                noDataMsg.classList.remove('hidden');
                return;
            }
            
            noDataMsg.classList.add('hidden');
            container.innerHTML = subscribers.map(sub => {
                const interestMap = {
                    'pricing': 'Advertising Pricing',
                    'new-tools': 'New Free Tools',
                    'both': 'Both Updates',
                    'partnerships': 'Partnerships'
                };
                const date = new Date(sub.date).toLocaleDateString();
                return `
                    <div class="border rounded-lg p-4 hover:bg-gray-50">
                        <div class="flex justify-between items-start">
                            <div class="flex-1">
                                <h3 class="font-bold text-lg text-indigo-600">${sub.name}</h3>
                                <p class="text-sm text-gray-600">${sub.email}</p>
                                <p class="text-sm text-gray-500 mt-1">Interest: ${interestMap[sub.interest] || sub.interest}</p>
                                <p class="text-xs text-gray-400 mt-1">Subscribed: ${date}</p>
                            </div>
                            <button onclick="deleteSubscriber(${sub.id})" class="ml-4 text-red-500 hover:text-red-700">
                                <i data-lucide="trash-2" class="w-5 h-5"></i>
                            </button>
                        </div>
                    </div>
                `;
            }).join('');
            lucide.createIcons();
        }

        function deleteSubscriber(id) {
            if (confirm('Remove this subscriber?')) {
                let subscribers = JSON.parse(localStorage.getItem('subscribers') || '[]');
                subscribers = subscribers.filter(s => s.id !== id);
                localStorage.setItem('subscribers', JSON.stringify(subscribers));
                renderSubscribers();
            }
        }

        function logout() {
            sessionStorage.removeItem('adminLoggedIn');
            sessionStorage.removeItem('adminEmail');
            window.location.href = 'login.html';
        }

        // Sites Management
        document.getElementById('addSiteForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const site = {
                id: Date.now(),
                name: document.getElementById('siteName').value,
                category: document.getElementById('siteCategory').value,
                url: document.getElementById('siteUrl').value,
                replaces: document.getElementById('siteReplaces').value,
                description: document.getElementById('siteDescription').value,
                image: document.getElementById('siteImage').value || 'http://static.photos/tech/640x360/' + Math.floor(Math.random() * 100),
                affiliate: document.getElementById('siteAffiliate').value
            };
            
            sites.push(site);
            localStorage.setItem('sites', JSON.stringify(sites));
            this.reset();
            renderSites();
            alert('Site added successfully!');
        });

        function renderSites() {
            const container = document.getElementById('sitesList');
            if (sites.length === 0) {
                container.innerHTML = '<p class="text-gray-500 text-center py-4">No sites added yet.</p>';
                return;
            }
            
            container.innerHTML = sites.map(site => `
                <div class="border rounded-lg p-4 flex justify-between items-start hover:bg-gray-50">
                    <div class="flex-1">
                        <h3 class="font-bold text-lg text-purple-600">${site.name}</h3>
                        <p class="text-sm text-gray-600">${site.category} • Replaces: ${site.replaces}</p>
                        <p class="text-sm text-gray-500 mt-1">${site.description.substring(0, 100)}...</p>
                        <a href="${site.url}" target="_blank" class="text-blue-500 text-sm hover:underline break-all">${site.url}</a>
                        ${site.affiliate ? `<p class="text-xs text-orange-500 mt-1">Affiliate: ${site.affiliate}</p>` : ''}
                    </div>
                    <button onclick="deleteSite(${site.id})" class="ml-4 text-red-500 hover:text-red-700">
                        <i data-lucide="trash-2" class="w-5 h-5"></i>
                    </button>
                </div>
            `).join('');
            lucide.createIcons();
        }

        function deleteSite(id) {
            if (confirm('Are you sure you want to delete this site?')) {
                sites = sites.filter(s => s.id !== id);
                localStorage.setItem('sites', JSON.stringify(sites));
                renderSites();
            }
        }

        // Ads Management
        document.getElementById('addAdForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const ad = {
                id: Date.now(),
                title: document.getElementById('adTitle').value,
                advertiser: document.getElementById('adAdvertiser').value,
                content: document.getElementById('adContent').value,
                position: document.getElementById('adPosition').value,
                startDate: document.getElementById('adStartDate').value,
                endDate: document.getElementById('adEndDate').value,
                price: parseFloat(document.getElementById('adPrice').value),
                active: true
            };
            
            ads.push(ad);
            localStorage.setItem('ads', JSON.stringify(ads));
            this.reset();
            renderAds();
            alert('Advertisement added successfully!');
        });

        function renderAds() {
            const container = document.getElementById('adsList');
            if (ads.length === 0) {
                container.innerHTML = '<p class="text-gray-500 text-center py-4">No advertisements added yet.</p>';
                return;
            }
            
            container.innerHTML = ads.map(ad => `
                <div class="border rounded-lg p-4 hover:bg-gray-50">
                    <div class="flex justify-between items-start">
                        <div class="flex-1">
                            <h3 class="font-bold text-lg text-orange-600">${ad.title}</h3>
                            <p class="text-sm text-gray-600">By: ${ad.advertiser} • Position: ${ad.position}</p>
                            <p class="text-sm text-gray-500">Duration: ${ad.startDate} to ${ad.endDate}</p>
                            <p class="text-sm font-semibold text-green-600">$${ad.price.toFixed(2)}</p>
                            <div class="mt-2 p-2 bg-gray-100 rounded text-xs font-mono overflow-hidden">${ad.content.substring(0, 100)}...</div>
                        </div>
                        <button onclick="deleteAd(${ad.id})" class="ml-4 text-red-500 hover:text-red-700">
                            <i data-lucide="trash-2" class="w-5 h-5"></i>
                        </button>
                    </div>
                </div>
            `).join('');
            lucide.createIcons();
        }

        function deleteAd(id) {
            if (confirm('Are you sure you want to delete this advertisement?')) {
                ads = ads.filter(a => a.id !== id);
                localStorage.setItem('ads', JSON.stringify(ads));
                renderAds();
            }
        }

        function updateStats() {
            document.getElementById('totalSites').textContent = sites.length;
            
            const today = new Date().toISOString().split('T')[0];
            const activeAds = ads.filter(a => a.startDate <= today && a.endDate >= today);
            document.getElementById('totalAds').textContent = activeAds.length;
            
            const totalRevenue = ads.reduce((sum, a) => sum + a.price, 0);
            document.getElementById('totalRevenue').textContent = '$' + totalRevenue.toFixed(2);
        }

        // Initialize
        renderSites();
        renderAds();
        lucide.createIcons();
    </script>
</body>
</html>