<!---app/templates/base.html--->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SMARTFLARE - Smart App Gallery - {% block title %}{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.ico') }}">
    <style>
        .navbar-light {
            background-color: #ffffff !important;
            border-bottom: 1px solid #e0e0e0;
        }
        .navbar-brand {
            font-weight: bold;
            color: #007bff !important;
        }
        .nav-link {
            color: #333 !important;
            transition: color 0.2s ease;
        }
        .nav-link:hover {
            color: #007bff !important;
        }
        .nav-link.active {
            color: #007bff !important;
            font-weight: bold;
            border-bottom: 2px solid #007bff;
        }
        .dropdown-menu {
            animation: fadeIn 0.3s ease;
            border: none;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }
        .dropdown-item {
            padding: 0.5rem 1rem;
            transition: background-color 0.2s ease;
        }
        .dropdown-item:hover {
            background-color: #e9ecef;
        }
        .dropdown-item.active {
            background-color: #007bff;
            color: white !important;
        }
        .app-card {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            border-radius: 10px;
            overflow: hidden;
        }
        .app-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
        }
        .card-img-top {
            background-color: #f8f9fa;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .dark-mode .navbar-light {
            background-color: #343a40 !important;
            border-bottom: 1px solid #495057;
        }
        .dark-mode .nav-link {
            color: #f8f9fa !important;
        }
        .dark-mode .nav-link:hover, .dark-mode .nav-link.active {
            color: #4dabf7 !important;
            border-bottom: 2px solid #4dabf7;
        }
        .dark-mode .dropdown-menu {
            background-color: #495057;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }
        .dark-mode .dropdown-item {
            color: #f8f9fa;
        }
        .dark-mode .dropdown-item:hover {
            background-color: #6c757d;
        }
        .dark-mode .dropdown-item.active {
            background-color: #4dabf7;
        }
        .dark-mode .app-card {
            background-color: #343a40;
            color: #f8f9fa;
        }
        .dark-mode .card-img-top {
            background-color: #495057;
        }
        .dark-mode .text-muted {
            color: #adb5bd !important;
        }
        .dark-mode .navbar-brand {
            color: #4dabf7 !important;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-light">
        <div class="container-fluid">
            <a class="navbar-brand" href="{{ url_for('gallery.gallery') }}">SMART App Gallery</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('gallery.gallery') }}">Gallery</a>
                    </li>
                    {% if current_user.is_authenticated %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('gallery.register') }}">Register App</a>
                        </li>
                    {% endif %}
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <span class="nav-link theme-toggle" onclick="toggleTheme()">Toggle Theme</span>
                    </li>
                    {% if current_user.is_authenticated %}
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                {% if current_user.email and current_user.email | md5 %}
                                    <img src="https://www.gravatar.com/avatar/{{ current_user.email | md5 }}?s=30&d=identicon" class="user-avatar" alt="User Avatar">
                                {% else %}
                                    <div class="initials-avatar">{{ current_user.username[:2] | upper }}</div>
                                {% endif %}
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
                                <li><a class="dropdown-item" href="{{ url_for('gallery.my_listings') }}">My Listings</a></li>
                                <li><a class="dropdown-item" href="{{ url_for('auth.logout') }}">Logout</a></li>
                            </ul>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('auth.login') }}">Login</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
    <div class="container mt-4">
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        {% block content %}{% endblock %}
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
    <script>
        function toggleTheme() {
            const html = document.documentElement;
            const currentTheme = html.getAttribute('data-theme');
            if (currentTheme === 'dark') {
                html.removeAttribute('data-theme');
                localStorage.setItem('theme', 'light');
            } else {
                html.setAttribute('data-theme', 'dark');
                localStorage.setItem('theme', 'dark');
            }
        }

        document.addEventListener('DOMContentLoaded', () => {
            const savedTheme = localStorage.getItem('theme');
            if (savedTheme === 'dark') {
                document.documentElement.setAttribute('data-theme', 'dark');
            }
        });
    </script>
</body>
</html>