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

<?php $__env->startSection('content'); ?>

<div style="margin-bottom:1.75rem">
  <h1 style="font-size:1.625rem;font-weight:700;color:var(--foreground);letter-spacing:-.03em;line-height:1.2;margin:0 0 .25rem">Downloads</h1>
  <p style="font-size:.875rem;color:var(--muted-foreground);margin:0">Download your purchased products. License must be active.</p>
</div>

<?php $typeIcons=['plugin'=>'🔌','module'=>'🧩','software'=>'💻','theme'=>'🎨','api'=>'⚡','saas'=>'☁️']; ?>


<div style="display:flex;align-items:center;gap:.5rem;margin-bottom:.875rem">
  <svg width="14" height="14" fill="none" stroke="var(--foreground)" viewBox="0 0 24 24">
    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75"
      d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
  </svg>
  <span style="font-size:.875rem;font-weight:600;color:var(--foreground)">Available Downloads</span>
  <span style="font-size:.6875rem;font-weight:600;color:var(--muted-foreground);
    background:var(--muted);border:1px solid var(--border);
    padding:.1rem .45rem;border-radius:.35rem"><?php echo e($licenses->count()); ?></span>
</div>


<div style="border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;margin-bottom:2rem">
  <?php $__empty_1 = true; $__currentLoopData = $licenses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $license): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
  <?php
    $latest = $license->product->latestVersion;
    $isLast = $loop->last;
  ?>
  <div style="display:flex;align-items:center;gap:.875rem;padding:1rem 1.25rem;
    background:var(--card);<?php echo e(!$isLast ? 'border-bottom:1px solid var(--border);' : ''); ?>

    transition:background .1s"
    onmouseover="this.style.background='var(--muted)'" onmouseout="this.style.background='var(--card)'">

    
    <div style="width:2.25rem;height:2.25rem;border-radius:.5rem;background:var(--muted);
      border:1px solid var(--border);display:flex;align-items:center;
      justify-content:center;font-size:1rem;flex-shrink:0">
      <?php echo e($typeIcons[$license->product->type??'-']??'-'); ?>

    </div>

    
    <div style="flex:1;min-width:0">
      <div style="font-size:.875rem;font-weight:600;color:var(--foreground);margin-bottom:.25rem">
        <?php echo e($license->product->name); ?>

      </div>
      <div style="display:flex;align-items:center;gap:.5rem;font-size:.72rem;color:var(--muted-foreground)">
        <?php if($latest): ?>
          <span>v<?php echo e($latest->version); ?></span>
          <span>.</span>
          <span><?php echo e(number_format($latest->file_size / 1024 / 1024, 1)); ?> MB</span>
          <span>.</span>
          <span style="padding:.1rem .4rem;border-radius:.3rem;font-size:.65rem;font-weight:600;
            background:#f0fdf4;color:#166534;border:1px solid #bbf7d0">Stable</span>
        <?php else: ?>
          <span>No file available yet</span>
        <?php endif; ?>
      </div>
    </div>

    
    <div style="display:flex;align-items:center;gap:.625rem;flex-shrink:0">
      <span style="display:flex;align-items:center;gap:.3rem;font-size:.75rem;
        font-weight:500;color:var(--muted-foreground)">
        <span style="width:6px;height:6px;border-radius:50%;
          background:<?php echo e($license->status==='active'?'#22c55e':'#9ca3af'); ?>;flex-shrink:0"></span>
        <?php echo e(ucfirst($license->status)); ?>

      </span>

      <?php if($latest && $latest->file_path): ?>
      <a href="<?php echo e(route('customer.downloads.get', $license)); ?>"
         style="display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .75rem;
           border-radius:var(--radius);font-size:.8rem;font-weight:500;
           color:var(--foreground);background:var(--card);border:1px solid var(--border);
           text-decoration:none;transition:all .12s;white-space:nowrap"
         onmouseover="this.style.background='var(--foreground)';this.style.color='var(--card)';this.style.borderColor='var(--foreground)'"
         onmouseout="this.style.background='var(--card)';this.style.color='var(--foreground)';this.style.borderColor='var(--border)'">
        <svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
            d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
        </svg>
        Download
      </a>
      <?php else: ?>
      <span style="display:inline-flex;align-items:center;padding:.375rem .75rem;
        border-radius:var(--radius);font-size:.8rem;font-weight:500;
        color:var(--muted-foreground);background:var(--muted);border:1px solid var(--border);
        opacity:.6;cursor:not-allowed">No file</span>
      <?php endif; ?>
    </div>
  </div>
  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
  <div style="padding:4rem 2rem;text-align:center;background:var(--card)">
    <div style="width:3rem;height:3rem;border-radius:.75rem;background:var(--muted);
      border:1px solid var(--border);display:flex;align-items:center;justify-content:center;
      margin:0 auto .875rem;font-size:1.25rem">📥</div>
    <div style="font-size:.9375rem;font-weight:600;color:var(--foreground);margin-bottom:.375rem">
      No downloads available
    </div>
    <p style="font-size:.875rem;color:var(--muted-foreground);margin:0 0 1.25rem">
      Purchase a product to get download access.
    </p>
    <a href="<?php echo e(route('customer.market')); ?>"
       style="display:inline-flex;align-items:center;gap:.375rem;padding:.5rem 1rem;
         border-radius:var(--radius);font-size:.875rem;font-weight:500;
         color:var(--foreground);background:var(--card);border:1px solid var(--border);
         text-decoration:none;transition:all .12s"
       onmouseover="this.style.background='var(--muted)'" onmouseout="this.style.background='var(--card)'">
      Browse Market →
    </a>
  </div>
  <?php endif; ?>
