@php($d = $d ?? [])
@php($c = (array) ($site->contact ?? []))
@php($showForm = ($d['show_form'] ?? '1') !== '0')
<section class="vs-section vs-contact" id="contact">
    <div class="vs-container">
        <div class="vs-head" data-aos="fade-up">
            <h2 class="vs-h2">{{ $d['heading'] ?? 'Get in touch' }}</h2>
            @if(!empty($d['subheading']))<p class="vs-lead">{{ $d['subheading'] }}</p>@endif
        </div>

        <div class="vs-contact-grid">
            <div class="vs-contact-info" data-aos="fade-right">
                @if(!empty($c['address']))
                    <div class="vs-contact-row"><i class="fas fa-location-dot"></i><span>{{ $c['address'] }}</span></div>
                @endif
                @if(!empty($c['phone']))
                    <div class="vs-contact-row"><i class="fas fa-phone"></i>
                        <a href="tel:{{ preg_replace('/[^0-9+]/','',$c['phone']) }}">{{ $c['phone'] }}</a></div>
                @endif
                @if(!empty($c['email']))
                    <div class="vs-contact-row"><i class="fas fa-envelope"></i>
                        <a href="mailto:{{ $c['email'] }}">{{ $c['email'] }}</a></div>
                @endif
                @if(!empty($c['whatsapp']))
                    <div class="vs-contact-row"><i class="fab fa-whatsapp"></i>
                        <a href="https://wa.me/{{ preg_replace('/[^0-9]/','',$c['whatsapp']) }}" target="_blank" rel="noopener">{{ $c['whatsapp'] }}</a></div>
                @endif

                @if(!empty($d['map_embed']))
                    <div class="vs-map"><iframe src="{{ $d['map_embed'] }}" loading="lazy" referrerpolicy="no-referrer-when-downgrade" allowfullscreen></iframe></div>
                @endif
            </div>

            @if($showForm)
            <div class="vs-contact-form" data-aos="fade-left">
                @if(!empty($sent))
                    <div class="vs-alert vs-alert-ok"><i class="fas fa-check-circle"></i> Thank you! Your message has been sent.</div>
                @endif
                <form method="POST" action="/contact">
                    <input type="hidden" name="return" value="{{ ltrim(request()->path(), '/') === '/' ? '' : ltrim(request()->path(), '/') }}">
                    {{-- honeypot: hidden from humans --}}
                    <div style="position:absolute;left:-9999px" aria-hidden="true">
                        <label>Company<input type="text" name="company" tabindex="-1" autocomplete="off"></label>
                    </div>
                    <div class="vs-field-row">
                        <div class="vs-field"><label>Name *</label><input type="text" name="name" required></div>
                        <div class="vs-field"><label>Phone</label><input type="text" name="phone"></div>
                    </div>
                    <div class="vs-field"><label>Email</label><input type="email" name="email"></div>
                    <div class="vs-field"><label>Subject</label><input type="text" name="subject"></div>
                    <div class="vs-field"><label>Message</label><textarea name="message" rows="4"></textarea></div>
                    <button type="submit" class="vs-btn vs-btn-primary"><i class="fas fa-paper-plane"></i> Send message</button>
                </form>
            </div>
            @endif
        </div>
    </div>
</section>
