@extends('layouts.app')

@section('content')
    @php($portalUser = auth()->user())

    <div class="page-shell">
        <header class="topbar">
            <a class="brand" href="{{ route('landing.index') }}">
                <span class="brand-mark"></span>
                <span>
                    <strong>{{ config('moonwell.realm.server_name') }}</strong>
                    <small>{{ config('moonwell.realm.tagline') }}</small>
                </span>
            </a>

            <nav class="topnav">
                <a href="{{ route('landing.index') }}">Главная</a>
                @if ($portalUser)
                    <a href="{{ route('cabinet.index') }}">Личный кабинет</a>
                    @if ($portalUser->canAccessAdminPanel())
                        <a href="{{ route('admin.accounts.index') }}">Аккаунты</a>
                        <a href="{{ route('admin.login-screen-news.index') }}">Новости WoW</a>
                    @endif
                @endif
            </nav>

            <div class="topbar-actions">
                @if ($portalUser)
                    <span class="topbar-user">{{ $portalUser->username }} · {{ $portalUser->accessLabel() }}</span>

                    <form method="POST" action="{{ route('logout') }}">
                        @csrf
                        <button class="button button--ghost" type="submit">Выйти</button>
                    </form>
                @else
                    <a class="button button--ghost" href="{{ route('login') }}">Войти</a>
                @endif
            </div>
        </header>

        @if (session('status'))
            <div class="alert alert--success">{{ session('status') }}</div>
        @endif

        @if (session('error'))
            <div class="alert alert--error">{{ session('error') }}</div>
        @endif

        <main>
            @yield('portal-content')
        </main>
    </div>
@endsection
