<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>Cro | Team</title>

<link rel="stylesheet" href="/static/home/layui/css/layui.css">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<style>
    /* -----------------------------------
   GENERAL RESET
----------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  background: #f4f7ff;
  color: #333;
  padding-bottom: 90px; /* space for footer if any */
}

/* -----------------------------------
   TOP BAR
----------------------------------- */
.top {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  background: #03316C;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  gap: 12px;
}

.top a.topLeft {
  color: #fff;
  font-size: 18px;
  text-decoration: none;
}

/* -----------------------------------
   INVITE BOX
----------------------------------- */
.invite-box {
  background: #fff;
  margin: 15px;
  padding: 15px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}

.invite-title {
  font-size: 16px;
  font-weight: 700;
  color: #03316C;
  margin-bottom: 12px;
}

/* Fix Invite Box Rows */
.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.invite-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #dce8ff;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
  background: #f4f7ff;
  min-width: 0; /* important for flex shrink on small screens */
}

.invite-row button.copy-btn {
  flex-shrink: 0; /* prevent shrinking */
  padding: 10px 12px;
  background: #03316C;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap; /* keep icon + text together */
}

.invite-row button.copy-btn i {
  font-size: 14px;
}


/* -----------------------------------
   TEAM STATS
----------------------------------- */
/* TEAM STATS - side by side boxes */
.team-totalNum {
  display: flex;
  justify-content: space-between;
  margin: 15px;
  gap: 12px; /* space between left and right box */
}

.team-stat {
  flex: 1;
  background: #fff;
  padding: 15px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  text-align: center;
}

.team-stat dl {
  margin: 0;
}

.team-stat dd {
  font-size: 18px;
  font-weight: 700;
  color: #03316C;
}

.team-stat dt {
  font-size: 12px;
  color: #4a4a4a;
}


/* -----------------------------------
   TABS
----------------------------------- */
.team-tab, .record-tab {
  display: flex;
  background: #dce8ff;
  margin: 15px;
  border-radius: 30px;
  padding: 5px;
}

.team-tab a, .record-tab a {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: #4a4a4a;
  border-radius: 22px;
  text-decoration: none;
  transition: 0.3s;
}

.team-tab a.active, .record-tab a.active {
  background: #03316C;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
/* Premium Tab Styling */
.team-tab.premium-tab {
  display: flex;
  justify-content: center;
  margin: 15px;
  border-radius: 30px;
  background: #dce8ff;
  padding: 5px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.team-tab.premium-tab a {
  flex: 1;
  text-align: center;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  color: #4a4a4a;
  border-radius: 25px;
  text-decoration: none;
  transition: 0.3s;
  background: transparent;
}

.team-tab.premium-tab a.active {
  background: linear-gradient(90deg, #03316C, #0057D9);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

/* -----------------------------------
   TEAM CARDS
----------------------------------- */
.teamList {
  display: flex;
  flex-direction: column;
  align-items: center; /* center cards horizontally */
  padding: 20px 0;
}

.team-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-bottom: 15px;
  width: 320px; /* fixed card width */
  overflow: hidden;
  border-left: 4px solid #03316C;
  transition: transform 0.2s;
}

.team-card:hover {
  transform: translateY(-4px);
}

.team-card.unrecharge-member {
  opacity: 0.8;
  border-left-color: #ccc;
}

.team-card-section {
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: #333;
}

.team-card-section:last-child {
  border-bottom: none;
}

/* Phone circle */
.phone-section .country-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #03316C;
  color: #fff;
  font-weight: 700;
  margin-right: 8px;
}

.phone-section .team-phone {
  font-weight: 600;
  color: #03316C;
}

/* Referrer, Income, Join styling */
.ref-section span,
.income-section span,
.join-section span {
  font-weight: 600;
  color: #0057D9;
}


/* Active / Unrecharge styles */
.active-member {
  border-left: 4px solid #03316C;
}

.unrecharge-member {
  opacity: 0.8;
}
.products-heading {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  margin: 20px 0;
  position: relative;
}

/* हल्की ऊपर की छाया */
.products-heading::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -6px;
  width: 80px;
  height: 6px;
  background: rgba(0, 0, 0, 0.15);
  filter: blur(6px);
  border-radius: 50%;
}
     /* -----------------------------------
   FOOTER MENU
----------------------------------- */
/* Footer Menu */
.footer-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #ffffff;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  z-index: 100;
}

.footer-menu a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: #4a4a4a;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: 0.25s;
}

.footer-menu a .icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.25s;
}

