"""
cPanel-specific Django settings for Yatra booking system.
Copy these settings to your main settings.py or import them.
"""

# SECURITY WARNING: keep the secret key used in production secret!
# Generate a new secret key for production: https://djecrety.ir/
SECRET_KEY = 'your-production-secret-key-here-change-this'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

# Add your domain here
ALLOWED_HOSTS = ['ctf.munaltech.com', 'munaltech.com', 'localhost']

# Database configuration for cPanel
# Update these values with your actual cPanel database details
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': ' ayurveda_yatra_booking',        # Usually prefixed with your cPanel username
        'USER': 'ayurveda_yatra',       # Database user you created
        'PASSWORD': ' !@#kali@123', # Database password
        'HOST': 'localhost',                 # Usually localhost, check with your host
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
    }
}

# Static files configuration for cPanel
STATIC_URL = '/static/'
STATIC_ROOT = '/home/yourusername/public_html/static/'  # Update with your actual path

# Media files configuration
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/yourusername/public_html/media/'    # Update with your actual path

# Channels configuration for cPanel (without Docker/Redis)
# Option 1: In-memory (single process only, no Redis needed)
CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels.layers.InMemoryChannelLayer"
    }
}

# Option 2: If you have Redis cloud service available
# CHANNEL_LAYERS = {
#     "default": {
#         "BACKEND": "channels_redis.core.RedisChannelLayer",
#         "CONFIG": {
#             "hosts": [("your-redis-cloud-url", 6379)],
#         },
#     },
# }

# Email configuration (if you want to use Gmail SMTP)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'your-email@gmail.com'
EMAIL_HOST_PASSWORD = 'your-app-password'  # Use app-specific password
DEFAULT_FROM_EMAIL = 'your-email@gmail.com'

# Security settings for production
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
X_FRAME_OPTIONS = 'DENY'
SECURE_HSTS_SECONDS = 31536000 if not DEBUG else 0
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True

# If using HTTPS (recommended)
# SECURE_SSL_REDIRECT = True
# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Session security
SESSION_COOKIE_SECURE = True  # Set to True if using HTTPS
CSRF_COOKIE_SECURE = True     # Set to True if using HTTPS
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_HTTPONLY = True

# Logging configuration for cPanel
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': '/home/yourusername/logs/django_error.log',  # Create this directory
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'ERROR',
            'propagate': True,
        },
    },
}

# Cache configuration using database (since Redis might not be available)
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'yatra_cache_table',
    }
}

# Time zone
TIME_ZONE = 'Asia/Kathmandu'  # Nepal time zone
USE_TZ = True

# Internationalization
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True

# File upload settings
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440  # 2.5 MB
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440  # 2.5 MB

# eSewa settings (keep your existing sandbox settings for testing)
ESEWA_SETTINGS = {
    'MERCHANT_CODE': 'EPAYTEST',
    'SECRET_KEY': '8gBm/:&EnhH.1/q',
    'SUCCESS_URL': 'https://uat.esewa.com.np/epay/transrec',
    'FAILURE_URL': 'https://uat.esewa.com.np/epay/transrec',
    'SERVICE_URL': 'https://uat.esewa.com.np/epay/transrec',
    'STATUS_CHECK_URL': 'https://uat.esewa.com.np/epay/transrec',
    # For production, update these URLs and credentials
}

# CORS settings (if needed for API access)
CORS_ALLOW_ALL_ORIGINS = False  # Set to False in production
CORS_ALLOWED_ORIGINS = [
    "https://ctf.munaltech.com",
    "https://munaltech.com",
]

# Default primary key field type
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'