<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\Tenant;
use App\Services\Theme\SkinManager;
use Illuminate\Database\Seeder;

class DefaultShopSkinsSeeder extends Seeder
{
    public function run(): void
    {
        $tenant = Tenant::withoutGlobalScopes()->where('domain', 'easybox.w-websoftsrv.kr')->first();
        if ($tenant) app()->instance('currentTenant', $tenant);

        /** @var SkinManager $mgr */
        $mgr = app(SkinManager::class);
        $found = $mgr->scan('shop');
        $mgr->activateDefault('shop', 'basic');

        // Also seed comment + page skins (single pass)
        app(SkinManager::class)->scan('comment');
        app(SkinManager::class)->activateDefault('comment', 'flat');
        app(SkinManager::class)->scan('page');
        app(SkinManager::class)->activateDefault('page', 'default');

        $this->command?->info('DefaultShopSkinsSeeder — scanned ' . $found->count() . ' shop skins (+ comment + page).');
    }
}
