<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('shipping_zones', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->json('cities')->comment('Lista de cidades atendidas');
            $table->json('districts')->nullable()->comment('Lista de bairros/distritos específicos');
            $table->decimal('base_price', 10, 2)->comment('Preço base do frete');
            $table->decimal('price_per_kg', 10, 2)->nullable()->comment('Preço adicional por kg');
            $table->decimal('free_shipping_min', 10, 2)->nullable()->comment('Valor mínimo para frete grátis');
            $table->integer('delivery_days')->comment('Dias úteis para entrega');
            $table->text('description')->nullable();
            $table->boolean('active')->default(true);
            $table->timestamps();

            // Indexes
            $table->index('active');
            $table->index('delivery_days');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('shipping_zones');
    }
};
