<layout name="layouts/admin" />

<div class="admin-page">
    <div class="page-header">
        <div class="d-flex justify-content-between align-items-center">
            <div>
                <h1>{{ title }}</h1>
                <if condition="{{ subtitle }}">
                    <p class="text-muted">{{ subtitle }}</p>
                </if>
            </div>
            <div>
                <a href="{{ backUrl }}" class="btn btn-secondary">
                    <i class="bi bi-arrow-left"></i> Back to List
                </a>
            </div>
        </div>
    </div>

    <div class="form-container">
        <div class="card">
            <div class="card-header">
                <h5 class="mb-0">{{ formTitle }}</h5>
            </div>
            <div class="card-body">
                <if condition="{{ errors }}">
                    <div class="alert alert-danger">
                        <h6>Please fix the following errors:</h6>
                        <ul class="mb-0">
                            <for var="error" in="errors">
                                <li>{{ error }}</li>
                            </for>
                        </ul>
                    </div>
                </if>

                {{ form }}

                <div class="form-actions mt-4 d-flex gap-2">
                    <button type="submit" form="{{ formId }}" class="btn btn-primary">
                        <i class="bi bi-save"></i> Create {{ resourceName }}
                    </button>
                    <if condition="{{ saveAndContinue }}">
                        <button type="submit" form="{{ formId }}" name="action" value="save-and-continue" class="btn btn-secondary">
                            <i class="bi bi-plus-circle"></i> Save & Create Another
                        </button>
                    </if>
                    <a href="{{ backUrl }}" class="btn btn-outline-secondary">Cancel</a>
                </div>
            </div>
        </div>

        <if condition="{{ helpText }}">
            <div class="card mt-3">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-info-circle"></i> Help</h6>
                </div>
                <div class="card-body">
                    <p class="mb-0">{{ helpText }}</p>
                </div>
            </div>
        </if>
    </div>
</div>
