
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <link th:href="@{/vendor/fontawesome-free/css/all.min.css}" rel="stylesheet">
  <link th:href="@{/css/sb-admin-2.min.css}" rel="stylesheet">
  <link rel="icon" href="data:,">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body id="page-top">
  <div id="wrapper">
    <div th:replace="~{fragments/fragment-menu :: menu}"></div>
    <div id="content-wrapper" class="d-flex flex-column">
      <div id="content" class="p-4">
        
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
  <!-- Botón hamburguesa solo visible en móvil -->
  <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
    <i class="fa fa-bars"></i>
  </button>
  <h1 class="h4 mb-0 text-gray-800">Formulario de usuario</h1>
</nav>

        
<div class="container-fluid">
  <h2 class="mb-4" th:text="${usuario.id} != null ? 'Editar usuario' : 'Nuevo usuario'">Nuevo usuario</h2>
  <form th:action="@{/usuarios/guardar}" th:object="${usuario}" method="post" class="row g-3">
    <input type="hidden" th:field="*{id}" />

    <div class="col-12 col-md-6">
      <label class="form-label">Usuario</label>
      <input type="text" th:field="*{username}" class="form-control" required />
    </div>

    <div class="col-12 col-md-6">
      <label class="form-label">Contraseña</label>
      <input type="password" th:field="*{password}" class="form-control" th:placeholder="${usuario.id} != null ? '••••••••' : ''" />
    </div>

    <div class="col-12 col-md-6">
      <label class="form-label">Rol</label>
      <select th:field="*{role}" class="form-select">
        <option value="USER">Usuario</option>
        <option value="ADMIN">Administrador</option>
      </select>
    </div>

    <div class="col-12">
      <button type="submit" class="btn btn-primary mt-3">Guardar</button>
    </div>
  </form>
</div>

      </div>
    </div>
  </div>
  
<script th:src="@{/vendor/jquery/jquery.min.js}"></script>
<script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/js/sb-admin-2.min.js}"></script>

</body>
</html>
