<?php  
session_start();  
include "db.php";  
  
/* ===== LOGIN CHECK ===== */  
if(!isset($_SESSION['user_id'])){  
    header("Location: login.php");  
    exit;  
}  
  
$user_id = $_SESSION['user_id'];  
  
/* ===== ADMIN CONFIG ===== */  
$gift_amount = 10;  
  
/* ===== FETCH USER DATA ===== */  
$sql = "SELECT balance, active_invest, gift_claimed FROM users WHERE id = ?";  
$stmt = $conn->prepare($sql);  
$stmt->bind_param("i", $user_id);  
$stmt->execute();  
$result = $stmt->get_result();  
$user = $result->fetch_assoc();  
  
$user_balance  = $user['balance'];  
$active_invest = $user['active_invest'];  
$gift_claimed  = $user['gift_claimed'];  
  
/* ===== GIFT CLAIM BACKEND ===== */  
if(isset($_POST['claim_gift'])){  
    if($gift_claimed == 0){  
        $update = $conn->prepare(  
            "UPDATE users SET balance = balance + ?, gift_claimed = 1 WHERE id = ?"  
        );  
        $update->bind_param("di", $gift_amount, $user_id);  
        $update->execute();  
  
        echo json_encode([  
            "status" => "success",  
            "amount" => $gift_amount  
        ]);  
    } else {  
        echo json_encode([  
            "status" => "already"  
        ]);  
    }  
    exit;  
}  
?>  <!DOCTYPE html>  <html lang="bn">  
<head>  
<meta charset="UTF-8">  
<meta name="viewport" content="width=device-width, initial-scale=1.0">  
<title>AMD Dashboard</title>  <style>  
*{box-sizing:border-box;font-family:Arial,Helvetica,sans-serif}  
body{  
    margin:0;  
    background:linear-gradient(180deg,#0c1c3a,#0b1530);  
    color:#fff;  
}  
.container{  
    max-width:420px;  
    margin:auto;  
    padding:15px;  
    padding-top:95px; /* fixed header space */  
}  
  
/* ===== FIXED HEADER ===== */  
.header{  
    position:fixed;  
    top:0;  
    left:0;  
    right:0;  
    background:#0b1530;  
    text-align:center;  
    padding:5px 0;  
    z-index:1000;  
}  
.header img{width:90px}  
  
/* SLIDER */  
.slider{  
    overflow:hidden;  
    border-radius:18px;  
    height:180px;  
}  
.slides{  
    display:flex;  
    transition:.5s;  
}  
.slides img{  
    width:100%;  
    height:180px;  
    object-fit:cover;  
    flex-shrink:0;  
    border-radius:18px;  
}  
  
/* NOTICE */  
.notice{  
    margin:18px 0 35px;  
    background:linear-gradient(90deg,#7b2cff,#ff2f92);  
    padding:12px 16px;  
    border-radius:30px;  
    display:flex;  
    align-items:center;  
    gap:10px;  
    overflow:hidden;  
}  
.notice img{width:26px}  
.notice span{  
    white-space:nowrap;  
    animation: marquee 12s linear infinite;  
}  
@keyframes marquee{  
    from{transform:translateX(100%)}  
    to{transform:translateX(-100%)}  
}  
  
/* INVEST STATUS CARD */  
.card{  
    background:#0f1f3f;  
    border-radius:26px;  
    padding:22px;  
    border:1px solid #fff;  
    margin-bottom:25px;  
}  
.card-header{  
    display:flex;  
    justify-content:space-between;  
    align-items:center;  
    margin-bottom:25px;  
}  
.card-header-left{  
    display:flex;  
    align-items:center;  
    gap:10px;  
    color:#fff;  
    font-size:16px;  
}  
.card-header-left svg{width:22px;fill:#fff}  
.card-header-right svg{width:22px;fill:#00ff66}  
  
.card-values{  
    display:flex;  
    justify-content:space-between;  
}  
.value-box{  
    width:48%;  
    background:#0f1f3f;  
    border-radius:18px;  
    padding:20px;  
    text-align:center;  
}  
.value-box .label{font-size:13px;opacity:.8}  
.value-box .amount{font-size:28px;font-weight:bold;margin-top:6px}  
.green{color:#FFD24A}  
.orange{color:#ff9966}  
  
/* ACTION CARD */  
.action-card{  
    background:#0f1f3f;  
    border:1px solid #fff;  
    border-radius:26px;  
    padding:22px;  
    display:flex;  
    justify-content:space-between;  
    margin-bottom:30px;  
}  
.action{  
    width:30%;  
    text-align:center;  
}  
.action img{width:56px;margin-bottom:10px}  
.action div{color:#fff;font-size:15px}  
  
/* LIVE FEED */  
.feed-title{  
    margin:12px 0;  
    font-size:16px;  
}  
.feed{  
    height:200px;  
    overflow:hidden;  
    position:relative;  
}  
.feed-inner{  
    position:absolute;  
    width:100%;  
}  
.feed-item{  
    background:#0f1f3f;  
    border-radius:14px;  
    padding:10px;  
    margin-bottom:8px;  
    font-size:14px;  
}  
.feed-item.green{color:#00ff66}  
.feed-item.yellow{color:#ffcc00}  
.feed-item.red{color:#ff4444}  
  
/* GIFT IMAGE */  
.gift{  
    position:fixed;  
    bottom:110px;  
    right:18px;  
    width:64px;  
    height:64px;  
    border-radius:50%;  
    cursor:pointer;  
    animation:shake 1.2s infinite;  
    z-index:999;  
}  
.gift img{  
    width:100%;  
    height:100%;  
    border-radius:50%;  
}  
@keyframes shake{  
    0%,100%{transform:rotate(0)}  
    25%{transform:rotate(-8deg)}  
    75%{transform:rotate(8deg)}  
}  
  
/* POPUP */  
.popup{  
    position:fixed;  
    inset:0;  
    background:rgba(0,0,0,.6);  
    display:none;  
    align-items:center;  
    justify-content:center;  
    z-index:1000;  
}  
.popup-box{  
    background:linear-gradient(180deg,#ff9900,#ff6a00);  
    width:85%;  
    max-width:320px;  
    border-radius:22px;  
    padding:22px;  
    text-align:center;  
}  
.popup-box h3{margin:10px 0}  
.popup-box .amount{  
    background:#fff;  
    color:#000;  
    padding:15px;  
    border-radius:12px;  
    font-size:26px;  
    margin:15px 0;  
}  
.popup-box button{  
    width:100%;  
    padding:14px;  
    border:none;  
    border-radius:14px;  
    background:#ff8800;  
    color:#fff;  
    font-size:16px;  
}  
</style>  </head>  <body>  <!-- FIXED HEADER -->  <div class="header">  
    <img src="https://i.postimg.cc/Vv89Mk8b/61710-removebg-preview.png">  
</div>  <div class="container">  <!-- SLIDER -->  <div class="slider">  
    <div class="slides" id="slides">  
        <img src="https://i.postimg.cc/wx5Sn06t/img1.jpg">  
        <img src="https://i.postimg.cc/nVK6N0HQ/img2.jpg">  
        <img src="https://i.postimg.cc/BZ5dRMqP/img3_(1).jpg">  
        <img src="https://i.postimg.cc/xjGWBt0z/img4.jpg">  
        <img src="https://i.postimg.cc/wx5Sn06v/img5.jpg">  
    </div>  
</div>  <!-- NOTICE -->  <div class="notice">  

    <span>গুরুত্বপূর্ণ ঘোষণা: নতুন প্যাকেজ ও বোনাস আপডেট এসেছে!</span>  
</div>  <!-- INVEST STATUS -->  <div class="card">  
    <div class="card-header">  
        <div class="card-header-left">  
            <svg viewBox="0 0 24 24"><path d="M3 12h4l2-5 4 10 2-5h4"/></svg>  
            বিনিয়োগ স্ট্যাটাস  
        </div>  
        <div class="card-header-right">  
            <svg viewBox="0 0 24 24"><path d="M12 5c-7 0-11 7-11 7s4 7 11 7 11-7 11-7-4-7-11-7zm0 11a4 4 0 1 1 0-8 4 4 0 0 1 0 8z"/></svg>  
        </div>  
    </div>  <div class="card-values">  
    <div class="value-box">  
        <div class="label">বর্তমান ব্যালেন্স</div>  
        <div class="amount green"> <?= number_format($user_balance,2) ?></div>  
    </div>  
    <div class="value-box">  
        <div class="label">সক্রিয় বিনিয়োগ</div>  
        <div class="amount orange"> <?= number_format($active_invest,2) ?></div>  
    </div>  
</div>

</div>  
<div class="action-card">  

    <a href="withdraw.php" class="action">
        <img src="https://i.postimg.cc/0j3mV7Hv/withdraw2.png">
        <div>প্রত্যাহার</div>
    </a>  

    <a href="checkin.php" class="action">
        <img src="https://i.postimg.cc/0j3mV7HP/equipment3.png">
        <div>দৈনিক চেকিং</div>
    </a>  

    <a href="support.php" class="action">
        <img src="https://i.postimg.cc/D0Dsx1YF/help5.png">
        <div>গ্রাহক সেবা</div>
    </a>  

</div>
</div>  <!-- LIVE FEED -->  <div class="feed-title">লাইভ অ্যাক্টিভিটি ফিড</div>  
<div class="feed">  
    <div class="feed-inner" id="feedInner">  
        <div class="feed-item red">01986*****68 এখনই সফল ভাবে ৳6498 উত্তোলন করলেন</div>  
        <div class="feed-item yellow">0197*****686 এর জন্য ৳76 টাকা কমিশন যোগ হয়েছে</div>  
        <div class="feed-item green">0195*****73 এখনই ৳165 রিটার্ন পেয়েছেন</div>  
        <div class="feed-item green">01986*****68 এখনি সফল ভাবে ৳5346 টাকা জমা দিয়েছে</div>  
    </div>  
</div>  <!-- TASK MISSION INCLUDE -->  <?php include "task.php"; ?>  </div>  <?php if($gift_claimed == 0){ ?> 
<?php } ?>  <!-- POPUP -->  <div class="popup" id="popup">  
    <div class="popup-box">  
        <h3>চেক-ইন টাস্কটি সম্পন্ন করুন</h3>  
        <div class="amount">BDT <?= $gift_amount ?></div>  
        <button onclick="claimGift()">নিশ্চিত করুন</button>  
    </div>  
</div>  <!-- FOOTER MENU -->  <?php include "menu.php"; ?>  
<script>
/* ========= SLIDER ========= */
let i = 0;
const slides = document.getElementById("slides");

if(slides){
    setInterval(()=>{
        i = (i + 1) % slides.children.length;
        slides.style.transform = "translateX(-" + i * 100 + "%)";
    },3000);
}

/* ========= LIVE FEED ========= */
const feed = document.getElementById("feedInner");

if(feed){
    setInterval(()=>{
        const first = feed.children[0];
        const itemHeight = first.offsetHeight + 8; // margin সহ

        feed.style.transition = "transform .5s ease";
        feed.style.transform = `translateY(-${itemHeight}px)`;

        setTimeout(()=>{
            feed.appendChild(first);
            feed.style.transition = "none";
            feed.style.transform = "translateY(0)";
        },500);
    },2500);
}

/* ========= GIFT ========= */
function claimGift(){
    fetch("dashboard.php",{
        method:"POST",
        headers:{
            "Content-Type":"application/x-www-form-urlencoded"
        },
        body:"claim_gift=1"
    })
    .then(res => res.json())
    .then(data => {
        if(data.status === "success"){
            alert("আপনি " + data.amount + " টাকা পেয়েছেন");
            location.reload();
        }else{
            alert("আপনি ইতিমধ্যে গিফট পেয়েছেন");
        }
    });
}

/* ========= TELEGRAM ========= */
function goTelegram(){
    window.location.href = "https://t.me/YourTelegramUsername";
}
</script>