<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
  <title><?php echo e(env('APP_NAME')); ?> | Order</title>
  
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/layui@2.8.17/dist/css/layui.css">
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">

  <style>
    :root {
      --accent-black: #1a1a1a;
      --accent-gradient: linear-gradient(135deg, #1a1a1a 0%, #3a3a3a 100%);
      --bg-light: #eef7ff; /* Light blue-ish background from image 3 */
    }

    * {
      box-sizing: border-box;
    }

    body {
      font-family: 'Roboto', sans-serif;
      background-color: var(--bg-light);
      margin: 0; padding: 0;
      padding-bottom: 70px;
      animation: fadeInBody 0.5s ease;
    }

    @keyframes fadeInBody {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    @keyframes fadeInUp {
      from { opacity: 0; transform: translateY(15px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @keyframes popIn {
      from { opacity: 0; transform: scale(0.94); }
      to { opacity: 1; transform: scale(1); }
    }

    @keyframes slideDown {
      from { opacity: 0; transform: translateY(-12px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    /* 🔹 Header */
    .top-header {
      padding: 15px 20px;
      background: var(--bg-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      animation: slideDown 0.4s ease both;
    }

    .top-header h2 { font-size: 20px; font-weight: 700; color: #1e293b; margin: 0; }
    .top-header i {
      font-size: 24px;
      color: #cbd5e1;
      transition: transform 0.25s ease, color 0.25s ease;
    }
    .top-header i:hover { color: var(--accent-black); transform: scale(1.15); }

    /* 🔹 Summary Card (Matching Image 3) */
    .summary-card {
      margin: 10px 15px;
      padding: 20px;
      background: var(--accent-gradient);
      border-radius: 15px;
      color: white;
      position: relative;
      overflow: hidden;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
      animation: popIn 0.5s ease 0.05s both;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .summary-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    }

    .summary-card h3 { font-size: 24px; font-weight: 800; margin: 0; }
    .summary-card p { font-size: 14px; opacity: 0.9; margin: 4px 0 15px; }
    .summary-card .today-box { font-size: 15px; font-weight: 600; }
    
    .rocket-img {
      position: absolute;
      right: 10px;
      top: 10px;
      width: 100px;
      animation: floatRocket 3s ease-in-out infinite;
    }

    @keyframes floatRocket {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-6px); }
    }

    /* 🔹 Collect Button */
    .collect-container {
      text-align: center;
      margin: 20px 0;
      animation: fadeInUp 0.4s ease 0.15s both;
    }

    .btn-collect {
      background: var(--accent-gradient);
      color: white;
      border: none;
      padding: 12px 60px;
      border-radius: 30px;
      font-size: 18px;
      font-weight: 600;
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
      cursor: pointer;
      transition: transform 0.2s ease, box-shadow 0.25s ease, opacity 0.2s ease;
    }

    .btn-collect:hover {
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
      transform: translateY(-2px);
    }

    .btn-collect:active {
      transform: scale(0.96);
    }

    /* 🔹 Tabs (Matching Image 3) */
    .tab-nav {
      display: flex;
      justify-content: space-around;
      margin-top: 10px;
      border-bottom: 1px solid rgba(0,0,0,0.05);
      animation: fadeInUp 0.4s ease 0.2s both;
    }

    .tab-nav a {
      padding: 10px 0;
      font-size: 15px;
      color: #64748b;
      text-decoration: none;
      position: relative;
      width: 50%;
      text-align: center;
      transition: color 0.25s ease;
    }

    .tab-nav a.active {
      color: #1e293b;
      font-weight: 700;
    }

    .tab-nav a.active::after {
      content: '';
      position: absolute;
      bottom: 0; left: 40%; width: 20%;
      height: 3px;
      background: var(--accent-black);
      border-radius: 10px;
      animation: popIn 0.3s ease both;
    }

    /* 🔹 List Content */
    .order-content { padding: 20px; text-align: center; }

    .tab-pane { animation: fadeIn 0.35s ease both; }

    .empty-state { margin-top: 50px; animation: fadeInUp 0.4s ease both; }
    .empty-state img { width: 120px; margin-bottom: 15px; opacity: 0.8; }
    .empty-state p { color: #64748b; font-size: 14px; }

    .order-item {
      background: #fff;
      border-radius: 12px;
      padding: 15px;
      margin-bottom: 15px;
      display: flex;
      text-align: left;
      animation: fadeInUp 0.4s ease both;
      transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    .order-item:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 18px rgba(0,0,0,0.07);
    }

    .order-item img {
      width: 80px;
      height: 80px;
      border-radius: 8px;
      margin-right: 15px;
      transition: transform 0.3s ease;
    }

    .order-item:hover img { transform: scale(1.05); }
    .order-item h4 { margin: 0 0 5px; color: #1e293b; }
    .order-item p { font-size: 12px; color: #94a3b8; margin: 2px 0; }

    /* 🔹 Bottom Nav Bar */
    .footer-nav {
      position: fixed;
      bottom: 0; width: 100%;
      background: #fff;
      display: flex;
      justify-content: space-around;
      padding: 10px 0;
      border-top: 1px solid #f1f5f9;
      z-index: 100;
    }

    .foot-item { text-align: center; text-decoration: none; color: #94a3b8; }
    .foot-item.active { color: var(--accent-black); }
    .foot-item i { font-size: 22px; }
    .foot-item p { font-size: 11px; margin-top: 4px; }
  </style>
</head>
<body class="huiBg">

  <?php
    $user = auth()->user();
    $totalAssets = \App\Models\Purchase::where('user_id', $user->id)->where('status', 'active')->sum('amount'); 
    $totalIncome = \App\Models\UserLedger::where('user_id', $user->id)->where('reason', 'daily_income')->sum('amount');
    $activePurchases = \App\Models\Purchase::where('user_id', $user->id)->where('status', 'active')->get();
    $expiredPurchases = \App\Models\Purchase::where('user_id', $user->id)->where('status', 'expired')->get();
  ?>

  <div class="top-header">
    <h2>Order</h2>
    <i class="layui-icon layui-icon-headset"></i>
  </div>

  <div class="summary-card">
    <img src="rocal/333.232b606c.png" class="rocket-img" alt="Rocket"> <h3>₱<?php echo e(($totalIncome)); ?></h3>
    <p>Cumulative income</p>
    <div class="today-box">Today's earning: ₱<?php echo e(($user->receive_able_amount)); ?></div>
  </div>

  <div class="collect-container">
    <button type="button" class="btn-collect" id="claim-income">Collect Earning</button>
  </div>

  <div class="tab-nav">
    <a href="#" class="active" data-tab="valid">Active Orders (<?php echo e($activePurchases->count()); ?>)</a>
    <a href="#" data-tab="expired">Expired (<?php echo e($expiredPurchases->count()); ?>)</a>
  </div>

  <div class="order-content">
    
    <div id="valid" class="tab-pane">
      <?php $__empty_1 = true; $__currentLoopData = $activePurchases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $purchase): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <div class="order-item">
          <img src="<?php echo e(asset($purchase->package->photo)); ?>">
          <div>
            <h4><?php echo e($purchase->package->name); ?></h4>
            <p>Cycle: <?php echo e($purchase->package->validity); ?> Days</p>
            <p>Total: ₱<?php echo e(($purchase->package->commission_with_avg_amount)); ?></p>
            
          </div>
        </div>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <div class="empty-state">
          <img src="rocal/empty.262bd713.png" alt="Empty"> <p>Did not find any information!</p>
        </div>
      <?php endif; ?>
    </div>

    <div id="expired" class="tab-pane" style="display:none;">
      <?php $__empty_1 = true; $__currentLoopData = $expiredPurchases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $purchase): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <div class="order-item">
          <img src="<?php echo e(asset($purchase->package->photo)); ?>" style="filter: grayscale(1);">
          <div>
            <h4><?php echo e($purchase->package->name); ?></h4>
            <p>Status: Expired</p>
            <p>Time: <?php echo e($purchase->created_at->format('Y-m-d H:i')); ?></p>
          </div>
        </div>
      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <div class="empty-state">
          <img src="rocal/empty.262bd713.png" alt="Empty">
          <p>No expired records.</p>
        </div>
      <?php endif; ?>
    </div>
  </div>

<style>
  :root {
    --accent-black: #1a1a1a;
    --inactive-color: #94a3b8;
    --nav-bg: rgba(255, 255, 255, 0.95);
  }

  .foot {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--nav-bg);
    backdrop-filter: blur(10px); /* Modern blur effect */
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid rgba(0,0,0,0.05);
    z-index: 9999;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.03);
  }

  .foot ul {
    width: 100%;
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    align-items: flex-end;
  }

  .foot li {
    flex: 1;
    text-align: center;
    position: relative;
  }

  .foot li a {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--inactive-color);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  /* 🔹 PRO ICON STYLING */
  .foot li img {
    width: 28px; /* Slightly larger for Pro look */
    height: 28px;
    margin-bottom: 4px;
    filter: grayscale(1) opacity(0.4);
    transition: all 0.4s ease;
  }

  .foot li p {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
  }

  /* 🔹 ACTIVE STATE: MINE (BLACK PRO) */
  .foot li.cur a {
    color: var(--accent-black);
  }

  .foot li.cur img {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); /* Subtle dark glow */
    transform: translateY(-5px) scale(1.2); /* Lift effect */
  }

  /* Small indicator dot under active icon */
  .foot li.cur::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent-black);
    border-radius: 50%;
  }

  .foot li.cur p {
    font-weight: 800;
  }
</style>

<div class="foot">
 <ul>
  <li >
    <a href="/dashboard">
      <img src="https://cdn-icons-png.flaticon.com/512/1946/1946436.png" alt="Home">
      <p>Home</p>
    </a>
  </li>

  <li class="cur">
    <a href="/ordered">
      <img src="https://cdn-icons-png.flaticon.com/512/1170/1170678.png" alt="Order">
      <p>Order</p>
    </a>
  </li>

  <li>
    <a href="/my-team">
      <img src="https://cdn-icons-png.flaticon.com/512/912/912318.png" alt="Team">
      <p>Team</p>
    </a>
  </li>

  <li>
    <a href="/my-profile">
      <img src="https://cdn-icons-png.flaticon.com/512/1077/1077063.png" alt="Mine">
      <p>Mine</p>
    </a>
  </li>
</ul>

  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/layui@2.8.17/dist/layui.js"></script>

  <script>
    // Tab Switching
    $('.tab-nav a').click(function(e) {
      e.preventDefault();
      $('.tab-nav a').removeClass('active');
      $(this).addClass('active');
      $('.tab-pane').hide();
      $('#' + $(this).data('tab')).show();
    });

    // Claim Logic
    layui.use(['layer'], function(){
      var layer = layui.layer;
      $('#claim-income').click(function(){
        const btn = $(this);
        btn.prop('disabled', true).css('opacity', '0.7');
        
        $.ajax({
          url: "<?php echo e(route('user.mining.received_amount')); ?>",
          method: "POST",
          headers: { 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' },
          success: function(res){
            btn.prop('disabled', false).css('opacity', '1');
            if(res.status){
              layer.msg(res.success, {icon: 1});
              confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
              setTimeout(() => { location.reload(); }, 1500);
            } else {
              layer.msg(res.error, {icon: 2});
            }
          }
        });
      });
    });
  </script>
</body>
</html>
<?php /**PATH /home/pocomito/tz.gocycles.xyz/resources/views/app/main/ordered.blade.php ENDPATH**/ ?>