<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BlickBox Dashboard</title>
    <!-- Tailwind CSS CDN -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Font Awesome for icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
    {% load static %}
    <!-- Custom CSS -->
    <link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body class="bg-gray-100 font-sans">
    <div class="flex h-screen">
        <!-- Sidebar Navigation -->
        <aside id="sidebar" class="w-64 bg-[#CE052D] text-white fixed h-full transition-transform duration-300 transform md:translate-x-0 -translate-x-full">
            <div class="p-4 flex justify-between items-center">
                <h1 class="text-2xl font-bold">BlickBox</h1>
                <button id="sidebar-toggle" class="md:hidden text-white focus:outline-none">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <nav class="mt-4">
                <ul>
                    <li class="p-4 hover:bg-[#000000]">
                        <a href="{% url 'home' %}" class="flex items-center">
                            <i class="fas fa-home mr-2"></i> Home
                        </a>
                    </li>
                    <li class="p-4 hover:bg-[#000000]">
                        <a href="{% url 'movies' %}" class="flex items-center">
                            <i class="fas fa-film mr-2"></i> Movies
                        </a>
                    </li>
                    <li class="p-4 hover:bg-[#000000]">
                        <a href="{% url 'series' %}" class="flex items-center">
                            <i class="fas fa-tv mr-2"></i> Series
                        </a>
                    </li>
                    <li class="p-4 hover:bg-[#000000]">
                        <a href="{% url 'profile' %}" class="flex items-center">
                            <i class="fas fa-user mr-2"></i> Profile
                        </a>
                    </li>
                    <li class="p-4 hover:bg-[#000000]">
                        <a href="{% url 'logout' %}" class="flex items-center">
                            <i class="fas fa-sign-out-alt mr-2"></i> Logout
                        </a>
                    </li>
                </ul>
            </nav>
        </aside>

        <!-- Main Content -->
        <main class="flex-1 md:ml-64 p-8 bg-[#FFFFFF]">
            <!-- Header -->
            <header class="flex justify-between items-center mb-8">
                <div class="flex items-center">
                    <button id="menu-toggle" class="md:hidden text-[#CE052D] mr-4">
                        <i class="fas fa-bars text-2xl"></i>
                    </button>
                    <h2 class="text-3xl font-semibold text-[#000000]">Welcome, {{ user.username }}!</h2>
                </div>
                <div class="flex items-center">
                    <a href="{% url 'profile' %}" class="text-[#CE052D] hover:underline">Edit Profile</a>
                </div>
            </header>

            <!-- Dashboard Content -->
            <section class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- Recently Watched Card -->
                <div class="bg-[#ECD4FF] p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold text-[#000000] mb-4">Recently Watched</h3>
                    <div id="recently-watched">
                        {% if recently_watched %}
                            <ul>
                                {% for item in recently_watched %}
                                    <li class="mb-2">
                                        <a href="{% url 'movie_detail' item.id %}" class="text-[#CE052D] hover:underline">
                                            {{ item.title }}
                                        </a>
                                    </li>
                                {% endfor %}
                            </ul>
                        {% else %}
                            <p class="text-gray-600">No recently watched items.</p>
                        {% endif %}
                    </div>
                </div>

                <!-- Account Status Card -->
                <div class="bg-[#ECD4FF] p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold text-[#000000] mb-4">Account Status</h3>
                    <p class="text-gray-600">Subscription: {% if user.subscription %}Active{% else %}Inactive{% endif %}</p>
                    <p class="text-gray-600">Last Login: {{ user.last_login|date:"F d, Y" }}</p>
                    <a href="{% url 'subscription' %}" class="mt-4 inline-block bg-[#CE052D] text-white px-4 py-2 rounded hover:bg-[#000000]">
                        Manage Subscription
                    </a>
                </div>

                <!-- Recommendations Card -->
                <div class="bg-[#ECD4FF] p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-semibold text-[#000000] mb-4">Recommended for You</h3>
                    <div id="recommendations">
                        {% if recommendations %}
                            <ul>
                                {% for item in recommendations %}
                                    <li class="mb-2">
                                        <a href="{% url 'movie_detail' item.id %}" class="text-[#CE052D] hover:underline">
                                            {{ item.title }}
                                        </a>
                                    </li>
                                {% endfor %}
                            </ul>
                        {% else %}
                            <p class="text-gray-600">No recommendations yet.</p>
                        {% endif %}
                    </div>
                </div>
            </section>
        </main>
    </div>

    <!-- JavaScript for Interactivity -->
    <script src="{% static 'js/dashboard.js' %}"></script>
</body>
</html>