 {% comment %} <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}BlickBox{% endblock %}</title>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #000000;
            color: #FFFFFF;
            overflow-x: hidden;
        }
        .container {
            min-height: 100vh;
            position: relative;
            padding-bottom: 60px; /* Space for bottom nav on mobile */
        }
        /* Mobile Bottom Navigation */
        .bottom-nav {
            display: flex;
            justify-content: space-around;
            align-items: center;
            position: fixed;
            bottom: 0;
            width: 100%;
            background-color: #000000;
            padding: 10px 0;
            border-top: 1px solid #333;
        }
        .bottom-nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #808080;
            text-decoration: none;
            font-size: 12px;
        }
        .bottom-nav-item.active {
            color: #CE052D;
        }
        .bottom-nav-item i {
            font-size: 24px;
            margin-bottom: 4px;
        }
        /* Desktop Sidebar Navigation */
        .sidebar {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 200px;
            height: 100%;
            background-color: #1C1C1C;
            padding-top: 20px;
        }
        .sidebar-item {
            display: block;
            padding: 15px 20px;
            color: #808080;
            text-decoration: none;
            font-size: 16px;
        }
        .sidebar-item.active {
            color: #CE052D;
            background-color: #2A2A2A;
        }
        .sidebar-item i {
            margin-right: 10px;
        }
        .main-content {
            margin: 0;
        }
        /* Responsive Design */
        @media (min-width: 768px) {
            .bottom-nav {
                display: none;
            }
            .sidebar {
                display: block;
            }
            .main-content {
                margin-left: 200px;
            }
            .container {
                padding-bottom: 0;
            }
        }
        /* Font Awesome for Icons */
        @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css');
    </style>
</head>
<body>
    <!-- Sidebar for Desktop -->
    <nav class="sidebar">
        <a href="/home/" class="sidebar-item {% if request.path == '/home/' %}active{% endif %}">
            <i class="fas fa-home"></i> Home
        </a>
        <a href="/explore/" class="sidebar-item {% if request.path == '/explore/' %}active{% endif %}">
            <i class="fas fa-search"></i> Search
        </a>
        <a href="/downloads/" class="sidebar-item {% if request.path == '/downloads/' %}active{% endif %}">
            <i class="fas fa-download"></i> Downloads
        </a>
        <a href="/account/" class="sidebar-item {% if request.path == '/account/' %}active{% endif %}">
            <i class="fas fa-user"></i> Account
        </a>
    </nav>
    <!-- Main Content -->
    <div class="main-content">
        <div class="container">
            {% block content %}
            {% endblock %}
        </div>
    </div>
    <!-- Bottom Navigation for Mobile -->
    <nav class="bottom-nav">
        <a href="/home/" class="bottom-nav-item {% if request.path == '/home/' %}active{% endif %}">
            <i class="fas fa-home"></i> Home
        </a>
        <a href="/explore/" class="bottom-nav-item {% if request.path == '/explore/' %}active{% endif %}">
            <i class="fas fa-search"></i> Search
        </a>
        <a href="/downloads/" class="bottom-nav-item {% if request.path == '/downloads/' %}active{% endif %}">
            <i class="fas fa-download"></i> Downloads
        </a>
        <a href="/account/" class="bottom-nav-item {% if request.path == '/account/' %}active{% endif %}">
            <i class="fas fa-user"></i> Account
        </a>
    </nav>
    {% block scripts %}
    {% endblock %}
</body>
</html>  {% endcomment %}

