#!/bin/bash
# ============================================
# BreakPilot Stop Services
# ============================================
# Usage: ./scripts/stop.sh [dev|staging|prod]
# ============================================

set -e

ENV=${1:-dev}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(dirname "$SCRIPT_DIR")"

# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

cd "$ROOT_DIR"

echo -e "${YELLOW}Stopping $ENV services...${NC}"

case $ENV in
    dev|development)
        docker compose down
        ;;
    staging)
        docker compose -f docker-compose.yml -f docker-compose.staging.yml down
        ;;
    prod|production)
        docker compose -f docker-compose.yml -f docker-compose.prod.yml down
        ;;
    *)
        echo "Unknown environment: $ENV"
        echo "Usage: $0 [dev|staging|prod]"
        exit 1
        ;;
esac

echo -e "${GREEN}✓ Services stopped.${NC}"
