<!DOCTYPE html>
<html lang="ar" dir="rtl" data-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}مُلهِم - منصة تعليمية ذكية{% endblock %}</title>

    <!-- Tailwind CSS and DaisyUI -->
    <link href="https://cdn.jsdelivr.net/npm/daisyui@4.4.19/dist/full.min.css" rel="stylesheet" type="text/css" />
    <script src="https://cdn.tailwindcss.com"></script>

    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css">

    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%2210 0 100 100%22><text y=%22.90em%22 font-size=%2290%22>📘</text></svg>"></link>
    <style>
        body {
            font-family: 'Tajawal', sans-serif;
        }
        /* Fade-out animation for loading screen */
        @keyframes fadeOut {
            0% { opacity: 1; }
            100% { opacity: 0; visibility: hidden; }
        }
        .fade-out {
            animation: fadeOut 0.5s forwards;
        }
    </style>

    <script>
        tailwind.config = {
            theme: {
                extend: {
                    fontFamily: {
                        sans: ['Tajawal', 'sans-serif'],
                    },
                },
            },
            daisyui: {
                themes: [
                    {
                        light: {
                            ...require("daisyui/src/theming/themes")["light"],
                            primary: "#3b82f6",
                            secondary: "#1d4ed8",
                            accent: "#2563eb",
                        },
                        dark: {
                            ...require("daisyui/src/theming/themes")["dark"],
                            primary: "#3b82f6",
                            secondary: "#1d4ed8",
                            accent: "#2563eb",
                        },
                    },
                ],
            },
        }
    </script>
