<% if controller_name.in?(%w[sessions registrations]) && action_name.in?(%w[new create]) %>
<%# Determine the active tab from the controller, not current_page?:
a failed POST re-renders :new from #create, where the request
path is the form target (not /sessions/new), so current_page?
would mis-highlight the switch. %>
<% on_sign_in = controller_name == "sessions" %>
<%= link_to new_session_path,
class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{on_sign_in ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %>
<%= t("layouts.auth.sign_in") %>
<% end %>
<%= link_to new_registration_path,
class: "w-1/2 px-2 py-1 rounded-md text-sm text-center font-medium #{!on_sign_in ? 'bg-surface shadow-sm text-primary' : 'text-secondary'}" do %>
<%= t("layouts.auth.sign_up") %>
<% end %>
<% end %>