import logging
from pydantic_settings import BaseSettings
from pydantic import ConfigDict
from dotenv import load_dotenv

log = logging.getLogger(__name__)

# Set up logging to show environment loading
logging.basicConfig(level=logging.WARNING)

if not load_dotenv():
    log.error(f"Environment file .env not found.")
else:
    log.info(f"Successfully loaded environment from .env")

class ApplicationSettings(BaseSettings):
    """Define application configuration model.

    Constructor will attempt to determine the values of any fields not passed
    as keyword arguments by reading from the environment. Default values will
    still be used if the matching environment variable is not set.

    Environment variables:
        * FASTAPI_DEBUG
        * FASTAPI_PROJECT_NAME
        * FASTAPI_VERSION
        * FASTAPI_DOCS_URL
        * FASTAPI_USE_REDIS

    Attributes:
        DEBUG (bool): FastAPI logging level. You should disable this for
            production.
        PROJECT_NAME (str): FastAPI project name.
        VERSION (str): Application version.
        DOCS_URL (str): Path where swagger ui will be served at.
        USE_REDIS (bool): Whether or not to use Redis.

    """

    model_config = ConfigDict(case_sensitive=True, env_prefix="HOTEL_BOT_")

    DEBUG: bool = False
    PROJECT_NAME: str = "Hotel Bot"
    DOCS_URL: str = "/"
    OPENAPI_URL: str = "/openapi.json"
    REDOC_URL: str = "/redoc"
    
    ENCRYPTION_PASSWORD:str="" # AES-256 bits
    ENCRYPTION_KEY:str=""
        
    ADMIN_EMAIL: str = ''

    OPENAI_API_KEY: str = ''
    
    FE_URL: str = ''

    ENV: str = 'development'
    

settings = ApplicationSettings()
