<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Product>
 */
class ProductFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $brands = ['Shimano', 'Venzo', 'Trek', 'Specialized', 'Maxxis', 'Sram', 'Raleigh'];
        $bikeModels = ['Loki', 'Marlin 5', 'Chisel', 'Talon 3', 'Aspect 950'];
        $accessories = ['Cadena 9v', 'Pedales Aluminio', 'Casco MTB', 'Luz Delantera USB', 'Cámara 29"', 'Cubierta Kevlar'];
        
        $type = $this->faker->randomElement(['bike', 'accessory', 'service']);
        
        // Generar nombre según el tipo
        if ($type === 'bike') {
            $name = $this->faker->randomElement($brands) . ' ' . $this->faker->randomElement($bikeModels);
        } elseif ($type === 'accessory') {
            $name = $this->faker->randomElement($accessories) . ' ' . $this->faker->randomElement(['Pro', 'Basic', 'Comp', 'Elite']);
        } else {
            $name = $this->faker->randomElement(['Service General', 'Ajuste Cambios', 'Centrado de Rueda', 'Lavado y Engrase']);
        }

        // Lógica de Precios
        $price = $this->faker->numberBetween(5000, 800000);
        $cost = $price * $this->faker->randomFloat(2, 0.5, 0.7);

        return [
            'name' => $name,
            'sku' => strtoupper($this->faker->bothify('???-#####')),
            'description' => $this->faker->sentence(10),
            'price' => $price,
            'cost' => $cost,
            'stock_quantity' => $type === 'service' ? 0 : $this->faker->numberBetween(0, 50),
            'min_stock_alert' => $this->faker->numberBetween(2, 10),
            'type' => $type,
            // Nro de serie si es bicicleta
            'serial_number' => $type === 'bike' ? strtoupper($this->faker->bothify('##??##??')) : null,
        ];
    }
}
