<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="/">DDoCHI</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarContent">
      <!-- 로그인/로그아웃 및 회원가입 버튼 -->
      <ul class="navbar-nav ms-auto">
        {% if request.user.is_authenticated %}
          <!-- 로그아웃 버튼 -->
          <li class="nav-item">
            <form method="post" action="{% url 'custom_auth:logout' %}">
              {% csrf_token %}
              <button type="submit" class="btn btn-outline-danger w-100">Logout</button>
            </form>
          </li>
        {% else %}
          <!-- 로그인 버튼 -->
          <li class="nav-item me-3">
            <button type="button" class="btn btn-outline-primary w-100 mb-2" data-bs-toggle="modal" data-bs-target="#loginModal">Login</button>
          </li>
          <!-- 회원가입 버튼 -->
          <li class="nav-item me-3">
            <button type="button" class="btn btn-outline-success w-100" data-bs-toggle="modal" data-bs-target="#signupModal">Sign Up</button>
          </li>
        {% endif %}
      </ul>
    </div>
  </div>
</nav>


<!-- 로그인 모달 -->
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="loginModalLabel">Login</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- 로그인 폼 -->
        <form method="post" action="{% url 'custom_auth:login' %}">
          {% csrf_token %}
          <div class="mb-3">
            <label for="username" class="form-label">Username</label>
            <input type="text" class="form-control" id="username" name="username" required="required">
          </div>
          <div class="mb-3">
            <label for="password" class="form-label">Password</label>
            <input type="password" class="form-control" id="password" name="password" required="required">
          </div>
          <button type="submit" class="btn btn-primary w-100">Login</button>
        </form>
      </div>
    </div>
  </div>
</div>

<!-- 회원가입 모달 -->
<div class="modal fade" id="signupModal" tabindex="-1" aria-labelledby="signupModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="signupModalLabel">Sign Up</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <!-- 회원가입 폼 -->
        <form method="post" action="{% url 'custom_auth:signup' %}">
          {% csrf_token %}
          <div class="mb-3">
            <label for="usernameSignup" class="form-label">Username</label>
            <input type="text" class="form-control" id="usernameSignup" name="username" required="required">
          </div>
          <div class="mb-3">
            <label for="passwordSignup" class="form-label">Password</label>
            <input type="password" class="form-control" id="passwordSignup" name="password1" required="required">
          </div>
          <div class="mb-3">
            <label for="passwordConfirmSignup" class="form-label">Confirm Password</label>
            <input type="password" class="form-control" id="passwordConfirmSignup" name="password2" required="required">
          </div>
          <a href="{% url 'butler:privacy' %}" class="text-dark" target="_blank">개인정보 처리방침</a>
          <p class="text-danger">회원 가입후 권한 신청 메일을 보내주세요.</p>
          <p class="text-danger">회원 가입시 본 개인정보 처리방침에 동의하는 것으로 간주됩니다.</p>
          <button type="submit" class="btn btn-success w-100">Sign Up</button>
        </form>
      </div>
    </div>
  </div>
</div>