<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WaifuBoard - Marketplace</title>
    <link rel="stylesheet" href="/views/css/globals.css">
    <link rel="stylesheet" href="/views/css/components/navbar.css">
    <link rel="stylesheet" href="/views/css/marketplace.css">
    <link rel="stylesheet" href="/views/css/components/updateNotifier.css">
    <link rel="icon" href="/public/assets/waifuboards.ico" type="image/x-icon">
    <link rel="stylesheet" href="/views/css/components/titlebar.css">
    <script src="/src/scripts/titlebar.js"></script>
</head>
<body>
<div id="titlebar"> <div class="title-left">
    <img class="app-icon" src="/public/assets/waifuboards.ico"  alt=""/>
    <span class="app-title">WaifuBoard</span>
</div>
    <div class="title-right">
        <button class="min">—</button>
        <button class="max">🗖</button>
        <button class="close">✕</button>
    </div>
</div>

<nav class="navbar" id="navbar">
    <a href="#" class="nav-brand">
        <div class="brand-icon">
            <img src="/public/assets/waifuboards.ico" alt="WF Logo">
        </div>
        WaifuBoard
    </a>

    <div class="nav-center">
        <button class="nav-button" onclick="window.location.href='/anime'">Anime</button>
        <button class="nav-button" onclick="window.location.href='/books'">Books</button>
        <button class="nav-button" onclick="window.location.href='/gallery'">Gallery</button>
        <button class="nav-button" onclick="window.location.href='/schedule'">Schedule</button>
        <button class="nav-button" onclick="window.location.href='/my-list'">My List</button>
        <button class="nav-button active">Marketplace</button>
    </div>

    <div class="nav-right">
        <div class="search-wrapper" style="visibility: hidden;">
            <svg class="search-icon" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                <circle cx="11" cy="11" r="8"/>
                <path d="M21 21l-4.35-4.35"/>
            </svg>
            <input type="text" class="search-input" id="search-input" placeholder="Search anime..." autocomplete="off">
            <div class="search-results" id="search-results"></div>
        </div>

        <div class="nav-user" id="nav-user" style="display:none;">
            <div class="user-avatar-btn">
                <img id="nav-avatar" src="/public/assets/waifuboards.ico" alt="avatar">
                <div class="online-indicator"></div>
            </div>

            <div class="nav-dropdown" id="nav-dropdown">
                <div class="dropdown-header">
                    <img id="dropdown-avatar" src="/public/assets/waifuboards.ico" alt="avatar" class="dropdown-avatar">
                    <div class="dropdown-user-info">
                        <div class="dropdown-username" id="nav-username"></div>
                    </div>
                </div>

                <a href="/my-list" class="dropdown-item">
                    <svg width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                        <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>
                        <polyline points="17 21 17 13 7 13 7 21"/>
                        <polyline points="7 3 7 8 15 8"/>
                    </svg>
                    <span>My List</span>
                </a>
                <button class="dropdown-item logout-item" id="nav-logout">
                    <svg width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
                        <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
                        <polyline points="16 17 21 12 16 7"/>
                        <line x1="21" y1="12" x2="9" y2="12"/>
                    </svg>
                    <span>Logout</span>
                </button>
            </div>
        </div>
    </div>
</nav>

<div class="hero-spacer"></div>

<main>
    <section class="section">

        <header class="section-header">
            <p class="marketplace-subtitle">Explore, install, and manage all available data source extensions for WaifuBoard.</p>
            <div class="filter-controls">
                <label for="extension-filter" class="filter-label">Filter by Type:</label>
                <select id="extension-filter" class="filter-select">
                    <option value="All">All Extensions</option>
                    <option value="Image">Image Boards</option>
                    <option value="Anime">Anime Boards</option>
                    <option value="Book">Book Boards</option>
                    <option value="Local">Local Only</option>
                </select>
            </div>
        </header>
        <div class="marketplace-grid" id="extensions-grid">
            <div class="extension-card skeleton grid-item">
                <div class="skeleton-icon" style="width: 50px; height: 50px;"></div>
                <div class="card-content-wrapper">
                    <div class="skeleton-text title-skeleton" style="width: 80%; height: 1.1em;"></div>
                    <div class="skeleton-text text-skeleton" style="width: 50%; height: 0.7em; margin-top: 0.25rem;"></div>
                </div>
                <div class="skeleton-button" style="width: 100%; height: 32px; margin-top: 0.5rem;"></div>
            </div>
            <div class="extension-card skeleton grid-item">
                <div class="skeleton-icon" style="width: 50px; height: 50px;"></div>
                <div class="card-content-wrapper">
                    <div class="skeleton-text title-skeleton" style="width: 80%; height: 1.1em;"></div>
                    <div class="skeleton-text text-skeleton" style="width: 50%; height: 0.7em; margin-top: 0.25rem;"></div>
                </div>
                <div class="skeleton-button" style="width: 100%; height: 32px; margin-top: 0.5rem;"></div>
            </div>
            <div class="extension-card skeleton grid-item">
                <div class="skeleton-icon" style="width: 50px; height: 50px;"></div>
                <div class="card-content-wrapper">
                    <div class="skeleton-text title-skeleton" style="width: 80%; height: 1.1em;"></div>
                    <div class="skeleton-text text-skeleton" style="width: 50%; height: 0.7em; margin-top: 0.25rem;"></div>
                </div>
                <div class="skeleton-button" style="width: 100%; height: 32px; margin-top: 0.5rem;"></div>
            </div>
        </div>
    </section>
    <div id="customModal" class="modal-overlay hidden">
        <div class="modal-content">
            <h3 id="modalTitle"></h3>
            <p id="modalMessage"></p>
            <div class="modal-actions">
                <button id="modalConfirmButton" class="modal-button btn-uninstall hidden">Confirm</button>
                <button id="modalCloseButton" class="modal-button btn-install">OK</button>
            </div>
        </div>
    </div>
</main>

<div id="updateToast" class="hidden">
    <p>Update available: <span id="latestVersionDisplay">v1.x</span></p>

    <a
            id="downloadButton"
            href="https://git.waifuboard.app/ItsSkaiya/WaifuBoard/releases"
            target="_blank"
    >
        Click To Download
    </a>
</div>

<script src="/src/scripts/updateNotifier.js"></script>
<script src="/src/scripts/rpc-inapp.js"></script>
<script src="/src/scripts/marketplace.js"></script>
<script src="/src/scripts/titlebar.js"></script>
<script src="/src/scripts/auth-guard.js"></script>
</body>
</html>