<?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 - Header (All)',
                'placement_key' => 'article_header',
                'type' => 'code',
                // Responsive style placeholder
                '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 Header (Responsive)</div>',
                'dimensions' => 'Responsive',
                'target_url' => null,
                'is_active' => true,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'name' => 'Article - After Cover (Rect)',
                'placement_key' => 'article_after_cover',
                'type' => 'code',
                'content' => '<div style="width:300px;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;margin:0 auto;">Ad 300x250</div>',
                'dimensions' => '300x250',
                '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_header',
            'article_after_cover'
        ])->delete();
    }
};