<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"> 
  <title>{{ config('app.name') }} | Product Detail</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-soft: #2e2e2e;
      --bg-gray: #f4f6f8;
      --text-main: #334155;
    }

    * {
      box-sizing: border-box;
    }

    body {
      font-family: 'Roboto', sans-serif;
      background-color: #ffffff;
      margin: 0; padding: 0;
      color: var(--text-main);
      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); }
    }

    /* 🔹 Top Navigation */
    .top-nav {
      position: fixed;
      top: 0; width: 100%;
      height: 50px;
      background: #fff;
      display: flex;
      align-items: center;
      padding: 0 15px;
      z-index: 100;
      border-bottom: 1px solid #f1f5f9;
      animation: slideDown 0.4s ease both;
    }

    .top-nav a {
      color: var(--text-main);
      font-size: 20px;
      transition: transform 0.2s ease, color 0.2s ease;
      display: inline-flex;
    }

    .top-nav a:hover { color: var(--accent-black); transform: translateX(-3px); }
    .top-nav .title { flex: 1; text-align: center; font-weight: 700; font-size: 18px; margin-right: 30px; }

    /* 🔹 Main Banner Area */
    .product-hero {
      margin-top: 50px;
      width: 100%;
      height: 160px;
      background: var(--bg-gray);
      display: flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      animation: popIn 0.5s ease 0.05s both;
    }

    .product-hero img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.5s ease;
    }

    .product-hero:hover img {
      transform: scale(1.04);
    }

    /* 🔹 Info Section */
    .content-box { padding: 20px; padding-bottom: 100px; }

    .header-info {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      animation: fadeInUp 0.4s ease 0.1s both;
    }
    .header-info h1 { font-size: 22px; font-weight: 700; color: #1e293b; margin: 0; }
    .header-info .badge {
      background: #fee2e2;
      color: #ef4444;
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 12px;
      font-weight: 700;
      animation: popIn 0.4s ease 0.2s both;
    }

    /* 🔹 Stats Grid */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;
      margin-top: 20px;
    }

    .stat-card {
      background: var(--bg-gray);
      padding: 15px;
      border-radius: 12px;
      text-align: center;
      animation: fadeInUp 0.4s ease both;
      transition: transform 0.25s ease, box-shadow 0.25s ease;
    }

    .stat-card:nth-child(1) { animation-delay: 0.15s; }
    .stat-card:nth-child(2) { animation-delay: 0.2s; }

    .stat-card:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    }

    .stat-card h3 { color: var(--accent-black); font-size: 18px; font-weight: 700; margin: 0; }
    .stat-card p { font-size: 12px; color: #64748b; margin-top: 5px; }

    /* 🔹 Description Area */
    .desc-section {
      margin-top: 25px;
      padding-top: 20px;
      border-top: 1px solid #f1f5f9;
      animation: fadeInUp 0.4s ease 0.25s both;
    }

    .desc-section h4 { font-size: 16px; margin-bottom: 15px; color: #1e293b; }
    .desc-item {
      display: flex;
      justify-content: space-between;
      margin-bottom: 12px;
      font-size: 14px;
      transition: transform 0.2s ease;
    }
    .desc-item:hover { transform: translateX(2px); }
    .desc-item span:first-child { color: #64748b; }
    .desc-item span:last-child { color: #1e293b; font-weight: 600; }

    /* 🔹 Bottom Action Bar */
    .action-bar {
      position: fixed;
      bottom: 0; width: 100%;
      padding: 15px 20px;
      background: #fff;
      box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
      display: flex;
      align-items: center;
      justify-content: space-between;
      box-sizing: border-box;
      z-index: 100;
      animation: fadeInUp 0.4s ease 0.1s both;
    }

    .price-tag { font-size: 20px; font-weight: 700; color: #1e293b; }
    .price-tag small { font-size: 12px; color: #94a3b8; font-weight: 400; display: block; }

    .btn-main {
      background: var(--accent-black);
      color: white;
      border: none;
      padding: 14px 40px;
      border-radius: 12px;
      font-size: 16px;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-width: 150px;
    }

    .btn-main:hover {
      background: var(--accent-soft);
      box-shadow: 0 6px 14px rgba(0,0,0,0.18);
    }
    
    .btn-main:active { opacity: 0.8; transform: scale(0.96); }

    .btn-main:disabled {
      opacity: 0.75;
      cursor: not-allowed;
      transform: none;
    }

    /* 🔹 Loading Spinner */
    .btn-spinner {
      display: none;
      width: 16px;
      height: 16px;
      border: 2px solid rgba(255,255,255,0.4);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin 0.6s linear infinite;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .btn-main.is-loading .btn-spinner { display: inline-block; }
    .btn-main.is-loading .btn-label { opacity: 0.85; }
  </style>
</head>
<body>

  <div class="top-nav">
    <a href="javascript:history.back()"><i class="layui-icon layui-icon-left"></i></a>
    <div class="title">Product Details</div>
  </div>

  <div class="product-hero">
    <img src="{{ asset($package->photo) }}" alt="{{ $package->name }}">
  </div>

  <div class="content-box">
    <div class="header-info">
      <h1>{{ $package->name }}</h1>
      <div class="badge">Hot Products</div>
    </div>

    <div class="stats-grid">
      <div class="stat-card">
        <h3>{{ $package->validity }} Days</h3>
        <p>Cycle</p>
      </div>
      <div class="stat-card">
        <h3>{{ number_format($package->commission_with_avg_amount / $package->validity, 2) }}</h3>
        <p>Daily Income</p>
      </div>
      
    </div>

    <div class="desc-section">
      <h4>Investment Summary</h4>
      <div class="desc-item"><span>Product Name</span><span>{{ $package->name }}</span></div>
      <div class="desc-item"><span>Income Type</span><span>Daily Income 24 HRS</span></div>
      
    </div>
  </div>

  <div class="action-bar">
    <div class="price-tag">
      <small>Total Price</small>
      ₱{{ ($package->price) }}
    </div>
    
    <form method="POST" action="{{ route('purchase.confirmation', $package->id) }}" id="purchase-form">
        @csrf
        <button type="submit" class="btn-main" id="purchase-btn">
          <span class="btn-spinner"></span>
          <span class="btn-label">Buy Now</span>
        </button>
    </form>
  </div>

  @include('alert-message')

  <script>
    document.getElementById('purchase-form').addEventListener('submit', function () {
      var btn = document.getElementById('purchase-btn');
      if (btn.disabled) return; // prevent double submit
      btn.disabled = true;
      btn.classList.add('is-loading');
      btn.querySelector('.btn-label').textContent = 'PROCESSING...';
    });
  </script>

</body>
</html>
