@extends('admin.layouts.app')

@section('title', 'Contact Page Management')

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h1 class="h3 mb-0">Contact Page Management</h1>
                <a href="{{ route('admin.contact.edit') }}" class="btn btn-primary">
                    <i class="bi bi-pencil"></i> Edit Contact Page
                </a>
            </div>
        </div>
    </div>

    <!-- Contact Sections Overview -->
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title mb-0">Contact Page Sections</h5>
                </div>
                <div class="card-body">
                    @if($contactSections->count() > 0)
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>Section</th>
                                        <th>Title</th>
                                        <th>Status</th>
                                        <th>Last Updated</th>
                                        <th>Actions</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($contactSections as $section)
                                        <tr>
                                            <td>
                                                <span class="badge bg-info">{{ ucfirst(str_replace('_', ' ', $section->section_key)) }}</span>
                                            </td>
                                            <td>{{ $section->title ?? 'No title set' }}</td>
                                            <td>
                                                @if($section->is_active)
                                                    <span class="badge bg-success">Active</span>
                                                @else
                                                    <span class="badge bg-secondary">Inactive</span>
                                                @endif
                                            </td>
                                            <td>{{ $section->updated_at->format('M d, Y H:i') }}</td>
                                            <td>
                                                <a href="{{ route('admin.contact.edit') }}" class="btn btn-sm btn-outline-primary">
                                                    <i class="bi bi-pencil"></i> Edit
                                                </a>
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    @else
                        <div class="text-center py-4">
                            <i class="bi bi-inbox display-4 text-muted"></i>
                            <h5 class="mt-3 text-muted">No contact sections found</h5>
                            <p class="text-muted">Start by creating your first contact section.</p>
                            <a href="{{ route('admin.contact.edit') }}" class="btn btn-primary">
                                <i class="bi bi-plus"></i> Create Contact Sections
                            </a>
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Stats -->
    <div class="row mt-4">
        <div class="col-md-4">
            <div class="card bg-primary text-white">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <h4 class="card-title">{{ $contactSections->where('section_key', 'hero')->count() }}</h4>
                            <p class="card-text">Hero Section</p>
                        </div>
                        <div class="align-self-center">
                            <i class="bi bi-star fs-2"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card bg-success text-white">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <h4 class="card-title">{{ $contactSections->where('section_key', 'offices')->count() }}</h4>
                            <p class="card-text">Offices Section</p>
                        </div>
                        <div class="align-self-center">
                            <i class="bi bi-building fs-2"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card bg-info text-white">
                <div class="card-body">
                    <div class="d-flex justify-content-between">
                        <div>
                            <h4 class="card-title">{{ $contactSections->where('section_key', 'quick_contact')->count() }}</h4>
                            <p class="card-text">Quick Contact</p>
                        </div>
                        <div class="align-self-center">
                            <i class="bi bi-telephone fs-2"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection