<?php $__env->startPush('style'); ?>
<style>
  .service-back {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #111;
    text-decoration: none;
  }

  .service-top-pill {
    border: 1px solid #ececec;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #2f2f2f;
    background: #fff;
  }

  .service-banner {
    background: linear-gradient(120deg, #5c1fa3 0%, #7b30d7 100%);
    border-radius: 8px;
    color: #fff;
    padding: 20px 24px;
  }

  .service-banner-title {
    font-size: 29px;
    font-weight: 700;
  }

  .service-banner-price {
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    color: #ffcb4b;
  }

  .service-tab-pill {
    border-radius: 8px;
    padding: 7px 12px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: #9ea0a4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .service-tab-pill.active {
    background: #ff9800;
  }

  .sort-btn {
    border: 0;
    border-radius: 10px;
    padding: 8px 14px;
    font-weight: 700;
    color: #232323;
    background: #f4f4f4;
  }

  .filter-chip {
    border: 1px solid #ececec;
    border-radius: 9px;
    padding: 12px 16px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    font-size: 14px;
  }

  .listing-card {
    border: 1px solid #8ac54b;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    position: relative;
  }

  .listing-online {
    position: absolute;
    right: 12px;
    top: -9px;
    background: #d9efbb;
    color: #57a30d;
    border-radius: 7px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 600;
  }

  .score-ring {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 4px solid #f3bd3f;
    color: #5fbb2d;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
  }

  .listing-price {
    color: #ff9200;
    font-weight: 700;
    font-size: 38px;
    line-height: 1;
    margin: 12px 0 8px;
  }

  .listing-price span {
    font-size: 16px;
    color: #111;
    font-weight: 500;
  }

  .seat-icons {
    display: flex;
    gap: 5px;
    color: #f09300;
    font-size: 15px;
    margin-bottom: 10px;
  }

  .seat-icons .empty {
    color: #d3d3d3;
  }

  .join-btn {
    background: #ff9800;
    border-color: #ff9800;
    color: #fff;
    font-weight: 700;
    border-radius: 8px;
    width: 100%;
  }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<?php
  $lowestPrice = $summary['lowest_price'] ?? 0;
  $listingCount = $summary['listing_count'] ?? 0;
  $availableSlots = $summary['total_available_slots'] ?? 0;
?>

<div class="container-xxl flex-grow-1 container-p-y">
  <div class="d-flex justify-content-between align-items-center gap-3 flex-wrap mb-3">
    <div class="d-flex align-items-center gap-2">
      <a href="<?php echo e(route('subscriptions.index')); ?>" class="service-back">
        <i class="icon-base ti tabler-chevron-left icon-md"></i>
      </a>
      <h2 class="mb-0 fw-bold"><?php echo e($subscription->service->name); ?></h2>
    </div>

    <div class="d-flex gap-2 flex-wrap">
      <span class="service-top-pill"><i class="icon-base ti tabler-link icon-xs me-1"></i> Type</span>
      <span class="service-top-pill"><i class="icon-base ti tabler-file-text icon-xs me-1"></i> Infos</span>
      <span class="service-top-pill"><i class="icon-base ti tabler-help-circle icon-xs me-1"></i> FAQ</span>
    </div>
  </div>

  <div class="service-banner mb-4">
    <div class="row g-3 align-items-center">
      <div class="col-lg-7">
        <div class="service-banner-title">Share your <?php echo e($subscription->service->name); ?> directly</div>
        <div class="mt-2"><?php echo e($availableSlots); ?> slots currently available. New joins happen fast.</div>
      </div>
      <div class="col-lg-5 text-lg-end">
        <div class="small text-white-50">Starting from</div>
        <div class="service-banner-price"><?php echo e(number_format($lowestPrice, 2)); ?> &euro;<span class="fs-6 text-white"> / month</span></div>
        <div class="small mt-2">Across <?php echo e($listingCount); ?> listing(s)</div>
      </div>
    </div>
  </div>

  <div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-4">
    <div class="d-flex gap-2 flex-wrap">
      <a
        href="<?php echo e(route('subscriptions.show', $subscription)); ?>"
        class="service-tab-pill <?php echo e($selectedPlan <= 0 ? 'active' : ''); ?>"
      >
        All (<?php echo e($listingCount); ?>)
      </a>
      <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $planCounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $plan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a
          href="<?php echo e(route('subscriptions.show', ['subscription' => $subscription->id, 'plan' => $plan['id']])); ?>"
          class="service-tab-pill <?php echo e($selectedPlan === $plan['id'] ? 'active' : ''); ?>"
        >
          <?php echo e($plan['name']); ?> (<?php echo e($plan['count']); ?>)
        </a>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>

    <button type="button" class="sort-btn"><i class="icon-base ti tabler-sort-ascending icon-sm me-1"></i> Sort</button>
  </div>

  <div class="fw-bold mb-2">Sort by:</div>
  <div class="row g-2 mb-4">
    <div class="col-lg-3 col-md-6">
      <div class="filter-chip"><i class="icon-base ti tabler-rosette-discount-check icon-sm"></i> Verified Invoice</div>
    </div>
    <div class="col-lg-3 col-md-6">
      <div class="filter-chip"><i class="icon-base ti tabler-point-filled icon-sm text-success"></i> Online</div>
    </div>
    <div class="col-lg-3 col-md-6">
      <div class="filter-chip"><i class="icon-base ti tabler-medal icon-sm"></i> Trust score</div>
    </div>
    <div class="col-lg-3 col-md-6">
      <div class="filter-chip"><i class="icon-base ti tabler-coins icon-sm"></i> Lowest price</div>
    </div>
  </div>

  <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($serviceSubscriptions->isEmpty()): ?>
    <div class="card">
      <div class="card-body py-5 text-center">No listings found for this filter.</div>
    </div>
  <?php else: ?>
    <div class="row g-3">
      <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $serviceSubscriptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
          $totalSeats = (int) $item->total_slots;
          $remainingSeats = (int) $item->available_slots;
          $occupiedSeats = max($totalSeats - $remainingSeats, 0);
          $visibleSeatSlots = min(max($totalSeats, 1), 6);
          $trustScore = (int) max(60, min(100, 80 + (float) ($item->owner?->trust_score ?? 0)));
          $isJoinable = $item->status === 'active' && $remainingSeats > 0;
        ?>
        <div class="col-lg-4 col-md-6">
          <div class="listing-card h-100">
            <span class="listing-online">Online</span>

            <div class="d-flex align-items-center">
              <div class="score-ring"><?php echo e($trustScore); ?></div>
              <div>
                <h5 class="mb-0 fw-semibold"><?php echo e($item->owner?->name ?? 'N/A'); ?></h5>
                <small class="text-muted"><?php echo e($item->servicePlan?->name ?? 'Plan N/A'); ?></small>
              </div>
            </div>

            <div class="listing-price"><?php echo e(number_format((float) $item->price_per_slot, 2)); ?><span>&euro; / month</span></div>

            <div class="seat-icons">
              <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php for($i = 0; $i < $visibleSeatSlots; $i++): ?>
                <i class="icon-base ti tabler-user-filled <?php echo e($i >= $occupiedSeats ? 'empty' : ''); ?>"></i>
              <?php endfor; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            <div class="text-end small mb-3"><?php echo e($remainingSeats); ?> remaining seat(s)</div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(auth()->guard()->check()): ?>
              <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((int) auth()->id() === (int) $item->owner_id): ?>
                <button type="button" class="btn btn-secondary w-100" disabled>Your Listing</button>
              <?php elseif(! $isJoinable): ?>
                <button type="button" class="btn btn-secondary w-100" disabled>Not Available</button>
              <?php else: ?>
                <a href="<?php echo e(route('subscriptions.join.create', $item)); ?>" class="btn join-btn">Join</a>
              <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php else: ?>
              <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(! $isJoinable): ?>
                <button type="button" class="btn btn-secondary w-100" disabled>Not Available</button>
              <?php else: ?>
                <a href="<?php echo e(route('login')); ?>" class="btn join-btn">Login to Join</a>
              <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
          </div>
        </div>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>
  <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.subscriptions', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\xampp\htdocs\G_desizn\marketplace\resources\views/subscriptions/show.blade.php ENDPATH**/ ?>