{{define "title"}}Add Mailbox - Email Server{{end}}

{{define "content"}}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="card">
                <div class="card-header"><h4 class="mb-0"><i class="bi bi-mailbox me-2"></i>Add New Mailbox</h4></div>
                <div class="card-body">
                    <form method="POST">
                        <div class="mb-3">
                            <label for="local_part" class="form-label">Email Address</label>
                            <div class="input-group">
                                <input type="text" class="form-control" id="local_part" name="local_part" required placeholder="user"
                                       pattern="[a-zA-Z0-9._%+-]+" title="Letters, numbers, and . _ % + - only">
                                <span class="input-group-text">@</span>
                                <select class="form-select" id="domain_id" name="domain_id" required style="max-width: 260px;">
                                    <option value="">Select a domain...</option>
                                    {{range .domains}}<option value="{{.ID}}">{{.DomainName}}</option>{{end}}
                                </select>
                            </div>
                            <div class="form-text">This is the mailbox's login username — it never changes, even if aliases are added later.</div>
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label">Password</label>
                            <input type="password" class="form-control" id="password" name="password" required minlength="8">
                            <div class="form-text">Used for the self-service account portal only — never for IMAP/SMTP clients. Those use a separate app password (create one after adding this mailbox).</div>
                        </div>
                        <div class="mb-4">
                            <label for="quota_gb" class="form-label">Storage Quota (GB)</label>
                            <input type="number" class="form-control" id="quota_gb" name="quota_gb" min="0.1" step="0.1" placeholder="5">
                            <div class="form-text">Leave blank to use the domain's default quota.</div>
                        </div>
                        <div class="d-flex justify-content-between">
                            <a href="/pymta-manager/mailboxes" class="btn btn-secondary"><i class="bi bi-arrow-left me-2"></i>Back to Mailboxes</a>
                            <button type="submit" class="btn btn-success"><i class="bi bi-mailbox me-2"></i>Add Mailbox</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{{end}}
