<?php
require 'includes/db.php';
$user_id = $_SESSION['user_id'];
// ===============================
// 💰 BTC + LOCAL CURRENCY DISPLAY
// ===============================

require 'includes/settings.php';
require 'includes/currency.php';

// 🔧 SETTINGS
$btc_amount = getSetting('default_amount_btc');
$btc_rate   = getSetting('btc_rate');

// ===============================
// 💱 GET CURRENCY FROM COOKIE
// ===============================
$currency_cookie = $_COOKIE['currency_selected'] ?? 'USD';

// 🔥 MAP SYMBOL → ISO CODE
$currency_map = [
    "R"  => "ZAR",
    "₦"  => "NGN",
    "$"  => "USD",
    "€"  => "EUR",
    "£"  => "GBP"
];

// ✅ GET ISO CODE
$user_currency_code = $currency_map[$currency_cookie] ?? $currency_cookie;

// 🔒 FORCE UPPERCASE
$user_currency_code = strtoupper(trim($user_currency_code));

// 🔒 VALIDATE (ONLY ISO CODES HERE)
$allowed = ["USD","ZAR","NGN","EUR","GBP","CHF","CAD","AUD","INR"];

if (!in_array($user_currency_code, $allowed)) {
    $user_currency_code = "USD";
}

// ===============================
// 💾 STORE ISO CODE IN SESSION
// ===============================
$_SESSION['currency'] = $user_currency_code;

// ===============================
// 💲 CONVERSION
// ===============================

// BTC → USD
$usd_value = $btc_amount * $btc_rate;

// USD → LOCAL
$local_value = convertCurrency($usd_value, 'USD', $user_currency_code);

// ===============================
// 💱 SYMBOL (DISPLAY ONLY)
// ===============================
$symbols = [
    "USD"=>"$",
    "ZAR"=>"R",
    "NGN"=>"₦",
    "EUR"=>"€",
    "GBP"=>"£",
    "CHF"=>"₣",
    "CAD"=>"$",
    "AUD"=>"$",
    "INR"=>"₹"
];

$symbol = $symbols[$user_currency_code] ?? "";
$admin_id = 1;

// SEND MESSAGE
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $msg = trim($_POST['message']);

    if(!empty($msg)){
        $stmt = $conn->prepare("
            INSERT INTO messages (sender_id, receiver_id, message)
            VALUES (?, ?, ?)
        ");
        $stmt->bind_param("iis", $user_id, $admin_id, $msg);
        $stmt->execute();
    }
}

