Dealing with Unseen Creatures
If you are unaware of a creature, aware of a creature’s presence, or aware of a creature’s location, that creature is considered to be “unseen” for you. A stationary unseen creature has a +40 bonus to Stealth checks, but this bonus is reduced to +20 if the unseen creature moves (and these bonuses are negated for potential observers with blindsense). An unseen creature benefits from total concealment (50% miss chance) against attacks. In addition, you are considered flat-footed against an unseen creature’s attacks.
If you are unaware of a creature or aware only of its presence, you cannot directly attack it. You must first succeed at a Perception check to search for the creature’s location, which then allows you to become aware of the creature’s location (if using an imprecise sense) or to observe the creature (if using a precise sense). If an unseen creature makes a melee attack against you from a space adjacent to you, you automatically determine its location, though this doesn’t stop it from moving after the attack.
Source
Core Rulebook pg. 261