<?php $this->load->view('superadmin/layouts/header'); ?>

<!-- Page Header -->
<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <h3 class="mb-1">Add New Portal</h3>
        <p class="text-muted mb-0">Configure a new marketing portal</p>
    </div>
    <a href="<?= base_url('superadmin/portals') ?>" class="btn btn-outline-secondary">
        <i class="bi bi-arrow-left me-2"></i>Back to Portals
    </a>
</div>

<!-- Create Form -->
<div class="row">
    <div class="col-lg-8">
        <div class="table-card">
            <div class="card-header">
                <h5><i class="bi bi-grid-3x3-gap me-2"></i>Portal Information</h5>
            </div>
            <div class="card-body">
                <?php if($this->session->flashdata('error')): ?>
                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                    <i class="bi bi-exclamation-circle me-2"></i><?= $this->session->flashdata('error') ?>
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
                <?php endif; ?>
                
                <form method="POST" action="<?= base_url('superadmin/portals/store') ?>">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Portal Name <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="portal_name" required placeholder="e.g., Auriga Marketing Portal">
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Portal Code <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="portal_code" required placeholder="e.g., auriga" maxlength="50">
                            <small class="text-muted">Unique identifier (lowercase, no spaces)</small>
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label">Portal URL</label>
                        <input type="url" class="form-control" name="portal_url" placeholder="https://example.com">
                    </div>
                    
                    <div class="mb-3">
                        <label class="form-label">Description</label>
                        <textarea class="form-control" name="description" rows="3" placeholder="Brief description of this portal"></textarea>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Database Name</label>
                            <input type="text" class="form-control" name="database_name" placeholder="e.g., ac3_marketing_portal">
                        </div>
                        
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Status</label>
                            <select class="form-select" name="status">
                                <option value="active">Active</option>
                                <option value="inactive">Inactive</option>
                                <option value="maintenance">Maintenance</option>
                            </select>
                        </div>
                    </div>
                    
                    <hr class="my-4">
                    
                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-sa-primary">
                            <i class="bi bi-check-circle me-2"></i>Create Portal
                        </button>
                        <a href="<?= base_url('superadmin/portals') ?>" class="btn btn-outline-secondary">
                            Cancel
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-lg-4">
        <div class="table-card">
            <div class="card-header">
                <h5><i class="bi bi-info-circle me-2"></i>Help</h5>
            </div>
            <div class="card-body">
                <h6>Portal Code</h6>
                <p class="text-muted small">The portal code should be a unique identifier using lowercase letters. Examples: <code>auriga</code>, <code>trump</code>, <code>ascensiontech</code></p>
                
                <h6>Portal URL</h6>
                <p class="text-muted small">Enter the full URL where this portal is hosted, including https://</p>
                
                <h6>Status</h6>
                <ul class="text-muted small">
                    <li><strong>Active:</strong> Portal is fully operational</li>
                    <li><strong>Inactive:</strong> Portal is disabled</li>
                    <li><strong>Maintenance:</strong> Portal is under maintenance</li>
                </ul>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('superadmin/layouts/footer'); ?>
