"""
============================================================================
🌐 E SPACE 2.0 - MASTER PROJECT CONFIGURATION FILE (config.py)
============================================================================
INSTRUCTIONS:
This is the SINGLE MASTER CONFIG FILE for the ENTIRE project (Backend, Web, Mobile).
If you want to change ANY setting in this project (URLs, Database, Port,
Razorpay keys, Google OAuth, Pricing, File paths), change it right here in this file!

After changing any setting here:
  - Run 'sync_config.bat' (to sync Flutter & Web immediately)
  - Or simply run 'start_backend.bat' (which auto-syncs on startup)
============================================================================
"""

import os

# ==============================================================================
# 1. SERVER, NETWORK & BASE URLS
# ==============================================================================
# Production Cloud Server URL (Set this when you deploy to VPS/Cloud, e.g. "https://api.yourdomain.com")
PRODUCTION_URL = ""

# Port on which the Python Flask backend runs
PORT = 5000

# Server host ("0.0.0.0" binds to all network interfaces for LAN / Mobile access)
HOST = "0.0.0.0"

# Backend Base URL (Used by web browser, APIs, and OAuth redirects)
# - Local development: "http://127.0.0.1:5000"
# - Production with domain: "https://api.yourdomain.com"
BASE_URL = f"http://127.0.0.1:{PORT}"

# Frontend Web Portal URL (Where users access the web dashboard)
# - Local development: "http://127.0.0.1:5000"
# - Production with domain: "https://yourdomain.com"
FRONTEND_URL = f"http://127.0.0.1:{PORT}"

# Public Cloudflare Edge Tunnel / Reverse Proxy URL (For global phone access on 4G/5G)
PUBLIC_EDGE_URL = "https://figured-chorus-vendors-assistant.trycloudflare.com"

# Local Wi-Fi Network IPv4 of laptop (For testing Android app on the same Wi-Fi)
WIFI_BASE_URL = "http://10.198.118.101:5000"


# ==============================================================================
# 2. DATABASE CONFIGURATION (XAMPP MySQL / SQLite / Cloud Database)
# ==============================================================================
# Database engine: "mysql" for XAMPP MySQL, or "sqlite" for standalone local file
DB_ENGINE = "mysql"

# MySQL Host (XAMPP default is "127.0.0.1" or "localhost")
MYSQL_HOST = "127.0.0.1"

# MySQL Port (XAMPP standard is 3306, if customized in XAMPP use 3307)
MYSQL_PORT = 3307

# MySQL Username (XAMPP default is "root")
MYSQL_USER = "root"

# MySQL Password (XAMPP default is empty)
MYSQL_PASSWORD = ""

# MySQL Database Name
MYSQL_DB = "cloudvault"

# Full SQLAlchemy Database Connection String
# (Auto-constructed from above, or override directly for cloud databases like Supabase, Neon, AWS RDS)
DATABASE_URL = f"mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset=utf8mb4"

# SQLite Fallback Database File Path (Used automatically if MySQL is stopped)
SQLITE_DB_PATH = "backend/cloudvault_central.db"


# ==============================================================================
# 3. GOOGLE DRIVE & OAUTH 2.0 CREDENTIALS
# ==============================================================================
# Google Cloud Console -> APIs & Services -> Credentials -> OAuth 2.0 Client ID
GOOGLE_CLIENT_ID = "1033028674120-cckgpja5lpchtiv2uk6s30fi892i88p3.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET = "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"

# Google OAuth Callback URL (Must be registered in Authorized Redirect URIs on Google Cloud Console)
GOOGLE_REDIRECT_URI = f"{BASE_URL}/api/drive/callback"


# ==============================================================================
# 4. PAYMENT GATEWAY & MONETIZATION (Razorpay / UPI)
# ==============================================================================
# Razorpay Key ID or Payment Button ID
RAZORPAY_KEY_ID = "pl_RBcBgFQx5N2HsF"
RAZORPAY_KEY_SECRET = ""

# Direct Razorpay Quick Payment / UPI link (Used as alternative payment option)
RAZORPAY_PAYMENT_URL = "https://razorpay.me/@indsac"

# Subscription Price in INR for Pro Plan (Annual Pass)
PRO_PRICE_INR = 1.0

# Number of successful friend referrals required to unlock 1-Year Free Storage VIP Pass
REFERRAL_VIP_REQUIRED_COUNT = 2


# ==============================================================================
# 5. SECURITY, AUTHENTICATION & JWT TOKENS
# ==============================================================================
# Secret key used to sign JWT auth tokens (Change in production to a random strong string)
JWT_SECRET_KEY = "cloudvault_super_secret_jwt_key_2026"
JWT_SECRET = "cloudvault_super_secret_jwt_key_2026"

# JWT token expiration time in hours
JWT_EXPIRATION_HOURS = 24


# ==============================================================================
# 6. FILE PATHS & STORAGE DIRECTORIES
# ==============================================================================
# Directory where uploaded files are stored temporarily before streaming to Google Drive
UPLOAD_FOLDER = "backend/uploads"

# Path where the compiled Android APK release file is stored for direct web downloads
RELEASE_APK_PATH = "web/dist/ESpace.apk"

# Directory where the compiled React Web production bundle (HTML, JS, CSS) is served
WEB_DIST_PATH = "web/dist"
