# ═══════════════════════════════════════════════════════════════════════════════
# meSEO — Environment Variables
# ═══════════════════════════════════════════════════════════════════════════════
#
# Copy this file to .env.local and fill in your values.
# NEVER commit .env.local — it contains secrets.
#
# This .env.example is safe to commit (no real secrets).
# ═══════════════════════════════════════════════════════════════════════════════

# ── Environment ──────────────────────────────────────────────────────────────
# Options: development | staging | production
# If not set, auto-detected from NODE_ENV / VERCEL_ENV
MESEO_ENV=development

# ── Database (required) ──────────────────────────────────────────────────────
# PostgreSQL connection string (Neon, Supabase, Railway, or local)
DATABASE_URL="postgresql://user:password@host:5432/dbname?sslmode=require"
# Optional direct connection used by Prisma migrations/schema checks.
DIRECT_URL="postgresql://user:password@host:5432/dbname?sslmode=require"

# ── Auth — Clerk (required) ──────────────────────────────────────────────────
# Get these from https://dashboard.clerk.com → API Keys
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_..."
CLERK_SECRET_KEY="sk_test_..."
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/sign-up"

# ── App URLs ─────────────────────────────────────────────────────────────────
NEXT_PUBLIC_APP_URL="http://localhost:3000"
NEXT_PUBLIC_API_URL="http://localhost:3000/api"

# ── meSEO Site Tag (tracking) ───────────────────────────────────────────────
# Where the tracker script sends events. Default: /api/collect
NEXT_PUBLIC_COLLECT_ENDPOINT="/api/collect"
NEXT_PUBLIC_TRACKER_SCRIPT_URL="/t.js"

# ── Coolify scheduled jobs ──────────────────────────────────────────────────
# Keep this secret only in Coolify. Cron endpoints require it as a Bearer token.
CRON_SECRET="replace-with-a-long-random-value"

# ── AI Avatar (optional — Phase 2) ──────────────────────────────────────────
# AI Avatar — set ONE of these to enable real AI responses.
# If neither is set, the avatar uses smart mock responses.
#
# Option 1: Anthropic (Claude) — recommended
# Get from https://console.anthropic.com
ANTHROPIC_API_KEY=""
AI_MODEL_ID="claude-sonnet-4-20250514"
#
# Option 2: OpenAI (GPT)
# Get from https://platform.openai.com/api-keys
OPENAI_API_KEY=""
OPENAI_MODEL_ID="gpt-4o-mini"

# ── AI Search Verification (Phase 11A) ────────────────────────────────────────
# Perplexity AI — https://www.perplexity.ai/settings/api
PERPLEXITY_API_KEY=""
# Google Gemini — https://aistudio.google.com/app/apikey
GEMINI_API_KEY=""
# Brave Search API — https://api.search.brave.com/
BRAVE_SEARCH_API_KEY=""
FIRECRAWL_API_KEY=""
BROWSERLESS_API_KEY=""
# Vercel Blob — add BLOB_READ_WRITE_TOKEN from Vercel project settings > Storage
BLOB_READ_WRITE_TOKEN=""

# ── Google OAuth (for GSC, GA4, GBP) ─────────────────────────────────────────
# Create these at https://console.cloud.google.com → Credentials
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GOOGLE_REDIRECT_URI="http://localhost:3000/api/auth/google/callback"
GOOGLE_API_KEY=""
GOOGLE_SEARCH_CX=""
GOOGLE_SEARCH_CONSOLE_KEY=""
GOOGLE_ANALYTICS_KEY=""
GOOGLE_BUSINESS_PROFILE_KEY=""

# ── Google PageSpeed API Key (optional — works without it) ───────────────────
GOOGLE_PAGESPEED_API_KEY=""

# ── Bing Webmaster API Key ───────────────────────────────────────────────────
BING_WEBMASTER_API_KEY=""

# ── Optional image providers ────────────────────────────────────────────────
UNSPLASH_ACCESS_KEY=""
PEXELS_API_KEY=""

# ── DataForSEO (Rank Tracker + Keyword Research) ─────────────────────────────
# Powers daily SERP position checks, SERP feature detection (local pack,
# featured snippets, etc.), competitor positions, and keyword volume data.
# Sign up at https://app.dataforseo.com — your login is the account email.
# IMPORTANT: DATAFORSEO_PASSWORD is the API password from
# app.dataforseo.com/api-access — NOT your dashboard login password.
# When unset the rank tracker falls back to Google Custom Search (no SERP
# features, no competitor data) and keyword research falls back to AI estimates.
DATAFORSEO_LOGIN=""
DATAFORSEO_PASSWORD=""
# Soft daily cost cap for the /api/cron/rank-check job. Each Live SERP
# check is ~$0.002 — $5/day = ~2,500 keyword checks. Brands whose checks
# would push the running total past this cap are skipped for the day.
DATAFORSEO_DAILY_CAP_USD="5"

# ── Stripe Billing (optional — Phase 2) ──────────────────────────────────────
STRIPE_SECRET_KEY=""
STRIPE_WEBHOOK_SECRET=""

# ── Optional integrations used by server routes ─────────────────────────────
REDIS_URL=""
INTEGRATION_ENCRYPTION_KEY=""
ADMIN_SECRET=""
ADMIN_EMAILS=""
ALLOWED_EMAILS=""
SMTP_HOST=""
SMTP_PORT="587"
SMTP_USER=""
SMTP_PASS=""
SMTP_FROM="meSEO Reports <reports@example.com>"
RESEND_API_KEY=""
NANGO_SECRET_KEY=""
NEXT_PUBLIC_NANGO_PUBLIC_KEY=""
INNGEST_EVENT_KEY=""
INNGEST_SIGNING_KEY=""
TWILIO_ACCOUNT_SID=""
TWILIO_AUTH_TOKEN=""
TWILIO_PHONE_NUMBER=""
ALERT_EMAIL_RECIPIENT=""
CLIENT_SESSION_SECRET=""
BYPASS_PUBLIC_AUDIT_VERIFICATION="false"
SITE_TAG_SIDE_EFFECTS_ENABLED="true"
DEBUG_MIDDLEWARE="0"
DEBUG_CONFIDENCE="0"
PLATFORM_TELEMETRY_DISABLED="0"
COST_ALERT_TOTAL="200"
COST_ALERT_AI="50"
COST_ALERT_DB="50"
COST_ALERT_SERP="30"

# ── Feature Flags ────────────────────────────────────────────────────────────
# Set to "false" to disable a feature
FEATURE_AI_AVATAR=true
FEATURE_SITE_TAG=true
FEATURE_BILLING=true

# ── Debug ────────────────────────────────────────────────────────────────────
# Set to "true" to enable debug logging
DEBUG_MODE=false
