Spaces:
Running

File size: 19,340 Bytes
2b327c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e68691f
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Unified Email Client</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        .email-list-item:hover {
            background-color: #f3f4f6;
        }
        .email-list-item.active {
            background-color: #e5e7eb;
        }
        .custom-scrollbar::-webkit-scrollbar {
            width: 6px;
        }
        .custom-scrollbar::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }
    </style>
</head>
<body class="font-inter bg-gray-50 h-screen flex flex-col">
    <!-- Header -->
    <header class="bg-white shadow-sm py-3 px-6 flex items-center justify-between">
        <div class="flex items-center space-x-2">
            <i data-feather="mail" class="text-blue-500"></i>
            <h1 class="text-xl font-semibold text-gray-800">Unified Mail</h1>
        </div>
        <div class="flex items-center space-x-4">
            <button class="p-2 rounded-full hover:bg-gray-100">
                <i data-feather="settings"></i>
            </button>
            <div class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white font-medium">
                U
            </div>
        </div>
    </header>

    <div class="flex flex-1 overflow-hidden">
        <!-- Sidebar - Email Accounts -->
        <div class="w-64 bg-white border-r border-gray-200 flex flex-col">
            <div class="p-4 border-b border-gray-200">
                <button id="add-account-btn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md flex items-center justify-center space-x-2 transition-colors">
                    <i data-feather="plus" class="w-4 h-4"></i>
                    <span>Add Account</span>
                </button>
            </div>
            <div class="flex-1 overflow-y-auto custom-scrollbar">
                <div class="p-4">
                    <h2 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">Email Accounts</h2>
                    <ul id="email-accounts-list" class="space-y-1">
                        <!-- Accounts will be added here dynamically -->
                    </ul>
                </div>
            </div>
        </div>

        <!-- Email List -->
        <div class="w-96 bg-white border-r border-gray-200 flex flex-col">
            <div class="p-3 border-b border-gray-200 flex items-center space-x-2">
                <div class="flex-1 relative">
                    <i data-feather="search" class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                    <input type="text" placeholder="Search emails..." class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
                </div>
                <button class="p-2 rounded-md hover:bg-gray-100">
                    <i data-feather="filter"></i>
                </button>
            </div>
            <div class="flex-1 overflow-y-auto custom-scrollbar">
                <div id="email-list" class="divide-y divide-gray-200">
                    <!-- Emails will be added here dynamically -->
                </div>
            </div>
        </div>

        <!-- Email Content -->
        <div class="flex-1 bg-white flex flex-col">
            <div class="p-4 border-b border-gray-200 flex items-center justify-between">
                <div class="flex items-center space-x-4">
                    <button id="back-to-list" class="md:hidden p-2 rounded-md hover:bg-gray-100">
                        <i data-feather="arrow-left"></i>
                    </button>
                    <h2 class="text-lg font-medium text-gray-800">Message</h2>
                </div>
                <div class="flex items-center space-x-2">
                    <button class="p-2 rounded-md hover:bg-gray-100">
                        <i data-feather="archive"></i>
                    </button>
                    <button class="p-2 rounded-md hover:bg-gray-100">
                        <i data-feather="trash-2"></i>
                    </button>
                    <button class="p-2 rounded-md hover:bg-gray-100">
                        <i data-feather="more-vertical"></i>
                    </button>
                </div>
            </div>
            <div id="email-content" class="flex-1 overflow-y-auto custom-scrollbar p-6">
                <div class="max-w-3xl mx-auto">
                    <!-- Email content will be displayed here -->
                    <div class="text-center py-20 text-gray-400">
                        <i data-feather="mail" class="w-12 h-12 mx-auto mb-4"></i>
                        <p>Select an email to read</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Add Account Modal -->
    <div id="add-account-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
        <div class="bg-white rounded-lg shadow-xl w-full max-w-md">
            <div class="p-6">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="text-lg font-medium text-gray-900">Add Email Account</h3>
                    <button id="close-modal" class="text-gray-400 hover:text-gray-500">
                        <i data-feather="x"></i>
                    </button>
                </div>
                <div class="space-y-4">
                    <div>
                        <label for="email-address" class="block text-sm font-medium text-gray-700 mb-1">Email Address</label>
                        <input type="email" id="email-address" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="your@email.com">
                    </div>
                    <div>
                        <label for="email-password" class="block text-sm font-medium text-gray-700 mb-1">Password</label>
                        <input type="password" id="email-password" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="••••••••">
                    </div>
                    <div class="flex items-center">
                        <input type="checkbox" id="remember-me" class="h-4 w-4 text-blue-500 focus:ring-blue-500 border-gray-300 rounded">
                        <label for="remember-me" class="ml-2 block text-sm text-gray-700">Remember this account</label>
                    </div>
                </div>
            </div>
            <div class="bg-gray-50 px-6 py-3 flex justify-end space-x-3 rounded-b-lg">
                <button id="cancel-add-account" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                    Cancel
                </button>
                <button id="confirm-add-account" class="px-4 py-2 bg-blue-500 border border-transparent rounded-md text-sm font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                    Add Account
                </button>
            </div>
        </div>
    </div>

    <script>
        feather.replace();
        
        // Sample data for demonstration
        const sampleEmails = [
            {
                id: 1,
                from: "support@company.com",
                subject: "Your subscription is expiring soon",
                preview: "Your premium subscription will expire in 7 days. Renew now to avoid interruption...",
                date: "10:30 AM",
                read: false,
                content: `<div>
                    <div class="flex items-center justify-between mb-6">
                        <div class="flex items-center space-x-4">
                            <div class="w-10 h-10 rounded-full bg-purple-500 flex items-center justify-center text-white font-medium">
                                S
                            </div>
                            <div>
                                <p class="font-medium">Support Team</p>
                                <p class="text-sm text-gray-500">support@company.com</p>
                            </div>
                        </div>
                        <div class="text-sm text-gray-500">10:30 AM, May 15</div>
                    </div>
                    <h1 class="text-2xl font-bold mb-4">Your subscription is expiring soon</h1>
                    <div class="prose max-w-none">
                        <p>Dear Valued Customer,</p>
                        <p>Your premium subscription will expire in 7 days. Renew now to avoid interruption of service.</p>
                        <p>We're offering a special 15% discount if you renew before the expiration date. Use code <strong>RENEW15</strong> at checkout.</p>
                        <p>To renew your subscription, simply click the button below:</p>
                        <div class="my-6">
                            <a href="#" class="inline-block bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-md">Renew Subscription</a>
                        </div>
                        <p>If you have any questions about your subscription, please don't hesitate to contact our support team.</p>
                        <p>Best regards,<br>The Company Team</p>
                    </div>
                </div>`
            },
            {
                id: 2,
                from: "newsletter@tech.com",
                subject: "This Week in Tech: Latest Updates",
                preview: "Here are the biggest tech stories of the week: Apple announces new products...",
                date: "Yesterday",
                read: true,
                content: `<div>
                    <div class="flex items-center justify-between mb-6">
                        <div class="flex items-center space-x-4">
                            <div class="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center text-white font-medium">
                                T
                            </div>
                            <div>
                                <p class="font-medium">Tech Newsletter</p>
                                <p class="text-sm text-gray-500">newsletter@tech.com</p>
                            </div>
                        </div>
                        <div class="text-sm text-gray-500">May 14</div>
                    </div>
                    <h1 class="text-2xl font-bold mb-4">This Week in Tech: Latest Updates</h1>
                    <div class="prose max-w-none">
                        <p>Here are the biggest tech stories of the week:</p>
                        <h2 class="text-xl font-semibold mt-6">Apple Announces New Products</h2>
                        <p>Apple unveiled its latest lineup of products at the annual developer conference, including...</p>
                        <h2 class="text-xl font-semibold mt-6">Google's AI Breakthrough</h2>
                        <p>Google researchers have developed a new AI model that can...</p>
                        <h2 class="text-xl font-semibold mt-6">Microsoft's Cloud Expansion</h2>
                        <p>Microsoft announced plans to build three new data centers in Europe to...</p>
                        <p>Stay tuned for more updates next week!</p>
                        <p class="mt-8">- The Tech Newsletter Team</p>
                    </div>
                </div>`
            },
            {
                id: 3,
                from: "jane.doe@example.com",
                subject: "Meeting tomorrow at 2 PM",
                preview: "Hi there, just a reminder about our meeting tomorrow at 2 PM in conference room B...",
                date: "May 12",
                read: true,
                content: `<div>
                    <div class="flex items-center justify-between mb-6">
                        <div class="flex items-center space-x-4">
                            <div class="w-10 h-10 rounded-full bg-green-500 flex items-center justify-center text-white font-medium">
                                J
                            </div>
                            <div>
                                <p class="font-medium">Jane Doe</p>
                                <p class="text-sm text-gray-500">jane.doe@example.com</p>
                            </div>
                        </div>
                        <div class="text-sm text-gray-500">May 12</div>
                    </div>
                    <h1 class="text-2xl font-bold mb-4">Meeting tomorrow at 2 PM</h1>
                    <div class="prose max-w-none">
                        <p>Hi there,</p>
                        <p>Just a reminder about our meeting tomorrow at 2 PM in conference room B.</p>
                        <p>We'll be discussing:</p>
                        <ul class="list-disc pl-5">
                            <li>Q2 project updates</li>
                            <li>Budget review</li>
                            <li>Team expansion plans</li>
                        </ul>
                        <p>Please bring your reports and any materials you'd like to share with the team.</p>
                        <p>Looking forward to seeing everyone there!</p>
                        <p>Best,<br>Jane</p>
                    </div>
                </div>`
            }
        ];

        // DOM elements
        const addAccountBtn = document.getElementById('add-account-btn');
        const addAccountModal = document.getElementById('add-account-modal');
        const closeModalBtn = document.getElementById('close-modal');
        const cancelAddAccountBtn = document.getElementById('cancel-add-account');
        const confirmAddAccountBtn = document.getElementById('confirm-add-account');
        const emailAccountsList = document.getElementById('email-accounts-list');
        const emailList = document.getElementById('email-list');
        const emailContent = document.getElementById('email-content');
        const backToListBtn = document.getElementById('back-to-list');

        // Event listeners
        addAccountBtn.addEventListener('click', () => {
            addAccountModal.classList.remove('hidden');
        });

        closeModalBtn.addEventListener('click', () => {
            addAccountModal.classList.add('hidden');
        });

        cancelAddAccountBtn.addEventListener('click', () => {
            addAccountModal.classList.add('hidden');
        });

        confirmAddAccountBtn.addEventListener('click', () => {
            const email = document.getElementById('email-address').value;
            if (email) {
                addEmailAccount(email);
                document.getElementById('email-address').value = '';
                document.getElementById('email-password').value = '';
                addAccountModal.classList.add('hidden');
            }
        });

        backToListBtn.addEventListener('click', () => {
            document.querySelector('.md\\:hidden').classList.add('hidden');
            document.querySelector('.w-96').classList.remove('hidden');
        });

        // Functions
        function addEmailAccount(email) {
            const accountItem = document.createElement('li');
            accountItem.className = 'flex items-center justify-between p-2 rounded-md hover:bg-gray-100 cursor-pointer';
            accountItem.innerHTML = `
                <div class="flex items-center space-x-3">
                    <div class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white text-xs font-medium">
                        ${email.charAt(0).toUpperCase()}
                    </div>
                    <span class="text-sm font-medium truncate">${email}</span>
                </div>
                <i data-feather="chevron-right" class="w-4 h-4 text-gray-400"></i>
            `;
            accountItem.addEventListener('click', () => {
                loadEmailsForAccount(email);
            });
            emailAccountsList.appendChild(accountItem);
            feather.replace();
        }

        function loadEmailsForAccount(account) {
            // Clear existing emails
            emailList.innerHTML = '';
            
            // Add sample emails
            sampleEmails.forEach(email => {
                const emailItem = document.createElement('div');
                emailItem.className = `email-list-item p-4 cursor-pointer ${email.read ? '' : 'bg-blue-50'}`;
                emailItem.innerHTML = `
                    <div class="flex items-center justify-between mb-1">
                        <span class="font-medium ${email.read ? 'text-gray-700' : 'text-gray-900'}">${email.from}</span>
                        <span class="text-xs text-gray-500">${email.date}</span>
                    </div>
                    <h3 class="font-medium ${email.read ? 'text-gray-700' : 'text-gray-900'} mb-1">${email.subject}</h3>
                    <p class="text-sm text-gray-500 truncate">${email.preview}</p>
                `;
                emailItem.addEventListener('click', () => {
                    // Mark as read
                    email.read = true;
                    emailItem.classList.remove('bg-blue-50');
                    emailItem.querySelectorAll('.font-medium').forEach(el => {
                        el.classList.remove('text-gray-900');
                        el.classList.add('text-gray-700');
                    });
                    
                    // Show email content
                    emailContent.innerHTML = email.content;
                    feather.replace();
                    
                    // On mobile, hide list and show content
                    if (window.innerWidth < 768) {
                        document.querySelector('.w-96').classList.add('hidden');
                        document.querySelector('.md\\:hidden').classList.remove('hidden');
                    }
                });
                emailList.appendChild(emailItem);
            });
        }

        // Initialize with sample data
        addEmailAccount('user@example.com');
        loadEmailsForAccount('user@example.com');

        // Responsive behavior
        window.addEventListener('resize', () => {
            if (window.innerWidth >= 768) {
                document.querySelector('.w-96').classList.remove('hidden');
            }
        });
    </script>
</body>
</html>