# ================================================================
# TENANT SERVICE CONFIGURATION
# services/tenant/app/core/config.py
# ================================================================

"""
Tenant service configuration
Multi-tenant management and subscription handling
"""

from shared.config.base import BaseServiceSettings
import os

class TenantSettings(BaseServiceSettings):
    """Tenant service specific settings"""
    
    # Service Identity
    APP_NAME: str = "Tenant Service"
    SERVICE_NAME: str = "tenant-service"
    DESCRIPTION: str = "Multi-tenant management and subscription service"
    
    # Database Configuration
    DATABASE_URL: str = os.getenv("TENANT_DATABASE_URL",
                                  "postgresql+asyncpg://tenant_user:tenant_pass123@tenant-db:5432/tenant_db")
    
    # Redis Database (dedicated for tenant data)
    REDIS_DB: int = 4
    
    # Subscription Plans
    DEFAULT_PLAN: str = os.getenv("DEFAULT_PLAN", "basic")
    TRIAL_PERIOD_DAYS: int = int(os.getenv("TRIAL_PERIOD_DAYS", "14"))
    
    # Plan Limits
    BASIC_PLAN_LOCATIONS: int = int(os.getenv("BASIC_PLAN_LOCATIONS", "1"))
    BASIC_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("BASIC_PLAN_PREDICTIONS_PER_DAY", "100"))
    BASIC_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("BASIC_PLAN_DATA_RETENTION_DAYS", "90"))
    
    PREMIUM_PLAN_LOCATIONS: int = int(os.getenv("PREMIUM_PLAN_LOCATIONS", "5"))
    PREMIUM_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("PREMIUM_PLAN_PREDICTIONS_PER_DAY", "1000"))
    PREMIUM_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("PREMIUM_PLAN_DATA_RETENTION_DAYS", "365"))
    
    ENTERPRISE_PLAN_LOCATIONS: int = int(os.getenv("ENTERPRISE_PLAN_LOCATIONS", "50"))
    ENTERPRISE_PLAN_PREDICTIONS_PER_DAY: int = int(os.getenv("ENTERPRISE_PLAN_PREDICTIONS_PER_DAY", "10000"))
    ENTERPRISE_PLAN_DATA_RETENTION_DAYS: int = int(os.getenv("ENTERPRISE_PLAN_DATA_RETENTION_DAYS", "1095"))
    
    # Billing Configuration
    BILLING_ENABLED: bool = os.getenv("BILLING_ENABLED", "false").lower() == "true"
    BILLING_CURRENCY: str = os.getenv("BILLING_CURRENCY", "EUR")
    BILLING_CYCLE_DAYS: int = int(os.getenv("BILLING_CYCLE_DAYS", "30"))
    
    # Resource Limits
    MAX_API_CALLS_PER_MINUTE: int = int(os.getenv("MAX_API_CALLS_PER_MINUTE", "100"))
    MAX_STORAGE_MB: int = int(os.getenv("MAX_STORAGE_MB", "1024"))
    MAX_CONCURRENT_REQUESTS: int = int(os.getenv("MAX_CONCURRENT_REQUESTS", "10"))
    
    # Spanish Business Configuration
    SPANISH_TAX_RATE: float = float(os.getenv("SPANISH_TAX_RATE", "0.21"))  # IVA 21%
    INVOICE_LANGUAGE: str = os.getenv("INVOICE_LANGUAGE", "es")
    SUPPORT_EMAIL: str = os.getenv("SUPPORT_EMAIL", "soporte@bakeryforecast.es")
    
    # Onboarding
    ONBOARDING_ENABLED: bool = os.getenv("ONBOARDING_ENABLED", "true").lower() == "true"
    DEMO_DATA_ENABLED: bool = os.getenv("DEMO_DATA_ENABLED", "true").lower() == "true"
    
    # Compliance
    GDPR_COMPLIANCE_ENABLED: bool = True
    DATA_EXPORT_ENABLED: bool = True
    DATA_DELETION_ENABLED: bool = True

settings = TenantSettings()
