import os
from functools import lru_cache
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    SECRET_KEY: str = "supersecretjwtkey1234567890abcdef"
    DATABASE_URL: str = "sqlite:///./automation_platform.db"
    ENCRYPTION_KEY: str = "VGhpcyBpcyBhIDMyLWJ5dGUgZW5jcnlwdGlvbiBr"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440

    # LinkedIn OAuth2
    LINKEDIN_CLIENT_ID: str = ""
    LINKEDIN_CLIENT_SECRET: str = ""
    LINKEDIN_REDIRECT_URI: str = "http://localhost:8000/linkedin/callback"

    # Telegram Telethon
    TELEGRAM_API_ID: int = 0
    TELEGRAM_API_HASH: str = ""

    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"


@lru_cache()
def get_settings() -> Settings:
    return Settings()


settings = get_settings()

# Platform metadata
PLATFORMS = {
    "telegram": {
        "name": "telegram",
        "display_name": "Telegram",
        "icon": "fab fa-telegram",
        "color": "#0088cc",
        "description": "Post to Telegram channels and groups via Bot API",
    },
    "linkedin": {
        "name": "linkedin",
        "display_name": "LinkedIn",
        "icon": "fab fa-linkedin",
        "color": "#0077b5",
        "description": "Share professional updates to your LinkedIn profile or page",
    },
    "twitter": {
        "name": "twitter",
        "display_name": "Twitter / X",
        "icon": "fab fa-twitter",
        "color": "#1da1f2",
        "description": "Post tweets and threads via X API",
    },
    "reddit": {
        "name": "reddit",
        "display_name": "Reddit",
        "icon": "fab fa-reddit",
        "color": "#ff4500",
        "description": "Submit posts to any subreddit via Reddit API",
    },
    "instagram": {
        "name": "instagram",
        "display_name": "Instagram",
        "icon": "fab fa-instagram",
        "color": "#e1306c",
        "description": "Post images and captions to your Business Instagram",
    },
    "facebook": {
        "name": "facebook",
        "display_name": "Facebook",
        "icon": "fab fa-facebook",
        "color": "#1877f2",
        "description": "Publish posts to your Facebook Page",
    },
}