/* Active Tab */
.footer-menu a.active .icon-box {
  background: #03316C; /* Blue background for active */
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.footer-menu a i {
  font-size: 20px;
}

.footer-menu a.active i {
  color: #fff;
}

.footer-menu a span {
  font-size: 12px;
}

.footer-menu a.active span {
  color: #03316C; /* Optional: highlight text if needed */
}

</style>

</head>

<body>

<h2 class="products-heading">Team Program</h2>

<div class="team-main">

  <!-- INVITE SECTION -->
  <div class="invite-box">
    <h3 class="invite-title">Invite & Earn</h3>
    <div class="invite-row">
      <input type="text" readonly id="ref_id" value="{{ auth()->user()->ref_id }}">
      <button class="copy-btn" data-copy="ref_id"><i class="fa fa-copy"></i></button>
    </div>
    <div class="invite-row">
      <input type="text" readonly id="invite_link" value="{{ route('register', ['inviteCode' => auth()->user()->ref_id]) }}">
      <button class="copy-btn" data-copy="invite_link"><i class="fa fa-link"></i></button>
    </div>
  </div>

  <!-- TEAM STATS -->
<div class="team-totalNum">
  <div class="team-stat">
    <dl>
      <dd>{{ $team_size }}</dd>
      <dt>Team Size</dt>
    </dl>
  </div>
  <div class="team-stat">
    <dl>
      <dd>{{ price($totalDeposit1 + $totalDeposit2 + $totalDeposit3) }}</dd>
      <dt>Total Recharge</dt>
    </dl>
  </div>
</div>


<div class="team-tab premium-tab">
  <a href="javascript:void(0)" class="active" data-tab="unrecharge-member">Team Program</a>
</div>


  <div class="record-tab">
    <a href="javascript:void(0)" class="active" data-team="b">Team A</a>
    <a href="javascript:void(0)" data-team="c">Team B</a>
    <a href="javascript:void(0)" data-team="d">Team C</a>
  </div>

<div class="teamList">
  <div id="team-cards">

    {{-- First Level --}}
    @foreach($first_level_users as $u)
    <div class="team-card {{ $u->is_active ? 'active-member' : 'unrecharge-member' }}" data-team="b">
      <div class="team-card-section phone-section">
        <span class="country-code">+60</span>
        <span class="team-phone">{{ $u->phone }}</span>
      </div>
      <div class="team-card-section ref-section">
        Referrer: <span>{{ auth()->user()->name }}</span>
      </div>
      <div class="team-card-section income-section">
        Income: <span>+{{ price($u->total_income ?? 0) }}</span>
      </div>
      <div class="team-card-section join-section">
        Joined: <span>{{ $u->created_at->format('Y-m-d H:i') }}</span>
      </div>
    </div>
    @endforeach

    {{-- Second Level --}}
    @foreach($second_level_users as $u)
    <div class="team-card {{ $u->is_active ? 'active-member' : 'unrecharge-member' }}" data-team="c">
      <div class="team-card-section phone-section">
        <span class="country-code">+60</span>
        <span class="team-phone">{{ $u->phone }}</span>
      </div>
      <div class="team-card-section ref-section">
        Referrer: <span>{{ $u->ref_by_user->name ?? 'N/A' }}</span>
      </div>
      <div class="team-card-section income-section">
        Income: <span>+{{ price($u->total_income ?? 0) }}</span>
      </div>
      <div class="team-card-section join-section">
        Joined: <span>{{ $u->created_at->format('Y-m-d H:i') }}</span>
      </div>
    </div>
    @endforeach

    {{-- Third Level --}}
    @foreach($third_level_users as $u)
    <div class="team-card {{ $u->is_active ? 'active-member' : 'unrecharge-member' }}" data-team="d">
      <div class="team-card-section phone-section">
        <span class="country-code">+60</span>
        <span class="team-phone">{{ $u->phone }}</span>
      </div>
      <div class="team-card-section ref-section">
        Referrer: <span>{{ $u->ref_by_user->name ?? 'N/A' }}</span>
      </div>
      <div class="team-card-section income-section">
        Income: <span>+{{ price($u->total_income ?? 0) }}</span>
      </div>
      <div class="team-card-section join-section">
        Joined: <span>{{ $u->created_at->format('Y-m-d H:i') }}</span>
      </div>
    </div>
    @endforeach

  </div>
</div>


</div>
<br>
<br>
<!-- Bottom Menu Footer -->
<div class="footer-menu">
  <a href="/dashboard" >
    <div class="icon-box">
      <i class="fa-solid fa-house"></i>
    </div>
    <span>Home</span>
  </a>
  <a href="/product">
    <div class="icon-box">
      <i class="fa-solid fa-bag-shopping"></i>
    </div>
    <span>Products</span>
  </a>
  <a href="/my-team"  class="active">
    <div class="icon-box">
      <i class="fa-solid fa-users"></i>
    </div>
    <span>Team</span>
  </a>
  <a href="/my-profile">
    <div class="icon-box">
      <i class="fa-solid fa-user"></i>
    </div>
    <span>Mine</span>
  </a>
</div>

<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">



<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(function(){

  function filterCards(){
    let memberType = $(".team-tab a.active").data("tab");
    let teamType = $(".record-tab a.active").data("team");

    $(".team-card").hide();
    $(".team-card." + memberType + "[data-team='" + teamType + "']").fadeIn(200);
  }

  // Tab switching
  $(".team-tab a").on("click", function(){
    $(this).addClass("active").siblings().removeClass("active");
    filterCards();
  });

  $(".record-tab a").on("click", function(){
    $(this).addClass("active").siblings().removeClass("active");
    filterCards();
  });

  // Copy buttons
  $(".copy-btn").on("click", function(){
    let inputId = $(this).data("copy");
    let text = $("#" + inputId).val();
    navigator.clipboard.writeText(text);
    alert("Copied: " + text);
  });

  // Default tab set — Active Members of Team A only
  $(".team-tab a[data-tab='active-member']").addClass("active").siblings().removeClass("active");
  $(".record-tab a[data-team='b']").addClass("active").siblings().removeClass("active");

  filterCards(); // initial filter
});
</script>

</body>
</html>
