<?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('shops', function (Blueprint $table) {
            $table->id();
            
            // Link to the User (Seller) who owns the shop
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade');
            
            // Core Shop Details
            $table->string('name')->unique();
            $table->string('slug')->unique(); // For clean URLs
            $table->string('tagline')->nullable();
            
            // Contact & Location
            $table->string('contact_phone');
            $table->string('contact_email')->nullable();
            $table->string('address_line_1');
            $table->string('address_line_2')->nullable();
            $table->string('city');
            $table->string('state'); // State/Province (e.g., CA, NY, ON, QC)
            $table->string('zip_code'); // Zip/Postal Code
            $table->decimal('latitude', 10, 7)->nullable();
            $table->decimal('longitude', 10, 7)->nullable();
            
            // Business Hours
            // Use strings for simple open/close times (e.g., '09:00', '22:00')
            $table->string('opening_time')->default('09:00'); 
            $table->string('closing_time')->default('22:00');
            
            // Branding/Media
            $table->string('logo_path')->nullable(); // Path to the uploaded logo file
            $table->string('cover_image_path')->nullable(); // Optional: Header/Cover image
            
            // Status & Operations
            $table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
            $table->boolean('is_open')->default(true); // Current operating status
            
            $table->timestamps();
        });
    }

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