<?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' => 'Home - Mobile Top',
                'placement_key' => 'home_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 Header Ad</div>',
                'dimensions' => '320x100',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Home - Sidebar Top',
                'placement_key' => 'home_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;">Sidebar Top (300x250)</div>',
                'dimensions' => '300x250',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Home - Sidebar Bottom',
                'placement_key' => 'home_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;">Sidebar Sticky (300x600)</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', [
            'home_mobile_top',
            'home_sidebar_top',
            'home_sidebar_bottom'
        ])->delete();
    }
};