<% content_for :title, "新規登録" %>

<div class="max-w-md mx-auto">
  <h1 class="text-3xl font-bold text-gray-900 mb-6">新規登録</h1>

  <%= form_with model: @user, url: signup_path, class: "space-y-6" do |f| %>
    <% if @user.errors.any? %>
      <div class="bg-red-100 border border-red-400 text-red-800 px-4 py-3 rounded relative" role="alert">
        <strong class="font-bold">エラーがあります:</strong>
        <ul class="mt-2 list-disc list-inside">
          <% @user.errors.full_messages.each do |message| %>
            <li><%= message %></li>
          <% end %>
        </ul>
      </div>
    <% end %>

    <div>
      <%= f.label :username, "ユーザー名", class: "block text-sm font-medium text-gray-700" %>
      <%= f.text_field :username, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500", autofocus: true %>
    </div>

    <div>
      <%= f.label :email, "メールアドレス", class: "block text-sm font-medium text-gray-700" %>
      <%= f.email_field :email, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
    </div>

    <div>
      <%= f.label :password, "パスワード", class: "block text-sm font-medium text-gray-700" %>
      <%= f.password_field :password, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
      <p class="mt-1 text-sm text-gray-500">6文字以上</p>
    </div>

    <div>
      <%= f.label :password_confirmation, "パスワード(確認)", class: "block text-sm font-medium text-gray-700" %>
      <%= f.password_field :password_confirmation, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
    </div>

    <div>
      <%= f.submit "登録", class: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
    </div>
  <% end %>

  <div class="mt-6 text-center">
    <p class="text-sm text-gray-600">
      既にアカウントをお持ちですか？
      <%= link_to "ログイン", login_path, class: "font-medium text-indigo-600 hover:text-indigo-500" %>
    </p>
  </div>
</div>
