<?php $__env->startSection('title', 'My events'); ?>
<?php $__env->startSection('topbar', 'My events'); ?>

<?php $__env->startPush('styles'); ?>
<style>
    .tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.15rem; }
    .tab {
        padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--border);
        background: #fff; font-size: .8rem; font-weight: 700; color: var(--muted);
    }
    .tab.on { background: var(--primary-soft); border-color: #DDD6FE; color: var(--mexco-primary-dark); }
    .event-card {
        display: grid; grid-template-columns: 1.3fr .7fr .8fr .8fr auto; gap: 1rem; align-items: center;
        padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: 12px; background: #fff;
        margin-bottom: .75rem;
    }
    .event-card h3 { margin: 0; font-size: 1rem; font-weight: 800; }
    .meta { margin: .3rem 0 0; font-size: .8rem; color: var(--muted); }
    .usage-track { background: #F1F5F9; border-radius: 99px; height: 6px; overflow: hidden; margin-top: .35rem; }
    .usage-fill { height: 100%; background: var(--mexco-primary); border-radius: 99px; }
    .empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
    @media (max-width: 1100px) { .event-card { grid-template-columns: 1fr; } }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="pg-head">
    <div>
        <h1>My events</h1>
        <p>All event licenses for <?php echo e($organisation?->name); ?>.</p>
    </div>
    <div style="display:flex;gap:.5rem;flex-wrap:wrap">
        <?php if($activeDemo ?? null): ?>
            <a href="<?php echo e(url('/mexco')); ?>" class="btn-outline" target="_blank" rel="noopener">Visitor Pass ↗</a>
            <a href="<?php echo e(route('mexco.admin.login')); ?>" class="btn-purple">Organizer login</a>
        <?php else: ?>
            <a href="<?php echo e(route('mexco.plans')); ?>" class="btn-purple">+ Create event</a>
        <?php endif; ?>
    </div>
</div>

<div class="tabs">
    <a href="<?php echo e(route('mexco.portal.events', ['tab' => 'all'])); ?>" class="tab <?php echo e($tab === 'all' ? 'on' : ''); ?>">All (<?php echo e($counts['all']); ?>)</a>
    <a href="<?php echo e(route('mexco.portal.events', ['tab' => 'upcoming'])); ?>" class="tab <?php echo e($tab === 'upcoming' ? 'on' : ''); ?>">Upcoming (<?php echo e($counts['upcoming']); ?>)</a>
    <a href="<?php echo e(route('mexco.portal.events', ['tab' => 'ongoing'])); ?>" class="tab <?php echo e($tab === 'ongoing' ? 'on' : ''); ?>">Ongoing (<?php echo e($counts['ongoing']); ?>)</a>
    <a href="<?php echo e(route('mexco.portal.events', ['tab' => 'completed'])); ?>" class="tab <?php echo e($tab === 'completed' ? 'on' : ''); ?>">Completed (<?php echo e($counts['completed']); ?>)</a>
</div>

<?php $__empty_1 = true; $__currentLoopData = $rows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
    <?php
        $event = $row['event'];
        $u = $row['usage'];
        $pct = min(100, (float) ($u['percent'] ?? 0));
    ?>
    <article class="event-card">
        <div>
            <h3><?php echo e($event->name); ?></h3>
            <p class="meta"><?php echo e($row['schedule']); ?> · <?php echo e($organisation?->name); ?></p>
            <?php if($row['addons']): ?>
                <p class="meta">Add-ons: <?php echo e(implode(', ', $row['addons'])); ?></p>
            <?php endif; ?>
        </div>
        <div>
            <?php if($event->license?->plan): ?>
                <span class="plan-pill <?php echo e($event->license->plan->code); ?>"><?php echo e($event->license->plan->name); ?></span>
            <?php endif; ?>
            <div class="meta"><?php echo e($row['statusLabel']); ?></div>
        </div>
        <div>
            <div style="font-size:.8rem;font-weight:700">License: <?php echo e(ucfirst($row['licenseStatus'] ?? '-')); ?></div>
            <div class="meta">Expiry: <?php echo e($row['expiry'] ? $row['expiry']->format('j M Y') : '-'); ?></div>
        </div>
        <div>
            <?php if($u['limit']): ?>
                <div style="font-size:.8rem;font-weight:700"><?php echo e(number_format($u['current'])); ?> / <?php echo e(number_format($u['limit'])); ?></div>
                <div class="usage-track"><div class="usage-fill" style="width:<?php echo e($pct); ?>%"></div></div>
            <?php else: ?>
                <div style="font-size:.8rem;font-weight:700"><?php echo e(number_format($u['current'])); ?> participants</div>
            <?php endif; ?>
        </div>
        <div style="display:flex;gap:.4rem;flex-wrap:wrap">
            <?php if(($activeDemo ?? null) && $event->id === ($activeDemo->event_id ?? null)): ?>
                <a href="<?php echo e(url('/mexco')); ?>" class="btn-outline btn-sm" target="_blank" rel="noopener">Visitor</a>
            <?php endif; ?>
            <a href="<?php echo e(route('mexco.admin.login')); ?>" class="btn-purple btn-sm">Manage</a>
        </div>
    </article>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
    <div class="card empty">
        <strong style="display:block;color:var(--ink);margin-bottom:.35rem">No events in this tab</strong>
        <?php if($activeDemo ?? null): ?>
            <a href="<?php echo e(url('/mexco')); ?>" class="btn-purple" target="_blank" rel="noopener">Open Visitor Pass</a>
        <?php else: ?>
            <a href="<?php echo e(route('mexco.plans')); ?>" class="btn-purple">Create your event</a>
        <?php endif; ?>
    </div>
<?php endif; ?>
<?php $__env->stopSection(); ?>

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