

<?php $__env->startSection('content'); ?>
<div class="container-fluid py-3">

  <style>
    .pm-card { border:1px solid #e6e8ef; border-radius:16px; background:#fff; box-shadow:0 4px 18px rgba(17,24,39,.06) }
    .table thead th{font-weight:700;color:#0f172a;border-top:0}
    .table-hover tbody tr:hover{background:#fafafa}
    .badge-soft{ background:#eef2ff; color:#3730a3; border-radius:999px; padding:.35rem .6rem; font-weight:600 }
    .badge-soft.gray { background:#f1f5f9; color:#334155 }
    .badge-soft.green{ background:#dcfce7; color:#166534 }
    .badge-soft.red  { background:#fee2e2; color:#991b1b }
    .btn-create { background:#5b21b6; border-color:#5b21b6 }
    .btn-create:hover{ background:#4c1d95; border-color:#4c1d95 }
    @media (max-width: 768px){
      .table thead{ display:none }
      .table tbody tr{ display:block; margin:12px 0; border:1px solid #e5e7eb; border-radius:12px; padding:10px }
      .table td{ display:flex; justify-content:space-between; border:0; padding:.4rem .5rem }
      .table td::before{ content: attr(data-label); font-weight:600; color:#475569 }
    }
  </style>

  <div class="d-flex justify-content-between align-items-center mb-3">
    <h5 class="mb-0"><i class="fa-solid fa-gift me-2"></i> Offers</h5>
    <a class="btn btn-create text-white" href="<?php echo e(url('/admin/offers/create')); ?>"><i class="fa-solid fa-plus me-1"></i> Create</a>
  </div>

  <form class="pm-card p-3 mb-3" method="GET" action="<?php echo e(url('/admin/offers')); ?>">
    <div class="row g-2">
      <div class="col-md-4">
        <div class="input-group">
          <span class="input-group-text bg-white"><i class="fa-solid fa-magnifying-glass"></i></span>
          <input name="q" value="<?php echo e(request('q')); ?>" class="form-control" placeholder="Search title">
        </div>
      </div>
      <div class="col-md-3">
        <select name="operator_id" class="form-select">
          <option value="">All operators</option>
          <?php $__currentLoopData = $operators; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $op): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <option value="<?php echo e($op->id); ?>" <?php if(request('operator_id')==$op->id): echo 'selected'; endif; ?>><?php echo e($op->name); ?></option>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
      </div>
      <div class="col-md-3">
        <select name="status" class="form-select">
          <option value="">Any status</option>
          <option value="active"   <?php if(request('status')==='active'): echo 'selected'; endif; ?>>Active</option>
          <option value="inactive" <?php if(request('status')==='inactive'): echo 'selected'; endif; ?>>Inactive</option>
        </select>
      </div>
      <div class="col-md-2 d-grid">
        <button class="btn btn-outline-secondary"><i class="fa-solid fa-filter me-1"></i> Filter</button>
      </div>
    </div>
  </form>

  <?php if(session('success')): ?>
    <div class="alert alert-success pm-card p-2"><i class="fa-regular fa-circle-check me-1"></i><?php echo e(session('success')); ?></div>
  <?php endif; ?>

  <div class="table-responsive pm-card p-0">
    <table class="table table-hover align-middle mb-0">
      <thead class="table-light">
        <tr>
          <th>#</th>
          <th>Operator</th>
          <th>Title</th>
          <th>Prices</th>
          <th>Data / Minutes</th>
          <th>Validity</th>
          <th>Sort</th>
          <th>Status</th>
          <th class="text-end">Actions</th>
        </tr>
      </thead>
      <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $offers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $o): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <tr>
          <td data-label="#" class="text-muted"><?php echo e($o->id); ?></td>
          <td data-label="Operator">
            <span class="badge-soft gray"><i class="fa-solid fa-signal me-1"></i><?php echo e($o->operator?->name); ?></span>
          </td>
          <td data-label="Title" class="fw-semibold">
            <a class="text-decoration-none" href="<?php echo e(url('/admin/offers/'.$o->id)); ?>"><i class="fa-solid fa-ticket me-1 text-secondary"></i><?php echo e($o->title); ?></a>
          </td>
          <td data-label="Prices">
            <span class="badge-soft gray">Reg: <?php echo e(number_format($o->regular_price,2)); ?></span>
            <span class="badge-soft">Sale: <?php echo e(number_format($o->sale_price,2)); ?></span>
          </td>
          <td data-label="Data / Minutes">
            <?php echo e($o->data_gb ?? 0); ?> GB / <?php echo e($o->minutes ?? 0); ?> Min
          </td>
          <td data-label="Validity"><?php echo e($o->validity_days ?? '—'); ?> days</td>
          <td data-label="Sort"><?php echo e($o->sort_order); ?></td>
          <td data-label="Status">
            <span class="badge-soft <?php echo e($o->status==='active' ? 'green' : 'red'); ?>">
              <i class="fa-solid <?php echo e($o->status==='active' ? 'fa-toggle-on' : 'fa-toggle-off'); ?> me-1"></i><?php echo e(ucfirst($o->status)); ?>

            </span>
          </td>
          <td data-label="Actions" class="text-end">
            <div class="d-inline-flex gap-1 flex-wrap">
              <form action="<?php echo e(url('/admin/offers/'.$o->id.'/toggle')); ?>" method="POST"><?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
                <button class="btn btn-warning btn-sm"><i class="fa-solid fa-arrows-rotate"></i> Toggle</button>
              </form>
              <a class="btn btn-primary btn-sm" href="<?php echo e(url('/admin/offers/'.$o->id.'/edit')); ?>"><i class="fa-regular fa-pen-to-square"></i> Edit</a>
              <form action="<?php echo e(url('/admin/offers/'.$o->id)); ?>" method="POST" onsubmit="return confirm('Delete this item?')">
                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                <button class="btn btn-danger btn-sm"><i class="fa-regular fa-trash-can"></i> Delete</button>
              </form>
            </div>
          </td>
        </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <tr><td colspan="9" class="text-center text-muted py-4"><i class="fa-regular fa-folder-open me-1"></i>No offers</td></tr>
        <?php endif; ?>
      </tbody>
    </table>
  </div>

  <div class="mt-3"><?php echo e($offers->links()); ?></div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecareba2/new.rkmotorsbike.top/resources/views/backend/offers/index.blade.php ENDPATH**/ ?>