<?php
use App\Core\Auth;
use function App\Core\{e, logo_asset, t, url};

$user = Auth::user();
$logoAsset = logo_asset('music');
$path = parse_url($_SERVER['REQUEST_URI'] ?? '/music', PHP_URL_PATH) ?: '/music';
$isHome = $path === '/' || $path === '/music';
?>
<header class="site-header music-header">
    <div class="topbar container music-topbar">
        <a class="brand music-brand <?= $logoAsset ? 'has-logo' : 'has-fallback' ?>" href="<?= url('/music') ?>">
            <?php if ($logoAsset): ?>
                <img src="<?= url($logoAsset) ?>" alt="Zalorox" loading="eager">
            <?php else: ?>
                <span class="brand-text">Zalorox</span>
            <?php endif; ?>
        </a>

        <form class="search music-search" action="<?= url('/music/arama') ?>" method="get" data-music-search-form>
            <span class="search-leading" aria-hidden="true">/</span>
            <input name="q" data-music-live-search autocomplete="off" placeholder="Mod veya icerik ara...">
            <button class="search-submit" type="submit" aria-label="Music ara"><span aria-hidden="true">&#128269;</span></button>
            <div class="music-search-results" data-music-search-results hidden></div>
        </form>

        <div class="account music-account">
            <?php if (!$user): ?>
                <div class="guest-actions" aria-label="Hesap">
                    <span class="account-icon" aria-hidden="true"></span>
                    <a class="pill" href="<?= url('/giris-yap') ?>"><?= e(t('login')) ?></a>
                    <a class="pill primary" href="<?= url('/kayit') ?>"><?= e(t('register')) ?></a>
                </div>
                <?php require BASE_PATH . '/app/Views/partials/guest-dropdown.php'; ?>
            <?php else: ?>
                <div class="notification-center" data-notification-center>
                    <button class="notification-trigger" type="button" data-notification-toggle aria-label="Bildirimler" aria-expanded="false">
                        <span aria-hidden="true">!</span>
                        <i data-notification-count hidden>0</i>
                    </button>
                    <div class="notification-dropdown" data-notification-dropdown hidden>
                        <div class="notification-head">
                            <strong>Bildirimler</strong>
                            <button type="button" data-notification-read-all>Tumunu okundu yap</button>
                        </div>
                        <div class="notification-list" data-notification-list>
                            <div class="notification-empty">Bildirimler yukleniyor.</div>
                        </div>
                    </div>
                </div>
                <?php require BASE_PATH . '/app/Views/partials/user-dropdown.php'; ?>
            <?php endif; ?>
        </div>

        <button class="hamburger" type="button" data-menu aria-label="Menu" aria-expanded="false">
            <span></span><span></span><span></span>
        </button>
    </div>

    <nav class="menubar music-menubar">
        <div class="container menu music-menu">
            <a class="menu-link<?= $isHome ? ' is-active' : '' ?>" href="<?= url('/music') ?>">Ana Sayfa</a>
            <a class="menu-link" href="<?= url('/music/arama?sirala=newest') ?>">Yeni Sarkilar</a>
            <a class="menu-link" href="<?= url('/music/arama?sirala=popular') ?>">Populer</a>
            <a class="menu-link" href="<?= url('/music#turler') ?>">Turler</a>
            <a class="menu-link" href="<?= url('/music#sanatcilar') ?>">Sanatcilar</a>
            <a class="menu-link" href="<?= url('/music#listeler') ?>">Listeler</a>
            <a class="menu-link" href="<?= url('/studyo/muzik-yukle') ?>">Studio</a>
        </div>
    </nav>
</header>