<!-- templates/base.html -->
{% comment %}<!DOCTYPE html>
 <html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}BlickBox{% endblock %}</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <div class="nav-bar">
        <a href="/home/">Home</a>
        <div class="dropdown">
            <a href="#">Categories</a>
            <div class="dropdown-content" id="category-list"></div>
        </div>
        <a href="/explore/">Explore</a>
        <a href="/account/">Account</a>
        <a href="/request-movie/">Request Movie</a>
        <a href="/login/" onclick="logout()">Log Out</a>
    </div>
    <div class="container">
        {% if request.path != '/home/' %}
        <div class="back-button" onclick="history.back()"><span>←</span></div>
        {% endif %}
        {% block content %}
        {% endblock %}
    </div>
    <script>
        async function loadCategories() {
            try {
                const response = await fetch('/api/categories/', {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                if (!response.ok) throw new Error('Failed to fetch categories');
                const categories = await response.json();
                const categoryList = document.getElementById('category-list');
                categories.forEach(category => {
                    const link = document.createElement('a');
                    link.href = `/category/${category.name}/`;
                    link.textContent = category.name;
                    categoryList.appendChild(link);
                });
            } catch (err) {
                console.error('Error loading categories:', err);
            }
        }
        document.addEventListener('DOMContentLoaded', loadCategories);
    </script>
    <script>
        function logout() {
            localStorage.removeItem('access_token');
            localStorage.removeItem('refresh_token');
        }

        // Check authentication on page load
        document.addEventListener('DOMContentLoaded', () => {
            if (!localStorage.getItem('access_token') && !window.location.pathname.includes('/login/') && !window.location.pathname.includes('/signup/')) {
                window.location.href = '/login/';
            }
        });
    </script>
    {% block scripts %}
    {% endblock %}
</body>
</html> {% endcomment %}

<!-- templates/base.html -->
{% comment %} <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}BlickBox{% endblock %}</title>
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <div class="nav-bar">
        <div class="nav-logo">
            <a href="/home/"><img src="/static/images/blickbox_logo.png" alt="BlickBox Logo"></a>
        </div>
        <div class="nav-links">
            <a href="/home/">Home</a>
            <div class="dropdown">
                <a href="#" class="category-toggle">Categories</a>
                <div class="dropdown-content" id="category-list"></div>
            </div>
            <a href="/explore/">Explore</a>
            <a href="/account/">Account</a>
            <a href="/login/" onclick="logout()">Log Out</a>
        </div>
        <div class="nav-toggle">
            <div class="hamburger">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
    </div>
    <div class="nav-dropdown" id="nav-dropdown">
        <a href="/home/">Home</a>
        <div class="dropdown">
            <a href="#" class="category-toggle">Categories</a>
            <div class="dropdown-content" id="mobile-category-list"></div>
        </div>
        <a href="/explore/">Explore</a>
        <a href="/account/">Account</a>
        <a href="/login/" onclick="logout()">Log Out</a>
    </div>
    <div class="container">
        {% if request.path != '/home/' %}
        <div class="back-button" onclick="history.back()"><span>←</span></div>
        {% endif %}
        {% block content %}
        {% endblock %}
    </div>
    <script>
        async function loadCategories() {
            try {
                const response = await fetch('/api/categories/', {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                if (!response.ok) throw new Error('Failed to fetch categories');
                const categories = await response.json();
                const categoryList = document.getElementById('category-list');
                const mobileCategoryList = document.getElementById('mobile-category-list');
                categories.forEach(category => {
                    const link = document.createElement('a');
                    link.href = `/category/${category.name}/`;
                    link.textContent = category.name;
                    categoryList.appendChild(link.cloneNode(true));
                    mobileCategoryList.appendChild(link);
                });
            } catch (err) {
                console.error('Error loading categories:', err);
            }
        }

        document.addEventListener('DOMContentLoaded', () => {
            loadCategories();
            const hamburger = document.querySelector('.nav-toggle');
            const navDropdown = document.getElementById('nav-dropdown');
            const categoryToggle = document.querySelector('.nav-dropdown .category-toggle');
            const mobileCategoryList = document.getElementById('mobile-category-list');

            hamburger.addEventListener('click', () => {
                navDropdown.classList.toggle('active');
            });

            categoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                mobileCategoryList.classList.toggle('active');
            });

            // Close dropdown when clicking outside
            document.addEventListener('click', (e) => {
                if (!hamburger.contains(e.target) && !navDropdown.contains(e.target)) {
                    navDropdown.classList.remove('active');
                }
                if (!categoryToggle.contains(e.target) && !mobileCategoryList.contains(e.target)) {
                    mobileCategoryList.classList.remove('active');
                }
            });
        });
    </script>
    <script>
        function logout() {
            localStorage.removeItem('access_token');
            localStorage.removeItem('refresh_token');
        }

        // Check authentication on page load
        document.addEventListener('DOMContentLoaded', () => {
            if (!localStorage.getItem('access_token') && !window.location.pathname.includes('/login/') && !window.location.pathname.includes('/signup/')) {
                window.location.href = '/login/';
            }
        });
    </script>
    {% block scripts %}
    {% endblock %}
</body>
</html> {% endcomment %}

<!-- templates/base.html -->
{% comment %} <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}BlickBox{% endblock %}</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
</head>
<body>
    <div class="nav-bar">
        <div class="nav-logo">
            <a href="/home/"><img src="/static/images/blickbox_logo.png" alt="BlickBox Logo"></a>
        </div>
        <div class="nav-links">
            <a href="/home/" class="{% if request.path == '/home/' %}active{% endif %}">Home</a>
            <div class="dropdown">
                <a href="#" class="category-toggle">Categories</a>
                <div class="dropdown-content" id="category-list"></div>
            </div>
            <a href="/explore/" class="{% if request.path == '/explore/' %}active{% endif %}">Explore</a>
            <a href="/account/" class="{% if request.path == '/account/' %}active{% endif %}">Account</a>
            <a href="/login/" onclick="logout()">Log Out</a>
        </div>
        <div class="nav-toggle">
            <div class="hamburger">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
    </div>
    <div class="sidebar">
        <a href="/home/" class="sidebar-item {% if request.path == '/home/' %}active{% endif %}"><i class="fas fa-home"></i> Home</a>
        <div class="sidebar-dropdown">
            <a href="#" class="sidebar-item category-toggle"><i class="fas fa-list"></i> Categories</a>
            <div class="sidebar-dropdown-content" id="sidebar-category-list"></div>
        </div>
        <a href="/explore/" class="sidebar-item {% if request.path == '/explore/' %}active{% endif %}"><i class="fas fa-search"></i> Explore</a>
        <a href="/account/" class="sidebar-item {% if request.path == '/account/' %}active{% endif %}"><i class="fas fa-user"></i> Account</a>
        <a href="/login/" class="sidebar-item" onclick="logout()"><i class="fas fa-sign-out-alt"></i> Log Out</a>
    </div>
    <div class="nav-dropdown" id="nav-dropdown">
        <a href="/home/" class="{% if request.path == '/home/' %}active{% endif %}">Home</a>
        <div class="dropdown">
            <a href="#" class="category-toggle">Categories</a>
            <div class="dropdown-content" id="mobile-category-list"></div>
        </div>
        <a href="/explore/" class="{% if request.path == '/explore/' %}active{% endif %}">Explore</a>
        <a href="/account/" class="{% if request.path == '/account/' %}active{% endif %}">Account</a>
        <a href="/login/" onclick="logout()">Log Out</a>
    </div>
    <div class="container">
        <div class="main-content">
            {% if request.path != '/home/' %}
            <div class="back-button" onclick="history.back()"><span>←</span></div>
            {% endif %}
            {% block content %}
            {% endblock %}
        </div>
    </div>
    <div class="bottom-nav">
        <a href="/home/" class="bottom-nav-item {% if request.path == '/home/' %}active{% endif %}">
            <i class="fas fa-home"></i>
            <span>Home</span>
        </a>
        <div class="bottom-nav-item bottom-nav-dropdown">
            <a href="#" class="category-toggle">
                <i class="fas fa-list"></i>
                <span>Categories</span>
            </a>
            <div class="bottom-nav-dropdown-content" id="bottom-nav-category-list"></div>
        </div>
        <a href="/explore/" class="bottom-nav-item {% if request.path == '/explore/' %}active{% endif %}">
            <i class="fas fa-search"></i>
            <span>Explore</span>
        </a>
        <a href="/account/" class="bottom-nav-item {% if request.path == '/account/' %}active{% endif %}">
            <i class="fas fa-user"></i>
            <span>Account</span>
        </a>
        <a href="/login/" class="bottom-nav-item" onclick="logout()">
            <i class="fas fa-sign-out-alt"></i>
            <span>Log Out</span>
        </a>
    </div>
    <script>
        async function loadCategories() {
            try {
                const response = await fetch('/api/categories/', {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                if (!response.ok) throw new Error('Failed to fetch categories');
                const categories = await response.json();
                const lists = [
                    document.getElementById('category-list'),
                    document.getElementById('mobile-category-list'),
                    document.getElementById('sidebar-category-list'),
                    document.getElementById('bottom-nav-category-list')
                ];
                categories.forEach(category => {
                    const link = document.createElement('a');
                    link.href = `/category/${category.name}/`;
                    link.textContent = category.name;
                    lists.forEach(list => list.appendChild(link.cloneNode(true)));
                });
            } catch (err) {
                console.error('Error loading categories:', err);
            }
        }

        function logout() {
            localStorage.removeItem('access_token');
            localStorage.removeItem('refresh_token');
        }

        document.addEventListener('DOMContentLoaded', () => {
            loadCategories();
            const hamburger = document.querySelector('.nav-toggle');
            const navDropdown = document.getElementById('nav-dropdown');
            const mobileCategoryToggle = document.querySelector('.nav-dropdown .category-toggle');
            const mobileCategoryList = document.getElementById('mobile-category-list');
            const sidebarCategoryToggle = document.querySelector('.sidebar .category-toggle');
            const sidebarCategoryList = document.getElementById('sidebar-category-list');
            const bottomNavCategoryToggle = document.querySelector('.bottom-nav .category-toggle');
            const bottomNavCategoryList = document.getElementById('bottom-nav-category-list');

            hamburger.addEventListener('click', () => {
                navDropdown.classList.toggle('active');
            });

            mobileCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                mobileCategoryList.classList.toggle('active');
            });

            sidebarCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                sidebarCategoryList.classList.toggle('active');
            });

            bottomNavCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                bottomNavCategoryList.classList.toggle('active');
            });

            document.addEventListener('click', (e) => {
                if (!hamburger.contains(e.target) && !navDropdown.contains(e.target)) {
                    navDropdown.classList.remove('active');
                }
                if (!mobileCategoryToggle.contains(e.target) && !mobileCategoryList.contains(e.target)) {
                    mobileCategoryList.classList.remove('active');
                }
                if (!sidebarCategoryToggle.contains(e.target) && !sidebarCategoryList.contains(e.target)) {
                    sidebarCategoryList.classList.remove('active');
                }
                if (!bottomNavCategoryToggle.contains(e.target) && !bottomNavCategoryList.contains(e.target)) {
                    bottomNavCategoryList.classList.remove('active');
                }
            });

            if (!localStorage.getItem('access_token') && !window.location.pathname.includes('/login/') && !window.location.pathname.includes('/signup/')) {
                window.location.href = '/login/';
            }
        });
    </script>
    {% block scripts %}
    {% endblock %}
