@extends('layouts.admin')

@section('title', 'Site Settings')

@section('content')
    <form action="{{ route('admin.settings.update') }}" method="POST" enctype="multipart/form-data">
        @csrf
        @method('PUT')

        <div class="row g-4">
            <div class="col-lg-8">
                <div class="card mb-4">
                    <div class="card-header bg-white"><h6 class="mb-0"><i class="bi bi-building me-2"></i>Company Information</h6></div>
                    <div class="card-body">
                        <div class="row g-3">
                            <div class="col-md-6">
                                <label class="form-label">Company Name</label>
                                <input type="text" name="company_name" class="form-control" value="{{ old('company_name', $settings->company_name) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Address</label>
                                <input type="text" name="address" class="form-control" value="{{ old('address', $settings->address) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Primary Phone</label>
                                <input type="text" name="phone_primary" class="form-control" value="{{ old('phone_primary', $settings->phone_primary) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Secondary Phone</label>
                                <input type="text" name="phone_secondary" class="form-control" value="{{ old('phone_secondary', $settings->phone_secondary) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Primary Email</label>
                                <input type="email" name="email_primary" class="form-control" value="{{ old('email_primary', $settings->email_primary) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Secondary Email</label>
                                <input type="email" name="email_secondary" class="form-control" value="{{ old('email_secondary', $settings->email_secondary) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">WhatsApp</label>
                                <input type="text" name="whatsapp" class="form-control" value="{{ old('whatsapp', $settings->whatsapp) }}">
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Working Hours</label>
                                <input type="text" name="working_hours" class="form-control" value="{{ old('working_hours', $settings->working_hours) }}">
                            </div>
                            <div class="col-12">
                                <label class="form-label">Footer Description</label>
                                <textarea name="footer_description" class="form-control" rows="3">{{ old('footer_description', $settings->footer_description) }}</textarea>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Copyright Text</label>
                                <input type="text" name="copyright" class="form-control" value="{{ old('copyright', $settings->copyright) }}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="card mb-4">
                    <div class="card-header bg-white"><h6 class="mb-0"><i class="bi bi-share me-2"></i>Social Links</h6></div>
                    <div class="card-body">
                        <div class="row g-3">
                            <div class="col-md-6"><label class="form-label">Facebook</label><input type="url" name="facebook" class="form-control" value="{{ old('facebook', $settings->facebook) }}"></div>
                            <div class="col-md-6"><label class="form-label">Instagram</label><input type="url" name="instagram" class="form-control" value="{{ old('instagram', $settings->instagram) }}"></div>
                            <div class="col-md-6"><label class="form-label">LinkedIn</label><input type="url" name="linkedin" class="form-control" value="{{ old('linkedin', $settings->linkedin) }}"></div>
                            <div class="col-md-6"><label class="form-label">YouTube</label><input type="url" name="youtube" class="form-control" value="{{ old('youtube', $settings->youtube) }}"></div>
                            <div class="col-12">
                                <label class="form-label">Google Maps URL</label>
                                <input type="url" name="map_url" class="form-control" value="{{ old('map_url', $settings->map_url) }}">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-lg-4">
                <div class="card mb-4">
                    <div class="card-header bg-white"><h6 class="mb-0"><i class="bi bi-image me-2"></i>Logo & Favicon</h6></div>
                    <div class="card-body">
                        <label class="form-label">Company Logo</label>
                        <input type="file" name="logo" class="form-control">
                        @if($settings->logo)
                            <img src="{{ \App\Services\FileUploadService::url($settings->logo) }}" alt="Logo" class="img-fluid border rounded mt-2 bg-white" style="max-height:80px">
                        @endif
                        <hr>
                        <label class="form-label">Favicon</label>
                        <input type="file" name="favicon" class="form-control">
                        @if($settings->favicon)
                            <img src="{{ \App\Services\FileUploadService::url($settings->favicon) }}" alt="Favicon" class="border rounded mt-2 bg-white" style="height:32px">
                        @endif
                        <hr>
                        <button type="submit" class="btn btn-primary w-100"><i class="bi bi-check-circle me-1"></i> Save Settings</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
@endsection
