<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\FeatureOption;
use App\Models\FeatureType;
use Illuminate\Support\Str;

class FeatureOptionSeeder extends Seeder
{
    public function run(): void
    {
        $brandingType = FeatureType::where('slug', 'branding-type')->first();
        $laminationType = FeatureType::where('slug', 'lamination-type')->first();
        $bindingType = FeatureType::where('slug', 'binding-type')->first();
        $cuttingType = FeatureType::where('slug', 'cutting-type')->first();

        $featureOptions = [
            // Branding Options (from Item Branding table)
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'UV',
                'slug' => 'uv',
                'description' => 'UV printing method for vibrant colors',
                'price_adjustment' => 0.50,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Screen Printing',
                'slug' => 'screen-printing',
                'description' => 'Traditional screen printing method',
                'price_adjustment' => 0.75,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Water Transfer',
                'slug' => 'water-transfer',
                'description' => 'Water transfer printing technique',
                'price_adjustment' => 1.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 3,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Monogram',
                'slug' => 'monogram',
                'description' => 'Custom monogram branding',
                'price_adjustment' => 2.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 4,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Borderless',
                'slug' => 'borderless',
                'description' => 'Borderless printing option',
                'price_adjustment' => 0.25,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 5,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Silicon',
                'slug' => 'silicon',
                'description' => 'Silicon-based branding method',
                'price_adjustment' => 1.50,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 6,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Puff',
                'slug' => 'puff',
                'description' => 'Puff print for raised texture',
                'price_adjustment' => 1.25,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 7,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'No branding Option (Straight to request or Upload design)',
                'slug' => 'no-branding',
                'description' => 'No additional branding, customer provides design',
                'price_adjustment' => 0.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 8,
            ],
            [
                'feature_type_id' => $brandingType->id,
                'name' => 'Sublimation',
                'slug' => 'sublimation',
                'description' => 'Sublimation printing for full-color designs',
                'price_adjustment' => 1.75,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 9,
            ],
            // Lamination Options (from Printing Finish table)
            [
                'feature_type_id' => $laminationType->id,
                'name' => 'Gloss',
                'slug' => 'gloss',
                'description' => 'Glossy lamination finish',
                'price_adjustment' => 0.15,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'feature_type_id' => $laminationType->id,
                'name' => 'Matt',
                'slug' => 'matt',
                'description' => 'Matte lamination finish',
                'price_adjustment' => 0.15,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'feature_type_id' => $laminationType->id,
                'name' => 'Pattern',
                'slug' => 'pattern',
                'description' => 'Patterned lamination finish',
                'price_adjustment' => 0.25,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 3,
            ],
            [
                'feature_type_id' => $laminationType->id,
                'name' => 'Crystal',
                'slug' => 'crystal',
                'description' => 'Crystal clear lamination finish',
                'price_adjustment' => 0.30,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 4,
            ],
            // Binding Options
            [
                'feature_type_id' => $bindingType->id,
                'name' => 'Nill',
                'slug' => 'nil',
                'description' => 'No binding required',
                'price_adjustment' => 0.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'feature_type_id' => $bindingType->id,
                'name' => 'Perfect Binding',
                'slug' => 'perfect-binding',
                'description' => 'Perfect binding for books and documents',
                'price_adjustment' => 0.50,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'feature_type_id' => $bindingType->id,
                'name' => 'Spiral',
                'slug' => 'spiral',
                'description' => 'Spiral binding for notebooks and reports',
                'price_adjustment' => 0.35,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 3,
            ],
            // Cutting Options
            [
                'feature_type_id' => $cuttingType->id,
                'name' => 'Die-cut',
                'slug' => 'die-cut',
                'description' => 'Custom die-cutting for unique shapes',
                'price_adjustment' => 0.20,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 1,
            ],
            [
                'feature_type_id' => $cuttingType->id,
                'name' => 'Straight cut',
                'slug' => 'straight-cut',
                'description' => 'Standard straight cutting',
                'price_adjustment' => 0.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 2,
            ],
            [
                'feature_type_id' => $cuttingType->id,
                'name' => 'Nill',
                'slug' => 'no-cutting',
                'description' => 'No cutting required',
                'price_adjustment' => 0.00,
                'price_adjustment_type' => 'fixed',
                'is_active' => true,
                'sort_order' => 3,
            ],
        ];

        foreach ($featureOptions as $featureOption) {
            FeatureOption::updateOrCreate(
                ['slug' => $featureOption['slug']],
                $featureOption
            );
        }
    }
}
