<?php $__env->startSection('title', 'Campus application'); ?>

<?php $__env->startSection('content'); ?>
<div class="pg-head">
    <div>
        <h1><?php echo e($application->reference_no); ?></h1>
        <p><?php echo e($application->institution); ?> - <?php echo e($application->event_name); ?></p>
    </div>
    <a href="<?php echo e(route('mexco.super.campus')); ?>" class="btn-outline">← All applications</a>
</div>

<?php if(session('organiser_password')): ?>
    <div class="alert-flash alert-success">
        Organiser login: <strong><?php echo e($application->contact_email); ?></strong> /
        password <span class="mono"><?php echo e(session('organiser_password')); ?></span>
        Share securely with the applicant.
    </div>
<?php endif; ?>

<div class="stat-row" style="grid-template-columns:repeat(3,1fr)">
    <div class="card stat-card">
        <div class="stat-label">Status</div>
        <div class="stat-num" style="font-size:1.1rem"><?php echo e($application->statusLabel()); ?></div>
    </div>
    <div class="card stat-card">
        <div class="stat-label">In-kind sponsorship</div>
        <div class="stat-num" style="font-size:1.1rem"><?php echo e($application->formattedSponsorshipValue()); ?></div>
    </div>
    <div class="card stat-card">
        <div class="stat-label">Linked event</div>
        <div class="stat-num" style="font-size:1rem;font-family:ui-monospace,monospace">
            <?php echo e($application->event_id ?? '-'); ?>

        </div>
    </div>
</div>