</div>


<?php if($history->count()): ?>
<div style="display:flex;align-items:center;gap:.5rem;margin-bottom:.875rem">
  <svg width="14" height="14" fill="none" stroke="var(--foreground)" viewBox="0 0 24 24">
    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75"
      d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
  </svg>
  <span style="font-size:.875rem;font-weight:600;color:var(--foreground)">Download History</span>
</div>

<div style="border:1px solid var(--border);border-radius:var(--radius);overflow:hidden">
  <table style="width:100%;border-collapse:collapse">
    <thead>
      <tr style="border-bottom:1px solid var(--border);background:var(--muted)">
        <?php $__currentLoopData = ['Product','Version','Date','IP Address']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $h): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <th style="padding:.625rem 1.25rem;font-size:.6875rem;font-weight:600;
          color:var(--muted-foreground);text-transform:uppercase;letter-spacing:.07em;text-align:left">
          <?php echo e($h); ?>

        </th>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </tr>
    </thead>
    <tbody>
      <?php $__currentLoopData = $history; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dl): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
      <tr style="background:var(--card);border-bottom:1px solid var(--border);
        transition:background .1s"
        onmouseover="this.style.background='var(--muted)'"
        onmouseout="this.style.background='var(--card)'">
        <td style="padding:.75rem 1.25rem;font-size:.8375rem;font-weight:500;color:var(--foreground)">
          <?php echo e($dl->product->name??'-'); ?>

        </td>
        <td style="padding:.75rem 1.25rem">
          <span style="font-size:.72rem;font-weight:600;padding:.15rem .45rem;border-radius:.35rem;
            background:var(--muted);color:var(--muted-foreground);border:1px solid var(--border)">
            v<?php echo e($dl->version?->version??'-'); ?>

          </span>
        </td>
        <td style="padding:.75rem 1.25rem;font-size:.78rem;color:var(--muted-foreground);white-space:nowrap">
          <?php echo e(\Carbon\Carbon::parse($dl->created_at)->format('M d, Y H:i')); ?>

        </td>
        <td style="padding:.75rem 1.25rem;font-family:monospace;font-size:.75rem;color:var(--muted-foreground)">
          <?php echo e($dl->ip_address??'-'); ?>

        </td>
      </tr>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </tbody>
  </table>
</div>
<?php endif; ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.customer', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\License system\license-platform\resources\views/customer/downloads/index.blade.php ENDPATH**/ ?>