// FETCH CHAT (ONLY BETWEEN USER & ADMIN)
$res = mysqli_query($conn, "
    SELECT * FROM messages 
    WHERE 
        (sender_id='$user_id' AND receiver_id='$admin_id') 
        OR 
        (sender_id='$admin_id' AND receiver_id='$user_id')
    ORDER BY id ASC
");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment - Geneva & Exeter Coin Dashboard</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: #4f46e5;
            min-height: 100vh;
            position: relative;
            overflow-x: hidden;
        }

        /* Crypto icons background pattern */
        .crypto-bg {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
            pointer-events: none;
            z-index: 0;
        }

        .crypto-icon {
            position: absolute;
            opacity: 0.06;
            color: white;
            font-size: 48px;
            font-weight: bold;
        }

        /* Bitcoin symbols */
        .crypto-icon.btc:nth-child(1) { top: 10%; left: 5%; transform: rotate(-15deg); font-size: 64px; }
        .crypto-icon.btc:nth-child(2) { top: 70%; left: 15%; transform: rotate(10deg); font-size: 56px; }
        .crypto-icon.btc:nth-child(3) { top: 30%; right: 10%; transform: rotate(-5deg); font-size: 72px; }
        .crypto-icon.btc:nth-child(4) { bottom: 20%; right: 25%; transform: rotate(20deg); font-size: 48px; }
        .crypto-icon.btc:nth-child(5) { top: 50%; left: 40%; transform: rotate(-10deg); font-size: 60px; }

        /* Ethereum symbols */
        .crypto-icon.eth:nth-child(6) { top: 20%; left: 25%; transform: rotate(5deg); font-size: 52px; }
        .crypto-icon.eth:nth-child(7) { top: 60%; right: 5%; transform: rotate(-10deg); font-size: 60px; }
        .crypto-icon.eth:nth-child(8) { bottom: 30%; left: 8%; transform: rotate(15deg); font-size: 44px; }
        .crypto-icon.eth:nth-child(9) { top: 80%; right: 40%; transform: rotate(-5deg); font-size: 56px; }

        /* Generic crypto circle symbols */
        .crypto-icon.circle:nth-child(10) { top: 5%; left: 50%; transform: rotate(-8deg); font-size: 40px; }
        .crypto-icon.circle:nth-child(11) { top: 45%; left: 2%; transform: rotate(12deg); font-size: 36px; }
        .crypto-icon.circle:nth-child(12) { bottom: 10%; right: 8%; transform: rotate(-20deg); font-size: 52px; }
        .crypto-icon.circle:nth-child(13) { top: 85%; left: 60%; transform: rotate(8deg); font-size: 44px; }
        .crypto-icon.circle:nth-child(14) { top: 15%; right: 30%; transform: rotate(-12deg); font-size: 56px; }
        .crypto-icon.circle:nth-child(15) { bottom: 40%; left: 30%; transform: rotate(18deg); font-size: 48px; }

        /* Dashboard Navigation */
        .dashboard-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 48px;
            height: 64px;
            background: #3730a3;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        }

        .nav-left {
            display: flex;
            align-items: center;
            gap: 48px;
            height: 100%;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 12px;
            color: white;
            font-size: 24px;
            font-weight: 700;
            text-decoration: none;
            z-index: 10000;
            position: relative;
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background: white;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #3730a3;
            font-weight: bold;
        }

        .nav-links {
            display: flex;
            gap: 0;
            list-style: none;
            margin: 0;
            padding: 0;
            height: 100%;
            align-items: center;
        }

        .nav-links li {
            position: relative;
            z-index: 10000;
            height: 100%;
            display: flex;
            align-items: center;
        }

        /* SQUARE MENU LINKS - NO ROUNDED BORDERS */
        .nav-links a {
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            font-size: 15px;
            font-weight: 500;
            transition: all 0.2s;
            padding: 0 24px;
            height: 100%;
            display: flex;
            align-items: center;
            cursor: pointer;
            background: transparent;
            border: none;
            border-radius: 0;
            position: relative;
            z-index: 10000;
        }

        .nav-links a:hover {
            color: #ffffff;
            background: rgba(255, 255, 255, 0.1);
        }

        .nav-links a.active {
            color: #ffffff;
            background: rgba(255, 255, 255, 0.15);
            font-weight: 600;
        }

        /* Active indicator line at bottom */
        .nav-links a.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: #22c55e;
        }

        .nav-right {
            display: flex;
            align-items: center;
            gap: 24px;
            z-index: 10000;
            position: relative;
            height: 100%;
			
        }

        .balance-display {
            display: flex;
            align-items: center;
            background: rgba(255, 255, 255, 0.1);
            padding: 8px 16px;
            gap: 16px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0;
        }

        .balance-item {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #ffffff;
            font-size: 14px;
            font-weight: 600;
        }

        .balance-item.btc {
            border-right: 1px solid rgba(255, 255, 255, 0.3);
            padding-right: 16px;
        }

        .balance-item svg {
            width: 16px;
            height: 16px;
        }

        /* User Menu with Dropdown */
        .user-menu-container {
            position: relative;
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 12px;
            color: #ffffff;
            cursor: pointer;
            padding: 8px 12px;
            transition: background 0.2s;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0;
            height: 40px;
        }

        .user-menu:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        .user-icon {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .user-icon svg {
            width: 18px;
            height: 18px;
            color: white;
        }

        .username {
            font-size: 14px;
            font-weight: 600;
            color: #ffffff;
        }

        .dropdown-icon {
            width: 16px;
            height: 16px;
            color: rgba(255, 255, 255, 0.8);
            transition: transform 0.2s;
        }

        .user-menu-container.active .dropdown-icon {
            transform: rotate(180deg);
        }

        .notification-badge {
            position: absolute;
            top: -2px;
            right: -2px;
            width: 16px;
            height: 16px;
            background: #ef4444;
            color: white;
            font-size: 10px;
            font-weight: 700;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 2px solid #3730a3;
        }

        /* Dropdown Menu */
        .user-dropdown {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            background: white;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
            min-width: 280px;
            overflow: hidden;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.2s;
            z-index: 10001;
        }

        .user-menu-container.active .user-dropdown {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .dropdown-header {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 20px;
            background: #4f46e5;
            color: white;
        }

        .dropdown-header-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            border: 2px solid rgba(255, 255, 255, 0.3);
        }

        .dropdown-header-icon svg {
            width: 24px;
            height: 24px;
            color: white;
        }

        .dropdown-header-text {
            font-size: 20px;
            font-weight: 600;
        }

        .dropdown-menu {
            list-style: none;
            padding: 8px 0;
            margin: 0;
        }

        .dropdown-menu li {
            border-bottom: 1px solid #f1f5f9;
        }

        .dropdown-menu li:last-child {
            border-bottom: none;
        }

        .dropdown-menu a {
            display: flex;
            align-items: center;
            gap: 16px;
            padding: 16px 20px;
            color: #475569;
            text-decoration: none;
            font-size: 16px;
            font-weight: 500;
            transition: background 0.2s;
        }

        .dropdown-menu a:hover {
            background: #f8fafc;
        }

        .dropdown-menu-icon {
            width: 24px;
            height: 24px;
            color: #4f46e5;
        }

        .dropdown-menu-icon.logout {
            color: #ef4444;
        }

        /* Unread Badge */
        .unread-badge {
            background: #ec4899;
            color: white;
            font-size: 13px;
            font-weight: 600;
            padding: 6px 16px;
            border-radius: 20px;
            margin-left: auto;
        }

        .dropdown-menu a.logout-link {
            color: #ef4444;
        }

        .dropdown-menu a.logout-link:hover {
            background: #fef2f2;
        }

        /* Main Content Area */
        .main-content {
            position: relative;
            z-index: 10;
            min-height: 100vh;
            padding: 100px 48px 120px;
            background: #4f46e5;
        }

        /* Welcome Section */
        .welcome-section {
            margin-bottom: 32px;
        }

        .welcome-text {
            color: white;
            font-size: 24px;
            font-weight: 600;
        }

        /* Payment Grid */
        .payment-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 24px;
            max-width: 1400px;
        }

        /* Card Styles */
        .payment-card {
            background: #f8fafc;
            border-radius: 12px;
            padding: 32px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
        }

        .card-title {
            font-size: 16px;
            font-weight: 700;
            color: #1e1b4b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .expiry-timer {
            font-size: 14px;
            color: #1e1b4b;
            font-weight: 600;
        }

        /* Progress Bar */
        .progress-bar {
            width: 100%;
            height: 8px;
            background: #e2e8f0;
            border-radius: 4px;
            margin-bottom: 24px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            width: 85%;
            background: #6366f1;
            border-radius: 4px;
        }

        /* Payment Details */
        .detail-row {
            margin-bottom: 24px;
            padding-bottom: 24px;
            border-bottom: 1px solid #e2e8f0;
        }

        .detail-row:last-child {
            border-bottom: none;
        }

        .detail-label {
            font-size: 14px;
            font-weight: 700;
            color: #1e1b4b;
            text-transform: uppercase;
            margin-bottom: 8px;
            display: block;
        }

        .detail-value {
            font-size: 16px;
            color: #4f46e5;
            font-weight: 600;
            word-break: break-all;
        }

        .copy-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-top: 8px;
            color: #64748b;
            font-size: 14px;
            cursor: pointer;
            background: none;
            border: none;
            padding: 0;
        }

        .copy-btn:hover {
            color: #4f46e5;
        }

        /* QR Code Section */
        .qr-section {
            margin: 24px 0;
        }

        .qr-code {
            width: 200px;
            height: 200px;
            background: white;
            padding: 12px;
            margin-bottom: 12px;
        }

        .qr-hint {
            font-size: 13px;
            color: #64748b;
            line-height: 1.5;
        }

        /* Remarks Section */
        .remarks-section {
            margin-top: 24px;
            padding-top: 24px;
            border-top: 1px solid #e2e8f0;
        }

        .remarks-text {
            font-size: 15px;
            color: #334155;
            line-height: 1.7;
        }

        .remarks-text p {
            margin-bottom: 12px;
        }

        .remarks-text p:last-child {
            margin-bottom: 0;
        }

        /* FAQ Section */
        .faq-section {
            margin-top: 48px;
            padding-top: 32px;
            border-top: 2px solid #e2e8f0;
        }

        .faq-title {
            font-size: 20px;
            font-weight: 700;
            color: #1e1b4b;
            margin-bottom: 24px;
        }

        .faq-item {
            border-bottom: 1px solid #e2e8f0;
            padding: 20px 0;
        }

        .faq-item:last-child {
            border-bottom: none;
        }

        .faq-question {
            font-size: 17px;
            font-weight: 600;
            color: #1e1b4b;
            margin-bottom: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .faq-question:hover {
            color: #4f46e5;
        }

        .faq-answer {
            font-size: 15px;
            color: #64748b;
            line-height: 1.7;
            padding-left: 0;
        }

        /* History Card */
        .history-hint {
            font-size: 14px;
            color: #64748b;
            margin-bottom: 24px;
            padding-bottom: 16px;
            border-bottom: 1px solid #e2e8f0;
        }

        .empty-state {
            text-align: center;
            padding: 48px 0;
        }

        .empty-text {
            font-size: 16px;
            color: #1e1b4b;
            font-weight: 500;
            margin-bottom: 24px;
        }

        .status-indicator {
            width: 48px;
            height: 48px;
            border: 2px solid #22c55e;
            border-radius: 50%;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .status-dot {
            width: 16px;
            height: 16px;
            background: #22c55e;
            border-radius: 50%;
        }

        /* Footer */
        .dashboard-footer {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 48px;
            height: 80px;
            background: #4f46e5;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }

        .footer-left {
            display: flex;
            align-items: center;
            gap: 32px;
        }

        .footer-logo {
            width: 48px;
            height: 48px;
            background: white;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #4f46e5;
            font-size: 24px;
            font-weight: bold;
            text-decoration: none;
        }

        .footer-links {
            display: flex;
            gap: 32px;
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .footer-links a {
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            font-size: 15px;
            font-weight: 500;
            transition: color 0.2s;
        }

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

        .footer-right {
            text-align: right;
            color: rgba(255, 255, 255, 0.8);
            font-size: 14px;
            line-height: 1.6;
        }

        .footer-right p {
            margin: 0;
        }

        /* Floating animation for background icons */
        @keyframes float {
            0%, 100% { transform: translateY(0) rotate(var(--rotation, 0deg)); }
            50% { transform: translateY(-10px) rotate(var(--rotation, 0deg)); }
        }

        .crypto-icon {
            animation: float 6s ease-in-out infinite;
        }

        .crypto-icon:nth-child(odd) { animation-delay: 0s; }
        .crypto-icon:nth-child(even) { animation-delay: 3s; }

        /* Responsive */
        @media (max-width: 1024px) {
            .payment-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .dashboard-nav {
                padding: 0 24px;
            }

            .nav-links {
                display: none;
            }

            .balance-display {
                display: none;
            }

            .main-content {
                padding: 100px 24px 120px;
            }

            .payment-card {
                padding: 24px;
            }

            .user-dropdown {
                right: -12px;
                min-width: 260px;
            }

            .dashboard-footer {
                padding: 0 24px;
                flex-direction: column;
                height: auto;
                padding-top: 20px;
                padding-bottom: 20px;
                gap: 16px;
            }

            .footer-left {
                flex-direction: column;
                gap: 16px;
            }

            .footer-right {
                text-align: center;
            }
        }
		.timer-box {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
}


        input {
            width:100%;
            padding:12px;
            margin:10px 0;
            border:none;
            border-radius:5px;
        }
        button {
            width:100%;
            padding:12px;
            background:#3b82f6;
            border:none;
            color:#fff;
            cursor:pointer;
        }
        #status {
            margin-top:20px;
            font-weight:bold;
        }
/* ================= REFERRAL RESPONSIVE FIX ================= */

/* CENTER CARD */
.referral-wrapper{
    max-width:600px;
    margin:auto;
}

/* CLEAN CARD */
.referral-card{
    background:#fff;
    padding:25px;
    border-radius:10px;
    text-align:center;
}

/* INPUT FIX */
#refLink{
    width:100%;
    padding:12px;
    border-radius:6px;
    border:1px solid #ddd;
    text-align:center;
    font-size:14px;
}

/* BUTTON */
.ref-btn{
    width:100%;
    padding:12px;
    margin-top:10px;
    background:#3b82f6;
    color:#fff;
    border:none;
    border-radius:6px;
    cursor:pointer;
}

/* MOBILE FIX */
@media (max-width:768px){

    .main-content{
        padding:90px 15px 120px;
    }

    .payment-card{
        padding:20px;
    }

    .referral-wrapper{
        max-width:100%;
    }

    .referral-card{
        padding:20px;
    }

    h1{
        font-size:20px;
    }

}
/* ================= HEADER RESPONSIVE ================= */

/* LOGO */
.logo-img{
    width:180px;
    height:auto;
}

/* HAMBURGER */
.hamburger{
    display:none;
    flex-direction:column;
    gap:4px;
    cursor:pointer;
}
.hamburger span{
    width:25px;
    height:3px;
    background:#fff;
}

/* MOBILE MENU */
.mobile-menu{
    position:fixed;
    top:0;
    left:-260px;
    width:260px;
    height:100%;
    background:#3730a3;
    padding-top:80px;
    transition:.3s;
    z-index:9999;
}
.mobile-menu a{
    display:block;
    padding:15px 20px;
    color:#fff;
    text-decoration:none;
    border-bottom:1px solid rgba(255,255,255,0.1);
}
.mobile-menu.active{left:0}

/* OVERLAY */
.menu-overlay{
    position:fixed;
    top:0;left:0;right:0;bottom:0;
    background:rgba(0,0,0,.5);
    opacity:0;
    visibility:hidden;
    transition:.3s;
}
.menu-overlay.active{
    opacity:1;
    visibility:visible;
}

/* ================= MOBILE ================= */
@media (max-width:768px){

    .dashboard-nav{
        padding:0 16px;
    }

    .hamburger{
        display:flex;
    }

    .nav-links{
        display:none;
    }

    /* HIDE THESE */
    .balance-display{
        display:none!important;
    }

    .user-menu-container{
        display:none!important;
    }

    /* LOGO SMALLER */
    .logo-img{
        width:140px;
    }
}
/* ================= FOOTER RESPONSIVE ================= */

.dashboard-footer{
    position:fixed;
    bottom:0;
    left:0;
    right:0;

    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:0 40px;
    height:80px;

    background:#4f46e5;
    border-top:1px solid rgba(255,255,255,0.2);
    z-index:9999;
}

/* LEFT SIDE */
.footer-left{
    display:flex;
    align-items:center;
    gap:30px;
}

/* LOGO */
.footer-logo{
    width:48px;
    height:48px;
    background:#fff;
    color:#4f46e5;
    font-weight:bold;
    font-size:20px;
    border-radius:12px;

    display:flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
}

/* LINKS */
.footer-links{
    display:flex;
    gap:25px;
    list-style:none;
}

.footer-links a{
    color:rgba(255,255,255,0.8);
    text-decoration:none;
    font-size:14px;
}

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

/* RIGHT */
.footer-right{
    text-align:right;
    color:rgba(255,255,255,0.8);
    font-size:13px;
}

/* ================= MOBILE ================= */
@media (max-width:768px){

    .dashboard-footer{
        position:relative; /* 🔥 prevents overlap */
        flex-direction:column;
        height:auto;
        padding:20px;
        gap:15px;
        text-align:center;
    }

    .footer-left{
        flex-direction:column;
        gap:15px;
    }

    .footer-links{
        flex-direction:column;
        gap:10px;
        align-items:center;
    }

    .footer-right{
        text-align:center;
        font-size:12px;
    }
}
#menuOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    z-index: 998;
}

#menuOverlay.active {
    opacity: 1;
    visibility: visible;
}

