<!-- o = App\Models\Service\Email::class -->
<div class="row">
	<!-- DOMAIN NAME -->
	<div class="col-6">
		<div class="form-group has-validation">
			<label for="domain_name">Email Domain Name</label>
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fas fa-fw fa-globe-asia"></i></span>
				</div>
				<input type="text" class="form-control col-9 text-right @error('email.domain_name') is-invalid @enderror" id="domain_name" name="email[domain_name]" placeholder="Domain Name..." value="{{ old('email.domain_name',$o->domain_name) }}" required>
				<div class="input-group-append">
					<span class="input-group-text">.</span>
				</div>
				<select class="form-control col-3" name="email[tld_id]">
					@foreach(\App\Models\TLD::orderBy('name')->get() as $oo)
						<option value="{{ $oo->id }}" @if($oo->id == old('email.tld_id',$o->tld_id))selected @endif>{{ $oo->name }}</option>
					@endforeach
				</select>

				<span class="invalid-feedback" role="alert">
					@error('email.domain_name')
						{{ $message }}
					@else
						Domain Name is required.
					@enderror
				</span>
			</div>
			<span class="input-helper">Domain Name</span>
		</div>
	</div>

	<!-- EXPIRY -->
	<div class="col-3">
		<div class="form-group has-validation">
			<label for="expire_at">Expiry</label>
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
				</div>
				<input type="date" class="form-control @error('email.expire_at') is-invalid @enderror" id="expire_at" name="email[expire_at]" value="{{ old('email.expire_at',($o->expire_at ? $o->expire_at->format('Y-m-d') : NULL)) }}">
				<span class="invalid-feedback" role="alert">
					@error('email.expire_at')
						{{ $message }}
					@enderror
				</span>
			</div>
			<span class="input-helper">Email Hosting Expires</span>
		</div>
	</div>
</div>

<div class="row">
	<!-- ADMIN URL -->
	<div class="col-9">
		<div class="form-group has-validation">
			<label for="admin_url">Hosting Admin URL</label>
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fab fa-fw fa-safari"></i></span>
				</div>
				<input type="text" class="form-control @error('email.admin_url') is-invalid @enderror" id="admin_url" name="email[admin_url]" placeholder="Admin URL..." value="{{ old('email.admin_url',$o->admin_url) }}">
				<span class="invalid-feedback" role="alert">
					@error('email.admin_url')
						{{ $message }}
					@enderror
				</span>
			</div>
			<span class="input-helper">Admin URL</span>
		</div>
	</div>

	<!-- ACCOUNTS -->
	<div class="col-3">
		<div class="form-group has-validation">
			<label for="accounts">Accounts</label>
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fas fa-fw fa-hashtag"></i></span>
				</div>
				<input type="text" class="form-control @error('email.accounts') is-invalid @enderror" id="accounts" name="email[accounts]" placeholder="Accounts" value="{{ old('email.accounts',$o->accounts) }}">
				<span class="invalid-feedback" role="alert">
					@error('email.accounts')
						{{ $message }}
					@enderror
				</span>
			</div>
			<span class="input-helper"># Accounts</span>
		</div>
	</div>
</div>

<div class="row">
	<!-- ADMIN USER -->
	<div class="col-6">
		<div class="form-group has-validation">
			<label for="admin_user">Admin User</label>
			<div class="input-group flex-nowrap">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
				</div>
				<input type="text" class="form-control @error('email.admin_user') is-invalid @enderror" id="admin_user" name="email[admin_user]" placeholder="Admin USER" value="{{ old('email.admin_user',$o->admin_user) }}">
				<span class="invalid-feedback" role="alert">
					@error('email.admin_user')
						{{ $message }}
					@enderror
				</span>
			</div>
			<span class="input-helper">Admin USER</span>
		</div>
	</div>

	<!-- ADMIN PASS -->
	<div class="col-6">
		<div class="form-group has-validation">
			<label for="admin_pass">Admin Pass</label>
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
				</div>
				<input type="text" class="form-control @error('email.admin_pass') is-invalid @enderror" id="admin_pass" name="email[admin_pass]" value="{{ old('email.admin_pass',$o->admin_pass) }}">
				<span class="invalid-feedback" role="alert">
					@error('email.admin_pass')
						{{ $message }}
					@enderror
				</span>
			</div>
			<span class="input-helper">Admin PASSWORD</span>
		</div>
	</div>
</div>

@section('page-scripts')
	@css(select2)
	@js(select2,autofocus)

	<style>
		.select2-selection.select2-selection--single {
			height: calc(2.25rem + 2px) !important;
		}
		.select2.select2-container.select2-container--default {
			display: flex;
			flex: 1 1 auto;
		}
		.select2.select2-container.select2-container--default .selection {
			width: 100%;
		}
	</style>

	<script type="text/javascript">
		$(document).ready(function() {
			// @todo This is taking up too much width
			//$('#tld_id').select2();
		});
	</script>
@append