@extends('layouts.app')
@section('title', __('vetSite::lang.domain_seo'))

@section('content')
<section class="content-header">
    <h1><i class="fas fa-link"></i> {{ __('vetSite::lang.domain_seo') }}
        <small>How visitors reach your website</small></h1>
</section>

<section class="content">
    @include('vetSite::admin._flash')
    <div class="row">
        <div class="col-md-8">
            @component('components.widget', ['title' => 'Web address', 'class' => 'box-primary'])
                <form method="POST" action="{{ route('vs.domain.save') }}">@csrf
                    <div class="form-group">
                        <label>Subdomain</label>
                        <div class="input-group">
                            <input type="text" name="subdomain_slug" class="form-control" value="{{ $site->subdomain_slug }}" placeholder="happy-paws">
                            <span class="input-group-addon">.{{ $baseDomain ?: 'yourdomain.com' }}</span>
                        </div>
                        @if($baseDomain && $site->subdomain_slug)
                            <small class="text-success">Live at
                                <a href="//{{ $site->subdomain_slug }}.{{ $baseDomain }}" target="_blank">{{ $site->subdomain_slug }}.{{ $baseDomain }}</a></small>
                        @elseif(!$baseDomain)
                            <small class="text-muted">Set <code>VETSITE_BASE_DOMAIN</code> in your environment to enable subdomains.</small>
                        @endif
                    </div>

                    <hr>
                    <div class="form-group">
                        <label>Custom domain</label>
                        <input type="text" name="custom_domain" class="form-control" value="{{ $site->custom_domain }}" placeholder="www.yourclinic.com">
                        @if($site->custom_domain)
                            <small class="{{ $site->custom_domain_verified ? 'text-success' : 'text-warning' }}">
                                <i class="fa {{ $site->custom_domain_verified ? 'fa-check-circle' : 'fa-clock' }}"></i>
                                {{ $site->custom_domain_verified ? 'Verified & live.' : 'Awaiting DNS — point your domain to this server (see below).' }}
                            </small>
                        @endif
                    </div>
                    <button class="btn btn-primary"><i class="fa fa-save"></i> Save web address</button>
                </form>
            @endcomponent
        </div>

        <div class="col-md-4">
            @component('components.widget', ['title' => 'Point your domain (DNS)'])
                <p class="text-muted" style="font-size:13px;">To use a custom domain, create a DNS record at your registrar:</p>
                <table class="table table-condensed" style="font-size:12px;">
                    <tr><th>Type</th><th>Name</th><th>Value</th></tr>
                    <tr><td>CNAME</td><td>www</td><td>{{ parse_url(config('app.url'), PHP_URL_HOST) ?: 'app.yourdomain.com' }}</td></tr>
                    <tr><td>A</td><td>@</td><td>your server IP</td></tr>
                </table>
                <p class="text-muted" style="font-size:12px;">DNS changes can take up to 24 hours. Once it resolves here, the site goes live automatically.</p>
            @endcomponent
        </div>
    </div>
</section>
@endsection