#mobileMenu {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100%;
    transition: 0.3s;
    z-index: 999;
}

#mobileMenu.active {
    left: 0;
}
/* CONTAINER */
.box{
            text-align:center;
            padding:30px;
            border-radius:12px;
            background:#fff;
            box-shadow:0 10px 30px rgba(0,0,0,0.1);
            width:90%;
            max-width:400px;
        }

        .spinner{
            width:40px;
            height:40px;
            border:4px solid #22c55e;
            border-top:4px solid transparent;
            border-radius:50%;
            animation:spin 1s linear infinite;
            margin:0 auto 20px;
        }

        @keyframes spin{
            to{transform:rotate(360deg);}
        }

        .status{
            font-size:16px;
            font-weight:600;
        }

        .sub{
            font-size:13px;
            color:#64748b;
        }
		        .chat-box {
            height: 400px;
            overflow-y: auto;
            background: #f8f9fa;
            padding: 15px;
            border-radius: 10px;
        }

        .msg {
            padding: 10px 15px;
            border-radius: 15px;
            margin-bottom: 10px;
            max-width: 70%;
        }

        .me {
            background: #0d6efd;
            color: #fff;
            margin-left: auto;
            text-align: right;
        }

        .admin {
            background: #e9ecef;
            color: #000;
            margin-right: auto;
        }
    </style>

