<?php

declare(strict_types=1);

namespace Database\Seeders;

use PDO;

/**
 * BusinessLineSeeder
 *
 * Dev/demo data only. In production, tenants are created through the
 * public /signup flow or by a platform admin via
 * /platform/companies/onboard (see
 * App\Services\SubscriptionService::registerTenant) — never by running
 * this seeder. This creates exactly one demo company so a fresh local
 * checkout has something to log into; it deliberately does NOT seed
 * two companies the way earlier versions of this app did.
 */
final class BusinessLineSeeder implements SeederInterface
{
    public function run(PDO $pdo): void
    {
        $lines = [
            [
                'name' => 'Demo Company',
                'slug' => 'demo',
                'legal_name' => 'Demo Company Inc.',
                'brand_color' => '#174890',
                'support_email' => 'support@example.com',
                'support_phone' => '(555) 555-0100',
            ],
        ];

        $stmt = $pdo->prepare(
            "INSERT INTO business_lines (name, slug, legal_name, brand_color, support_email, support_phone, subscription_status, is_active, created_at, updated_at)
             VALUES (:name, :slug, :legal_name, :brand_color, :support_email, :support_phone, 'active', 1, NOW(), NOW())
             ON DUPLICATE KEY UPDATE
                name = VALUES(name), legal_name = VALUES(legal_name), brand_color = VALUES(brand_color),
                support_email = VALUES(support_email), support_phone = VALUES(support_phone)"
        );

        foreach ($lines as $line) {
            $stmt->execute($line);
        }

        echo '  seeded ' . count($lines) . " business line (demo tenant)\n";
    }
}
