<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<header class="site-header">
    <div class="site-header__inner">
        <a class="logo" href="${pageContext.request.contextPath}/">비빔밥</a>
        <form class="search" method="get" action="${pageContext.request.contextPath}/">
            <input type="search" name="q" value="<c:out value='${q}'/>" placeholder="게임 이름 또는 제작자 검색" aria-label="검색"/>
            <button type="submit">검색</button>
        </form>
        <nav class="auth">
            <sec:authorize access="isAuthenticated()">
                <a href="${pageContext.request.contextPath}/games/new">게임 올리기</a>
                <form action="${pageContext.request.contextPath}/logout" method="post" class="logout-form">
                    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                    <button type="submit" class="link-btn">로그아웃</button>
                </form>
            </sec:authorize>
            <sec:authorize access="!isAuthenticated()">
                <a href="${pageContext.request.contextPath}/login">로그인</a>
                <a class="btn-primary" href="${pageContext.request.contextPath}/register">회원가입</a>
            </sec:authorize>
        </nav>
    </div>
</header>
