import os

# CONFIG_DIR is your app package; go up one to the project root
CONFIG_DIR   = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT = os.path.dirname(CONFIG_DIR)

class Config:
    SECRET_KEY = os.environ['SECRET_KEY']
    MAX_CONTENT_LENGTH = int(
        os.environ.get('MAX_CONTENT_LENGTH', 20 * 1024 * 1024 * 1024)
    )
    ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}

    UPLOAD_FOLDER = os.path.join(PROJECT_ROOT, "static", "uploads")

    # MySQL connection parameters
    MYSQL_USER     = os.environ['MYSQL_USER']
    MYSQL_PASSWORD = os.environ['MYSQL_PASSWORD']
    MYSQL_HOST     = os.environ['MYSQL_HOST']
    MYSQL_PORT     = int(os.environ.get('MYSQL_PORT', 3306))
    MYSQL_DATABASE = os.environ['MYSQL_DATABASE']

    # Build the SQLAlchemy database URI
    SQLALCHEMY_DATABASE_URI = (
        f"mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}"
        f"@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DATABASE}"
    )
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # Optional toggles
    ENABLE_DB_SEEDING = os.environ.get('ENABLE_DB_SEEDING', '0') == '1'
    DOCKER_ENV        = os.environ.get('FLASK_ENV', 'production')

    # Neo4j configuration
    NEO4J_URI      = os.getenv('NEO4J_URI', 'bolt://neo4j:7687')
    NEO4J_USER     = os.getenv('NEO4J_USER', 'neo4j')
    NEO4J_PASSWORD = os.getenv('NEO4J_PASSWORD', 'your_secure_password')

    # Standard image size (for placeholders, etc.)
    STANDARD_IMG_SIZE = tuple(
        map(int, os.getenv('STANDARD_IMG_SIZE', '300x200').split('x'))
    )