</body>
</html> {% endcomment %}

<!-- templates/base.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}BlickBox{% endblock %}</title>
    <link rel="stylesheet" href="/static/css/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
</head>
<body>
    <div class="nav-bar">
        <div class="nav-logo">
            <a href="/"><img src="/static/images/blickbox_logo.png" alt="BlickBox Logo"></a>
        </div>
        <div class="nav-links">
            <a href="/home/" class="{% if request.path == '/home/' %}active{% endif %}">Home</a>
            <div class="dropdown">
                <a href="#" class="category-toggle">Categories</a>
                <div class="dropdown-content" id="category-list"></div>
            </div>           
             <a href="/see-all/" class="{% if request.path == '/see-all/' %}active{% endif %}">See-all</a>
            <a href="/explore/" class="{% if request.path == '/explore/' %}active{% endif %}">Explore</a>
            <a href="/account/" class="{% if request.path == '/account/' %}active{% endif %}">Account</a>
            <a href="/login/" onclick="logout()">Log Out</a>
        </div>
        <div class="nav-toggle">
            <div class="hamburger">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
    </div>
    <div class="sidebar">
        <a href="/home/" class="sidebar-item {% if request.path == '/home/' %}active{% endif %}"><i class="fas fa-home"></i> Home</a>
        <div class="sidebar-dropdown">
            <a href="#" class="sidebar-item category-toggle"><i class="fas fa-list"></i> Categories</a>
            <div class="sidebar-dropdown-content" id="sidebar-category-list"></div>
        </div>
        <a href="/see-all/" class="sidebar-item {% if request.path == '/see-all/' %}active{% endif %}"><i class="fas fa-search"></i> See all</a>
        <a href="/explore/" class="sidebar-item {% if request.path == '/explore/' %}active{% endif %}"><i class="fas fa-search"></i> Explore</a>
        <a href="/account/" class="sidebar-item {% if request.path == '/account/' %}active{% endif %}"><i class="fas fa-user"></i> Account</a>
        <a href="/login/" class="sidebar-item" onclick="logout()"><i class="fas fa-sign-out-alt"></i> Log Out</a>
    </div>
    <div class="nav-dropdown" id="nav-dropdown">
        <a href="/home/" class="{% if request.path == '/home/' %}active{% endif %}">Home</a>
        <div class="dropdown">
            <a href="#" class="category-toggle">Categories</a>
            <div class="dropdown-content" id="mobile-category-list"></div>
        </div>
        <a href="/see-all/" class="{% if request.path == '/see-all/' %}active{% endif %}">See all</a>

        <a href="/explore/" class="{% if request.path == '/explore/' %}active{% endif %}">Explore</a>
        <a href="/account/" class="{% if request.path == '/account/' %}active{% endif %}">Account</a>
        <a href="/login/" onclick="logout()">Log Out</a>
    </div>
    <div class="container">
        <div class="main-content">
            {% if request.path != '/home/' %}
            <div class="back-button" onclick="history.back()"><span>←</span></div>
            {% endif %}
            {% block content %}
            {% endblock %}
        </div>
    </div>
    <div class="bottom-nav">
        <a href="/home/" class="bottom-nav-item {% if request.path == '/home/' %}active{% endif %}">
            <i class="fas fa-home"></i>
            <span>Home</span>
        </a>
        <div class="bottom-nav-item bottom-nav-dropdown">
            <a href="#" class="category-toggle">
                <i class="fas fa-list"></i>
                <span>Categories</span>
            </a>
            <div class="bottom-nav-dropdown-content" id="bottom-nav-category-list"></div>
        </div>
        <a href="/see-all/" class="bottom-nav-item {% if request.path == '/see-all/' %}active{% endif %}">
            <i class="fas fa-search"></i>
            <span>See all/</span>
        </a>
        <a href="/explore/" class="bottom-nav-item {% if request.path == '/explore/' %}active{% endif %}">
            <i class="fas fa-search"></i>
            <span>Explore</span>
        </a>
        
        <a href="/account/" class="bottom-nav-item {% if request.path == '/account/' %}active{% endif %}">
            <i class="fas fa-user"></i>
            <span>Account</span>
        </a>
        <a href="/login/" class="bottom-nav-item" onclick="logout()">
            <i class="fas fa-sign-out-alt"></i>
            <span>Log Out</span>
        </a>
    </div>
    
    <script>
        async function loadCategories() {
            try {
                const response = await fetch('/api/categories/', {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                });
                if (!response.ok) throw new Error('Failed to fetch categories');
                const categories = await response.json();
                const lists = [
                    document.getElementById('category-list'),
                    document.getElementById('mobile-category-list'),
                    document.getElementById('sidebar-category-list'),
                    document.getElementById('bottom-nav-category-list')
                ];
                categories.forEach(category => {
                    const link = document.createElement('a');
                    link.href = `/category/${category.name}/`;
                    link.textContent = category.name;
                    lists.forEach(list => list && list.appendChild(link.cloneNode(true)));
                });
            } catch (err) {
                console.error('Error loading categories:', err);
            }
        }

        function logout() {
            localStorage.removeItem('access_token');
            localStorage.removeItem('refresh_token');
        }

        document.addEventListener('DOMContentLoaded', () => {
            loadCategories();
            const hamburger = document.querySelector('.nav-toggle');
            const navDropdown = document.getElementById('nav-dropdown');
            const mobileCategoryToggle = document.querySelector('.nav-dropdown .category-toggle');
            const mobileCategoryList = document.getElementById('mobile-category-list');
            const sidebarCategoryToggle = document.querySelector('.sidebar .category-toggle');
            const sidebarCategoryList = document.getElementById('sidebar-category-list');
            const bottomNavCategoryToggle = document.querySelector('.bottom-nav .category-toggle');
            const bottomNavCategoryList = document.getElementById('bottom-nav-category-list');

            hamburger.addEventListener('click', () => {
                navDropdown.classList.toggle('active');
            });

            mobileCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                mobileCategoryList.classList.toggle('active');
            });

            sidebarCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                sidebarCategoryList.classList.toggle('active');
            });

            bottomNavCategoryToggle.addEventListener('click', (e) => {
                e.preventDefault();
                bottomNavCategoryList.classList.toggle('active');
            });

            document.addEventListener('click', (e) => {
                if (!hamburger.contains(e.target) && !navDropdown.contains(e.target)) {
                    navDropdown.classList.remove('active');
                }
                if (!mobileCategoryToggle.contains(e.target) && !mobileCategoryList.contains(e.target)) {
                    mobileCategoryList.classList.remove('active');
                }
                if (!sidebarCategoryToggle.contains(e.target) && !sidebarCategoryList.contains(e.target)) {
                    sidebarCategoryList.classList.remove('active');
                }
                if (!bottomNavCategoryToggle.contains(e.target) && !bottomNavCategoryList.contains(e.target)) {
                    bottomNavCategoryList.classList.remove('active');
                }
            });

            // Redirect authenticated users from index to home
            

            // Redirect non-authenticated users to login for non-public pages
            const publicPaths = ['/login/', '/signup/', '/', '/terms/', '/privacy/', '/about/', '/contact/'];
            if (!localStorage.getItem('access_token') && !publicPaths.some(path => window.location.pathname === path)) {
                window.location.href = '/login/';
            }
        });
    </script>
    {% block scripts %}
    {% endblock %}
</body>
</html>