<?php
include 'header.php';
?>


<!-- Main Content Wrapper -->
<main class="main-content w-full px-[var(--margin-x)] pb-8">
      <div class="mt-4 grid grid-cols-12 gap-4 sm:mt-5 sm:gap-5 lg:mt-6 lg:gap-6">
        <div class=" col-span-12">

          <!-- TradingView Widget BEGIN -->
          <div class="tradingview-widget-container ">
            <div class="tradingview-widget-container__widget "></div>

            <script type="text/javascript"
              src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async>
                {
                  "symbols": [
                    {
                      "proName": "FOREXCOM:SPXUSD",
                      "title": "S&P 500"
                    },
                    {
                      "proName": "FOREXCOM:NSXUSD",
                      "title": "US 100"
                    },
                    {
                      "proName": "FX_IDC:EURUSD",
                      "title": "EUR/USD"
                    },
                    {
                      "proName": "BITSTAMP:BTCUSD",
                      "title": "Bitcoin"
                    },
                    {
                      "proName": "BITSTAMP:ETHUSD",
                      "title": "Ethereum"
                    }
                  ],
                    "showSymbolLogo": true,
                      "colorTheme": "dark",
                        "isTransparent": false,
                          "displayMode": "regular",
                            "locale": "en"
                }
              </script>
          </div>
          <!-- TradingView Widget END -->

        </div>
      </div>
      <div class="mt-4 grid grid-cols-12 gap-4 sm:mt-5 sm:gap-5 lg:mt-6 lg:gap-6">

        <div class="col-span-12 space-y-4 sm:space-y-5 lg:col-span-8 lg:space-y-6">
          <div class="col-span-12 lg:col-span-8">

            <div class="card bg-gradient-to-br from-blue-500 to-indigo-600 px-4 pb-4 sm:px-5">

              <div class="flex items-center justify-between py-3 text-white">
                <h2 class="text-sm+ font-medium tracking-wide">Welcome Back, <?=ucfirst($fname)?>! </h2>
                <div x-data="usePopper({placement:'bottom-end',offset:4})"
                  @click.outside="if(isShowPopper) isShowPopper = false" class="inline-flex">
                  <button x-ref="popperRef" @click="isShowPopper = !isShowPopper"
                    class="btn -mr-1.5 h-8 w-8 rounded-full p-0 hover:bg-white/20 focus:bg-white/20 active:bg-white/25">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
                      stroke="currentColor" stroke-width="2">
                      <path stroke-linecap="round" stroke-linejoin="round"
                        d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z">
                      </path>
                    </svg>
                  </button>

                </div>
              </div>
              <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-5 lg:gap-6">
                <div>
                  <div class="flex w-9/12 items-center space-x-1">
                    <p class="text-xs text-indigo-100 ">
                      Available Balance
                    </p>

                  </div>
                  <div class="mt-3 text-3xl font-semibold text-white">
                    $<?=number_format($balance)?>
                  </div>
                  <p class="mt-3 text-xs+ text-indigo-100"><?php echo number_format( getCryptoValueByShortCode("BTC", $balance),4) ; ?> BTC</p>
                </div>

                <div class="grid grid-cols-3 gap-4 sm:gap-5 lg:gap-6">
                  <div>


                    <div x-data="{showModal:false}">
                      <button @click="showModal = true"
                        class="btn mt-3 w-full border border-white/10 bg-white/20 text-white hover:bg-white/30 focus:bg-white/30">

                        <span> Deposit </span>
                      </button>






                      <template x-teleport="#x-teleport-target">
                        <div
                          class="fixed inset-0 z-[100] flex flex-col items-center backdrop-blur justify-center overflow-hidden px-4 py-6 sm:px-5"
                          x-show="showModal" role="dialog" @keydown.window.escape="showModal = false">
                          <div class="absolute inset-0 bg-slate-900/60 transition-opacity duration-300"
                            @click="showModal = false" x-show="showModal" x-transition:enter="ease-out"
                            x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100"
                            x-transition:leave="ease-in" x-transition:leave-start="opacity-100"
                            x-transition:leave-end="opacity-0"></div>
                          <div
                            class="relative w-full max-w-lg origin-top rounded-lg bg-white transition-all duration-300 dark:bg-navy-700"
                            x-show="showModal" x-transition:enter="easy-out"
                            x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100"
                            x-transition:leave="easy-in" x-transition:leave-start="opacity-100 scale-100"
                            x-transition:leave-end="opacity-0 scale-95">
                            <div
                              class="flex justify-between rounded-t-lg bg-slate-200 px-4 py-3 dark:bg-navy-800 sm:px-5">
                              <h3 class="text-base font-medium text-slate-700 dark:text-navy-100">
                                Deposit Funds
                              </h3>
                              <button @click="showModal = !showModal"
                                class="btn -mr-1.5 h-7 w-7 rounded-full p-0 hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-4.5 w-4.5" fill="none"
                                  viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
                                  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
                                </svg>
                              </button>
                            </div>
                            <div class="px-4 py-4 sm:px-5">



                              <form action="deposit.php" method="post">
                                <div class="mt-4 space-y-4">

                                  <label class="block">
                                    <span>Enter Amount ($)</span>
                                    <input
                                      class="form-input mt-1.5 h-12 w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
                                      placeholder="Enter Amount" required type="number" name="amount" />
                                  </label>

                                  <label class="block">
                                    <span>Select Payment Method</span>
                                    <select
                                      class="form-select mt-1.5 w-full rounded-lg border border-slate-300 bg-white px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent"
                                      name="dtype">
                                      <?php 
                                        foreach ($payMethods as $name => $address) {
                                      ?>
                                        <option value="<?php echo $name ?>"><?php echo $name ?></option>
                                    <?php } ?>
                                    </select>
                                  </label>


                                  <div class="space-x-2 text-right">
                                    <button @click="showModal = false"
                                      class="btn min-w-[7rem] rounded-full border border-slate-300 font-medium text-slate-800 hover:bg-slate-150 focus:bg-slate-150 active:bg-slate-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90">
                                      Close
                                    </button>
                                    <button @click="showModal = false"
                                      class="btn min-w-[7rem] rounded-full bg-primary font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
                                      type="submit" name="sub-upd">
                                      Proceed to Payment
                                    </button>
                                  </div>

                                </div>
                              </form>
                            </div>
                          </div>
                        </div>
                      </template>
                    </div>
                  </div>
                  <div>


                    <a href="investment.php"
                      class="btn mt-3 w-full border border-white/10 bg-white/20 text-white hover:bg-white/30 focus:bg-white/30">
                      Invest
                    </a>
                  </div>
                  <div>

                    <a href="withdrawal.php"
                      class="btn mt-3 w-full border border-white/10 bg-white/20 text-white hover:bg-white/30 focus:bg-white/30">
                      Withdraw
                    </a>
                  </div>
                </div>
              </div>
              <div class="absolute bottom-0 right-0 overflow-hidden rounded-lg">
                <img class="w-12 translate-x-1/4 translate-y-1/4 opacity-50" src="images/illustrations/the-dollar.svg"
                  alt="image">
              </div>
            </div>

            <div class="mt-6 grid grid-cols-3 gap-4 sm:grid-cols-3 sm:gap-5 lg:gap-6">
              <div class="card p-4 sm:p-5">
                <div
                  class="flex h-9 w-9 items-center justify-center rounded-lg bg-primary shadow-xl shadow-primary/50 dark:bg-accent dark:shadow-accent/50">
                  <i class="fa fa-dollar-sign text-md text-white"></i>
                </div>

                <p class="mt-6">Total Profit</p>
                <p class="mt-2 font-medium text-slate-700 dark:text-navy-100">
                  <span class="text-xl">$<?php echo number_format($profit, 2) ?></span>
                </p>
                <div x-data="{showModal:false}">
                  <button @click="showModal = true"
                    class="btn mt-1 px-4 text-xs+ font-medium  bg-info/10 font-medium text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25">

                    <span><i class="fa fa-exchange" aria-hidden="true"></i>
                      Transfer Funds </span>
                  </button>






                  <template x-teleport="#x-teleport-target">
                    <div
                      class="fixed inset-0 z-[100] flex flex-col items-center backdrop-blur justify-center overflow-hidden px-4 py-6 sm:px-5"
                      x-show="showModal" role="dialog" @keydown.window.escape="showModal = false">
                      <div class="absolute inset-0 bg-slate-900/60 transition-opacity duration-300"
                        @click="showModal = false" x-show="showModal" x-transition:enter="ease-out"
                        x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100"
                        x-transition:leave="ease-in" x-transition:leave-start="opacity-100"
                        x-transition:leave-end="opacity-0"></div>
                      <div
                        class="relative w-full max-w-lg origin-top rounded-lg bg-white transition-all duration-300 dark:bg-navy-700"
                        x-show="showModal" x-transition:enter="easy-out" x-transition:enter-start="opacity-0 scale-95"
                        x-transition:enter-end="opacity-100 scale-100" x-transition:leave="easy-in"
                        x-transition:leave-start="opacity-100 scale-100" x-transition:leave-end="opacity-0 scale-95">
                        <div class="flex justify-between rounded-t-lg bg-slate-200 px-4 py-3 dark:bg-navy-800 sm:px-5">
                          <h3 class="text-base font-medium text-slate-700 dark:text-navy-100">
                            Transfer Profits to <span
                              class="bg-gradient-to-r from-fuchsia-600 to-pink-600 bg-clip-text text-lg font-semibold text-transparent">
                              Available Balance
                            </span>
                          </h3>
                          <button @click="showModal = !showModal"
                            class="btn -mr-1.5 h-7 w-7 rounded-full p-0 hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25">
                            <svg xmlns="http://www.w3.org/2000/svg" class="h-4.5 w-4.5" fill="none" viewBox="0 0 24 24"
                              stroke="currentColor" stroke-width="2">
                              <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
                            </svg>
                          </button>
                        </div>
                        <div class="px-4 py-4 sm:px-5">



                          <form action="" method="post">
                            <div class="mt-4 space-y-4">

                              <h3 class="text-md font-semibold"><span
                                  class="btn h-10 px-4 text-sm font-semibold bg-primary/10 font-medium text-primary hover:bg-primary/20 focus:bg-primary/20 active:bg-primary/25">
                                  Total Profits - $<?=$profit?> </span></h3>

                              <label class="block">
                                <span>Enter Amount to transfer </span>

                                <input
                                  class="form-input mt-1.5 h-12 w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
                                  placeholder="Enter Amount" type="number" name="profit1" />
                              </label>



                              <div class="space-x-2 text-right">
                                <button @click="showModal = false"
                                  class="btn min-w-[7rem] rounded-full border border-slate-300 font-medium text-slate-800 hover:bg-slate-150 focus:bg-slate-150 active:bg-slate-150/80 dark:border-navy-450 dark:text-navy-50 dark:hover:bg-navy-500 dark:focus:bg-navy-500 dark:active:bg-navy-500/90">
                                  Close
                                </button>
                                <button @click="showModal = false"
                                  class="btn min-w-[7rem] rounded-full bg-primary font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
                                  type="submit" name="sub-trf">
                                  Submit
                                </button>
                              </div>

                            </div>
                          </form>
                        </div>
                      </div>
                    </div>
                  </template>
                </div>
              </div>

              <div class="card p-4 sm:p-5">
                <div class="flex h-9 w-9 items-center justify-center rounded-lg bg-info shadow-xl shadow-info/50">
                  <i class="fa fa-coins text-md text-white"></i>
                </div>
                <p class="mt-6">Referral Bonus</p>
                <p class="mt-2 font-medium text-slate-700 dark:text-navy-100">
                  <span class="text-xl">$<?=number_format($ref_balance,2)?></span>
                </p>
                <p class="mt-1 flex items-center text-xs text-success">
                  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-success" fill="none" viewBox="0 0 24 24"
                    stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                      d="M7 11l5-5m0 0l5 5m-5-5v12" />
                  </svg>
                  <span>7.11%</span>
                </p>
              </div>
              <div class="card p-4 sm:p-5">
                <div
                  class="flex h-9 w-9 items-center justify-center rounded-lg bg-secondary shadow-xl shadow-secondary/50">
                  <i class="fa fa-coins text-md text-white"></i>
                </div>

                <p class="mt-6">Total Deposit</p>
                <p class="mt-2 font-medium text-slate-700 dark:text-navy-100">
                  <span class="text-xl">$<?php echo number_format($total_deposit,2) ?></span>
                </p>
                <p class="mt-1 flex items-center text-xs text-success">
                  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-success" fill="none" viewBox="0 0 24 24"
                    stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                      d="M7 11l5-5m0 0l5 5m-5-5v12" />
                  </svg>
                  <span>8.34%</span>
                </p>
                <p class="mt-6">Live Traders</p>
                <p class="mt-2 font-medium text-slate-700 dark:text-navy-100">
                  <span class="text-xl">$5000.00</span>
                </p>
                <p class="mt-1 flex items-center text-xs text-success">
                  <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-success" fill="none" viewBox="0 0 24 24"
                    stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                      d="M7 11l5-5m0 0l5 5m-5-5v12" />
                  </svg>
                  <span>61.38%</span>
                </p>
              </div>

            </div>

            <div class="mt-6  col-span-12 lg:col-span-8">
              <div class="space-y-4">

                <?php
                    if($status == "Not Verified"){
                ?>
                <div x-data="{isShow:true}" :class="!isShow && 'opacity-0 transition-opacity duration-300'"
                  class="alert flex items-center justify-between overflow-hidden rounded-lg border bg-warning/15 dark:bg-warning-light/15 border-warning text-warning">
                  <div class="flex">

                    <div class="px-4 py-3 sm:px-5"><b><i class="fa fa-exclamation-circle" aria-hidden="true"></i>
                        KYC Status -</b> <a class="ml-1" href="profile.php?active=kyc"
                        class="text-md font-semibold mt-4"><span
                          class="btn h-10 px-4 text-sm font-semibold bg-warning/10 font-medium dark:text-navy-100 hover:bg-warning/20 focus:bg-warning/20 active:bg-warning/25">
                          <?php echo $status ?> </span></a></div>
                  </div>
                  <div class="px-2">
                    <button @click="isShow = false; setTimeout(()=>$root.remove(),300)"
                      class="btn h-7 w-7 rounded-full p-0 font-medium text-warning hover:bg-warning/20 focus:bg-warning/20 active:bg-warning/25">
                      <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"
                        stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M6 18L18 6M6 6l12 12" />
                      </svg>
                    </button>
                  </div>
                </div>
                <?php } ?>

                <?php
                    if($status == "submitted"){
                ?>
                <div x-data="{isShow:true}" :class="!isShow && 'opacity-0 transition-opacity duration-300'"
                  class="alert flex items-center justify-between overflow-hidden rounded-lg border bg-primary/15 dark:bg-primary-light/15 border-primary text-primary">
                  <div class="flex">

                    <div class="px-4 py-3 sm:px-5"><b><i class="fa fa-exclamation-circle" aria-hidden="true"></i>
                        KYC Status -</b> <a class="ml-1" href="profile.php?active=kyc"
                        class="text-md font-semibold mt-4"><span
                          class="btn h-10 px-4 text-sm font-semibold bg-primary/10 font-medium dark:text-navy-100 hover:bg-primary/20 focus:bg-primary/20 active:bg-primary/25">
                          Submitted </span></a></div>
                  </div>
                  <div class="px-2">
                    <button @click="isShow = false; setTimeout(()=>$root.remove(),300)"
                      class="btn h-7 w-7 rounded-full p-0 font-medium text-warning hover:bg-primary/20 focus:bg-primary/20 active:bg-primary/25">
                      <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"
                        stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M6 18L18 6M6 6l12 12" />
                      </svg>
                    </button>
                  </div>
                </div>
                <?php } ?>

                <?php
                    if($status == "Verified"){
                ?>
                <div x-data="{isShow:true}" :class="!isShow && 'opacity-0 transition-opacity duration-300'"
                  class="alert flex items-center justify-between overflow-hidden rounded-lg border bg-success/15 dark:bg-success-light/15 border-success text-success">
                  <div class="flex">

                    <div class="px-4 py-3 sm:px-5"><b><i class="fa fa-exclamation-circle" aria-hidden="true"></i>
                        KYC Status -</b> <a class="ml-1" href="profile.php?active=kyc"
                        class="text-md font-semibold mt-4"><span
                          class="btn h-10 px-4 text-sm font-semibold bg-success/10 font-medium dark:text-navy-100 hover:bg-success/20 focus:bg-success/20 active:bg-success/25">
                          <?php echo $status ?> </span></a></div>
                  </div>
                  <div class="px-2">
                    <button @click="isShow = false; setTimeout(()=>$root.remove(),300)"
                      class="btn h-7 w-7 rounded-full p-0 font-medium text-warning hover:bg-success/20 focus:bg-success/20 active:bg-success/25">
                      <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"
                        stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                          d="M6 18L18 6M6 6l12 12" />
                      </svg>
                    </button>
                  </div>
                </div>
                <?php } ?>

                




              </div>




            </div>





          </div>


        </div>





        <div class="col-span-12 lg:col-span-4">
          <div class="grid grid-cols-1 gap-4 sm:grid-cols-1 sm:gap-5 lg:grid-cols-1 lg:gap-6">

            <div class="card space-y-6 p-4 sm:px-5">
              <div class="flex items-center justify-between">
                <div>
                  <p class="text-md font-semibold  text-primary dark:text-accent-light">
                    Ongoing Investment
                  </p>
                </div>

              </div>
              <?php 
                $query = mysqli_query($link, "SELECT * FROM investments WHERE status = 'running' AND userId = '$userId' ORDER BY id DESC LIMIT 1 ");
                if(mysqli_num_rows($query) > 0){
                    $dat = mysqli_fetch_assoc($query);
                    $amt = $dat['invest_amt'];
                    $date = date("D, j M Y", strtotime($dat['date']));
                    $total_profit = $dat['total_profit'];
                    $plan_name = $dat['plan_name'];

                    $start_date = $dat['start_date'];
                    $end_date = $dat['end_date'];
                    $current_date = date("d-m-Y h:i:s"); 
                    
                    $inv = 1;

                }else{
                    $plan_name = "...";
                    $amt = 0;
                    $date = "...";
                    $total_profit = 0;
                    
                    $inv = 0;
                }

              ?>
              <div>
                <p class="text-xs uppercase">Investment Plan</p>
                <p class="text-base font-medium text-success"><?php echo $plan_name ?> </p>
              </div>
              <div class="grid grid-cols-2">
                <div>
                  <p class="text-xs+ text-slate-400 dark:text-navy-300">
                    Amount
                  </p>
                  <p class="text-lg font-semibold text-slate-700 dark:text-navy-100">
                    $<?php echo $amt ?> </p>
                </div>
                <div>
                  <p class="text-xs+ text-slate-400 dark:text-navy-300">
                    Date
                  </p>
                  <p class="text-lg font-semibold text-slate-700 dark:text-navy-100">
                  <?php echo $date ?> </p>
                </div>
                <div class="mt-4">
                  <p class="text-xs+ text-slate-400 dark:text-navy-300">
                    Profit
                  </p>
                  <p class="text-lg font-semibold text-slate-700 dark:text-navy-100">
                    $<?php echo $total_profit ?> </p>
                </div>
              </div>
              <div class="space-y-3">


            <?php
                $start_timestamp = strtotime($start_date);
                $end_timestamp = strtotime($end_date);
                $current_timestamp = strtotime($current_date);

                $total_duration = ($end_timestamp - $start_timestamp) / (60 * 60 * 24);

                $elapsed_days = ($current_timestamp - $start_timestamp) / (60 * 60 * 24);
                $elapsed_days = max(0, $elapsed_days); 

                $progress_percentage = ($elapsed_days / $total_duration) * 100;
                $progress_percentage = min(100, max(0, $progress_percentage)); 

            ?>


                <?php 
                    if($inv == 0){
                ?>
                <div class="progress mt-1 h-3.5 bg-secondary dark:bg-navy-500 mb-4">
                    <div
                        class="is-active relative w-0/12 overflow-hidden rounded-full bg-gradient-to-br from-blue-500 to-indigo-600">
                    </div>
                </div>
                <?php } ?>
                <?php 
                    if($inv == 1){
                ?>
                <div class="progress mt-1 h-3.5 bg-secondary dark:bg-navy-500 mb-4">
                    <div
                        class="is-active relative overflow-hidden rounded-full bg-gradient-to-br from-blue-500 to-indigo-600"
                        style="width: <?php echo $progress_percentage; ?>%;">
                    </div>
                </div>
                <?php } ?>

              </div>
              <div class="flex flex-wrap space-x-2 mb-4">
                <div class="badge bg-info/10 text-info dark:bg-info/15">
                  Transc: ...
                </div>

              </div>

              <div class="absolute bottom-0 right-0 overflow-hidden rounded-lg opacity-50 ">
                <img class="w-32 translate-x-1/4 translate-y-1/4 opacity-50" src="images/illustrations/crypto.svg"
                  alt="image">
              </div>

              <div class="mt-2s">


              </div>
            </div>



          </div>
        </div>
      </div>

      <div class="mt-2 grid lg:grid-cols-3 gap-4 sm:grid-cols-1 sm:gap-5 lg:gap-6">

        <div class=" card col-span-1 lg:col-span-2">
          <div class="mt-3 flex flex-col justify-between px-4 sm:flex-row sm:items-center sm:px-5">
            <div class="flex flex-1 items-center justify-between space-x-2 sm:flex-initial">
              <h2 class="text-sm+ font-medium tracking-wide text-slate-700 dark:text-navy-100"> Chart Overview </h2>

            </div>
            <div class="hidden space-x-2 sm:flex" x-data="{activeTab:'tabYearly'}">

              <button @click="activeTab = 'tabYearly'" class="btn h-8 rounded-full text-xs+ font-medium"
                :class="activeTab === 'tabYearly' ? 'bg-primary/10 text-primary dark:bg-accent-light/10 dark:text-accent-light' : 'hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 hover:text-slate-800 focus:text-slate-800 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25 dark:hover:text-navy-100 dark:focus:text-navy-100'">
                #BTCUSD
              </button>
            </div>
          </div>

          <!-- TradingView Widget BEGIN -->
          <div class="tradingview-widget-container px-2 py-2 ">
            <div style="height: 400px;" class="rounded-md" id="tradingview_da309"></div>

            <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
            <script type="text/javascript">
              new TradingView.widget(
                {
                  "autosize": true,
                  "symbol": "COINBASE:BTCUSD",
                  "interval": "1",
                  "timezone": "Etc/UTC",
                  "theme": "dark",
                  "style": "2",
                  "locale": "en",
                  "toolbar_bg": "#f1f3f6",
                  "enable_publishing": false,
                  "save_image": false,

                  "container_id": "tradingview_da309"
                }
              );
            </script>
          </div>
          <!-- TradingView Widget END -->


        </div>




        <div class="card px-2 pb-4 sm:px-3">
          <div class="my-3 flex h-8 items-center justify-between">
            <h2 class="font-medium tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base">
              #Latest Updates
            </h2>

          </div>



          <div class="py-1 px-1">



            <div class="tradingview-widget-container" style="width: 100%; height: 400px;">
              <iframe scrolling="yes" allowtransparency="false" frameborder=""
                src="https://s.tradingview.com/embed-widget/timeline/?locale=en#%7B%22colorTheme%22%3A%22light%22%2C%22isTransparent%22%3Atrue%2C%22displayMode%22%3A%22regular%22%2C%22width%22%3A%22100%25%22%2C%22height%22%3A%22500%22%2C%22utm_source%22%3A%22localhost%22%2C%22utm_medium%22%3A%22widget%22%2C%22utm_campaign%22%3A%22timeline%22%7D"
                style="box-sizing: border-box; height: 400px; width: 100%; border-radius: 5px; color: red;"></iframe>


              <style>
                .tradingview-widget-copyright {
                  font-size: 13px !important;
                  line-height: 32px !important;
                  text-align: center !important;
                  vertical-align: middle !important;
                  /* @mixin sf-pro-display-font; */
                  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif !important;
                  color: #9db2bd !important;
                }

                .tradingview-widget-copyright .blue-text {
                  color: #2962FF !important;
                }

                .tradingview-widget-copyright a {
                  text-decoration: none !important;
                  color: #9db2bd !important;
                }

                .tradingview-widget-copyright a:visited {
                  color: #9db2bd !important;
                }

                .tradingview-widget-copyright a:hover .blue-text {
                  color: #1E53E5 !important;
                }

                .tradingview-widget-copyright a:active .blue-text {
                  color: #1848CC !important;
                }

                .tradingview-widget-copyright a:visited .blue-text {
                  color: #2962FF !important;
                }
              </style>
            </div>




          </div>

        </div>


      </div>


      <div class="mt-4 grid lg:grid-cols-3 gap-4 sm:grid-cols-1 sm:gap-5 lg:gap-6">

        <div class="card px-4 py-4 col-span-2 sm:px-4 ">
          <div class="flex items-center justify-between ">
            <h2 class="font-medium tracking-wide text-slate-700 dark:text-navy-100">
              Pending Transactions
            </h2>


          </div>
          <div x-data="{activeTab:'tabHome'}" class="tabs items-center flex flex-col">
            <div class="is-scrollbar-hidden overflow-x-auto">
              <div class="border-b-2 border-slate-150 dark:border-navy-500">
                <div class="tabs-list -mb-0.5 flex">
                  <button @click="activeTab = 'tabHome'"
                    :class="activeTab === 'tabHome' ? 'border-primary dark:border-accent text-primary dark:text-accent-light' : 'border-transparent hover:text-slate-800 focus:text-slate-800 dark:hover:text-navy-100 dark:focus:text-navy-100'"
                    class="btn shrink-0 space-x-2 rounded-none border-b-2 px-3 py-2 font-medium">
                    <i class="fa fa-arrow-circle-down" aria-hidden="true"></i>
                    <span>Deposits</span>
                  </button>
                  <button @click="activeTab = 'tabProfile'"
                    :class="activeTab === 'tabProfile' ? 'border-primary dark:border-accent text-primary dark:text-accent-light' : 'border-transparent hover:text-slate-800 focus:text-slate-800 dark:hover:text-navy-100 dark:focus:text-navy-100'"
                    class="btn shrink-0 space-x-2 rounded-none border-b-2 px-3 py-2 font-medium">
                    <i class="fa fa-arrow-circle-up" aria-hidden="true"></i>
                    <span>Withdrawals</span>
                  </button>

                </div>
              </div>
            </div>
            <div class="tab-content pt-1">
              <div x-show="activeTab === 'tabHome'" x-transition:enter="transition-all duration-500 easy-in-out"
                x-transition:enter-start="opacity-0 [transform:translate3d(1rem,0,0)]"
                x-transition:enter-end="opacity-100 [transform:translate3d(0,0,0)]">
                <div>
                  <div class="is-scrollbar-hidden min-w-full ">
                    <table class="is-hoverable text-left">

                      <tbody>
                      <?php
                            $q = mysqli_query($link, "SELECT * FROM deposits WHERE status = 'pending' AND userId = '$userId' ");
                            if(mysqli_num_rows($q) > 0){
                                while($row = mysqli_fetch_assoc($q)){
                                    $method = $row['method'];
                                    $img = $payMethods[$method];
                        ?>
                        <tr class="w-full">
                        
                          <td class="whitespace-nowrap py-2 px-8 sm:px-4">
                            <div class="flex items-center space-x-4">
                              <div
                                class="flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary dark:bg-accent dark:text-white">
                                <i class="fa fa-arrow-circle-down" aria-hidden="true"></i>

                              </div>
                              <div>
                                <p class="font-medium text-slate-700 dark:text-navy-100">
                                  <?php echo $row['tranxId'] ?>
                                </p>
                                <p class="mt-0.5 text-xs text-slate-400 dark:text-navy-300">
                                  <?php echo date("D, j M Y", strtotime($row['date'])); ?>
                                </p>
                              </div>
                            </div>
                          </td>

                        
                          <td class="whitespace-nowrap py-2 px-8 sm:px-4">
                            <div class="flex items-center space-x-4">


                              <span class="font-medium text-slate-700 dark:text-navy-100"><img style='display:inline'
                                  src='<?php echo $img['image'] ?>' width='24'> 0.0258
                              </span>
                            </div>
                          </td>

                          <td class="whitespace-nowrap py-2 px-8 sm:px-4">
                            <div class="badge bg-warning/10 text-warning dark:bg-warning/15">
                              <?php echo ucfirst($row['status']) ?>
                            </div>
                          </td>


                          <td class="whitespace-nowrap px-8 sm:px-4 py-2 ">
                            <p class="text-sm+ font-medium text-slate-700 dark:text-navy-100">
                              $<?php echo $row['amount'] ?>
                            </p>
                          </td>

                        </tr>
                        <?php }
                            } ?>
                      </tbody>
                    </table>
                  </div>

                  <div class="flex space-x-2 pt-3">
                    <a href="deposit.php"
                      class="tag rounded-full border border-primary text-primary dark:border-accent-light dark:text-accent-light">
                      View All
                    </a>

                  </div>
                </div>
              </div>
              <div x-show="activeTab === 'tabProfile'" x-transition:enter="transition-all duration-500 easy-in-out"
                x-transition:enter-start="opacity-0 [transform:translate3d(1rem,0,0)]"
                x-transition:enter-end="opacity-100 [transform:translate3d(0,0,0)]">
                <div>
                  <div class="is-scrollbar-hidden min-w-full ">
                    <table class="is-hoverable text-left">

                      <tbody>


                      </tbody>
                    </table>
                  </div>
                  <div class="flex space-x-2 pt-3">
                    <a href="withdrawal.php"
                      class="tag rounded-full border border-success text-success dark:border-success-light dark:text-success-light">
                      View All
                    </a>

                  </div>

                </div>
              </div>

            </div>
          </div>
        </div>



        <div class="card  px-4 pb-5 sm:px-5 ">
          <div class="flex items-center justify-between py-3">
            <h2 class="font-medium tracking-wide text-slate-700 dark:text-navy-100">
              Invite friends to earn
            </h2>

          </div>

          <div class=" flex items-center justify-between">
            <p class="text-xs+">Earn more commissions by inviting your friends to fund.</p>


          </div>
          <div class="mt-2 space-y-4">
            <script>
              function myFunction() {
                var copyText = document.getElementById("myInput");
                copyText.select();
                copyText.setSelectionRange(0, 99999);
                navigator.clipboard.writeText(copyText.value);

                var tooltip = document.getElementById("toolbut");
                tooltip.innerHTML = "Copied";

              }

              function getout() {
                var tooltip2 = document.getElementById("toolbut");
                tooltip2.innerHTML = "  <i class='fa fa-copy mr-1'></i> Copy ";
              }


            </script>
            <label class="block">

              <input
                class="form-input mt-1.5 h-9 w-full rounded-lg border border-slate-300 bg-transparent px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
                type="text" id="myInput"
                value="<?php echo $siteurl ?>/user/signup.php?ref=<?php echo $refcode?>" />
            </label>

          </div>


          <button
            class="btn mt-5 h-10 w-full bg-primary font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90"
            onclick="myFunction()" onmouseout="setTimeout(getout, 1500)" id="toolbut"> <svg
              xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
              stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" icon-name="copy"
              data-lucide="copy" class="lucide lucide-copy h-4">
              <rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
              <path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"></path>
            </svg>
            Copy Link
          </button>
        </div>


      </div>

    </main>


<?php
include 'footer.php';
?>