<div style="display:grid;grid-template-columns:1.2fr .8fr;gap:1rem;align-items:start">
    <div class="card form-panel">
        <h2>Application details</h2>
        <p class="panel-lead">Submitted <?php echo e($application->created_at->format('d M Y, H:i')); ?></p>
        <dl style="display:grid;grid-template-columns:140px 1fr;gap:.65rem 1rem;margin:0;font-size:.875rem">
            <dt style="color:var(--muted);font-weight:600">Institution</dt><dd style="margin:0"><?php echo e($application->institution); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Faculty</dt><dd style="margin:0"><?php echo e($application->faculty ?: '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Student org</dt><dd style="margin:0"><?php echo e($application->student_organisation ?: '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Event date</dt><dd style="margin:0"><?php echo e($application->event_date?->format('d M Y') ?? '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Expected size</dt>
            <dd style="margin:0">
                <?php echo e($application->expected_participants ?? '-'); ?> participants,
                <?php echo e($application->sessions_count ?? '-'); ?> sessions,
                <?php echo e($application->booths_count ?? '-'); ?> booths
            </dd>
            <dt style="color:var(--muted);font-weight:600">Contact</dt>
            <dd style="margin:0"><?php echo e($application->contact_person); ?> &lt;<?php echo e($application->contact_email); ?>&gt;</dd>
            <dt style="color:var(--muted);font-weight:600">Objective</dt><dd style="margin:0"><?php echo e($application->event_objective ?: '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Requested</dt><dd style="margin:0"><?php echo e($application->requested_sponsorship ?: '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Exposure</dt><dd style="margin:0"><?php echo e($application->promotional_exposure ?: '-'); ?></dd>
            <dt style="color:var(--muted);font-weight:600">Sponsorship letter</dt>
            <dd style="margin:0">
                <?php if($application->hasSponsorshipLetter()): ?>
                    <a href="<?php echo e(route('mexco.super.campus.letter', $application)); ?>" class="btn-outline btn-sm">Download <?php echo e($application->sponsorship_letter_name ?: 'letter'); ?></a>
                <?php else: ?>
                    -
                <?php endif; ?>
            </dd>
            <?php if($application->review_notes): ?>
                <dt style="color:var(--muted);font-weight:600">Review notes</dt><dd style="margin:0"><?php echo e($application->review_notes); ?></dd>
            <?php endif; ?>
        </dl>

        <?php if($application->event): ?>
            <hr style="margin:1.25rem 0;border-color:var(--border)">
            <h2 style="font-size:.95rem">Event &amp; retention</h2>
            <p class="panel-lead">
                Plan: <?php echo e($application->license?->plan?->name ?? 'CAMPUS'); ?> ·
                Availability: <?php echo e(app(\App\Services\MeetupService::class)->eventAvailability($application->event)); ?>

            </p>
            <?php if($application->license?->retention_expires_at): ?>
                <p class="form-hint" style="margin:0">
                    Data deletion scheduled: <strong><?php echo e($application->license->retention_expires_at->format('d M Y, H:i')); ?></strong>
                    (<?php echo e(config('mexco.campus.default_retention_days')); ?>-day retention after event ends)
                </p>
            <?php endif; ?>
            <div class="pg-actions" style="margin-top:1rem">
                <a href="<?php echo e(route('mexco.super.events.edit', $application->event_id)); ?>" class="btn-outline btn-sm">Edit event</a>
            </div>
        <?php endif; ?>
    </div>

    <div style="display:grid;gap:1rem">
        <?php if(in_array($application->status, ['submitted', 'under_review'], true)): ?>
            <?php if($application->status === 'submitted'): ?>
                <div class="card form-panel">
                    <h2>Start review</h2>
                    <p class="panel-lead">Mark as under review before approving or rejecting.</p>
                    <form method="POST" action="<?php echo e(route('mexco.super.campus.review', $application)); ?>">
                        <?php echo csrf_field(); ?>
                        <button type="submit" class="btn-outline">Mark under review</button>
                    </form>
                </div>
            <?php endif; ?>

            <div class="card form-panel">
                <h2>Approve &amp; create event</h2>
                <p class="panel-lead">Creates organisation (if needed), event, CAMPUS license, and organiser access.</p>
                <form method="POST" action="<?php echo e(route('mexco.super.campus.approve', $application)); ?>" class="form-stack">
                    <?php echo csrf_field(); ?>
                    <div class="form-row">
                        <label class="form-label">Organisation (optional)</label>
                        <select name="organisation_id" class="form-input">
                            <option value="">Auto-create from institution</option>
                            <?php $__currentLoopData = $organisations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $org): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($org->id); ?>" <?php if($application->organisation_id == $org->id): echo 'selected'; endif; ?>><?php echo e($org->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="form-row">
                        <label class="form-label">Event ID (optional)</label>
                        <input type="text" name="event_id" class="form-input mono" placeholder="Auto-generated if blank">
                    </div>
                    <div class="form-row">
                        <label class="form-label">Venue</label>
                        <input type="text" name="venue" class="form-input" value="<?php echo e($application->institution); ?>">
                    </div>
                    <div class="form-row">
                        <label class="form-label">Organiser password</label>
                        <input type="text" name="organiser_password" class="form-input" placeholder="Auto-generated if blank">
                    </div>
                    <div class="form-row">
                        <label class="form-label">In-kind value (sen)</label>
                        <input type="number" name="sponsorship_value_cents" class="form-input"
                               value="<?php echo e($application->sponsorship_value_cents ?? config('mexco.campus.default_sponsorship_value_cents')); ?>">
                        <div class="form-hint">Default: PRO plan equivalent (MYR <?php echo e(number_format(config('mexco.campus.default_sponsorship_value_cents') / 100, 0)); ?>)</div>
                    </div>
                    <div class="form-row">
                        <label class="form-label">Review notes</label>
                        <textarea name="review_notes" class="form-input" rows="2"><?php echo e($application->review_notes); ?></textarea>
                    </div>
                    <button type="submit" class="btn-purple">Approve &amp; provision CAMPUS event</button>
                </form>
            </div>

            <div class="card form-panel">
                <h2>Reject</h2>
                <form method="POST" action="<?php echo e(route('mexco.super.campus.reject', $application)); ?>" class="form-stack">
                    <?php echo csrf_field(); ?>
                    <div class="form-row">
                        <label class="form-label">Reason</label>
                        <textarea name="review_notes" class="form-input" rows="3" required></textarea>
                    </div>
                    <button type="submit" class="btn-danger btn-sm">Reject application</button>
                </form>
            </div>
        <?php elseif($application->status === 'retention' && $application->license): ?>
            <div class="card form-panel">
                <h2>Extend retention</h2>
                <p class="panel-lead">Postpone automatic data deletion.</p>
                <form method="POST" action="<?php echo e(route('mexco.super.campus.extend-retention', $application)); ?>" class="d-flex gap-2 align-items-end">
                    <?php echo csrf_field(); ?>
                    <div class="form-row" style="margin:0;flex:1">
                        <label class="form-label">Extra days</label>
                        <input type="number" name="extra_days" class="form-input" value="7" min="1" max="90">
                    </div>
                    <button type="submit" class="btn-outline">Extend</button>
                </form>
            </div>
        <?php endif; ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('super-admin.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\myapp\resources\views/super-admin/campus/show.blade.php ENDPATH**/ ?>