<x-admin-layout title="Help & Support">
    <div class="row g-4">
        <div class="col-lg-7">
            <div class="card">
                <div class="card-body">
                    <h5 class="fw-bold mb-3">Frequently Asked Questions</h5>

                    <div class="accordion" id="faqAccordion">
                        @php
                            $faqs = [
                                ['q' => 'How does the company code login work?', 'a' => 'Every company has its own login code, set under Organization → Companies. Your staff enter that code plus their username and password on the login screen — it keeps every company\'s data completely separate. Code 123 is reserved for the platform Super Admin.'],
                                ['q' => 'How do I book multiple vehicles on one trip?', 'a' => 'On the booking form, add a quantity next to each vehicle type you need (e.g. 2 Saloons + 1 Estate). A driver can only be pre-assigned when booking a single vehicle — with more than one, each car gets dispatched separately from the jobs table.'],
                                ['q' => 'Why can\'t I assign a driver to a second vehicle?', 'a' => 'Each driver can only hold one vehicle at a time — this is enforced automatically. Unassign the vehicle from their current one first if you need to move them.'],
                                ['q' => 'How do driver payouts work?', 'a' => 'Every completed job accrues to a driver\'s outstanding balance at their commission rate (set per-driver, or a company-wide default under Companies). Click "Generate Payouts" under Drivers → Payouts to create one payout per driver covering everything owed, then mark it Paid once you\'ve actually transferred the money.'],
                                ['q' => 'Where do customer/driver ratings show up?', 'a' => 'Both sides rate each other after a completed trip from their mobile app. The driver\'s average rating and count appear on the Driver List and on their profile page.'],
                                ['q' => 'Can I export my booking data?', 'a' => 'Yes — on the Reports page, choose a date range (including a custom one) and click Export CSV.'],
                                ['q' => 'What happens when a company\'s subscription expires?', 'a' => 'A company\'s Valid Until date (set under Companies) is checked daily. Admins get a warning 7 and 1 days before expiry, and access is automatically suspended the day after it passes — reactivate by updating Valid Until and Active on the company record.'],
                            ];
                        @endphp

                        @foreach ($faqs as $i => $faq)
                            <div class="accordion-item">
                                <h2 class="accordion-header">
                                    <button class="accordion-button {{ $i === 0 ? '' : 'collapsed' }}" type="button"
                                            data-bs-toggle="collapse" data-bs-target="#faq{{ $i }}">
                                        {{ $faq['q'] }}
                                    </button>
                                </h2>
                                <div id="faq{{ $i }}" class="accordion-collapse collapse {{ $i === 0 ? 'show' : '' }}" data-bs-parent="#faqAccordion">
                                    <div class="accordion-body text-muted">{{ $faq['a'] }}</div>
                                </div>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-5">
            <div class="card">
                <div class="card-body">
                    <h5 class="fw-bold mb-1">Still stuck?</h5>
                    <p class="text-muted small mb-3">Send us a message and we'll get back to you.</p>

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

                    <form method="POST" action="{{ route('admin.help.submit-ticket') }}">
                        @csrf
                        <div class="mb-3">
                            <label for="subject" class="form-label fw-semibold">Subject</label>
                            <input id="subject" name="subject" type="text" value="{{ old('subject') }}" required
                                   class="form-control @error('subject') is-invalid @enderror">
                            @error('subject')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>
                        <div class="mb-3">
                            <label for="message" class="form-label fw-semibold">Message</label>
                            <textarea id="message" name="message" rows="6" required
                                      class="form-control @error('message') is-invalid @enderror">{{ old('message') }}</textarea>
                            @error('message')<div class="invalid-feedback">{{ $message }}</div>@enderror
                        </div>
                        <button type="submit" class="btn btn-dark">Send Message</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</x-admin-layout>
