@props(['data' => []])

@php

// Map old props to data array format if needed
$title = $data['title'] ?? "";
$description = $data['description'] ?? "";
$layout = $data['layout'] ?? 'grid';
$icon_style = $data['icon_style'] ?? 'outline';
$icon_color = $data['icon_color'] ?? '#0ea5e9';
$features = $data['features'] ?? [];

$svgIcons = [
    'heroicon-o-shield-check' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />',
    'heroicon-o-clock' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />',
    'heroicon-o-user-group' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />',
    'heroicon-o-home' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />',
    'heroicon-o-currency-dollar' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />',
    'heroicon-o-heart' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />',
    'heroicon-o-beaker' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.384-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z" />',
    'heroicon-o-cube' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />',
    'heroicon-o-star' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />',
    'heroicon-o-trophy' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 14v3m4-3v3m4-3v3M3 21h18M3 10h18M5 6l.75-2.25h12.5L19 6M5 6v12a1 1 0 001 1h12a1 1 0 001-1V6M5 6h14" />',
    'heroicon-o-academic-cap' => '<path d="M12 14l9-5-9-5-9 5 9 5z" /><path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222" />',
    'heroicon-o-clipboard-document-check' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />',
    'heroicon-o-sparkles' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z" />',
    'heroicon-o-truck' => '<path d="M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 01-1 1H9m4-1V8a1 1 0 011-1h2.586a1 1 0 01.707.293l3.414 3.414a1 1 0 01.293.707V16a1 1 0 01-1 1h-1m-6-1a1 1 0 001 1h1M5 17a2 2 0 104 0m-4 0a2 2 0 114-4m6 6a2 2 0 104 0m-4 0a2 2 0 114-4" />',
    'heroicon-o-phone' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />',
    'heroicon-o-envelope' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />',
    'heroicon-o-map-pin' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />',
    'heroicon-o-check-circle' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />',
];
@endphp

<section class="py-20 bg-white">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        {{-- Section Header --}}
        <div class="text-center mb-16">
            <h2 class="text-3xl md:text-4xl font-bold text-gray-900 mb-4">{{ $title }}</h2>
            @if($description)
                <p class="text-lg text-gray-600 max-w-2xl mx-auto">{{ $description }}</p>
            @endif
            <div class="w-24 h-1 bg-theme-primary mx-auto mt-6 rounded-full"></div>
        </div>
        
        {{-- Features Grid --}}
        @if(!empty($features))
            @if($layout === 'grid')
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
                    @foreach($features as $feature)
                        <div class="group p-8 bg-gray-50 rounded-2xl hover:bg-white hover:shadow-xl transition-all duration-300 border border-gray-100 hover:border-primary-200">
                            <div class="w-14 h-14 rounded-xl flex items-center justify-center mb-6 group-hover:scale-110 transition-transform"
                                 style="background-color: color-mix(in srgb, {{ $icon_color }} 10%, white 90%)">
                                @if(($feature['icon_type'] ?? 'library') === 'image' && !empty($feature['icon_image']))
                                    <img src="{{ \Illuminate\Support\Facades\Storage::url($feature['icon_image']) }}" alt="" class="w-8 h-8 object-contain">
                                @elseif(isset($feature['icon']) && isset($svgIcons[$feature['icon']]))
                                    <svg class="w-7 h-7" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        {!! $svgIcons[$feature['icon']] !!}
                                    </svg>
                                @else
                                    <svg class="w-7 h-7" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                                    </svg>
                                @endif
                            </div>
                            <h3 class="text-xl font-bold text-gray-900 mb-3">{{ $data['title'] ?? "" }}</h3>
                            <p class="text-gray-600">{{ $data['description'] ?? "" }}</p>
                        </div>
                    @endforeach
                </div>
            @elseif($layout === 'list')
                <div class="max-w-3xl mx-auto space-y-6">
                    @foreach($features as $feature)
                        <div class="flex items-start p-6 bg-gray-50 rounded-xl hover:bg-white hover:shadow-lg transition-all duration-300">
                            <div class="w-12 h-12 rounded-lg flex items-center justify-center flex-shrink-0 mr-6"
                                 style="background-color: color-mix(in srgb, {{ $icon_color }} 10%, white 90%)">
                                @if(($feature['icon_type'] ?? 'library') === 'image' && !empty($feature['icon_image']))
                                    <img src="{{ \Illuminate\Support\Facades\Storage::url($feature['icon_image']) }}" alt="" class="w-7 h-7 object-contain">
                                @elseif(isset($feature['icon']) && isset($svgIcons[$feature['icon']]))
                                    <svg class="w-6 h-6" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        {!! $svgIcons[$feature['icon']] !!}
                                    </svg>
                                @else
                                    <svg class="w-6 h-6" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                                    </svg>
                                @endif
                            </div>
                            <div>
                                <h3 class="text-lg font-bold text-gray-900 mb-2">{{ $data['title'] ?? "" }}</h3>
                                <p class="text-gray-600">{{ $data['description'] ?? "" }}</p>
                            </div>
                        </div>
                    @endforeach
                </div>
            @elseif($layout === 'cards')
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                    @foreach($features as $feature)
                        <div class="group relative bg-white rounded-2xl shadow-lg hover:shadow-2xl transition-all duration-300 overflow-hidden border border-gray-100">
                            <div class="absolute inset-0 bg-gradient-to-br from-primary-500/5 to-primary-600/10 opacity-0 group-hover:opacity-100 transition-opacity"></div>
                            <div class="relative p-8 text-center">
                                <div class="w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-6 group-hover:scale-110 transition-transform"
                                     style="background-color: color-mix(in srgb, {{ $icon_color }} 10%, white 90%)">
                                    @if(($feature['icon_type'] ?? 'library') === 'image' && !empty($feature['icon_image']))
                                        <img src="{{ \Illuminate\Support\Facades\Storage::url($feature['icon_image']) }}" alt="" class="w-9 h-9 object-contain">
                                    @elseif(isset($feature['icon']) && isset($svgIcons[$feature['icon']]))
                                        <svg class="w-8 h-8" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            {!! $svgIcons[$feature['icon']] !!}
                                        </svg>
                                    @else
                                        <svg class="w-8 h-8" style="color: {{ $icon_color }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                                        </svg>
                                    @endif
                                </div>
                                <h3 class="text-lg font-bold text-gray-900 mb-3">{{ $data['title'] ?? "" }}</h3>
                                <p class="text-gray-600 text-sm">{{ $data['description'] ?? "" }}</p>
                            </div>
                        </div>
                    @endforeach
                </div>
            @endif
        @endif
    </div>
</section>
