<?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
{
    public function up(): void
    {
        $ads = [
            [
                'name' => 'Article - Mobile Top',
                'placement_key' => 'article_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;">Article Mobile Ad</div>',
                'dimensions' => '320x100',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Article - Sidebar Top',
                'placement_key' => 'article_sidebar_top',
                '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;">Article Sidebar Top</div>',
                'dimensions' => '300x250',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Article - Sidebar Bottom',
                'placement_key' => 'article_sidebar_bottom',
                'type' => 'code',
                'content' => '<div style="width:100%;height:600px;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;">Article Sidebar Sticky</div>',
                'dimensions' => '300x600',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ];

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

    public function down(): void
    {
        DB::table('ad_placements')->whereIn('placement_key', [
            'article_mobile_top',
            'article_sidebar_top',
            'article_sidebar_bottom'
        ])->delete();
    }
};