{{define "navbar"}}
<nav class="border-b border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900">
  <div class="mx-auto flex max-w-7xl flex-wrap items-center justify-between p-4">
    <a href="/" class="flex items-center space-x-3 rtl:space-x-reverse">
      <span class="self-center whitespace-nowrap text-xl font-semibold">Trustcontact</span>
    </a>

    <button data-collapse-toggle="navbar-main" type="button" class="inline-flex h-10 w-10 items-center justify-center rounded-lg p-2 text-sm text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-700 md:hidden" aria-controls="navbar-main" aria-expanded="false">
      <span class="sr-only" data-i18n="nav.open_main_menu">Apri menu principale</span>
      <svg class="h-5 w-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15" />
      </svg>
    </button>

    <div class="hidden w-full items-center justify-between md:order-1 md:flex md:w-auto" id="navbar-main">
      <ul class="mt-4 flex flex-col gap-2 rounded-lg border border-gray-100 bg-gray-50 p-4 text-sm font-medium md:mt-0 md:flex-row md:items-center md:gap-1 md:border-0 md:bg-transparent md:p-0 dark:border-gray-700 dark:bg-gray-800 md:dark:bg-transparent">
        {{if eq .NavSection "home"}}
        {{if .CurrentUser}}
        {{else}}
        <li><a href="/login" class="block rounded-lg px-3 py-2 text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700" data-i18n="nav.login">Login</a></li>
        {{end}}
        {{else if not .CurrentUser}}
        <li><a href="/login" class="block rounded-lg px-3 py-2 {{if eq .NavSection "login"}}bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300{{else}}text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700{{end}}" data-i18n="nav.login">Login</a></li>
        <li><a href="/signup" class="block rounded-lg px-3 py-2 {{if eq .NavSection "signup"}}bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300{{else}}text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700{{end}}" data-i18n="nav.signup">Signup</a></li>
        {{end}}
      </ul>

      <div class="mt-4 flex items-center gap-3 md:mt-0 md:ms-4">
        {{template "navbar_controls" .}}
      </div>
    </div>
  </div>
</nav>
{{end}}

{{define "navbar_controls"}}
{{template "language_dropdown" .}}

{{if .CurrentUser}}
<div class="relative">
  <button type="button" class="inline-flex h-8 items-center rounded-lg bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:bg-gray-800 dark:text-gray-100 dark:hover:bg-gray-700 dark:focus:ring-gray-700" id="user-menu-button" aria-expanded="false" data-dropdown-toggle="user-dropdown" data-dropdown-placement="bottom">
    <span class="sr-only" data-i18n="nav.open_user_menu">Apri menu utente</span>
    <span class="inline-flex items-center justify-center">
      <svg class="h-4 w-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15" />
      </svg>
    </span>
  </button>
  <div class="z-50 my-4 hidden w-56 list-none divide-y divide-gray-100 rounded-lg bg-white text-base shadow-sm dark:divide-gray-700 dark:bg-gray-800" id="user-dropdown">
    <div class="px-4 py-3">
      <span class="block truncate text-sm text-gray-900 dark:text-gray-100">{{if .CurrentUser.Name}}{{.CurrentUser.Name}}{{else}}Utente{{end}}</span>
      <span class="block truncate text-sm text-gray-500 dark:text-gray-400">{{.CurrentUser.Email}}</span>
    </div>
    <div class="py-2">
      <a href="/private" class="block w-full rounded-lg px-2 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700">Private</a>
      {{if eq .CurrentUser.Role "admin"}}
      <a href="/admin" class="block w-full rounded-lg px-2 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700" data-i18n="nav.admin">Admin</a>
      {{end}}
      <form action="/logout" method="post" class="px-2">
        <button type="submit" class="block w-full rounded-lg px-2 py-2 text-left text-sm text-red-700 hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-900/40" data-i18n="nav.logout">Logout</button>
      </form>
    </div>
  </div>
</div>
{{end}}
{{end}}
