<?php
session_start();

// Redirect if not logged in
if (!isset($_SESSION['email'])) {
  header("Location: login.html");
  exit();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Mining Dashboard - Gobolcoin</title>
  <link rel="icon" type="image/png" href="/favicon.png">
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet" />
  <style>
    :root {
      --maroon: #8B0000;
      --white: #ffffff;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body, html {
      font-family: 'Inter', sans-serif;
      background: linear-gradient(to top right, #ffffff 70%, #8B0000 130%);
      color: #333;
    }

    .logo-box {
      position: fixed;
      top: 20px;
      left: 20px;
      background: rgba(139, 0, 0, 0.9);
      color: white;
      padding: 8px 14px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      z-index: 999;
      box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    }

    .logo-box img {
      width: 32px;
      height: 32px;
      margin-right: 10px;
    }

    .logo-box span {
      font-size: 1.2rem;
      font-weight: bold;
    }

    .top-bar {
      position: relative;
      margin-top: 100px;
      text-align: right;
      padding-right: 1em;
    }

    .menu-wrapper {
      position: absolute;
      top: 0;
      right: 1em;
      display: flex;
      align-items: center;
    }

    .dashboard-btn { /* Changed from .home-icon-btn */
            font-size: 1.1em; /* Reduced font size for better fit */
            text-decoration: none;
            background: var(--maroon);
            color: white;
            padding: 8px 14px;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            display: flex;
            align-items: center;
            gap: 0.5em; /* Added gap for spacing between icon and text */
        }

        .dashboard-btn .icon {
            font-size: 1.8em;
            line-height: 1; /* Aligns the icon better */
        }

    .whitepaper-btn {
      background-color: var(--maroon);
      color: white;
      padding: 0.4em 0.8em;
      border-radius: 6px;
      font-size: 0.85rem;
      font-weight: bold;
      text-decoration: none;
      margin-right: 0.5em;
      vertical-align: middle;
    }

    .container {
      text-align: center;
      padding: 6em 1em 4em;
    }

    h1 {
      margin-bottom: 0.5em;
    }

    #subtitle {
      font-style: italic;
      color: var(--maroon);
      margin-top: 0.5em;
      margin-bottom: 1.5em;
    }

    #rate-label {
      font-weight: bold;
      margin-bottom: 1.5em;
      color: var(--maroon);
    }

    #balance-container {
      width: 220px;
      height: 220px;
      margin: 2em auto;
      border-radius: 50%;
      border: 6px solid var(--maroon);
      background-color: #f9f9f9;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--maroon);
    }

    #balance {
      font-size: 2.5em;
      font-weight: bold;
    }

    #balance-label, #balance-unit {
      font-size: 1em;
    }

    #timer {
      font-size: 1.8em;
      font-weight: bold;
      margin: 1em 0;
    }

    #startMiningBtn {
      background-color: var(--maroon);
      color: white;
      padding: 1em 2em;
      font-size: 1.1em;
      border: none;
      border-radius: 10px;
      cursor: pointer;
    }

    #startMiningBtn:disabled {
      background-color: #aaa;
      cursor: not-allowed;
    }


    section {
      padding: 4em 1.5em;
      background-color: #fff;
      color: var(--maroon);
      text-align: center;
    }

    section h2 {
      font-size: 2em;
      margin-bottom: 1em;
    }
    
    .tokenomics table {
      width: 100%;
      max-width: 800px;
      margin: 0 auto;
      border-collapse: collapse;
      box-shadow: 0 0 10px rgba(0,0,0,0.05);
    }

    .tokenomics th, .tokenomics td {
      padding: 1em;
      border-bottom: 1px solid #ddd;
      text-align: left;
    }

    .tokenomics th {
      background-color: #8B0000;
      color: #fff;
    }

    .roadmap ul {
      list-style: none;
      padding: 0;
      max-width: 700px;
      margin: 2em auto;
      text-align: left;
    }

    .roadmap li {
      background: #fdfdfd;
      padding: 1em;
      border-left: 4px solid var(--maroon);
      margin-bottom: 1em;
      box-shadow: 0 0 5px rgba(0,0,0,0.05);
    }

    .utility img {
      width: 100%;
      max-width: 700px;
      height: auto;
      border-radius: 10px;
    }

    footer {
      text-align: center;
      padding: 2em 1em;
      background-color: #1a1a1a;
      color: #ccc;
      font-size: 0.9em;
    }

    .footer-links {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 1em;
      margin-bottom: 1em;
    }

    .footer-links a {
      color: #ccc;
      text-decoration: none;
    }

    .footer-links a:hover {
      color: #fff;
    }

    .socials {
      margin-top: 1em;
    }

    .socials a {
      margin: 0 8px;
    }

    .socials img {
      width: 24px;
      height: 24px;
    }

    .footer-bottom {
      margin-top: 1em;
      color: #888;
    }
  </style>