</head>
<body>
    <!-- Crypto icons background -->
    <div class="crypto-bg">
        <!-- Bitcoin symbols -->
        <div class="crypto-icon btc">₿</div>
        <div class="crypto-icon btc">₿</div>
        <div class="crypto-icon btc">₿</div>
        <div class="crypto-icon btc">₿</div>
        <div class="crypto-icon btc">₿</div>
        
        <!-- Ethereum symbols -->
        <div class="crypto-icon eth">◊</div>
        <div class="crypto-icon eth">◊</div>
        <div class="crypto-icon eth">◊</div>
        <div class="crypto-icon eth">◊</div>
        
        <!-- Circle/generic crypto symbols -->
        <div class="crypto-icon circle">◎</div>
        <div class="crypto-icon circle">◎</div>
        <div class="crypto-icon circle">◎</div>
        <div class="crypto-icon circle">◎</div>
        <div class="crypto-icon circle">◎</div>
        <div class="crypto-icon circle">◎</div>
    </div>

    <!-- Dashboard Navigation -->
    <nav class="dashboard-nav">
        <div class="nav-left">

    <!-- HAMBURGER -->
    <div class="hamburger" onclick="toggleMenu()">
        <span></span>
        <span></span>
        <span></span>
    </div>
           <a href="index.php" class="logo">
    <img src="img/logo_white.png" class="logo-img">
