"""
Development settings for PX360 project.
"""

from .base import *  # noqa

DEBUG = True

ALLOWED_HOSTS = ["localhost", "127.0.0.1", "0.0.0.0", ".ngrok-free.app", "micha-nonparabolic-lovie.ngrok-free.dev"]

# Database - Use PostgreSQL even in dev for consistency
# Override with SQLite if needed for quick local testing
# DATABASES = {
#     'default': env.db(
#         'DATABASE_URL',
#         default='postgresql://px360:px360@localhost:5432/px360'
#     )
# }

CSRF_TRUSTED_ORIGINS = [
    "https://*.ngrok-free.app",
    "https://*.ngrok.app",
    "https://micha-nonparabolic-lovie.ngrok-free.dev",
]

# Database inherits from base.py (PostgreSQL)
# To temporarily switch back to SQLite for testing, uncomment:
# DATABASES = {
#     "default": {
#         "ENGINE": "django.db.backends.sqlite3",
#         "NAME": BASE_DIR / "db.sqlite3",
#     }
# }
# Email backend for development
# Use simulator API for email (configured in .env with EMAIL_API_ENABLED=true)
# Emails will be sent to http://localhost:8000/api/simulator/send-email
# and displayed in terminal with formatted output
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'  # Disabled for simulator API

# Celery - Use eager mode for development (synchronous)
CELERY_TASK_ALWAYS_EAGER = env.bool("CELERY_TASK_ALWAYS_EAGER", default=False)
CELERY_TASK_EAGER_PROPAGATES = True

# CORS for development (if needed for frontend)
CORS_ALLOW_ALL_ORIGINS = True

# Django Debug Toolbar (optional)
if DEBUG:
    INSTALLED_APPS += ["django_extensions"]  # noqa

# Logging - More verbose in development
LOGGING["loggers"]["django"]["level"] = "DEBUG"  # noqa
LOGGING["loggers"]["apps"]["level"] = "DEBUG"  # noqa

# Redirect all SMS to this number in development (leave empty to disable)
DEV_SMS_RECIPIENT = env("DEV_SMS_RECIPIENT", default="")

# Disable some security features for development
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False

# Development session settings - persist across server reloads
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_COOKIE_AGE = 12 * 60 * 60  # 12 hours
