<div class="row justify-content-center"><div class="col-lg-9"><div class="card">
    <div class="card-header"><h5 class="mb-0"><i class="fas fa-bullhorn me-2"></i><?= lang('comm.create_bulk') ?></h5></div>
    <div class="card-body">
        <form method="POST" action="/communications/bulk" data-ajax="true">
            <?= csrf_field() ?>
            <div class="row g-3">
                <div class="col-md-6">
                    <label class="form-label">Campaign Name <span class="text-danger">*</span></label>
                    <input type="text" name="campaign_name" class="form-control" required>
                    <div class="invalid-feedback" data-field="campaign_name"></div>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Channel <span class="text-danger">*</span></label>
                    <select name="channel_id" class="form-select" required>
                        <option value="">-- Select --</option>
                        <?php foreach ($channels as $ch): ?>
                        <option value="<?= $ch['id'] ?>"><?= e($ch['name_en']) ?></option>
                        <?php endforeach; ?>
                    </select>
                    <div class="invalid-feedback" data-field="channel_id"></div>
                </div>
                <div class="col-md-3">
                    <label class="form-label">Template</label>
                    <select name="template_id" class="form-select">
                        <option value="">-- None --</option>
                        <?php foreach ($templates as $t): ?>
                        <option value="<?= $t['id'] ?>"><?= e($t['name_en']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div class="mt-3">
                <label class="form-label">Target Membership Types</label>
                <select name="target_membership_types[]" class="form-select select2" multiple>
                    <?php foreach ($memTypes as $mt): ?>
                    <option value="<?= $mt['id'] ?>"><?= e($mt['name_en']) ?></option>
                    <?php endforeach; ?>
                </select>
                <small class="text-muted">Leave empty to target all active members</small>
            </div>
            <div class="mt-3">
                <label class="form-label">Subject</label>
                <input type="text" name="subject" class="form-control">
            </div>
            <div class="mt-3">
                <label class="form-label">Message Body <span class="text-danger">*</span></label>
                <textarea name="body" class="form-control" rows="8" required placeholder="Type your message here..."></textarea>
                <div class="invalid-feedback" data-field="body"></div>
            </div>
            <div class="row g-3 mt-1">
                <div class="col-md-4">
                    <label class="form-label">Schedule At</label>
                    <input type="text" name="scheduled_at" class="form-control datetimepicker" placeholder="Leave empty to send immediately">
                </div>
                <div class="col-md-4">
                    <label class="form-label">Status</label>
                    <select name="status" class="form-select">
                        <option value="draft">Draft (save only)</option>
                        <option value="scheduled">Scheduled</option>
                    </select>
                </div>
            </div>
            <div class="mt-4 d-flex gap-2">
                <button type="submit" class="btn btn-primary"><i class="fas fa-save me-1"></i>Create Campaign</button>
                <a href="/communications/bulk" class="btn btn-secondary"><?= lang('common.cancel') ?></a>
            </div>
        </form>
    </div>
</div></div></div>