<?php
require_once __DIR__ . '/../../api/lib.php';
hw_require_auth(['client']);
$authUser = hw_get_auth_user();

$page_title = 'Choose Your Wellness Plan | Herbal Wellness Care';
$page_description = 'Select a membership plan to access your wellness dashboard';
$page_content = function () use ($authUser) {
?>
<style>
  nav.fixed { display: none !important; }
  main.pt-20 { padding-top: 0 !important; }
  body { 
    background: linear-gradient(135deg, #f0f9f6 0%, #fef9e7 50%, #f9fafb 100%);
    background-attachment: fixed;
  }
</style>

<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px;">
  <div style="max-width: 1200px; width: 100%;">
    
    <!-- Header -->
    <div style="text-align: center; margin-bottom: 48px;">
      <div style="display: inline-block; background: linear-gradient(135deg, rgba(15, 82, 64, 0.1) 0%, rgba(212, 173, 49, 0.1) 100%); border: 1px solid rgba(15, 82, 64, 0.2); border-radius: 9999px; padding: 8px 20px; font-size: 13px; font-weight: 600; color: #0b3d2e; letter-spacing: 0.025em; text-transform: uppercase; margin-bottom: 24px;">
        <span style="width: 8px; height: 8px; background: #d4ad31; border-radius: 50%; display: inline-block; margin-right: 8px;"></span>
        Choose Your Plan
      </div>
      
      <h1 style="font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; color: #0f172a; margin: 0 0 16px 0; line-height: 1.1; background: linear-gradient(135deg, #0b3d2e 0%, #d4ad31 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">
        Start Your Wellness Journey
      </h1>
      
      <p style="font-size: 18px; color: #475569; max-width: 600px; margin: 0 auto;">
        Select a plan to unlock unlimited consultations, personalized care, and exclusive wellness benefits.
      </p>
    </div>

    <!-- Plans Grid -->
    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 32px; margin-bottom: 32px;">
      
      <!-- Personal Plan -->
      <div style="position: relative; background: rgba(255, 255, 255, 0.95); border-radius: 24px; padding: 40px; border: 2px solid #e5e7eb; transition: all 0.3s; backdrop-filter: blur(20px); overflow: hidden;">
        <div style="position: absolute; top: 0; left: 0; right: 0; height: 5px; background: linear-gradient(90deg, #0f5240, #146651);"></div>
        
        <div style="text-align: center; margin-bottom: 32px;">
          <div style="width: 80px; height: 80px; margin: 0 auto 20px; background: linear-gradient(135deg, #f0f9f6, #e6f3f0); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px;">
            👤
          </div>
          <h2 style="font-size: 28px; font-weight: 700; color: #0b3d2e; margin: 0 0 8px 0;">Personal</h2>
          <p style="color: #64748b; margin: 0;">Perfect for personal wellness</p>
        </div>
        
        <div style="text-align: center; margin-bottom: 32px;">
          <div style="font-size: 48px; font-weight: 800; color: #0f5240; line-height: 1;">
            $49
            <span style="font-size: 18px; font-weight: 600; color: #64748b;">/month</span>
          </div>
        </div>
        
        <ul style="list-style: none; padding: 0; margin: 0 0 32px 0; display: flex; flex-direction: column; gap: 16px;">
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #0f5240; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span><strong>Unlimited video consultations</strong></span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #0f5240; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Digital health records</span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #0f5240; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Store discounts (10%)</span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #0f5240; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Priority scheduling</span>
          </li>
        </ul>
        
        <button onclick="selectPlan('personal', 49)" style="width: 100%; background: #0f5240; color: white; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; border: none; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 12px rgba(15, 82, 64, 0.3);">
          Get Started
        </button>
      </div>
      
      <!-- Family Plan (Most Popular) -->
      <div style="position: relative; background: rgba(255, 255, 255, 0.95); border-radius: 24px; padding: 40px; border: 2px solid #d4ad31; transition: all 0.3s; backdrop-filter: blur(20px); overflow: hidden; box-shadow: 0 20px 40px rgba(212, 173, 49, 0.2);">
        <div style="position: absolute; top: 0; left: 0; right: 0; height: 5px; background: linear-gradient(90deg, #d4ad31, #c9a227);"></div>
        
        <!-- Popular Badge -->
        <div style="position: absolute; top: 20px; right: 20px; background: linear-gradient(135deg, #d4ad31, #c9a227); color: white; padding: 6px 16px; border-radius: 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;">
          Most Popular
        </div>
        
        <div style="text-align: center; margin-bottom: 32px;">
          <div style="width: 80px; height: 80px; margin: 0 auto 20px; background: linear-gradient(135deg, #fef9e7, #f9edd4); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px;">
            👨‍👩‍👧‍👦
          </div>
          <h2 style="font-size: 28px; font-weight: 700; color: #0b3d2e; margin: 0 0 8px 0;">Family</h2>
          <p style="color: #64748b; margin: 0;">Wellness for everyone</p>
        </div>
        
        <div style="text-align: center; margin-bottom: 32px;">
          <div style="font-size: 48px; font-weight: 800; color: #d4ad31; line-height: 1;">
            $99
            <span style="font-size: 18px; font-weight: 600; color: #64748b;">/month</span>
          </div>
          <div style="font-size: 13px; color: #10b981; font-weight: 600; margin-top: 8px;">
            💰 Save $293/year vs Personal plans
          </div>
        </div>
        
        <ul style="list-style: none; padding: 0; margin: 0 0 32px 0; display: flex; flex-direction: column; gap: 16px;">
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #d4ad31; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span><strong>Up to 8 family members</strong></span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #d4ad31; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span><strong>All Personal features</strong></span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #d4ad31; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Family wellness plans</span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #d4ad31; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Shared health dashboard</span>
          </li>
          <li style="display: flex; align-items: flex-start; gap: 12px; color: #334155; font-size: 15px;">
            <svg style="width: 24px; height: 24px; color: #d4ad31; flex-shrink: 0;" fill="currentColor" viewBox="0 0 20 20">
              <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
            </svg>
            <span>Enhanced store discounts (20%)</span>
          </li>
        </ul>
        
        <button onclick="selectPlan('family', 99)" style="width: 100%; background: linear-gradient(135deg, #d4ad31, #c9a227); color: white; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 700; border: none; cursor: pointer; transition: all 0.3s; box-shadow: 0 4px 12px rgba(212, 173, 49, 0.4);">
          Get Started
        </button>
      </div>
      
    </div>

    <!-- Trust Indicators -->
    <div style="background: rgba(255, 255, 255, 0.8); padding: 24px; border-radius: 16px; text-align: center; backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.5);">
      <div style="display: flex; justify-content: center; gap: 48px; flex-wrap: wrap;">
        <div style="display: flex; align-items: center; gap: 12px; color: #475569;">
          <i class="fas fa-shield-alt" style="font-size: 24px; color: #0f5240;"></i>
          <span style="font-size: 14px; font-weight: 600;">Secure Payment</span>
        </div>
        <div style="display: flex; align-items: center; gap: 12px; color: #475569;">
          <i class="fas fa-undo" style="font-size: 24px; color: #0f5240;"></i>
          <span style="font-size: 14px; font-weight: 600;">Cancel Anytime</span>
        </div>
        <div style="display: flex; align-items: center; gap: 12px; color: #475569;">
          <i class="fas fa-headset" style="font-size: 24px; color: #0f5240;"></i>
          <span style="font-size: 14px; font-weight: 600;">24/7 Support</span>
        </div>
      </div>
    </div>
    
  </div>
</div>

<script>
function selectPlan(planType, price) {
  const confirmed = confirm(`Subscribe to ${planType.charAt(0).toUpperCase() + planType.slice(1)} Plan for $${price}/month?\n\nYou'll be redirected to complete payment.`);
  
  if (confirmed) {
    // For now, simulate activation (in production, integrate with payment gateway)
    activatePlan(planType, price);
  }
}

async function activatePlan(planType, price) {
  try {
    // Show loading
    document.body.style.cursor = 'wait';
    
    // Simulate payment and activation
    const response = await fetch('/files/atasteofafricanmarketplace/api/membership/activate.php', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      credentials: 'include',
      body: JSON.stringify({
        plan_type: planType,
        amount: price,
        payment_method: 'demo',
        paypal_order_id: 'DEMO_' + Date.now(),
        paypal_payment_id: 'PAY_DEMO_' + Math.random().toString(36).substr(2, 9)
      })
    });
    
    const result = await response.json();
    
    if (result.success) {
      alert('🎉 Welcome to the ' + planType.charAt(0).toUpperCase() + planType.slice(1) + ' Plan!\n\nYour membership has been activated. Redirecting to your dashboard...');
      window.location.href = '/files/atasteofafricanmarketplace/dashboard/user/index.php';
    } else {
      alert('Error: ' + (result.message || 'Failed to activate membership. Please try again.'));
    }
  } catch (error) {
    alert('Network error. Please check your connection and try again.');
  } finally {
    document.body.style.cursor = 'default';
  }
}
</script>

<?php };
include __DIR__ . '/../../partials/layout.php';
?>
