.PHONY: help
help: ## Show this help message
	@echo 'Usage: make [target]'
	@echo ''
	@echo 'Targets:'
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: dev-up
dev-up: ## Start development databases (PostgreSQL and Redis)
	docker-compose -f docker-compose.dev.yml up -d

.PHONY: dev-down
dev-down: ## Stop development databases
	docker-compose -f docker-compose.dev.yml down

.PHONY: dev-logs
dev-logs: ## Show development database logs
	docker-compose -f docker-compose.dev.yml logs -f

.PHONY: build
build: ## Build all Docker images
	docker-compose build

.PHONY: up
up: ## Start all services
	docker-compose up -d

.PHONY: down
down: ## Stop all services
	docker-compose down

.PHONY: logs
logs: ## Show logs for all services
	docker-compose logs -f

.PHONY: logs-api
logs-api: ## Show API service logs
	docker-compose logs -f api

.PHONY: logs-worker
logs-worker: ## Show worker service logs
	docker-compose logs -f worker

.PHONY: restart
restart: ## Restart all services
	docker-compose restart

.PHONY: restart-api
restart-api: ## Restart API service
	docker-compose restart api

.PHONY: restart-worker
restart-worker: ## Restart worker service
	docker-compose restart worker

.PHONY: ps
ps: ## Show running services
	docker-compose ps

.PHONY: exec-api
exec-api: ## Execute bash in API container
	docker-compose exec api /bin/sh

.PHONY: exec-worker
exec-worker: ## Execute bash in worker container
	docker-compose exec worker /bin/sh

.PHONY: migrate
migrate: ## Run database migrations
	docker-compose run --rm migrate

.PHONY: clean
clean: ## Remove all containers and volumes
	docker-compose down -v

.PHONY: rebuild
rebuild: clean build up ## Clean, rebuild, and start all services

.PHONY: test-scan
test-scan: ## Run a test accessibility scan
	@echo "Running test scan on example.com..."
	@curl -X POST http://localhost:3001/api/scans \
		-H "Content-Type: application/json" \
		-H "Authorization: Bearer YOUR_JWT_TOKEN" \
		-d '{"websiteId": "test-website-id", "url": "https://example.com"}'