</head>
<body>

  <div class="logo-box">
    <img src="images/gobolcoin-logo.png" alt="Gobolcoin Logo">
    <span>Gobolchain Network</span>
  </div>

  <div class="top-bar">
        <div class="menu-wrapper">
            <a href="docs/gobolcoin-whitepaper.pdf" class="whitepaper-btn" target="_blank">White Paper ↑</a>
            <a href="dashboard.php" class="dashboard-btn" title="Go to Dashboard">
                <span class="icon">🏠</span> Dashboard
            </a>
        </div>
    </div>

  <div class="container">
    <h1 style="color: var(--maroon);">MINING</h1>
    <h2>Welcome to Gobolcoin</h2>
    <div id="subtitle">Mine it, Own it, Shape the Future</div>
    <div id="rate-label">Mining Rate: 0.025 GBL/hr</div>

    <div id="balance-container">
        <div id="balance-label">Total Balance</div>
        <div id="balance">0.00000000</div>
        <div id="balance-unit">GBL</div>
    </div>

    <div id="timer-label">Remaining Time</div>
    <div id="timer">08h.00m.00s</div>

    <button id="startMiningBtn">Start Mining</button>
</div>

<script src="mining.js"></script>
 
  <!-- Tokenomics Section -->
<section class="tokenomics" id="tokenomics">
  <h2>Gobolcoin Tokenomics</h2>
  <div class="tokenomics-table">
    <table>
      <thead>
        <tr><th>Category</th><th>%</th><th>GBL Amount</th></tr>
      </thead>
      <tbody>
        <tr><td>Community & Ecosystem Incentives</td><td>50%</td><td>7,500,000</td></tr>
        <tr><td>Development & Operations</td><td>20%</td><td>3,000,000</td></tr>
        <tr><td>Strategic Partnerships</td><td>15%</td><td>2,250,000</td></tr>
        <tr><td>ICO</td><td>10%</td><td>1,500,000</td></tr>
        <tr><td>Founders & Advisors</td><td>5%</td><td>750,000</td></tr>
        <tr><td><strong>Total</strong></td><td><strong>100%</strong></td><td><strong>15,000,000</strong></td></tr>
      </tbody>
    </table>
  </div>
</section>

<section id="team" style="padding: 4em 1em; background: #f9f9f9;">
  <div class="section-content" style="max-width: 1000px; margin: 0 auto;">
    <h1 style="text-align:center; color: #8B0000; margin-bottom: 2em;">Meet Our Team</h1>
    <div class="team-container" style="display: flex; flex-direction: column; gap: 1.5em;">

      <!-- Team Member 1 -->
      <div class="team-member" style="display: flex; align-items: center; gap: 1.2em; background: #fff; padding: 1.2em; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.05);">
        <img src="images/jibala.jpeg" alt="Jibala Godstime Boloo" style="width: 90px; height: 90px; object-fit: cover; border-radius: 50%; border: 3px solid #8B0000;">
        <div class="info">
          <h2 style="margin: 0; color: #8B0000; font-size: 1.1rem;">JIBALA GODSTIME BOLOO</h2>
          <h3 style="margin: 0.3em 0; font-size: 0.95rem; color: #666;">Founder and CEO</h3>
          <p style="margin: 0.4em 0; font-size: 0.9rem;">Visionary leader driving Gobolchain to success</p>
          <div class="socials">
            <a href="https://www.facebook.com/profile.php?id=61576398855235" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733547.png" alt="Facebook" style="width: 22px;"></a>
            <a href="https://x.com/JibalaRex?t=YB6IgorkOZdjPtPslogXBQ&s=08" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733579.png" alt="Twitter" style="width: 22px;"></a>
            <a href="https://www.linkedin.com/in/jibala-godstime-boloo-76704b359?trk=contact-info" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733561.png" alt="LinkedIn" style="width: 22px;"></a>
          </div>
        </div>
      </div>

      <!-- Team Member 2 -->
      <div class="team-member" style="display: flex; align-items: center; gap: 1.2em; background: #fff; padding: 1.2em; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.05);">
        <img src="images/harsh.jpeg" alt="Dr. Harsh Vardhan Chopra" style="width: 90px; height: 90px; object-fit: cover; border-radius: 50%; border: 3px solid #8B0000;">
        <div class="info">
          <h2 style="margin: 0; color: #8B0000; font-size: 1.1rem;">DR. HARSH VARDHAN CHOPRA</h2>
          <h3 style="margin: 0.3em 0; font-size: 0.95rem; color: #666;">Advisory Director</h3>
          <p style="margin: 0.4em 0; font-size: 0.9rem;">Guiding innovation and excellence at Gobolchain</p>
          <div class="socials">
            <a href="https://www.facebook.com/HVCrealm" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733547.png" alt="Facebook" style="width: 22px;"></a>
            <a href="https://twitter.com/hvcrealm" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733579.png" alt="Twitter" style="width: 22px;"></a>
            <a href="https://instagram.com/hvcrealm" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733558.png" alt="Instagram" style="width: 22px;"></a>
            <a href="https://linkedin.com/in/hvchopra" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733561.png" alt="LinkedIn" style="width: 22px;"></a>
          </div>
        </div>
      </div>

      <!-- Team Member 3 -->
      <div class="team-member" style="display: flex; align-items: center; gap: 1.2em; background: #fff; padding: 1.2em; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.05);">
        <img src="images/mahtab.jpeg" alt="Mahtab Hassan" style="width: 90px; height: 90px; object-fit: cover; border-radius: 50%; border: 3px solid #8B0000;">
        <div class="info">
          <h2 style="margin: 0; color: #8B0000; font-size: 1.1rem;">MAHTAB HASSAN</h2>
          <h3 style="margin: 0.3em 0; font-size: 0.95rem; color: #666;">Developer</h3>
          <p style="margin: 0.4em 0; font-size: 0.9rem;">Blockchain expert committed to building scalable tech</p>
          <div class="socials">
            <a href="https://www.facebook.com/mahtab.has.159" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733547.png" alt="Facebook" style="width: 22px;"></a>
            <a href="https://www.linkedin.com/in/mehtab-hassan-33761b1a0" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733561.png" alt="LinkedIn" style="width: 22px;"></a>
          </div>
        </div>
      </div>

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

<!-- ANNOUNCEMENT SECTION -->
<section id="announcement" style="padding: 4em 1.5em; background: #fff;">
 <div style="max-width: 900px; margin: auto; text-align: justify; line-height: 1.7; font-size: 1rem;">
    <h1 style="text-align:center; color: #8B0000; margin-bottom: 1em;">GOBOLCHAIN NETWORK ANNOUNCEMENT</h1>
    <p>We're excited to share updates about Gobolchain Network:</p>
    <ul style="margin-top: 1em; padding-left: 1.5em;">
      <li><strong>Gobolcoin Mobile Mining App:</strong> Our app is under development and will be released soon. Mining Gobolcoin will be totally free, with no requests for money or cryptocurrency for gas fees, subscriptions, or in-app purchases.</li>
      <li><strong>Beware of Scams:</strong> Never pay for anything to mine Gobolcoin. Follow our official social media handles for verified updates.</li>
      <li><strong>ICO Announcement:</strong> Our Gobolcoin (GBL) ICO will be publicly announced on our social media handles when it's live.</li>
      <li><strong>Gobolcoin Vision:</strong> We're building a brand like Apple, Samsung, or Toyota. Stay patient and join us on this journey to financial freedom.</li>
      <li><strong>Key Facts:</strong>
        <ul style="margin-top: 0.5em; padding-left: 1.2em;">
          <li>Total supply: 15 million GBL tokens (no additional tokens will be generated)</li>
          <li>Gobolcoin is the native token of Gobolchain Network</li>
          <li>Open for partnerships</li>
        </ul>
      </li>
    </ul>
    <h2 style="margin-top: 2em; color: #8B0000; text-align: left;">Join the Movement</h2>
    <p>Gobolchain Network is led by a team of innovators and experts from 4 countries. Don't miss this opportunity, just like you might have with Bitcoin. We're committed to transparency and reliability. Join us and let's work towards financial freedom together!</p>
  </div>
</section>

<!-- Roadmap Section -->
<section class="roadmap" id="roadmap">
  <h2>Gobolcoin Roadmap</h2>
  <ul>
    <li><strong>2025:</strong> Polygon Launch, ICO, White Paper v1.0</li>
    <li><strong>2026:</strong> Gobolchain Mainnet, CEX/DEX Listings</li>
    <li><strong>2027:</strong> Marketplace Live, Merchant Pilots</li>
    <li><strong>2028:</strong> Gobol Social App Beta</li>
    <li><strong>2029:</strong> Gobol Technology Co. Device Production</li>
    <li><strong>2030+:</strong> EVs, AI Machines, University, Global Adoption</li>
  </ul>
</section>

<!-- Utility Section -->
<section class="utility" id="utility">
  <h2>Gobolcoin Utility</h2>
  <img src="images/gobolcoin-utility.jpeg" alt="Gobolcoin Utility Graphic">
</section>

  <!-- Footer -->
  <footer>
    <div class="footer-links">
      <a href="terms.html">Policy & Terms</a>
      <a href="meet-our-team.html">Meet Our Team</a>
      <a href="support.html">Support</a>
      <a href="faq.html">FAQ</a>
      <a href="announcement.html">Announcement</a>
    </div>

    <div class="socials">
      <a href="https://x.com/gobolcoin?s=08" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/733/733579.png" alt="Twitter"></a>
      <a href="https://youtube.com/@gobolcoin?si=ByrsmImTnkALKIzX" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/1384/1384060.png" alt="YouTube"></a>
      <a href="https://t.me/+DvAqx1PFYAE2MDE0" target="_blank"><img src="https://cdn-icons-png.flaticon.com/512/2111/2111646.png" alt="Telegram"></a>
    </div>

    <div class="footer-bottom">
      All right reserve &copy; Gobolchain Network 2025</p>
    </div>
  </footer>

 <script>
document.addEventListener("DOMContentLoaded", function () {
    const startBtn = document.getElementById("startMiningBtn");
    const balanceDisplay = document.getElementById("balance");
    const timerDisplay = document.getElementById("timer");

    let miningActive = false;
    let saveInterval = null;
    let timerInterval = null;
    let startTime = null;

    const ratePerHour = 0.025;
    const maxHours = 8;
    const maxSeconds = maxHours * 3600;

    function formatGBL(num) {
        return parseFloat(num).toFixed(4);
    }

    function formatTime(seconds) {
        let h = Math.floor(seconds / 3600);
        let m = Math.floor((seconds % 3600) / 60);
        let s = seconds % 60;
        return `${h.toString().padStart(2, "0")}h.${m.toString().padStart(2, "0")}m.${s.toString().padStart(2, "0")}s`;
    }

    // Start Mining button click
    startBtn.addEventListener("click", function () {
    fetch("start-mining.php", {
        method: "POST",
        credentials: "include"
    })
    .then(res => res.json())
    .then(data => {
        if (data.success) {
            miningActive = true;
            startTime = data.start_time;
            startBtn.disabled = true; // disable button
            startLiveUpdates();
        } else {
            alert(data.message);
            if (data.remaining_seconds) {
                startBtn.disabled = true;
                let mins = Math.ceil(data.remaining_seconds / 60);
                startBtn.textContent = `Mining in progress (${mins} min left)`;
            }
        }
    })
    .catch(err => console.error(err));
});

    // Save mining progress (every 10s)
    function saveMiningProgress() {
        fetch("save-mining.php", {
            method: "POST",
            credentials: "include"
        })
        .then(res => res.json())
        .then(data => {
            if (data.success) {
                balanceDisplay.textContent = formatGBL(data.total_balance);
                if (data.session_finished) {
                    stopMining();
                    alert("8 hours finished. Click Start Mining again to continue.");
                }
            }
        })
        .catch(err => console.error(err));
    }

    // Get mining status on page load
    function getMiningStatus() {
        fetch("get-mining-status.php", {
            method: "GET",
            credentials: "include"
        })
        .then(res => res.json())
        .then(data => {
            if (data.success) {
                balanceDisplay.textContent = formatGBL(data.balance);
                miningActive = data.mining;
                if (data.mining) {
                    startTime = Math.floor(Date.now() / 1000) - Math.floor(data.elapsed_hours * 3600);
                    startLiveUpdates();
                } else {
                    stopMining();
                }
            }
        })
        .catch(err => console.error(err));
    }

    // Update the timer every second
    function updateTimerEverySecond() {
        if (!startTime) return;
        let elapsed = Math.floor(Date.now() / 1000) - startTime;
        let remaining = maxSeconds - elapsed;
        if (remaining < 0) remaining = 0;
        timerDisplay.textContent = formatTime(remaining);

        if (remaining <= 0 && miningActive) {
            stopMining();
            alert("8 hours finished. Click Start Mining again to continue.");
        }
    }

    // Start live updates
    function startLiveUpdates() {
        stopMining(); // Clear old intervals if any

        // Save mining progress every 10 seconds
        saveInterval = setInterval(saveMiningProgress, 10000);

        // Smooth timer update every second
        timerInterval = setInterval(updateTimerEverySecond, 1000);
    }

    // Stop mining updates
    function stopMining() {
        clearInterval(saveInterval);
        clearInterval(timerInterval);
        miningActive = false;
        timerDisplay.textContent = "00h.00m.00s";
    }

    // Initial status check
    getMiningStatus();
});

// Save user email from PHP session to localStorage
  localStorage.setItem("user_email", "<?php echo $_SESSION['email'] ?? ''; ?>");
  
</script>

</body>
</html>