</a>
            <ul class="nav-links">
                <li><a href="dashboard.php">Dashboard</a></li>
                <li><a href="deposit.php">Deposit</a></li>
                <li><a href="withdraw.php" class="active">Withdraw</a></li>
                <li><a href="referral.php">Referral </a></li>
                <li><a href="contact.php">Contact </a></li>
            </ul>
        </div>
        <div class="nav-right">
            <div class="balance-display">
                <div class="balance-item btc">
                    <span><div><?php if (is_numeric($local_value)) {
    echo "" 
        . $symbol . number_format($local_value, 2) . "";
} else {
    echo "($local_value)";
} ?></div></span>
                    <svg viewBox="0 0 24 24" fill="currentColor">
                        <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v2h-1v2h1v4h-1v2h1v2h1.5v-2h1v-2h-1v-4h1V9h-1V7z"/>
                    </svg>
                </div>
                <div class="balance-item">
                    <span><?php echo number_format($btc_amount, 2) . " BTC "; ?></span>
                </div>
            </div>
            
            <!-- User Menu with Dropdown -->
            <div class="user-menu-container" id="userMenuContainer">
                <div class="user-menu" onclick="toggleDropdown()">
                    <div class="user-icon" style="position: relative;">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                            <circle cx="12" cy="7" r="4"></circle>
                        </svg>
                    </div>
                    <svg class="dropdown-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <polyline points="6 9 12 15 18 9"></polyline>
                    </svg>
                </div>
                
                <!-- Dropdown Menu -->
                <div class="user-dropdown">
                    <div class="dropdown-header">
                        <div class="dropdown-header-icon">
                            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                                <circle cx="12" cy="7" r="4"></circle>
                            </svg>
                        </div> <span class="dropdown-header-text"></span>
                    </div>
                    <ul class="dropdown-menu">
                        
                        
                        <li>
                            <a href="logout.php" class="logout-link">
                                <svg class="dropdown-menu-icon logout" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>
                                    <polyline points="16 17 21 12 16 7"></polyline>
                                    <line x1="21" y1="12" x2="9" y2="12"></line>
                                </svg>
                                Logout
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
<div class="mobile-menu" id="mobileMenu">
    <a href="dashboard.php">Dashboard</a>
    <a href="deposit.php">Deposit</a>
    <a href="withdraw.php" class="active">Withdraw</a>
    <a href="referral.php">Referral</a>
    <a href="contact.php">Contact</a>
