<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // We use insertOrIgnore to prevent errors if you run this multiple times
        // Defaulting to 'code' type with a simple HTML placeholder so you can see them immediately.
        
        $ads = [
            [
                'name' => 'Author Profile - Mobile Top',
                'placement_key' => 'author_mobile_top',
                'type' => 'code',
                'content' => '<div style="width:100%;height:100px;background:#f3f4f6;border:1px dashed #ccc;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:12px;font-weight:bold;text-transform:uppercase;">Mobile Top Ad (320x100)</div>',
                'dimensions' => '320x100',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Author Profile - Sidebar Top',
                'placement_key' => 'author_sidebar_1',
                'type' => 'code',
                'content' => '<div style="width:100%;height:250px;background:#f3f4f6;border:1px dashed #ccc;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:12px;font-weight:bold;text-transform:uppercase;">Sidebar Ad 1 (300x250)</div>',
                'dimensions' => '300x250',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Author Profile - Sidebar Bottom',
                'placement_key' => 'author_sidebar_2',
                'type' => 'code',
                'content' => '<div style="width:100%;height:250px;background:#f3f4f6;border:1px dashed #ccc;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:12px;font-weight:bold;text-transform:uppercase;">Sidebar Ad 2 (300x250)</div>',
                'dimensions' => '300x250',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ];

        DB::table('ad_placements')->insertOrIgnore($ads);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        DB::table('ad_placements')->whereIn('placement_key', [
            'author_mobile_top',
            'author_sidebar_1',
            'author_sidebar_2'
        ])->delete();
    }
};