</head>
<body class="min-h-screen bg-base-100">
    <!-- Loading Screen -->
    <div id="loading-screen" class="fixed inset-0 flex items-center justify-center bg-base-100 z-50">
        <!-- DaisyUI Spinner -->
        <div class="flex flex-col items-center">
            <div class="loader ease-linear rounded-full border-8 border-t-8 border-gray-200 h-24 w-24"></div>
            <p class="mt-4 text-lg font-semibold">جارٍ التحميل...</p>
        </div>
    </div>

    <!-- Navbar -->
    <div class="navbar bg-base-200">
        <div class="navbar-start">
            <div class="dropdown">
                <div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16" />
                    </svg>
                </div>
                <ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-200 rounded-box w-52">
                    {% if current_user.is_authenticated %}
                        <li><a href="{{ url_for('books_list') }}">المكتبة</a></li>
                        <li><a href="{{ url_for('chat_history') }}">المحادثات</a></li>
                        <li><a href="{{ url_for('profile') }}">الملف الشخصي</a></li>
                    {% else %}
                        <li><a href="{{ url_for('login') }}">تسجيل الدخول</a></li>
                        <li><a href="{{ url_for('register') }}">إنشاء حساب</a></li>
                    {% endif %}
                </ul>
            </div>
            <a href="{{ url_for('index') }}" style="font-size: 1.5rem;" class="btn btn-ghost text-xl">مُلهِم</a>
        </div>

        <div class="navbar-center hidden lg:flex">
            <ul class="menu menu-horizontal px-1">
                {% if current_user.is_authenticated %}
                    <li><a href="{{ url_for('books_list') }}">المكتبة</a></li>
                    <li><a href="{{ url_for('chat_history') }}">المحادثات</a></li>
                    <li><a href="{{ url_for('profile') }}">الملف الشخصي</a></li>
                {% else %}
                    <li><a href="{{ url_for('login') }}">تسجيل الدخول</a></li>
                    <li><a href="{{ url_for('register') }}">إنشاء حساب</a></li>
                {% endif %}
            </ul>
        </div>

        <div class="navbar-end">
            <!-- Theme Toggle -->
            <label class="swap swap-rotate mx-4">
                <input type="checkbox" class="theme-controller" value="dark" />
                <svg class="swap-on fill-current w-5 h-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73Z"/></svg>
                <svg class="swap-off fill-current w-5 h-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73ZM21,11H20a1,1,0,0,0,0,2h1a1,1,0,0,0,0-2Zm-9,8a1,1,0,0,0-1,1v1a1,1,0,0,0,2,0V20A1,1,0,0,0,12,19ZM18.36,17A1,1,0,0,0,17,18.36l.71.71a1,1,0,0,0,1.41,0,1,1,0,0,0,0-1.41ZM12,6.5A5.5,5.5,0,1,0,17.5,12,5.51,5.51,0,0,0,12,6.5Zm0,9A3.5,3.5,0,1,1,15.5,12,3.5,3.5,0,0,1,12,15.5Z"/></svg>
            </label>

            {% if current_user.is_authenticated %}
                <div class="dropdown dropdown-end">
                    <label tabindex="0" class="btn btn-ghost btn-circle avatar placeholder">
                        <div class="bg-primary text-primary-content rounded-full w-10">
                            <span class="text-lg">{{ current_user.user_data.username[0] | upper }}</span>
                        </div>
                    </label>
                    <ul tabindex="0" class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-200 rounded-box w-52">
                        <li>
                            <a href="{{ url_for('profile') }}" class="justify-between">
                                الملف الشخصي
                                <i class="fas fa-user"></i>
                            </a>
                        </li>
                        <li>
                            <a href="{{ url_for('chat_history') }}" class="justify-between">
                                سجل المحادثات
                                <i class="fas fa-history"></i>
                            </a>
                        </li>
                        <li>
                            <a href="{{ url_for('logout') }}" class="justify-between">
                                تسجيل الخروج
                                <i class="fas fa-sign-out-alt"></i>
                            </a>
                        </li>
                    </ul>
                </div>
            {% endif %}
        </div>
    </div>

    {% block flash_messages %}
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                <div id="flash-messages" class="fixed top-4 right-4 z-50 space-y-2">
                    {% for category, message in messages %}
                        <div class="alert {{ 'alert-success' if category == 'success' else 'alert-error' }} shadow-lg fade-out">
                            <div>
                                {% if category == 'success' %}
                                    <svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
                                {% else %}
                                    <svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/></svg>
                                {% endif %}
                                <span>{{ message }}</span>
                            </div>
                        </div>
                    {% endfor %}
                </div>

                <style>
                    @keyframes fadeOut {
                        0% { opacity: 1; }
                        90% { opacity: 1; }
                        100% { opacity: 0; }
                    }
                    .fade-out {
                        animation: fadeOut 3s forwards;
                    }
                </style>

                <script>
                    document.addEventListener('DOMContentLoaded', function() {
                        const flashMessages = document.getElementById('flash-messages');
                        if (flashMessages) {
                            setTimeout(() => {
                                flashMessages.remove();
                            }, 3000);
                        }
                    });
                </script>
            {% endif %}
        {% endwith %}
    {% endblock %}

    <!-- Main Content -->
    <main>
        {% block content %}{% endblock %}
    </main>

    <!-- Conditional Footer -->
    {% if request.path in ['/', '/login', '/register'] %}
        <footer class="footer footer-center p-4 bg-base-200 text-base-content">
            <aside>
                <p>جميع الحقوق محفوظة © 2024 - مُلهِم</p>
            </aside>
        </footer>
    {% endif %}

    <!-- Theme Controller Script -->
    <script>
        // Check for saved theme preference or default to dark
        const themeController = document.querySelector('.theme-controller');
        const savedTheme = localStorage.getItem('theme') || 'dark';
        document.documentElement.setAttribute('data-theme', savedTheme);
        themeController.checked = savedTheme === 'dark';

        // Theme toggle handler
        themeController.addEventListener('change', function(e) {
            const newTheme = e.target.checked ? 'dark' : 'light';
            document.documentElement.setAttribute('data-theme', newTheme);
            localStorage.setItem('theme', newTheme);
        });

        // Loading Screen Handler
        window.addEventListener('load', function() {
            const loadingScreen = document.getElementById('loading-screen');
            if (loadingScreen) {
                loadingScreen.classList.add('fade-out');
                loadingScreen.addEventListener('animationend', () => {
                    loadingScreen.remove();
                });
            }
        });
    </script>
</body>
</html>



make navbar not visable if in /chat/* route
give me new full code