</div>

<div class="menu-overlay" id="menuOverlay" onclick="toggleMenu()"></div>
    <!-- Main Content -->
    <div class="main-content">
       

        <div class="payment-grid">
        
            <div class="payment-card">
            

            <div class="card-header">
                
                    <h2 class="card-title"> Support Chat</h2>
                  
                </div>


              <div class="container mt-4" style="max-width:600px;">

    <div class="border-0 shadow-sm">
 
  <div class="container mt-5">
    <div class="card shadow">

        <!-- HEADER -->
       

        <!-- CHAT BODY -->
        <div class="card-body chat-box">

            <?php while($row = mysqli_fetch_assoc($res)): ?>

                <?php if($row['sender_id'] == $user_id): ?>
                    <div class="msg me">
                        <?php echo htmlspecialchars($row['message']); ?>
                    </div>
                <?php else: ?>
                    <div class="msg admin">
                        <?php echo htmlspecialchars($row['message']); ?>
                    </div>
                <?php endif; ?>

            <?php endwhile; ?>

        </div>

        <!-- INPUT -->
        <div class="card-footer">
            <form method="POST" class="d-flex gap-2">
                <input type="text" name="message" 
                       class="form-control" 
                       placeholder="Type message..." required>
                <button class="btn btn-primary">Send</button>
            </form>
        </div>

    </div>
