<app-modal-shell title="Add Goal" (closed)="cancelled.emit()">
    <div class="field">
        <label class="field-label">Category</label>
        <input class="field-input" type="text" [(ngModel)]="form.category"
            placeholder="e.g. Reading, Math, Behavior…" />
    </div>
    <div class="field">
        <label class="field-label">Baseline</label>
        <textarea class="field-input field-textarea" [(ngModel)]="form.baseline"
            placeholder="Enter baseline..."></textarea>
    </div>
    <div class="field">
        <label class="field-label">Goal</label>
        <textarea class="field-input field-textarea" [(ngModel)]="form.description"
            placeholder="Enter goal..."></textarea>
    </div>
    <div class="field">
        <label class="field-label">Target Completion Date</label>
        <input class="field-input" type="date" [(ngModel)]="form.targetCompletionDate" />
    </div>

    @if (errorMessage()) {
    <p class="error">{{ errorMessage() }}</p>
    }

    <div class="modal-actions">
        <button class="btn-secondary" (click)="cancelled.emit()">Cancel</button>
        <button class="btn-primary" (click)="onSubmit()" [disabled]="isSubmitting() || !form.category.trim()">
            {{ isSubmitting() ? 'Saving...' : 'Add Goal' }}
        </button>
    </div>
</app-modal-shell>
