@extends('admin.ad_master')

@section('title', $title)
@section('ad_page_title', 'Edit About Us Page')
@section('ad_page_subtitle', 'Edit labels/text (EN/AR) + SEO')

@section('ad_content')
    @php
        $contentEn = $contentEn ?? [];
        $contentAr = $contentAr ?? [];
    @endphp

    <div class="container-fluid py-4">
        <div class="mb-4">
            <h1 class="h3 mb-1">About Us Page</h1>
            <p class="text-muted mb-0">Hero, story sections, CTA band, and contact block.</p>
        </div>

        @if (session('success'))
            <div class="alert alert-success" role="alert">{{ session('success') }}</div>
        @endif

        @if ($errors->any())
            <div class="alert alert-danger" role="alert">
                <ul class="mb-0">
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

        <form action="{{ route('admin.pages.about-us.update') }}" method="POST">
            @csrf
            @method('PUT')

            <div class="card shadow-sm border-0">
                <div class="card-body p-4">
                    <ul class="nav nav-tabs mb-4" role="tablist">
                        <li class="nav-item" role="presentation">
                            <button class="nav-link active" type="button" data-bs-toggle="tab" data-bs-target="#tab-en" role="tab">English</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button class="nav-link" type="button" data-bs-toggle="tab" data-bs-target="#tab-ar" role="tab" dir="rtl">Arabic</button>
                        </li>
                    </ul>

                    <div class="tab-content">
                        <div class="tab-pane fade show active" id="tab-en" role="tabpanel">
                            <div class="row g-4">
                                <div class="col-12"><div class="fw-bold mb-2">Hero</div></div>
                                <div class="col-12">
                                    <label class="form-label">Image alt</label>
                                    <input class="form-control" name="en[hero][image_alt]" value="{{ old('en.hero.image_alt', data_get($contentEn, 'hero.image_alt')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Mini bar</label>
                                    <input class="form-control" name="en[hero][mini_bar]" value="{{ old('en.hero.mini_bar', data_get($contentEn, 'hero.mini_bar')) }}">
                                </div>
                                <div class="col-lg-8">
                                    <label class="form-label">H1</label>
                                    <input class="form-control" name="en[hero][h1]" value="{{ old('en.hero.h1', data_get($contentEn, 'hero.h1')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Lead</label>
                                    <textarea class="form-control" rows="2" name="en[hero][lead]">{{ old('en.hero.lead', data_get($contentEn, 'hero.lead')) }}</textarea>
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">Feature line {{ $i + 1 }} (HTML ok)</label>
                                        <textarea class="form-control" rows="2" name="en[hero][features][{{ $i }}]">{{ old('en.hero.features.'.$i, data_get($contentEn, 'hero.features.'.$i)) }}</textarea>
                                    </div>
                                @endfor
                                <div class="col-lg-4">
                                    <label class="form-label">Primary CTA text</label>
                                    <input class="form-control" name="en[hero][primary_cta][text]" value="{{ old('en.hero.primary_cta.text', data_get($contentEn, 'hero.primary_cta.text')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Primary CTA href</label>
                                    <input class="form-control" name="en[hero][primary_cta][href]" value="{{ old('en.hero.primary_cta.href', data_get($contentEn, 'hero.primary_cta.href')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Secondary CTA text</label>
                                    <input class="form-control" name="en[hero][secondary_cta][text]" value="{{ old('en.hero.secondary_cta.text', data_get($contentEn, 'hero.secondary_cta.text')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Secondary CTA href</label>
                                    <input class="form-control" name="en[hero][secondary_cta][href]" value="{{ old('en.hero.secondary_cta.href', data_get($contentEn, 'hero.secondary_cta.href')) }}">
                                </div>

                                <div class="col-12"><hr class="my-2"><div class="fw-bold mb-2">Center intro</div></div>
                                <div class="col-lg-4">
                                    <label class="form-label">Kicker</label>
                                    <input class="form-control" name="en[center][kicker]" value="{{ old('en.center.kicker', data_get($contentEn, 'center.kicker')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">H2</label>
                                    <input class="form-control" name="en[center][h2]" value="{{ old('en.center.h2', data_get($contentEn, 'center.h2')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Lead</label>
                                    <textarea class="form-control" rows="2" name="en[center][lead]">{{ old('en.center.lead', data_get($contentEn, 'center.lead')) }}</textarea>
                                </div>

                                <div class="col-12"><div class="fw-bold mb-2">Cards</div></div>
                                <div class="col-lg-6">
                                    <label class="form-label">Who — title</label>
                                    <input class="form-control" name="en[cards][who_title]" value="{{ old('en.cards.who_title', data_get($contentEn, 'cards.who_title')) }}">
                                </div>
                                <div class="col-lg-6">
                                    <label class="form-label">Who — paragraph 1</label>
                                    <textarea class="form-control" rows="2" name="en[cards][who_p1]">{{ old('en.cards.who_p1', data_get($contentEn, 'cards.who_p1')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Who — paragraph 2</label>
                                    <textarea class="form-control" rows="2" name="en[cards][who_p2]">{{ old('en.cards.who_p2', data_get($contentEn, 'cards.who_p2')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">What — title</label>
                                    <input class="form-control" name="en[cards][what_title]" value="{{ old('en.cards.what_title', data_get($contentEn, 'cards.what_title')) }}">
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">What — item {{ $i + 1 }}</label>
                                        <input class="form-control" name="en[cards][what_items][{{ $i }}]" value="{{ old('en.cards.what_items.'.$i, data_get($contentEn, 'cards.what_items.'.$i)) }}">
                                    </div>
                                @endfor
                                <div class="col-12">
                                    <label class="form-label">Why — title</label>
                                    <input class="form-control" name="en[cards][why_title]" value="{{ old('en.cards.why_title', data_get($contentEn, 'cards.why_title')) }}">
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">Why — item {{ $i + 1 }}</label>
                                        <input class="form-control" name="en[cards][why_items][{{ $i }}]" value="{{ old('en.cards.why_items.'.$i, data_get($contentEn, 'cards.why_items.'.$i)) }}">
                                    </div>
                                @endfor
                                <div class="col-lg-6">
                                    <label class="form-label">Commitment — title</label>
                                    <input class="form-control" name="en[cards][commitment_title]" value="{{ old('en.cards.commitment_title', data_get($contentEn, 'cards.commitment_title')) }}">
                                </div>
                                <div class="col-lg-6">
                                    <label class="form-label">Commitment — p1</label>
                                    <textarea class="form-control" rows="2" name="en[cards][commitment_p1]">{{ old('en.cards.commitment_p1', data_get($contentEn, 'cards.commitment_p1')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Commitment — p2</label>
                                    <textarea class="form-control" rows="2" name="en[cards][commitment_p2]">{{ old('en.cards.commitment_p2', data_get($contentEn, 'cards.commitment_p2')) }}</textarea>
                                </div>

                                <div class="col-12"><hr class="my-2"><div class="fw-bold mb-2">CTA band</div></div>
                                <div class="col-12">
                                    <label class="form-label">H2</label>
                                    <input class="form-control" name="en[cta_band][h2]" value="{{ old('en.cta_band.h2', data_get($contentEn, 'cta_band.h2')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Paragraph</label>
                                    <textarea class="form-control" rows="2" name="en[cta_band][p]">{{ old('en.cta_band.p', data_get($contentEn, 'cta_band.p')) }}</textarea>
                                </div>
                                @for ($i = 0; $i < 3; $i++)
                                    <div class="col-lg-4">
                                        <label class="form-label">Button {{ $i + 1 }} text</label>
                                        <input class="form-control" name="en[cta_band][actions][{{ $i }}][text]" value="{{ old('en.cta_band.actions.'.$i.'.text', data_get($contentEn, 'cta_band.actions.'.$i.'.text')) }}">
                                    </div>
                                    <div class="col-lg-4">
                                        <label class="form-label">Button {{ $i + 1 }} href</label>
                                        <input class="form-control" name="en[cta_band][actions][{{ $i }}][href]" value="{{ old('en.cta_band.actions.'.$i.'.href', data_get($contentEn, 'cta_band.actions.'.$i.'.href')) }}">
                                    </div>
                                @endfor

                                @include('admin.pages._contact-block-fields', ['prefix' => 'en', 'c' => $contentEn])
                            </div>
                        </div>

                        <div class="tab-pane fade" id="tab-ar" role="tabpanel">
                            <div class="row g-4" dir="rtl">
                                <div class="col-12"><div class="fw-bold mb-2">البطل</div></div>
                                <div class="col-12">
                                    <label class="form-label">Image alt</label>
                                    <input class="form-control" name="ar[hero][image_alt]" value="{{ old('ar.hero.image_alt', data_get($contentAr, 'hero.image_alt')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Mini bar</label>
                                    <input class="form-control" name="ar[hero][mini_bar]" value="{{ old('ar.hero.mini_bar', data_get($contentAr, 'hero.mini_bar')) }}">
                                </div>
                                <div class="col-lg-8">
                                    <label class="form-label">H1</label>
                                    <input class="form-control" name="ar[hero][h1]" value="{{ old('ar.hero.h1', data_get($contentAr, 'hero.h1')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Lead</label>
                                    <textarea class="form-control" rows="2" name="ar[hero][lead]">{{ old('ar.hero.lead', data_get($contentAr, 'hero.lead')) }}</textarea>
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">Feature {{ $i + 1 }}</label>
                                        <textarea class="form-control" rows="2" name="ar[hero][features][{{ $i }}]">{{ old('ar.hero.features.'.$i, data_get($contentAr, 'hero.features.'.$i)) }}</textarea>
                                    </div>
                                @endfor
                                <div class="col-lg-4">
                                    <label class="form-label">Primary CTA text</label>
                                    <input class="form-control" name="ar[hero][primary_cta][text]" value="{{ old('ar.hero.primary_cta.text', data_get($contentAr, 'hero.primary_cta.text')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Primary CTA href</label>
                                    <input class="form-control" name="ar[hero][primary_cta][href]" value="{{ old('ar.hero.primary_cta.href', data_get($contentAr, 'hero.primary_cta.href')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Secondary CTA text</label>
                                    <input class="form-control" name="ar[hero][secondary_cta][text]" value="{{ old('ar.hero.secondary_cta.text', data_get($contentAr, 'hero.secondary_cta.text')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Secondary CTA href</label>
                                    <input class="form-control" name="ar[hero][secondary_cta][href]" value="{{ old('ar.hero.secondary_cta.href', data_get($contentAr, 'hero.secondary_cta.href')) }}">
                                </div>

                                <div class="col-12"><hr class="my-2"><div class="fw-bold mb-2">مقدمة المركز</div></div>
                                <div class="col-lg-4">
                                    <label class="form-label">Kicker</label>
                                    <input class="form-control" name="ar[center][kicker]" value="{{ old('ar.center.kicker', data_get($contentAr, 'center.kicker')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">H2</label>
                                    <input class="form-control" name="ar[center][h2]" value="{{ old('ar.center.h2', data_get($contentAr, 'center.h2')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Lead</label>
                                    <textarea class="form-control" rows="2" name="ar[center][lead]">{{ old('ar.center.lead', data_get($contentAr, 'center.lead')) }}</textarea>
                                </div>

                                <div class="col-12"><div class="fw-bold mb-2">البطاقات</div></div>
                                <div class="col-lg-6">
                                    <label class="form-label">من نحن — عنوان</label>
                                    <input class="form-control" name="ar[cards][who_title]" value="{{ old('ar.cards.who_title', data_get($contentAr, 'cards.who_title')) }}">
                                </div>
                                <div class="col-lg-6">
                                    <label class="form-label">من نحن — فقرة 1</label>
                                    <textarea class="form-control" rows="2" name="ar[cards][who_p1]">{{ old('ar.cards.who_p1', data_get($contentAr, 'cards.who_p1')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">من نحن — فقرة 2</label>
                                    <textarea class="form-control" rows="2" name="ar[cards][who_p2]">{{ old('ar.cards.who_p2', data_get($contentAr, 'cards.who_p2')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">ماذا نقدم — عنوان</label>
                                    <input class="form-control" name="ar[cards][what_title]" value="{{ old('ar.cards.what_title', data_get($contentAr, 'cards.what_title')) }}">
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">ماذا نقدم — بند {{ $i + 1 }}</label>
                                        <input class="form-control" name="ar[cards][what_items][{{ $i }}]" value="{{ old('ar.cards.what_items.'.$i, data_get($contentAr, 'cards.what_items.'.$i)) }}">
                                    </div>
                                @endfor
                                <div class="col-12">
                                    <label class="form-label">لماذا نحن — عنوان</label>
                                    <input class="form-control" name="ar[cards][why_title]" value="{{ old('ar.cards.why_title', data_get($contentAr, 'cards.why_title')) }}">
                                </div>
                                @for ($i = 0; $i < 4; $i++)
                                    <div class="col-12">
                                        <label class="form-label">لماذا نحن — بند {{ $i + 1 }}</label>
                                        <input class="form-control" name="ar[cards][why_items][{{ $i }}]" value="{{ old('ar.cards.why_items.'.$i, data_get($contentAr, 'cards.why_items.'.$i)) }}">
                                    </div>
                                @endfor
                                <div class="col-lg-6">
                                    <label class="form-label">Commitment — title</label>
                                    <input class="form-control" name="ar[cards][commitment_title]" value="{{ old('ar.cards.commitment_title', data_get($contentAr, 'cards.commitment_title')) }}">
                                </div>
                                <div class="col-lg-6">
                                    <label class="form-label">Commitment — p1</label>
                                    <textarea class="form-control" rows="2" name="ar[cards][commitment_p1]">{{ old('ar.cards.commitment_p1', data_get($contentAr, 'cards.commitment_p1')) }}</textarea>
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Commitment — p2</label>
                                    <textarea class="form-control" rows="2" name="ar[cards][commitment_p2]">{{ old('ar.cards.commitment_p2', data_get($contentAr, 'cards.commitment_p2')) }}</textarea>
                                </div>

                                <div class="col-12"><hr class="my-2"><div class="fw-bold mb-2">شريط الدعوة</div></div>
                                <div class="col-12">
                                    <label class="form-label">H2</label>
                                    <input class="form-control" name="ar[cta_band][h2]" value="{{ old('ar.cta_band.h2', data_get($contentAr, 'cta_band.h2')) }}">
                                </div>
                                <div class="col-12">
                                    <label class="form-label">Paragraph</label>
                                    <textarea class="form-control" rows="2" name="ar[cta_band][p]">{{ old('ar.cta_band.p', data_get($contentAr, 'cta_band.p')) }}</textarea>
                                </div>
                                @for ($i = 0; $i < 3; $i++)
                                    <div class="col-lg-4">
                                        <label class="form-label">Button {{ $i + 1 }} text</label>
                                        <input class="form-control" name="ar[cta_band][actions][{{ $i }}][text]" value="{{ old('ar.cta_band.actions.'.$i.'.text', data_get($contentAr, 'cta_band.actions.'.$i.'.text')) }}">
                                    </div>
                                    <div class="col-lg-4">
                                        <label class="form-label">Button {{ $i + 1 }} href</label>
                                        <input class="form-control" name="ar[cta_band][actions][{{ $i }}][href]" value="{{ old('ar.cta_band.actions.'.$i.'.href', data_get($contentAr, 'cta_band.actions.'.$i.'.href')) }}">
                                    </div>
                                @endfor

                                @include('admin.pages._contact-block-fields', ['prefix' => 'ar', 'c' => $contentAr])
                            </div>
                        </div>
                    </div>

                    <hr class="my-4">
                    @include('admin.pages._seo-fields', ['seo' => $seo])

                    <div class="d-flex justify-content-end gap-2 mt-4">
                        <a href="{{ route('admin.dashboard') }}" class="btn btn-light border">Cancel</a>
                        <button type="submit" class="btn btn-primary px-4">Save Changes</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
@endsection
