<?php
session_start();
include('include/config.php');
if(strlen($_SESSION['alogin'])==0){ 
    header('location:index.php');
} else {
?>
<script type="text/javascript">
function f2() { window.close(); }
function f3() { window.print(); }
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>User Profile</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- ✅ Bootstrap + Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">

<style>
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: #f7f8fa;
}

/* Center popup content */
.popup-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100%;
    padding: 30px 10px;
    box-sizing: border-box;
}

/* Profile Card */
.profile-card {
    width: 100%;
    max-width: 700px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Header */
.profile-header {
    background: linear-gradient(90deg, #ff7a00, #ffb366);
    color: #fff;
    padding: 25px 30px;
    text-align: center;
}
.profile-header img.logo {
    max-width: 180px;
    margin-bottom: 15px;
}
.profile-header h3 {
    font-weight: 600;
    margin-bottom: 5px;
}
.profile-header p {
    margin: 0;
    font-size: 14px;
}

/* Body */
.profile-body {
    padding: 25px 30px;
    max-height: 70vh;
    overflow-y: auto;
}
.profile-body table {
    width: 100%;
}
.profile-body td {
    padding: 10px 0;
    vertical-align: top;
}
.label {
    font-weight: 600;
    color: #333;
    width: 40%;
}
.value {
    color: #555;
}
.status-active {
    color: #198754;
    font-weight: 600;
}
.status-block {
    color: #dc3545;
    font-weight: 600;
}

/* Buttons */
.btn-area {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #eee;
    background-color: #fafafa;
}
.btn-close-window {
    border: none;
    background: linear-gradient(90deg, #ff7a00, #ffb366);
    color: #fff;
    padding: 10px 25px;
    border-radius: 30px;
    font-weight: 500;
    transition: 0.3s;
}
.btn-close-window:hover {
    opacity: 0.9;
}
.btn-print {
    border: 1px solid #6c757d;
    color: #6c757d;
    border-radius: 30px;
}
.btn-print:hover {
    background: #6c757d;
    color: #fff;
}
</style>
</head>

<body>
<?php 
$ret1 = mysqli_query($bd, "SELECT * FROM users WHERE id='".$_GET['uid']."'");
while($row = mysqli_fetch_array($ret1)) {
?>
<div class="popup-wrapper">
    <div class="profile-card">
        <div class="profile-header">
            <!-- Logo Above Name -->
            <img src="https://www.gniotips.in/img/logo-textprimary.png" alt="GNIOT Logo" class="logo">
            <h3><i class="bi bi-person-circle me-2"></i><?php echo htmlentities($row['fullName']); ?>'s Profile</h3>
            <p>Registered on <?php echo htmlentities($row['regDate']); ?></p>
        </div>

        <div class="profile-body">
            <table class="table border-0">
                <tr><td class="label">User Email:</td><td class="value"><?php echo htmlentities($row['userEmail']); ?></td></tr>
                <tr><td class="label">Contact No:</td><td class="value"><?php echo htmlentities($row['contactNo']); ?></td></tr>
                <tr><td class="label">Address:</td><td class="value"><?php echo htmlentities($row['address']); ?></td></tr>
                <tr><td class="label">State:</td><td class="value"><?php echo htmlentities($row['State']); ?></td></tr>
                <tr><td class="label">Country:</td><td class="value"><?php echo htmlentities($row['country']); ?></td></tr>
                <tr><td class="label">Pincode:</td><td class="value"><?php echo htmlentities($row['pincode']); ?></td></tr>
                <tr><td class="label">Last Updation:</td><td class="value"><?php echo htmlentities($row['updationDate']); ?></td></tr>
                <tr>
                    <td class="label">Status:</td>
                    <td class="value">
                        <?php if($row['status']==1) { ?>
                            <span class="status-active"><i class="bi bi-check-circle-fill"></i> Active</span>
                        <?php } else { ?>
                            <span class="status-block"><i class="bi bi-x-circle-fill"></i> Blocked</span>
                        <?php } ?>
                    </td>
                </tr>
            </table>
        </div>

        <div class="btn-area">
            <button type="button" class="btn-close-window" onclick="f2()">
                <i class="bi bi-x-circle me-1"></i> Close Window
            </button>
            <button type="button" class="btn btn-print ms-2" onclick="f3()">
                <i class="bi bi-printer me-1"></i> Print
            </button>
        </div>
    </div>
</div>
<?php } ?>

<!-- ✅ Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php } ?>