</div>


    </div>

        </div>

    </div>

</div>
              </div>

            </div>

      
            
        </div>
    </div>

    <!-- Footer -->
<footer class="dashboard-footer">
    
    <div class="footer-right">
        <p>&copy; <?php echo date("Y"); ?>  Geneva & Exeter Coin. All rights reserved.</p>
    </div>
</footer>

    <script>
        function toggleDropdown() {
            const container = document.getElementById('userMenuContainer');
            container.classList.toggle('active');
        }

        // Close dropdown when clicking outside
        document.addEventListener('click', function(event) {
            const container = document.getElementById('userMenuContainer');
            if (!container.contains(event.target)) {
                container.classList.remove('active');
            }
        });

    </script>
    

<script>
        function toggleDropdown() {
            const container = document.getElementById('userMenuContainer');
            container.classList.toggle('active');
        }

        // Close dropdown when clicking outside
        document.addEventListener('click', function(event) {
            const container = document.getElementById('userMenuContainer');
            if (!container.contains(event.target)) {
                container.classList.remove('active');
            }
        });
function copyLink(){
    const input = document.getElementById('refLink');
    input.select();
    document.execCommand('copy');
    alert("Referral link copied!");
}
    </script>
<script>
function toggleMenu() {
    const menu = document.getElementById("mobileMenu");
    const overlay = document.getElementById("menuOverlay");

    menu.classList.toggle("active");
    overlay.classList.toggle("active");
}

// CLOSE when clicking overlay
document.getElementById("menuOverlay").addEventListener("click", function() {
    document.getElementById("mobileMenu").classList.remove("active");
    this.classList.remove("active");
});
</script>
</body>
</html>