"""Tier configuration, Stripe constants, and API key prefix."""

import os

# ─── Tier configuration ──────────────────────────────────────────────────────
# SendGrid-style tiers. Override via env vars.
TIERS = {
    "free": {
        "name": "Free",
        "max_sites": int(os.environ.get("TIER_FREE_SITES", "2")),
        "max_submissions": int(os.environ.get("TIER_FREE_SUBS", "50")),
        "price": 0,
        "analytics": "basic",
        "max_campaigns": 0,
        "max_recipients_per_campaign": 0,
        "max_custom_templates": 0,
        "max_api_email_sends": 0,
        "max_chains": 0,
        "max_documents": 0,
        "max_agents": 0,
    },
    "starter": {
        "name": "Starter",
        "max_sites": int(os.environ.get("TIER_STARTER_SITES", "5")),
        "max_submissions": int(os.environ.get("TIER_STARTER_SUBS", "500")),
        "price": 9,
        "analytics": "standard",
        "max_campaigns": 5,
        "max_recipients_per_campaign": 100,
        "max_custom_templates": 3,
        "max_api_email_sends": 100,
        "max_chains": 1,
        "max_documents": 10,
        "max_agents": 2,
    },
    "pro": {
        "name": "Pro",
        "max_sites": int(os.environ.get("TIER_PRO_SITES", "0")),
        "max_submissions": int(os.environ.get("TIER_PRO_SUBS", "5000")),
        "price": 29,
        "analytics": "advanced",
        "max_campaigns": 20,
        "max_recipients_per_campaign": 1000,
        "max_custom_templates": 10,
        "max_api_email_sends": 500,
        "max_chains": 3,
        "max_documents": 100,
        "max_agents": 10,
    },
    "teams": {
        "name": "Teams",
        "max_sites": 0,
        "max_submissions": int(os.environ.get("TIER_TEAMS_SUBS", "25000")),
        "max_members": 5,
        "price": 49,
        "analytics": "advanced",
        "max_campaigns": 50,
        "max_recipients_per_campaign": 5000,
        "max_custom_templates": 25,
        "max_api_email_sends": 2000,
        "max_chains": 10,
        "max_documents": 500,
        "max_agents": 50,
    },
    "teams_plus": {
        "name": "Teams Plus",
        "max_sites": 0,
        "max_submissions": int(os.environ.get("TIER_TEAMS_PLUS_SUBS", "50000")),
        "max_members": 0,
        "price": 99,
        "analytics": "advanced",
        "max_campaigns": -1,
        "max_recipients_per_campaign": -1,
        "max_custom_templates": -1,  # unlimited
        "max_api_email_sends": -1,  # unlimited
        "max_chains": -1,  # unlimited
        "max_documents": -1,  # unlimited
        "max_agents": -1,  # unlimited
    },
}

# Stripe price IDs — override via env vars for test/live
STRIPE_PRICE_IDS = {
    "starter": os.environ.get("STRIPE_STARTER_PRICE_ID") or os.environ.get("STRIPE_PRICE_STARTER", ""),
    "pro": os.environ.get("STRIPE_PRO_PRICE_ID") or os.environ.get("STRIPE_PRICE_PRO", ""),
    "teams": os.environ.get("STRIPE_TEAMS_PRICE_ID") or os.environ.get("STRIPE_PRICE_TEAMS", ""),
    "teams_plus": os.environ.get("STRIPE_TEAMS_PLUS_PRICE_ID") or os.environ.get("STRIPE_PRICE_TEAMS_PLUS", ""),
}
STRIPE_WEBHOOK_SECRET = os.environ.get("STRIPE_WEBHOOK_SECRET", "")
API_KEY_PREFIX = "af_"
