Foam, a versatile underbalanced drilling fluid, shows potential for improving the drilling efficiency and reducing formation damage. However, the existing literature lacks insight into foam behavior under high-pH drilling conditions. This study introduces a novel approach using synthesized seawater, replacing the conventional use of freshwater on-site for the foaming system's liquid base. This approach is in line with sustainability objectives and offers novel perspectives on foam stability under high-pH conditions. Experiments, conducted with a high-pressure, high-temperature (HPHT) foam analyzer, investigate how pressure and temperature affect foam properties. The biodegradable foaming agent ammonium alcohol ether sulfate (AAES) is employed. Results demonstrate that the pressure significantly impacts foam stability. Increasing pressure enhances stability, reducing decay rates and promoting uniform bubble sizes, especially at lower temperatures. This highlights foam's capacity to withstand high-pressure conditions. Conversely, the temperature plays a substantial role in foam decay, particularly at elevated temperatures (75 and 90 °C). Decreased liquid viscosity accelerates the liquid drainage and foam decay. While pressure mainly influences the AAES foam stability at temperatures up to 50 °C, temperature becomes the dominant factor at higher temperatures. Temperature's impact on foamability is minimal under constant pressure, maintaining consistent gas volume for maximum foam height. However, foam stability is sensitive to temperature variations, with increasing temperature leading to a more significant bubble size increase gradient. These findings stress the importance of considering temperature effects in foam drilling, particularly in deep and high-temperature environments. AAES foam exhibits stability at lower temperatures, making it suitable for surface and intermediate drilling. Understanding temperature-induced changes in foam structure and bubble size is essential for optimizing performance in high-temperature and deep drilling scenarios.