@extends('admin.ad_master')

@section('title', $title)
@section('ad_page_title', 'Home Page')
@section('ad_page_subtitle', 'Manage home page content in English and Arabic')

@section('ad_content')
@php
    $currentTab = $tab ?? request('tab', 'hero');

    $tabs = [
        'hero' => 'Hero Setting',
        'slider' => 'Slider Setting',
        'service_type' => 'Service Type',
        'how_it_works' => 'How It Works',
        'swift_process' => 'Swift Process',
        'nationalities' => 'Nationalities',
        'about' => 'About Us',
        'testimonials' => 'Testimonials',
        'faqs' => 'FAQs',
        'contact' => 'Contact Us Setting',
        'content' => 'Content',
        'seo' => 'SEO',
    ];
@endphp

<div class="container-fluid py-4">
    <div class="card shadow-sm border-0">
        <div class="card-body p-4">
            <div class="d-flex flex-wrap gap-2 mb-4">
                @foreach($tabs as $tabKey => $tabLabel)
                    <a href="{{ route('admin.home.edit', ['tab' => $tabKey]) }}" class="btn {{ $currentTab === $tabKey ? 'btn-primary' : 'btn-outline-primary' }}">
                        {{ $tabLabel }}
                    </a>
                @endforeach
            </div>

            <form action="{{ route('admin.home.update', ['tab' => $currentTab]) }}" method="POST" enctype="multipart/form-data">
                @csrf
                @method('PUT')

                @if($currentTab === 'hero')
                    @include('admin.home.partials.hero')
                @elseif($currentTab === 'slider')
                    @include('admin.home.partials.slider')
                @elseif($currentTab === 'service_type')
                    @include('admin.home.partials.section', ['sectionKey' => 'service_type', 'sectionTitle' => 'Service Type', 'section' => $serviceType])
                @elseif($currentTab === 'how_it_works')
                    @include('admin.home.partials.section', ['sectionKey' => 'how_it_works', 'sectionTitle' => 'How It Works', 'section' => $howItWorks])
                @elseif($currentTab === 'swift_process')
                    @include('admin.home.partials.section', ['sectionKey' => 'swift_process', 'sectionTitle' => 'Swift Process', 'section' => $swiftProcess])
                @elseif($currentTab === 'nationalities')
                    @include('admin.home.partials.section', ['sectionKey' => 'nationalities', 'sectionTitle' => 'Nationalities', 'section' => $nationalities])
                @elseif($currentTab === 'about')
                    @include('admin.home.partials.section', ['sectionKey' => 'about', 'sectionTitle' => 'About Us', 'section' => $aboutSection])
                @elseif($currentTab === 'testimonials')
                    @include('admin.home.partials.section', ['sectionKey' => 'testimonials', 'sectionTitle' => 'Testimonials', 'section' => $testimonials])
                @elseif($currentTab === 'faqs')
                    @include('admin.home.partials.section', ['sectionKey' => 'faqs', 'sectionTitle' => 'FAQs', 'section' => $faqs])
                @elseif($currentTab === 'contact')
                    @include('admin.home.partials.section', ['sectionKey' => 'contact', 'sectionTitle' => 'Contact Us Setting', 'section' => $contactSection])
                @elseif($currentTab === 'content')
                    @include('admin.home.partials.section', ['sectionKey' => 'content', 'sectionTitle' => 'Content', 'section' => $contentSection])
                @elseif($currentTab === 'seo')
                    @include('admin.home.partials.seo')
                @endif

                <div class="d-flex justify-content-end mt-4">
                    <button type="submit" class="btn btn-primary px-4">Save Changes</button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection