<?php include 'views/admin/header.php'; ?>

<div class="container-fluid py-4">
    <div class="row">
        <div class="col-12">
            <div class="card mb-4">
                <div class="card-header pb-0 d-flex justify-content-between align-items-center">
                    <h6>Send Newsletter</h6>
                    <a href="/admin/newsletter" class="btn btn-sm btn-secondary">Back to List</a>
                </div>
                <div class="card-body">
                    <?php if (isset($error)): ?>
                        <div class="alert alert-danger text-white">
                            <?php echo $error; ?>
                        </div>
                    <?php endif; ?>

                    <?php if (isset($success)): ?>
                        <div class="alert alert-success text-white">
                            <?php echo $success; ?>
                        </div>
                    <?php endif; ?>

                    <div class="alert alert-info text-white mb-4">
                        <i class="fas fa-info-circle me-2"></i>
                        This email will be sent to all <strong><?php echo $total_subscribers; ?></strong> subscribers via BCC.
                    </div>

                    <form action="/admin/newsletter/send" method="POST">
                        <div class="form-group mb-3">
                            <label for="subject" class="form-control-label">Subject</label>
                            <input class="form-control" type="text" name="subject" id="subject" required placeholder="Enter newsletter subject">
                        </div>
                        
                        <div class="form-group mb-3">
                            <label for="message" class="form-control-label">Message (HTML supported)</label>
                            <textarea class="form-control" name="message" id="message" rows="10" required placeholder="Write your message here..."></textarea>
                        </div>

                        <div class="text-end">
                            <button type="submit" class="btn btn-primary" onclick="return confirm('Are you sure you want to send this email to all subscribers?')">
                                <i class="fas fa-paper-plane me-2"></i> Send to All Subscribers
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<?php include 'views/admin/footer.php'; ?>