<?php 
require_once 'includes/session.php';
require_once '../includes/header.php'; 
?>

<div class="container-fluid min-vh-100 py-5" style="background: #f1f5f9;">
    <div class="container">
        
        <div class="d-flex justify-content-between align-items-center mb-4">
            <h2 class="fw-bold text-dark">Member Dashboard</h2>
            <a href="logout.php" class="btn btn-danger btn-sm rounded-pill px-3 shadow-sm"><i class="fas fa-sign-out-alt"></i> Logout</a>
        </div>

        <div class="row g-4">
            <!-- Profile Overview Card -->
            <div class="col-lg-4">
                <div class="card border-0 shadow-sm rounded-4 text-center p-4 h-100">
                    <div class="mb-3">
                        <?php if(!empty($member['photo'])): ?>
                            <img src="../assets/uploads/<?php echo $member['photo']; ?>" class="rounded-circle border shadow-sm" style="width: 120px; height: 120px; object-fit: cover;" alt="Profile Photo">
                        <?php else: ?>
                            <div class="rounded-circle bg-secondary d-inline-flex align-items-center justify-content-center text-white shadow-sm" style="width: 120px; height: 120px; font-size: 3rem;">
                                <i class="fas fa-user"></i>
                            </div>
                        <?php endif; ?>
                    </div>
                    <h4 class="fw-bold mb-1"><?php echo h($member['name']); ?></h4>
                    <p class="text-muted mb-2"><?php echo h($member['designation'] ?? 'No Designation'); ?></p>
                    <span class="badge bg-success mb-3 px-3 py-2 rounded-pill">Status: Active</span>
                    
                    <hr>
                    
                    <a href="profile.php" class="btn btn-outline-primary w-100 rounded-pill mt-2">
                        <i class="fas fa-edit me-2"></i> Update Profile
                    </a>
                </div>
            </div>

            <!-- Quick Actions & Details -->
            <div class="col-lg-8">
                <div class="row g-4">
                    
                    <!-- ID Card Widget -->
                    <div class="col-md-6">
                        <div class="card border-0 shadow-sm rounded-4 h-100" style="background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); color: white;">
                            <div class="card-body p-4 d-flex flex-column justify-content-between">
                                <div>
                                    <h5 class="fw-bold mb-3"><i class="fas fa-id-card me-2"></i> Membership Card</h5>
                                    <p class="opacity-75" style="font-size: 0.9rem;">Generate and download your official trust membership identity card.</p>
                                </div>
                                <a href="id-card.php" class="btn btn-light rounded-pill mt-3 fw-bold text-primary w-100 shadow-sm">Generate ID Card</a>
                            </div>
                        </div>
                    </div>

                    <!-- Personal Information -->
                    <div class="col-12">
                        <div class="card border-0 shadow-sm rounded-4">
                            <div class="card-header bg-white border-0 pt-4 pb-0 px-4">
                                <h5 class="fw-bold"><i class="fas fa-info-circle me-2 text-primary"></i> Registration Details</h5>
                            </div>
                            <div class="card-body p-4">
                                <div class="row mb-3">
                                    <div class="col-sm-4 text-muted fw-bold">Email</div>
                                    <div class="col-sm-8"><?php echo h($member['email']); ?></div>
                                </div>
                                <div class="row mb-3">
                                    <div class="col-sm-4 text-muted fw-bold">Phone Number</div>
                                    <div class="col-sm-8"><?php echo h($member['phone']); ?></div>
                                </div>
                                <div class="row mb-3">
                                    <div class="col-sm-4 text-muted fw-bold">Member Type</div>
                                    <div class="col-sm-8 text-capitalize"><?php echo h($member['type']); ?></div>
                                </div>
                                <div class="row mb-3">
                                    <div class="col-sm-4 text-muted fw-bold">Address</div>
                                    <div class="col-sm-8"><?php echo h($member['address']); ?></div>
                                </div>
                            </div>
                        </div>
                    </div>

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

    </div>
</div>

<?php require_once '../includes/footer.php'; ?>
