<div class="form-group">
	<label for="name" class="col-sm-3 control-label">Name:</label>
	<div class="col-sm-9">
		<input type="text" name="name" value="{{ old('name', $email->name ?? '') }}" class="form-control">
	</div>
</div>
<div class="form-group">
	<label for="email" class="col-sm-3 control-label label-required">Email:</label>
	<div class="col-sm-9">
		<input type="email" name="email" value="{{ old('email', $email->email ?? '') }}" class="form-control" required>
	</div>
</div>
<div class="form-group">
	<label for="server" class="col-sm-3 control-label label-required">Server:</label>
	<div class="col-sm-9">
		<input type="text" name="server" value="{{ old('server', $email->server ?? '') }}" class="form-control" placeholder="IP Address or Hostname" required>
	</div>
</div>
<div class="form-group">
	<label for="port" class="col-sm-3 control-label label-required">Port:</label>
	<div class="col-sm-9">
		<input type="text" name="port" value="{{ old('port', $email->port ?? '') }}" class="form-control" placeholder="Default: 143" required>
	</div>
</div>
<div class="form-group">
	<label for="protocol" class="col-sm-3 control-label label-required">Protocol:</label>
	<div class="col-sm-9">
		<select name="protocol" class="form-control" required>
			<option value="">Select Protocol</option>
			@foreach(App\Modules\Admin\EmailSettings::getProtocols() as $value => $label)
				<option value="{{ $value }}" {{ old('protocol', $email->protocol ?? '') == $value ? 'selected' : '' }}>{{ $label }}</option>
			@endforeach
		</select>
	</div>
</div>
<div class="form-group">
	<label for="username" class="col-sm-3 control-label label-required">Username:</label>
	<div class="col-sm-9">
		<input type="text" name="username" value="{{ old('username', $email->username ?? '') }}" class="form-control" required>
	</div>
</div>
<div class="form-group">
	<label for="password" class="col-sm-3 control-label label-required">Password:</label>
	<div class="col-sm-9">
		<input type="password" name="password" value="{{ old('password', $email->password ?? '') }}" class="form-control" required>
	</div>
</div>
<div class="form-group">
	<label for="booking_type" class="col-sm-3 control-label label-required">Book emails as:</label>
	<div class="col-sm-9">
		<select name="booking_type" class="form-control" required>
			<option value="">Select Booking Type</option>
			@foreach(App\Modules\Admin\EmailSettings::getTypes() as $value => $label)
				<option value="{{ $value }}" {{ old('booking_type', $email->booking_type ?? '') == $value ? 'selected' : '' }}>{{ $label }}</option>
			@endforeach
		</select>
	</div>
</div>

<div class="form-group">
	<div class="col-sm-offset-3 col-sm-9">
		<button type="button" id="test-imap-btn" class="btn btn-info">
			<i class="fa fa-download"></i> Test IMAP Connection
		</button>
		<span id="imap-test-result" class="help-block" style="margin-top: 5px; display: none;"></span>
	</div>
</div>

<hr style="margin: 30px 0;">
<h4 style="margin-bottom: 20px; color: #333;">SMTP Configuration (Outbound Emails)</h4>
<p class="text-muted" style="margin-bottom: 20px;">Configure SMTP settings for sending confirmation emails. Leave blank to use system defaults.</p>

<div class="form-group">
	<label for="smtp_host" class="col-sm-3 control-label">SMTP Host:</label>
	<div class="col-sm-9">
		<input type="text" name="smtp_host" value="{{ old('smtp_host', $email->smtp_host ?? '') }}" class="form-control" placeholder="smtp.gmail.com">
		<small class="text-muted">SMTP server hostname or IP address</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_port" class="col-sm-3 control-label">SMTP Port:</label>
	<div class="col-sm-9">
		<input type="number" name="smtp_port" value="{{ old('smtp_port', $email->smtp_port ?? '587') }}" class="form-control" placeholder="587">
		<small class="text-muted">Common ports: 587 (TLS), 465 (SSL), 25 (Non-encrypted)</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_encryption" class="col-sm-3 control-label">SMTP Encryption:</label>
	<div class="col-sm-9">
		<select name="smtp_encryption" class="form-control">
			@foreach(App\Modules\Admin\EmailSettings::getSmtpEncryptions() as $value => $label)
				<option value="{{ $value }}" {{ old('smtp_encryption', $email->smtp_encryption ?? 'tls') == $value ? 'selected' : '' }}>{{ $label }}</option>
			@endforeach
		</select>
	</div>
</div>

<div class="form-group">
	<label for="smtp_username" class="col-sm-3 control-label">SMTP Username:</label>
	<div class="col-sm-9">
		<input type="text" name="smtp_username" value="{{ old('smtp_username', $email->smtp_username ?? '') }}" class="form-control" placeholder="Usually your email address">
	</div>
</div>

<div class="form-group">
	<label for="smtp_password" class="col-sm-3 control-label">SMTP Password:</label>
	<div class="col-sm-9">
		<input type="password" name="smtp_password" value="{{ old('smtp_password', $email->smtp_password ?? '') }}" class="form-control" placeholder="Leave blank to keep existing password">
		<small class="text-muted">For Gmail, use an App Password instead of your regular password</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_from_name" class="col-sm-3 control-label">From Name:</label>
	<div class="col-sm-9">
		<input type="text" name="smtp_from_name" value="{{ old('smtp_from_name', $email->smtp_from_name ?? '') }}" class="form-control" placeholder="Support Team">
		<small class="text-muted">Display name for outgoing emails</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_from_address" class="col-sm-3 control-label">From Address:</label>
	<div class="col-sm-9">
		<input type="email" name="smtp_from_address" value="{{ old('smtp_from_address', $email->smtp_from_address ?? '') }}" class="form-control" placeholder="support@company.com">
		<small class="text-muted">Email address that will appear as the sender for all system emails</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_cc" class="col-sm-3 control-label">CC (Carbon Copy):</label>
	<div class="col-sm-9">
		<input type="text" name="smtp_cc" value="{{ old('smtp_cc', $email->smtp_cc ?? '') }}" class="form-control" placeholder="manager@company.com, admin@company.com">
		<small class="text-muted">Email addresses to CC on all outgoing emails (comma-separated)</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_bcc" class="col-sm-3 control-label">BCC (Blind Carbon Copy):</label>
	<div class="col-sm-9">
		<input type="text" name="smtp_bcc" value="{{ old('smtp_bcc', $email->smtp_bcc ?? '') }}" class="form-control" placeholder="archive@company.com, backup@company.com">
		<small class="text-muted">Email addresses to BCC on all outgoing emails (comma-separated)</small>
	</div>
</div>

<div class="form-group">
	<label for="smtp_test_to" class="col-sm-3 control-label">Test To Address:</label>
	<div class="col-sm-9">
		<input type="email" name="smtp_test_to" value="{{ old('smtp_test_to') }}" class="form-control" placeholder="test@company.com">
		<small class="text-muted">Test email address - this is just for test SMTP connect (not saved)</small>
	</div>
</div>

<div class="form-group">
	<div class="col-sm-offset-3 col-sm-9">
		<button type="button" id="test-smtp-btn" class="btn btn-warning">
			<i class="fa fa-send"></i> Test SMTP Connection
		</button>
		<span id="smtp-test-result" class="help-block" style="margin-top: 5px; display: none;"></span>
		<small class="text-muted">This will send a test email to the configured email address</small>
	</div>
</div>