@echo off
title AR-ElecArrangement — Instalación de dependencias
cd /d "%~dp0"

echo.
echo  =====================================================
echo   AR-ElecArrangement — Setup del entorno Python
echo  =====================================================
echo.

:: 1. Crear venv si no existe
if not exist "%~dp0venv\Scripts\python.exe" (
    echo [1/3] Creando entorno virtual...
    python -m venv venv
    if errorlevel 1 (
        echo ERROR: no se pudo crear venv. Verifica que Python 3.11+ esté instalado.
        pause
        exit /b 1
    )
) else (
    echo [1/3] Entorno virtual ya existe, salto.
)

:: 2. Actualizar pip
echo [2/3] Actualizando pip...
"%~dp0venv\Scripts\python.exe" -m pip install --upgrade pip >nul

:: 3. Instalar dependencias
echo [3/3] Instalando dependencias (esto tarda 1-2 minutos la primera vez)...
"%~dp0venv\Scripts\python.exe" -m pip install -r backend\requirements-dev.txt
if errorlevel 1 (
    echo ERROR durante pip install.
    pause
    exit /b 1
)

echo.
echo  =====================================================
echo   Instalación lista. Arranca con: start.bat
echo  =====================================================
pause
