"""
Demo Session Service Configuration
"""

import os
from pydantic_settings import BaseSettings
from typing import Optional


class Settings(BaseSettings):
    """Demo Session Service Settings"""

    # Service info
    SERVICE_NAME: str = "demo-session"
    VERSION: str = "1.0.0"
    DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"

    # Database
    DATABASE_URL: str = os.getenv(
        "DEMO_SESSION_DATABASE_URL",
        "postgresql+asyncpg://postgres:postgres@localhost:5432/demo_session_db"
    )

    # Redis
    REDIS_URL: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")
    REDIS_KEY_PREFIX: str = "demo:session"
    REDIS_SESSION_TTL: int = 1800  # 30 minutes

    # Demo session configuration
    DEMO_SESSION_DURATION_MINUTES: int = 30
    DEMO_SESSION_MAX_EXTENSIONS: int = 3
    DEMO_SESSION_CLEANUP_INTERVAL_MINUTES: int = 60

    # Demo account credentials (public)
    DEMO_ACCOUNTS: dict = {
        "individual_bakery": {
            "email": "demo.individual@panaderiasanpablo.com",
            "name": "Panadería San Pablo - Demo",
            "subdomain": "demo-sanpablo",
            "base_tenant_id": "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6"
        },
        "central_baker": {
            "email": "demo.central@panaderialaespiga.com",
            "name": "Panadería La Espiga - Demo",
            "subdomain": "demo-laespiga",
            "base_tenant_id": "b2c3d4e5-f6a7-48b9-c0d1-e2f3a4b5c6d7"
        }
    }

    # Service URLs
    AUTH_SERVICE_URL: str = os.getenv("AUTH_SERVICE_URL", "http://auth-service:8000")
    TENANT_SERVICE_URL: str = os.getenv("TENANT_SERVICE_URL", "http://tenant-service:8000")
    INVENTORY_SERVICE_URL: str = os.getenv("INVENTORY_SERVICE_URL", "http://inventory-service:8000")
    RECIPES_SERVICE_URL: str = os.getenv("RECIPES_SERVICE_URL", "http://recipes-service:8000")
    SALES_SERVICE_URL: str = os.getenv("SALES_SERVICE_URL", "http://sales-service:8000")
    ORDERS_SERVICE_URL: str = os.getenv("ORDERS_SERVICE_URL", "http://orders-service:8000")
    PRODUCTION_SERVICE_URL: str = os.getenv("PRODUCTION_SERVICE_URL", "http://production-service:8000")
    SUPPLIERS_SERVICE_URL: str = os.getenv("SUPPLIERS_SERVICE_URL", "http://suppliers-service:8000")

    # Logging
    LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")

    class Config:
        env_file = ".env"
        case_sensitive = True


settings = Settings()
