<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('events', function (Blueprint $table) {
            $table->id();
            $table->string('ems_event_id')->nullable()->unique();
            $table->string('name');
            $table->string('slug')->unique();
            $table->string('destination');
            $table->string('country')->default('Saudi Arabia');
            $table->text('description')->nullable();
            $table->enum('type', ['hajj', 'umrah', 'ziyarat', 'tourism'])->default('umrah');
            $table->date('start_date');
            $table->date('end_date');
            $table->unsignedSmallInteger('duration_days')->nullable();
            $table->unsignedBigInteger('price');
            $table->unsignedBigInteger('original_price')->nullable();
            $table->unsignedTinyInteger('discount_percent')->nullable();
            $table->unsignedSmallInteger('max_spots')->nullable();
            $table->unsignedSmallInteger('spots_remaining')->nullable();
            $table->enum('status', ['open', 'limited', 'sold_out', 'past'])->default('open');
            $table->string('hero_image_path')->nullable();
            $table->json('gallery_images')->nullable();
            $table->json('highlights')->nullable();
            $table->decimal('rating', 2, 1)->nullable();
            $table->unsignedInteger('review_count')->default(0);
            $table->boolean('is_featured')->default(false);
            $table->boolean('is_published')->default(false);
            $table->boolean('volunteer_enabled')->default(false);
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('events');
    }
};
