File size: 32,203 Bytes
935af47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FocusTube - Distraction-Free Study Player</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <script>
        tailwind.config = {
            darkMode: 'class',
            theme: {
                extend: {
                    colors: {
                        primary: {
                            light: '#FF0000',
                            dark: '#FF3333'
                        },
                        dark: {
                            900: '#0F0F0F',
                            800: '#181818',
                            700: '#202020',
                            600: '#282828'
                        }
                    },
                    animation: {
                        'fade-in': 'fadeIn 0.3s ease-out forwards',
                        'slide-up': 'slideUp 0.5s cubic-bezier(0.23, 1, 0.32, 1) forwards',
                        'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite'
                    },
                    keyframes: {
                        fadeIn: {
                            '0%': { opacity: '0' },
                            '100%': { opacity: '1' }
                        },
                        slideUp: {
                            '0%': { transform: 'translateY(20px)', opacity: '0' },
                            '100%': { transform: 'translateY(0)', opacity: '1' }
                        }
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
        
        body {
            font-family: 'Roboto', sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            background-color: #FFFFFF;
        }
        
        body.dark {
            background-color: #0F0F0F;
            color: #FFFFFF;
        }
        
        /* Custom scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        
        ::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-track {
            background-color: transparent;
        }
        
        .dark ::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.1);
        }
        
        /* Video player container aspect ratio */
        .video-container {
            position: relative;
            padding-bottom: 56.25%; /* 16:9 aspect ratio */
            height: 0;
            overflow: hidden;
        }
        
        .video-container iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border: none;
        }
        
        /* Focus mode overlay */
        .focus-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.9);
            z-index: 100;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }
        
        .focus-overlay.active {
            opacity: 1;
            pointer-events: all;
        }
        
        /* Timer animation */
        @keyframes timerPulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        
        .timer-pulse {
            animation: timerPulse 2s infinite;
        }
        
        /* Smooth transitions */
        .transition-slow {
            transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
        }
    </style>
</head>
<body class="dark:bg-dark-900 dark:text-white transition-colors duration-300">
    <div class="container mx-auto px-4 py-6 max-w-7xl">
        <!-- Header -->
        <header class="flex justify-between items-center mb-6 animate-fade-in">
            <div class="flex items-center">
                <div class="bg-primary-light dark:bg-primary-dark h-10 w-10 rounded-lg flex items-center justify-center mr-3">
                    <i class="fas fa-headphones text-white text-lg"></i>
                </div>
                <h1 class="text-2xl font-bold">Focus<span class="text-primary-light dark:text-primary-dark">Tube</span></h1>
            </div>
            <div class="flex items-center space-x-4">
                <button id="focus-mode-btn" class="flex items-center space-x-2 bg-gray-100 dark:bg-dark-700 hover:bg-gray-200 dark:hover:bg-dark-600 px-4 py-2 rounded-lg transition-slow">
                    <i class="fas fa-bullseye text-primary-light dark:text-primary-dark"></i>
                    <span class="hidden md:inline">Focus Mode</span>
                </button>
                <button id="dark-mode-btn" class="p-2 rounded-full hover:bg-gray-200 dark:hover:bg-dark-700 transition-slow">
                    <i class="fas fa-moon dark:hidden"></i>
                    <i class="fas fa-sun hidden dark:block"></i>
                </button>
            </div>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
            <!-- Video Player Section -->
            <div class="lg:col-span-3">
                <!-- Video Player -->
                <div class="bg-black rounded-xl overflow-hidden shadow-lg mb-6 animate-slide-up">
                    <div class="video-container">
                        <iframe id="youtube-player" src="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                    </div>
                </div>
                
                <!-- Video Info -->
                <div class="bg-white dark:bg-dark-800 rounded-xl shadow-lg p-6 mb-6 animate-slide-up">
                    <h2 id="video-title" class="text-xl font-bold mb-2">No video selected</h2>
                    <div class="flex items-center justify-between mb-4">
                        <div class="flex items-center space-x-4">
                            <div class="h-10 w-10 rounded-full bg-gray-300 dark:bg-dark-700 flex items-center justify-center">
                                <i class="fas fa-user text-gray-500 dark:text-gray-400"></i>
                            </div>
                            <div>
                                <p id="channel-name" class="font-medium">Channel Name</p>
                                <p class="text-sm text-gray-500 dark:text-gray-400">0 subscribers</p>
                            </div>
                        </div>
                        <button id="like-btn" class="flex items-center space-x-2 bg-gray-100 dark:bg-dark-700 hover:bg-gray-200 dark:hover:bg-dark-600 px-4 py-2 rounded-lg transition-slow">
                            <i class="far fa-thumbs-up"></i>
                            <span>Like</span>
                        </button>
                    </div>
                    
                    <div class="bg-gray-100 dark:bg-dark-700 rounded-lg p-4">
                        <div class="flex justify-between items-center mb-2">
                            <p class="text-sm font-medium">Description</p>
                            <button id="show-more-btn" class="text-primary-light dark:text-primary-dark text-sm font-medium">Show more</button>
                        </div>
                        <p id="video-description" class="text-sm line-clamp-3">Select a video from the sidebar to view its description here.</p>
                    </div>
                </div>
                
                <!-- Focus Timer (Hidden by default) -->
                <div id="focus-timer-container" class="bg-white dark:bg-dark-800 rounded-xl shadow-lg p-6 mb-6 hidden animate-slide-up">
                    <h3 class="text-lg font-bold mb-4">Focus Timer</h3>
                    <div class="flex flex-col items-center">
                        <div id="timer-display" class="text-5xl font-bold mb-6">25:00</div>
                        <div class="flex space-x-4">
                            <button id="start-timer-btn" class="bg-primary-light dark:bg-primary-dark text-white px-6 py-3 rounded-lg font-medium hover:bg-opacity-90 transition-slow">
                                Start Focus Session
                            </button>
                            <button id="stop-timer-btn" class="bg-gray-200 dark:bg-dark-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-300 dark:hover:bg-dark-600 transition-slow">
                                Stop
                            </button>
                        </div>
                        <div class="mt-6 w-full max-w-md">
                            <label for="timer-duration" class="block text-sm font-medium mb-2">Duration (minutes)</label>
                            <input type="range" id="timer-duration" min="5" max="120" value="25" class="w-full h-2 bg-gray-200 dark:bg-dark-600 rounded-lg appearance-none cursor-pointer">
                            <div class="flex justify-between text-sm text-gray-500 dark:text-gray-400 mt-1">
                                <span>5 min</span>
                                <span id="current-duration">25 min</span>
                                <span>120 min</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Sidebar -->
            <div class="lg:col-span-1">
                <!-- Search -->
                <div class="bg-white dark:bg-dark-800 rounded-xl shadow-lg p-4 mb-6 animate-slide-up">
                    <div class="relative">
                        <input type="text" id="video-search" placeholder="Search study videos..." class="w-full bg-gray-100 dark:bg-dark-700 border-none rounded-lg pl-10 pr-4 py-3 focus:ring-2 focus:ring-primary-light dark:focus:ring-primary-dark">
                        <i class="fas fa-search absolute left-3 top-3.5 text-gray-500 dark:text-gray-400"></i>
                    </div>
                </div>
                
                <!-- Playlists -->
                <div class="bg-white dark:bg-dark-800 rounded-xl shadow-lg p-4 mb-6 animate-slide-up">
                    <h3 class="font-bold mb-4">Study Playlists</h3>
                    <div class="space-y-3">
                        <button class="playlist-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-700 transition-slow" data-playlist="PLWKjhJtqVAbnZtkAI3BqcYxKnfRCNHgAk">
                            <i class="fas fa-music mr-2 text-primary-light dark:text-primary-dark"></i>
                            Focus Music
                        </button>
                        <button class="playlist-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-700 transition-slow" data-playlist="PL6K53MPRflr9kDvdX6h1vR7qPYyKvU5l1">
                            <i class="fas fa-graduation-cap mr-2 text-primary-light dark:text-primary-dark"></i>
                            Study With Me
                        </button>
                        <button class="playlist-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-700 transition-slow" data-playlist="PL6K53MPRflr8nwQ5U3RgLmW7sQjvQ6q9y">
                            <i class="fas fa-water mr-2 text-primary-light dark:text-primary-dark"></i>
                            Rain Sounds
                        </button>
                        <button class="playlist-btn w-full text-left px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-700 transition-slow" data-playlist="PL6K53MPRflr8nwQ5U3RgLmW7sQjvQ6q9y">
                            <i class="fas fa-leaf mr-2 text-primary-light dark:text-primary-dark"></i>
                            Nature Sounds
                        </button>
                    </div>
                </div>
                
                <!-- Video List -->
                <div class="bg-white dark:bg-dark-800 rounded-xl shadow-lg p-4 animate-slide-up">
                    <h3 class="font-bold mb-4">Recommended Videos</h3>
                    <div id="video-list" class="space-y-3 max-h-[500px] overflow-y-auto pr-2">
                        <!-- Videos will be loaded here -->
                        <div class="text-center py-8 text-gray-500 dark:text-gray-400">
                            <i class="fas fa-video text-3xl mb-3"></i>
                            <p>Search for videos to get started</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Focus Mode Overlay -->
    <div id="focus-overlay" class="focus-overlay">
        <div class="text-center">
            <div id="focus-timer" class="text-7xl font-bold mb-8">25:00</div>
            <p class="text-xl mb-6">Stay focused! The video will resume when timer ends.</p>
            <button id="exit-focus-btn" class="bg-primary-light dark:bg-primary-dark text-white px-8 py-3 rounded-lg font-medium hover:bg-opacity-90 transition-slow">
                Exit Focus Mode
            </button>
        </div>
    </div>
    
    <!-- Scripts -->
    <script>
        // DOM Elements
        const youtubePlayer = document.getElementById('youtube-player');
        const videoTitle = document.getElementById('video-title');
        const channelName = document.getElementById('channel-name');
        const videoDescription = document.getElementById('video-description');
        const showMoreBtn = document.getElementById('show-more-btn');
        const likeBtn = document.getElementById('like-btn');
        const videoSearch = document.getElementById('video-search');
        const videoList = document.getElementById('video-list');
        const playlistBtns = document.querySelectorAll('.playlist-btn');
        const darkModeBtn = document.getElementById('dark-mode-btn');
        const focusModeBtn = document.getElementById('focus-mode-btn');
        const focusOverlay = document.getElementById('focus-overlay');
        const focusTimer = document.getElementById('focus-timer');
        const exitFocusBtn = document.getElementById('exit-focus-btn');
        const timerDisplay = document.getElementById('timer-display');
        const startTimerBtn = document.getElementById('start-timer-btn');
        const stopTimerBtn = document.getElementById('stop-timer-btn');
        const timerDuration = document.getElementById('timer-duration');
        const currentDuration = document.getElementById('current-duration');
        const focusTimerContainer = document.getElementById('focus-timer-container');
        
        // State
        let currentVideoId = '';
        let isDescriptionExpanded = false;
        let isDarkMode = localStorage.getItem('darkMode') === 'true';
        let isFocusModeActive = false;
        let timerInterval;
        let timerSecondsLeft = 25 * 60;
        let isTimerRunning = false;
        
        // Initialize
        function init() {
            // Set dark mode if enabled
            if (isDarkMode) {
                document.documentElement.classList.add('dark');
            }
            
            // Load default playlist
            loadPlaylist('PL6K53MPRflr9kDvdX6h1vR7qPYyKvU5l1');
            
            // Show focus timer container
            focusTimerContainer.classList.remove('hidden');
            
            // Set up event listeners
            setupEventListeners();
        }
        
        // Set up event listeners
        function setupEventListeners() {
            // Dark mode toggle
            darkModeBtn.addEventListener('click', toggleDarkMode);
            
            // Focus mode toggle
            focusModeBtn.addEventListener('click', toggleFocusMode);
            
            // Exit focus mode
            exitFocusBtn.addEventListener('click', exitFocusMode);
            
            // Show more/less description
            showMoreBtn.addEventListener('click', toggleDescription);
            
            // Like button
            likeBtn.addEventListener('click', () => {
                likeBtn.innerHTML = '<i class="fas fa-thumbs-up"></i> Liked';
                likeBtn.classList.add('text-primary-light', 'dark:text-primary-dark');
                showToast('Video liked');
            });
            
            // Video search
            videoSearch.addEventListener('keypress', (e) => {
                if (e.key === 'Enter') {
                    searchVideos(videoSearch.value);
                }
            });
            
            // Playlist buttons
            playlistBtns.forEach(btn => {
                btn.addEventListener('click', () => {
                    const playlistId = btn.getAttribute('data-playlist');
                    loadPlaylist(playlistId);
                });
            });
            
            // Timer controls
            startTimerBtn.addEventListener('click', startTimer);
            stopTimerBtn.addEventListener('click', stopTimer);
            
            // Timer duration slider
            timerDuration.addEventListener('input', updateTimerDuration);
            
            // Hide focus timer when video is playing
            youtubePlayer.addEventListener('play', () => {
                if (isFocusModeActive) {
                    focusOverlay.classList.add('active');
                }
            });
        }
        
        // Toggle dark mode
        function toggleDarkMode() {
            isDarkMode = !isDarkMode;
            localStorage.setItem('darkMode', isDarkMode);
            
            if (isDarkMode) {
                document.documentElement.classList.add('dark');
            } else {
                document.documentElement.classList.remove('dark');
            }
            
            showToast(`Dark mode ${isDarkMode ? 'enabled' : 'disabled'}`);
        }
        
        // Toggle focus mode
        function toggleFocusMode() {
            isFocusModeActive = !isFocusModeActive;
            
            if (isFocusModeActive) {
                focusModeBtn.innerHTML = '<i class="fas fa-bullseye text-primary-light dark:text-primary-dark"></i><span class="hidden md:inline">Focus Active</span>';
                focusModeBtn.classList.add('bg-primary-light', 'dark:bg-primary-dark', 'bg-opacity-10');
                
                if (!youtubePlayer.paused) {
                    focusOverlay.classList.add('active');
                }
                
                showToast('Focus mode activated');
            } else {
                focusModeBtn.innerHTML = '<i class="fas fa-bullseye text-primary-light dark:text-primary-dark"></i><span class="hidden md:inline">Focus Mode</span>';
                focusModeBtn.classList.remove('bg-primary-light', 'dark:bg-primary-dark', 'bg-opacity-10');
                focusOverlay.classList.remove('active');
                
                showToast('Focus mode deactivated');
            }
        }
        
        // Exit focus mode
        function exitFocusMode() {
            toggleFocusMode();
            youtubePlayer.play();
        }
        
        // Toggle video description
        function toggleDescription() {
            isDescriptionExpanded = !isDescriptionExpanded;
            
            if (isDescriptionExpanded) {
                videoDescription.classList.remove('line-clamp-3');
                showMoreBtn.textContent = 'Show less';
            } else {
                videoDescription.classList.add('line-clamp-3');
                showMoreBtn.textContent = 'Show more';
            }
        }
        
        // Load YouTube playlist
        function loadPlaylist(playlistId) {
            // In a real app, we would use YouTube API to fetch playlist videos
            // For demo, we'll use mock data
            const mockPlaylists = {
                'PL6K53MPRflr9kDvdX6h1vR7qPYyKvU5l1': [
                    {
                        id: 'jfKfPfyJRdk',
                        title: 'lofi hip hop radio - beats to relax/study to',
                        channel: 'Lofi Girl',
                        description: 'A popular lofi hip hop livestream for studying and relaxing.',
                        thumbnail: 'https://i.ytimg.com/vi/jfKfPfyJRdk/mqdefault.jpg'
                    },
                    {
                        id: '5qap5aO4i9A',
                        title: '24/7 lofi hip hop radio - beats to study/relax to',
                        channel: 'Chillhop Music',
                        description: 'Non-stop lofi beats for your study sessions.',
                        thumbnail: 'https://i.ytimg.com/vi/5qap5aO4i9A/mqdefault.jpg'
                    },
                    {
                        id: 'DWcJFNfaw9c',
                        title: 'Jazz for Study, Work ☕ Relaxing Jazz Music & Cozy Coffee Shop Ambience',
                        channel: 'Coffee Relaxing Jazz',
                        description: 'Smooth jazz music perfect for studying and working.',
                        thumbnail: 'https://i.ytimg.com/vi/DWcJFNfaw9c/mqdefault.jpg'
                    },
                    {
                        id: 'rUxyKA_-grg',
                        title: 'Deep Focus Music To Improve Concentration - 12 Hours of Ambient Study Music',
                        channel: 'Quiet Quest - Study Music',
                        description: '12 hours of ambient study music to help you focus.',
                        thumbnail: 'https://i.ytimg.com/vi/rUxyKA_-grg/mqdefault.jpg'
                    },
                    {
                        id: '4xDzrJKXOOY',
                        title: 'Rain Sounds For Sleeping - 99% Instantly Fall Asleep With Rain And Thunder Sound',
                        channel: 'Nature Sounds TV',
                        description: 'Relaxing rain sounds for deep sleep and study.',
                        thumbnail: 'https://i.ytimg.com/vi/4xDzrJKXOOY/mqdefault.jpg'
                    }
                ],
                'PLWKjhJtqVAbnZtkAI3BqcYxKnfRCNHgAk': [
                    {
                        id: 'F5mRW7m7SlY',
                        title: 'Classical Music for Studying & Brain Power',
                        channel: 'HALIDONMUSIC',
                        description: 'The best classical music for studying and concentration.',
                        thumbnail: 'https://i.ytimg.com/vi/F5mRW7m7SlY/mqdefault.jpg'
                    },
                    {
                        id: 'pLJJP4LqIF4',
                        title: 'Bach Study Music',
                        channel: 'Classical Music',
                        description: 'Bach compositions perfect for studying.',
                        thumbnail: 'https://i.ytimg.com/vi/pLJJP4LqIF4/mqdefault.jpg'
                    }
                ]
            };
            
            const videos = mockPlaylists[playlistId] || mockPlaylists['PL6K53MPRflr9kDvdX6h1vR7qPYyKvU5l1'];
            displayVideos(videos);
            
            // Load first video by default
            if (videos.length > 0) {
                loadVideo(videos[0].id, videos[0].title, videos[0].channel, videos[0].description);
            }
        }
        
        // Search videos (mock implementation)
        function searchVideos(query) {
            if (!query.trim()) return;
            
            // In a real app, we would use YouTube API to search videos
            // For demo, we'll filter our mock data
            const mockVideos = [
                {
                    id: 'jfKfPfyJRdk',
                    title: 'lofi hip hop radio - beats to relax/study to',
                    channel: 'Lofi Girl',
                    description: 'A popular lofi hip hop livestream for studying and relaxing.',
                    thumbnail: 'https://i.ytimg.com/vi/jfKfPfyJRdk/mqdefault.jpg'
                },
                {
                    id: '5qap5aO4i9A',
                    title: '24/7 lofi hip hop radio - beats to study/relax to',
                    channel: 'Chillhop Music',
                    description: 'Non-stop lofi beats for your study sessions.',
                    thumbnail: 'https://i.ytimg.com/vi/5qap5aO4i9A/mqdefault.jpg'
                },
                {
                    id: 'DWcJFNfaw9c',
                    title: 'Jazz for Study, Work ☕ Relaxing Jazz Music & Cozy Coffee Shop Ambience',
                    channel: 'Coffee Relaxing Jazz',
                    description: 'Smooth jazz music perfect for studying and working.',
                    thumbnail: 'https://i.ytimg.com/vi/DWcJFNfaw9c/mqdefault.jpg'
                }
            ];
            
            const filteredVideos = mockVideos.filter(video => 
                video.title.toLowerCase().includes(query.toLowerCase()) ||
                video.channel.toLowerCase().includes(query.toLowerCase())
            );
            
            displayVideos(filteredVideos.length > 0 ? filteredVideos : mockVideos);
            showToast(`Found ${filteredVideos.length} videos`);
        }
        
        // Display videos in sidebar
        function displayVideos(videos) {
            videoList.innerHTML = '';
            
            if (videos.length === 0) {
                videoList.innerHTML = `
                    <div class="text-center py-8 text-gray-500 dark:text-gray-400">
                        <i class="fas fa-exclamation-circle text-3xl mb-3"></i>
                        <p>No videos found</p>
                    </div>
                `;
                return;
            }
            
            videos.forEach(video => {
                const videoElement = document.createElement('div');
                videoElement.className = 'flex items-center space-x-3 p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-700 cursor-pointer transition-slow';
                videoElement.innerHTML = `
                    <img src="${video.thumbnail}" alt="${video.title}" class="w-16 h-12 rounded-md object-cover">
                    <div class="flex-1 min-w-0">
                        <p class="text-sm font-medium truncate">${video.title}</p>
                        <p class="text-xs text-gray-500 dark:text-gray-400 truncate">${video.channel}</p>
                    </div>
                `;
                
                videoElement.addEventListener('click', () => {
                    loadVideo(video.id, video.title, video.channel, video.description);
                });
                
                videoList.appendChild(videoElement);
            });
        }
        
        // Load video into player
        function loadVideo(videoId, title, channel, description) {
            currentVideoId = videoId;
            youtubePlayer.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&rel=0&modestbranding=1`;
            
            videoTitle.textContent = title;
            channelName.textContent = channel;
            videoDescription.textContent = description;
            videoDescription.classList.add('line-clamp-3');
            isDescriptionExpanded = false;
            showMoreBtn.textContent = 'Show more';
            
            // Reset like button
            likeBtn.innerHTML = '<i class="far fa-thumbs-up"></i> Like';
            likeBtn.classList.remove('text-primary-light', 'dark:text-primary-dark');
            
            showToast('Video loaded');
        }
        
        // Timer functions
        function startTimer() {
            if (isTimerRunning) return;
            
            isTimerRunning = true;
            startTimerBtn.textContent = 'Pause';
            startTimerBtn.classList.remove('bg-primary-light', 'dark:bg-primary-dark');
            startTimerBtn.classList.add('bg-yellow-500');
            
            timerInterval = setInterval(() => {
                timerSecondsLeft--;
                
                updateTimerDisplay();
                
                if (timerSecondsLeft <= 0) {
                    stopTimer();
                    showToast('Focus session completed!');
                    
                    if (isFocusModeActive) {
                        focusOverlay.classList.remove('active');
                        youtubePlayer.pause();
                    }
                }
            }, 1000);
            
            if (isFocusModeActive) {
                focusOverlay.classList.add('active');
            }
        }
        
        function stopTimer() {
            clearInterval(timerInterval);
            isTimerRunning = false;
            startTimerBtn.textContent = 'Start Focus Session';
            startTimerBtn.classList.add('bg-primary-light', 'dark:bg-primary-dark');
            startTimerBtn.classList.remove('bg-yellow-500');
            
            // Reset timer to selected duration
            timerSecondsLeft = parseInt(timerDuration.value) * 60;
            updateTimerDisplay();
            
            if (isFocusModeActive) {
                focusOverlay.classList.remove('active');
            }
        }
        
        function updateTimerDuration() {
            const minutes = timerDuration.value;
            currentDuration.textContent = `${minutes} min`;
            
            if (!isTimerRunning) {
                timerSecondsLeft = minutes * 60;
                updateTimerDisplay();
            }
        }
        
        function updateTimerDisplay() {
            const minutes = Math.floor(timerSecondsLeft / 60);
            const seconds = timerSecondsLeft % 60;
            
            const displayTime = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            timerDisplay.textContent = displayTime;
            focusTimer.textContent = displayTime;
            
            // Add pulse animation when under 1 minute
            if (timerSecondsLeft < 60) {
                focusTimer.classList.add('timer-pulse', 'text-red-400');
            } else {
                focusTimer.classList.remove('timer-pulse', 'text-red-400');
            }
        }
        
        // Show toast notification
        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'fixed bottom-6 left-1/2 transform -translate-x-1/2 bg-gray-800 dark:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm animate-slide-up';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.classList.remove('animate-slide-up');
                toast.classList.add('opacity-0', 'transition-opacity', 'duration-300');
                setTimeout(() => {
                    toast.remove();
                }, 300);
            }, 3000);
        }
        
        // Initialize the app
        init();
    </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=atlkaran635/code" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>