"""
Django settings for project project.

Generated by 'django-admin startproject' using Django 5.2.2.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-&t(qeg%h0%j&$^y%x74=1!$4*t$5n9vokc5-(1d4cdv&qh9gid'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['a.niram-s.online', '.niram-s.online', 'niram-s.online', 'www.niram-s.online', '127.0.0.1', 'localhost']


# Application definition

INSTALLED_APPS = [
    'modeltranslation',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'contactus',
    'captcha',
    'carousel',
    'pages',
    'services',
    'portfolio',
    'stats',
    'questions',
    'about',
    'footer',
    'tinymce',
    'compressor',


]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'niram.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'carousel.context_processors.site_carousel',
                'stats.context_processors.stats_context',
                'footer.context_processors.layout_context',
                'about.context_processors.about_context',

            ],
        },
    },
]

WSGI_APPLICATION = 'niram.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/

# LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True

LANGUAGE_CODE = 'ar'

LANGUAGES = (
    ('ar', 'Arabic'),
    ('en', 'English'),
)

LOCALE_PATHS = [
    os.path.join(BASE_DIR, 'locale'),
]

MODELTRANSLATION_DEFAULT_LANGUAGE = 'ar'

MODELTRANSLATION_LANGUAGES = ('ar', 'en')
MODELTRANSLATION_PREPOPULATE_LANGUAGE = 'ar'

LANGUAGE_COOKIE_NAME = 'django_language'

PREFIX_DEFAULT_LANGUAGE = False

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/

STATIC_URL = '/static/'  # URL for static files
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
    BASE_DIR / 'staticfiles',  # Additional static files directory
]

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
]


# COMPRESS_ENABLED = True
COMPRESS_CSS_FILTERS = ['compressor.filters.css_default.CssAbsoluteFilter']




MEDIA_URL = '/media/'  # URL for accessing media files
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# MEDIA_URL = '/media/'
# MEDIA_ROOT = '/home/webdkvuy/public_html/media'
# Default primary key field type
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field

CSRF_USE_SESSIONS = True
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
CSRF_USE_SESSIONS = False
CSRF_COOKIE_SECURE = False
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_SAMESITE = None   # ← change from 'Lax' to None
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_PATH = '/'

SESSION_COOKIE_SECURE = False
SESSION_COOKIE_SAMESITE = None  # ← change from 'Lax' to None

CSRF_TRUSTED_ORIGINS = [
    'http://a.niram-s.online',
    'https://a.niram-s.online',
    'http://niram-s.online',
    'https://niram-s.online',
    'http://www.niram-s.online',
    'https://www.niram-s.online',
]

# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'http')

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


RECAPTCHA_PUBLIC_KEY = '6LejSaYsAAAAANa3WJ54xp_ZLVy2AarI9RM59j9D'
RECAPTCHA_PRIVATE_KEY = '6LejSaYsAAAAAJ02_quj-2N6wjCO3XDDIMRuxaTc'



TINYMCE_DEFAULT_CONFIG = {
    'selector': 'textarea',
    'language': 'ar',
    'directionality': 'rtl',
    'height': 500,
    'menubar': True,

    'plugins': (
        'advlist autolink lists link image charmap print preview anchor '
        'searchreplace visualblocks code fullscreen insertdatetime media table '
        'code help wordcount emoticons directionality template'
    ),

    'toolbar': (
        'undo redo | formatselect | fontselect | '  # حذفت fontsizeselect
        'bold italic underline strikethrough forecolor backcolor | '
        'alignleft aligncenter alignright alignjustify | '
        'bullist numlist outdent indent | '
        'link image media table charmap emoticons | '
        'ltr rtl | removeformat | code fullscreen preview print'
    ),

    'content_css': 'https://fonts.googleapis.com/css2?family=Cairo&display=swap',

    'content_style': """
        body {
            font-family: 'Cairo', Arial, sans-serif !important;
            font-size: 12px !important;
            direction: rtl;
        }
        @media (max-width: 576px) {
            body {
                font-size: 10px !important;
            }
        }
    """,

    # تقييد الأنماط المسموح بها ليمنع font-size
    'valid_styles': {
        '*': 'color,font-weight,font-style,text-decoration,text-align',  # بدون font-size
    },

}



# Email configuration (console backend for development/testing)
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'info.webd00@gmail.com'
EMAIL_HOST_PASSWORD = 'dloqngxiaohhjtmv'  # Not your Gmail password!








