import os
from pathlib import Path
from pydantic_settings import BaseSettings

# Project Directories
BASE_DIR = Path(__file__).resolve().parent.parent
ROOT_DIR = BASE_DIR.parent
UPLOAD_DIR = BASE_DIR / "uploads"
UPLOAD_PRODUCTS_DIR = UPLOAD_DIR / "products"
UPLOAD_CATEGORIES_DIR = UPLOAD_DIR / "categories"

# Ensure upload directories exist
UPLOAD_PRODUCTS_DIR.mkdir(parents=True, exist_ok=True)
UPLOAD_CATEGORIES_DIR.mkdir(parents=True, exist_ok=True)

class Settings(BaseSettings):
    PROJECT_NAME: str = "Nathji Marketing — Wholesale Kitchenware Catalogue"
    PROJECT_DESCRIPTION: str = "B2B Wholesale & Trading Digital Catalogue and Quotation Engine"
    VERSION: str = "1.0.0"
    
    # Database
    DATABASE_URL: str = f"sqlite:///{BASE_DIR / 'nathji.db'}"
    
    # Security / JWT
    SECRET_KEY: str = "nathji-super-secret-production-key-2026-secure-b2b-trading"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7  # 7 days
    
    # Default Admin Credentials
    DEFAULT_ADMIN_USERNAME: str = "admin"
    DEFAULT_ADMIN_PASSWORD: str = "nathji@admin2026"
    DEFAULT_ADMIN_EMAIL: str = "admin@nathjimarketing.com"
    DEFAULT_ADMIN_NAME: str = "Nathji Admin"
    
    # Business & WhatsApp Settings
    DEFAULT_WHATSAPP_NUMBER: str = "919876543210"  # Format: country code without '+'
    BUSINESS_NAME: str = "Nathji Marketing"
    BUSINESS_TAGLINE: str = "Wholesale Kitchenware Catalogue"
    BUSINESS_PHONE: str = "+91 98765 43210"
    BUSINESS_EMAIL: str = "contact@nathjimarketing.com"
    BUSINESS_ADDRESS: str = "Wholesale Market, Industrial Area, India"

    class Config:
        env_file = BASE_DIR / ".env"
        extra = "allow"

settings = Settings()
