<?php
if (session_status() === PHP_SESSION_NONE) { session_start(); }
include '_inc/dbconn.php';

// Authentication Check
if(!isset($_SESSION['customer_login'])) { 
    header('location:index.php'); 
    exit; 
}

$cust_id = $_SESSION['cust_id'];
// Updated to match your SQL schema (Table: users)
$sql = "SELECT * FROM users WHERE id='$cust_id'";
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
$user = mysqli_fetch_array($result);

$fullname = $user['fullname'];
$acc_no = $user['account_number'];
$balance = number_format($user['balance'], 2);
$initials = strtoupper(substr($fullname, 0, 1));
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>HL Security Deposit | Digital Banking</title>
    
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link href="https://cdn.materialdesignicons.com/6.5.95/css/materialdesignicons.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    
    <style>
    :root {
        --bank-blue: #0052FF;
        --bank-gradient: linear-gradient(135deg, #0052FF 0%, #003199 100%);
        --dark-navy: #0F172A;
        --soft-bg: #F4F7FE;
        --border-color: #E2E8F0;
        --sidebar-width: 270px;
        --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    }

    body { 
        font-family: 'Inter', -apple-system, sans-serif; 
        background: var(--soft-bg); 
        margin: 0; 
        overflow-x: hidden; 
        color: #1E293B;
    }
    
    /* Structural Layout */
    .app-wrapper { display: flex; min-height: 100vh; width: 100%; }
    
    #sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        background: var(--dark-navy);
        color: #fff;
        position: fixed;
        height: 100vh;
        z-index: 1050;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 30px rgba(0,0,0,0.05);
    }

    #content-area {
        flex-grow: 1;
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        transition: all 0.35s ease;
        padding-bottom: 50px;
    }

    /* Top Navigation Upgrade */
    .top-navbar {
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(10px); /* Modern Glass effect */
        height: 75px;
        padding: 0 30px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    /* Upgraded CoinTag */
    .cointag-user {
        background: #fff;
        border: 1px solid #E2E8F0;
        padding: 8px 18px;
        border-radius: 100px;
        display: flex;
        align-items: center;
        font-weight: 700;
        color: var(--dark-navy);
        box-shadow: var(--card-shadow);
        transition: 0.3s ease;
    }
    .cointag-user:hover { transform: translateY(-2px); border-color: var(--bank-blue); }
    
    .coin-icon {
        width: 26px;
        height: 26px;
        background: linear-gradient(135deg, #FFD700 0%, #F59E0B 100%);
        border: 2px solid #fff;
        border-radius: 50%;
        margin-right: 10px;
        box-shadow: 0 2px 4px rgba(245, 158, 11, 0.4);
    }

    /* Sidebar Navigation Links */
    .nav-link {
        color: #94A3B8 !important;
        padding: 14px 25px !important;
        margin: 4px 15px;
        border-radius: 12px;
        font-weight: 500;
        transition: all 0.3s;
    }
    .nav-link:hover { background: rgba(255,255,255,0.05); color: #fff !important; }
    .nav-link.active { 
        background: var(--bank-blue); 
        color: #fff !important; 
        box-shadow: 0 4px 12px rgba(0, 82, 255, 0.3);
    }

    /* Card Upgrades */
    .card {
        border: none;
        border-radius: 20px;
        box-shadow: var(--card-shadow);
        transition: 0.3s ease;
    }
    .card:hover { transform: translateY(-3px); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05); }

    .user-avatar {
        width: 44px;
        height: 44px;
        background: var(--bank-gradient);
        color: white;
        border-radius: 12px; /* Stylish squircle */
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 4px 10px rgba(0, 82, 255, 0.2);
    }

    /* Mobile Adjustments */
    @media (max-width: 992px) {
        #sidebar { transform: translateX(-100%); }
        #sidebar.active { transform: translateX(0); }
        #content-area { margin-left: 0; width: 100%; }
        .top-navbar { padding: 0 15px; }
    }
</style>

</head>
<body>
    <div class="app-wrapper">
