@extends('admin.ad_master')

@section('title', $title)
@section('ad_page_title', 'Edit Contact 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">Contact Us Page</h1>
            <p class="text-muted mb-0">Edit the contact page header, strip, map, and inquiry form labels.</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.contact-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">Page header</div></div>
                                <div class="col-lg-4">
                                    <label class="form-label">Kicker</label>
                                    <input class="form-control" name="en[page][kicker]" value="{{ old('en.page.kicker', data_get($contentEn, 'page.kicker')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Heading</label>
                                    <input class="form-control" name="en[page][heading]" value="{{ old('en.page.heading', data_get($contentEn, 'page.heading')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Description</label>
                                    <textarea class="form-control" rows="2" name="en[page][description]">{{ old('en.page.description', data_get($contentEn, 'page.description')) }}</textarea>
                                </div>
                                @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-lg-4">
                                    <label class="form-label">Kicker</label>
                                    <input class="form-control" name="ar[page][kicker]" value="{{ old('ar.page.kicker', data_get($contentAr, 'page.kicker')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Heading</label>
                                    <input class="form-control" name="ar[page][heading]" value="{{ old('ar.page.heading', data_get($contentAr, 'page.heading')) }}">
                                </div>
                                <div class="col-lg-4">
                                    <label class="form-label">Description</label>
                                    <textarea class="form-control" rows="2" name="ar[page][description]">{{ old('ar.page.description', data_get($contentAr, 'page.description')) }}</textarea>
                                </div>
                                @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
