<?php
// ============================================================
//  user/dashboard.php — Wadata User Dashboard
// ============================================================
session_start();
require_once '../includes/db.php';

// Auth guard
if (empty($_SESSION['user_id'])) {
    header('Location: login.php'); exit;
}

// Refresh user data
$user = db_fetch_one("SELECT * FROM users WHERE id = ?", [$_SESSION['user_id']]);
if (!$user) { session_destroy(); header('Location: login.php'); exit; }

// Update session in case data changed
$_SESSION['user_name']     = $user['full_name'];
$_SESSION['user_avatar']   = $user['avatar'];
$_SESSION['user_username'] = $user['username'];
$_SESSION['user_status']   = $user['status'];

// Stats
$member_since  = date('M Y', strtotime($user['created_at']));
$days_since    = max(1, (int)((time() - strtotime($user['created_at'])) / 86400));
$last_login    = $user['last_login'] ? date('d M Y, H:i', strtotime($user['last_login'])) : 'First visit';

$avatar_src = !empty($user['avatar']) && $user['avatar'] !== 'default_avatar.png'
    ? '../assets/images/avatars/' . htmlspecialchars($user['avatar'])
    : '../assets/images/avatars/default_avatar.png';

$greeting = (int)date('G') < 12 ? 'Good morning' : ((int)date('G') < 17 ? 'Good afternoon' : 'Good evening');
$first_name = explode(' ', $user['full_name'])[0];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>My Dashboard — WADATA Skills Acquisition Center</title>
<link rel="icon" type="image/png" href="../assets/img/logo.png"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"/>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Epilogue:wght@700;800&display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="../assets/css/style.css"/>
<style>
/* ── TOKENS ─────────────────────────────────────────────── */
:root {
  --primary:#0B2545; --primary-l:#1e3a5f;
  --accent:#FF6A00;  --accent-l:#ff8533;
  --light:#F6F9FC;   --page:#EDF4FC;
  --glass:rgba(255,255,255,.72); --glass2:rgba(255,255,255,.50); --glass3:rgba(255,255,255,.30);
  --bdr:rgba(255,255,255,.82);   --bdr2:rgba(11,37,69,.12);      --bdr3:rgba(11,37,69,.06);
  --sh:0 4px 24px rgba(11,37,69,.09),0 1px 4px rgba(0,0,0,.04);
  --sh2:0 16px 48px rgba(11,37,69,.13);
  --th:#0B2545; --tb:#2D3E5E; --tm:#6C7E9A;
  --mesh:rgba(11,37,69,.032);
  --w:250px; --top:62px; --rad:16px; --rads:10px; --radxs:7px;
  --t:.22s cubic-bezier(.22,1,.36,1);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;font-family:'Plus Jakarta Sans',sans-serif;background:var(--page);color:var(--tb);overflow-x:hidden}

/* ── SCENE ─────────────────────────────────────────────── */
.scene{position:fixed;inset:0;z-index:0;overflow:hidden;pointer-events:none}
.scene::before{content:'';position:absolute;inset:0;
  background:radial-gradient(ellipse 65% 55% at 3% 6%,rgba(255,106,0,.18),transparent 55%),
             radial-gradient(ellipse 60% 65% at 97% 95%,rgba(11,37,69,.13),transparent 55%),
             radial-gradient(ellipse 45% 45% at 55% 50%,rgba(255,165,0,.11),transparent 60%)}
.scene::after{content:'';position:absolute;inset:0;
  background-image:linear-gradient(var(--mesh) 1px,transparent 1px),linear-gradient(90deg,var(--mesh) 1px,transparent 1px);
  background-size:56px 56px}
.orb{position:absolute;border-radius:50%;filter:blur(90px);animation:drift ease-in-out infinite alternate;pointer-events:none}
.oa{width:460px;height:460px;background:radial-gradient(#ff8533,transparent 70%);top:-160px;left:-80px;opacity:.40;animation-duration:16s}
.ob{width:360px;height:360px;background:radial-gradient(#1e3a5f,transparent 70%);bottom:-100px;right:-70px;opacity:.32;animation-duration:13s;animation-delay:-6s}
@keyframes drift{0%{transform:translate(0,0) scale(1)}100%{transform:translate(38px,26px) scale(1.07)}}

/* ── LAYOUT ────────────────────────────────────────────── */
.shell{position:relative;z-index:1;display:flex;height:100vh;overflow:hidden}

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar{width:var(--w);flex-shrink:0;
  background:var(--glass);border-right:1px solid var(--bdr);
  backdrop-filter:blur(36px) saturate(200%);-webkit-backdrop-filter:blur(36px) saturate(200%);
  box-shadow:4px 0 28px rgba(0,0,0,.06);
  display:flex;flex-direction:column;overflow:hidden;transition:background .35s}

.sb-top{padding:18px 18px 14px;border-bottom:1px solid var(--bdr2);display:flex;align-items:center;gap:11px}
.sb-logo{width:36px;height:36px;border-radius:10px;overflow:hidden;background:#fff;padding:4px;
  box-shadow:0 3px 12px rgba(255,106,0,.2);flex-shrink:0;display:grid;place-items:center}
.sb-logo img{width:100%;height:100%;object-fit:contain}
.sb-logo .fb{width:100%;height:100%;border-radius:7px;background:linear-gradient(135deg,var(--accent),var(--primary));display:grid;place-items:center;color:#fff;font-size:14px}
.sb-name strong{display:block;font-family:'Epilogue',sans-serif;font-size:14px;font-weight:800;color:var(--th);letter-spacing:-.2px}
.sb-name em{font-style:normal;font-size:9px;font-weight:700;letter-spacing:1.8px;text-transform:uppercase;color:var(--accent)}

.sb-nav{padding:8px 10px;flex:1;overflow-y:auto;scrollbar-width:none}
.sb-nav::-webkit-scrollbar{display:none}
.sbl{font-size:9px;font-weight:800;letter-spacing:2px;text-transform:uppercase;color:var(--tm);padding:14px 10px 5px}
.sln{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:var(--rads);
  font-size:12.5px;font-weight:600;color:var(--tb);text-decoration:none;cursor:pointer;
  transition:all var(--t);margin-bottom:2px;border:1px solid transparent;position:relative}
.sln:hover{background:rgba(255,255,255,.78);color:var(--th)}
.sln.on{background:linear-gradient(135deg,rgba(255,106,0,.14),rgba(11,37,69,.08));
  border-color:rgba(255,106,0,.18);color:var(--accent)}
.sln.on::before{content:'';position:absolute;left:0;top:22%;bottom:22%;
  width:3px;border-radius:3px;background:linear-gradient(to bottom,var(--accent),var(--primary))}
.sln i{width:16px;text-align:center;font-size:13px;flex-shrink:0}

.sb-foot{padding:12px;border-top:1px solid var(--bdr2)}
.sb-user{display:flex;align-items:center;gap:9px;padding:9px 11px;border-radius:var(--rads);
  background:rgba(255,255,255,.55);border:1px solid var(--bdr2);transition:all var(--t);cursor:pointer}
.sb-user:hover{background:rgba(255,255,255,.80)}
.sb-av{width:32px;height:32px;border-radius:50%;object-fit:cover;border:2px solid var(--bdr);flex-shrink:0}
.sb-av-fb{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--primary));
  display:grid;place-items:center;color:#fff;font-size:11px;font-weight:800;flex-shrink:0;border:2px solid var(--bdr)}
.sb-ui strong{display:block;font-size:11.5px;font-weight:700;color:var(--th);line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}
.sb-ui span{font-size:10px;color:var(--tm)}

/* ── MAIN ───────────────────────────────────────────────── */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden}

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar{height:var(--top);flex-shrink:0;
  background:rgba(255,255,255,.75);border-bottom:1px solid var(--bdr2);
  backdrop-filter:blur(32px) saturate(180%);-webkit-backdrop-filter:blur(32px) saturate(180%);
  display:flex;align-items:center;justify-content:space-between;padding:0 26px;gap:16px}
.tb-l{display:flex;align-items:center;gap:14px}
.tb-bc{font-size:12.5px;color:var(--tm)}.tb-bc strong{color:var(--th);font-weight:700}
.tb-srch{display:flex;align-items:center;gap:8px;background:rgba(255,255,255,.88);
  border:1px solid var(--bdr2);border-radius:var(--rads);padding:7px 13px;transition:all .2s}
.tb-srch:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px rgba(255,106,0,.18)}
.tb-srch i{color:var(--tm);font-size:12px}
.tb-srch input{background:none;border:none;outline:none;font-family:inherit;font-size:12.5px;color:var(--th);width:170px}
.tb-srch input::placeholder{color:var(--tm)}
.tb-r{display:flex;align-items:center;gap:9px}
.tbb{width:34px;height:34px;border-radius:var(--radxs);background:rgba(255,255,255,.88);
  border:1px solid var(--bdr2);display:grid;place-items:center;cursor:pointer;
  font-size:13px;color:var(--tb);transition:all var(--t)}
.tbb:hover{background:rgba(255,255,255,1);color:var(--th)}
.tb-prof{display:flex;align-items:center;gap:9px;padding:4px 12px 4px 5px;
  background:rgba(255,255,255,.88);border:1px solid var(--bdr2);border-radius:var(--rads);
  cursor:pointer;transition:all var(--t);text-decoration:none}
.tb-prof:hover{background:rgba(255,255,255,1)}
.tb-pav{width:26px;height:26px;border-radius:50%;object-fit:cover;border:2px solid var(--bdr);flex-shrink:0}
.tb-pav-fb{width:26px;height:26px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--primary));
  display:grid;place-items:center;color:#fff;font-size:9.5px;font-weight:800}
.tb-prof span{font-size:12px;font-weight:700;color:var(--th)}

/* ── CONTENT ────────────────────────────────────────────── */
.content{flex:1;overflow-y:auto;padding:22px 26px;scrollbar-width:thin;scrollbar-color:var(--bdr2) transparent}
.content::-webkit-scrollbar{width:5px}
.content::-webkit-scrollbar-thumb{background:var(--bdr2);border-radius:10px}

/* ── GLASS CARD ─────────────────────────────────────────── */
.gc{background:var(--glass);border:1px solid var(--bdr);border-radius:var(--rad);
  backdrop-filter:blur(32px) saturate(180%);-webkit-backdrop-filter:blur(32px) saturate(180%);
  box-shadow:var(--sh);transition:background .35s,border-color .35s;animation:fadeUp .5s ease both}
@keyframes fadeUp{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:none}}
.gc-hd{display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px 12px;border-bottom:1px solid var(--bdr2)}
.gc-t{font-family:'Epilogue',sans-serif;font-size:14px;font-weight:800;color:var(--th)}
.gc-s{font-size:10.5px;color:var(--tm);margin-top:2px}
.gc-bd{padding:18px 20px}

/* ── WELCOME BANNER ─────────────────────────────────────── */
.welcome{background:linear-gradient(130deg,var(--accent) 0%,var(--accent-l) 38%,var(--primary) 100%);
  border-radius:var(--rad);padding:22px 26px;
  display:flex;align-items:center;justify-content:space-between;gap:20px;
  margin-bottom:20px;position:relative;overflow:hidden;
  animation:fadeUp .45s ease both;box-shadow:0 8px 30px rgba(255,106,0,.28)}
.welcome::before{content:'';position:absolute;width:280px;height:280px;border-radius:50%;
  background:rgba(255,255,255,.07);right:-70px;top:-90px;pointer-events:none}
.welcome::after{content:'';position:absolute;width:160px;height:160px;border-radius:50%;
  background:rgba(255,255,255,.05);left:32%;bottom:-65px;pointer-events:none}
.wl-av{width:54px;height:54px;border-radius:50%;object-fit:cover;
  border:3px solid rgba(255,255,255,.5);flex-shrink:0;z-index:1}
.wl-av-fb{width:54px;height:54px;border-radius:50%;background:rgba(255,255,255,.25);
  display:grid;place-items:center;color:#fff;font-size:20px;font-weight:800;
  border:3px solid rgba(255,255,255,.5);flex-shrink:0;z-index:1}
.wl-t h2{font-family:'Epilogue',sans-serif;font-size:18px;font-weight:800;color:#fff;margin-bottom:3px}
.wl-t p{font-size:12.5px;color:rgba(255,255,255,.82);line-height:1.5}
.wl-a{display:flex;gap:9px;flex-shrink:0;z-index:1}
.wlb{padding:8px 17px;border-radius:var(--radxs);font-size:12px;font-weight:700;
  text-decoration:none;display:flex;align-items:center;gap:6px;transition:all .2s}
.wlb.s{background:#fff;color:var(--accent)}.wlb.s:hover{transform:translateY(-2px);box-shadow:0 6px 18px rgba(0,0,0,.15)}
.wlb.g{background:rgba(255,255,255,.18);color:#fff;border:1px solid rgba(255,255,255,.3)}.wlb.g:hover{background:rgba(255,255,255,.28)}

/* ── STATUS CHIP ────────────────────────────────────────── */
.status-chip{display:inline-flex;align-items:center;gap:5px;padding:4px 11px;border-radius:20px;font-size:10.5px;font-weight:700}
.status-chip::before{content:'';width:5px;height:5px;border-radius:50%;flex-shrink:0}
.s-active{background:rgba(16,185,129,.12);color:#059669;border:1px solid rgba(16,185,129,.22)}.s-active::before{background:#10B981}
.s-pending{background:rgba(240,165,0,.12);color:#92400E;border:1px solid rgba(240,165,0,.22)}.s-pending::before{background:#F59E0B}
.s-inactive{background:rgba(139,92,246,.10);color:#5B21B6;border:1px solid rgba(139,92,246,.18)}.s-inactive::before{background:#8B5CF6}

/* ── STAT GRID ──────────────────────────────────────────── */
.sg{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.sc{background:var(--glass);border:1px solid var(--bdr);border-radius:var(--rad);
  padding:18px 18px 14px;position:relative;overflow:hidden;
  backdrop-filter:blur(32px) saturate(180%);-webkit-backdrop-filter:blur(32px) saturate(180%);
  transition:transform var(--t),box-shadow var(--t);animation:fadeUp .5s ease both;box-shadow:var(--sh)}
.sc:hover{transform:translateY(-4px);box-shadow:var(--sh2)}
.sc::before{content:'';position:absolute;top:0;left:0;right:0;height:3px;border-radius:var(--rad) var(--rad) 0 0}
.sc::after{content:'';position:absolute;width:80px;height:80px;border-radius:50%;right:-18px;bottom:-18px;filter:blur(28px);opacity:.14;pointer-events:none}
.or::before{background:linear-gradient(90deg,var(--accent),var(--accent-l))}.or::after{background:var(--accent)}
.bl::before{background:linear-gradient(90deg,#1A6FE8,#4E96F4)}.bl::after{background:#1A6FE8}
.gr::before{background:linear-gradient(90deg,#10B981,#34D399)}.gr::after{background:#10B981}
.gd::before{background:linear-gradient(90deg,#F0A500,#FBC344)}.gd::after{background:#F0A500}
.sc-row{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:8px}
.si{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;font-size:14px;flex-shrink:0}
.sn{font-family:'Epilogue',sans-serif;font-size:26px;font-weight:800;color:var(--th);line-height:1;letter-spacing:-1px;margin-bottom:2px}
.sl{font-size:11px;color:var(--tm);font-weight:500}
.sd{display:inline-flex;align-items:center;gap:4px;margin-top:7px;font-size:10.5px;font-weight:700;padding:3px 7px;border-radius:20px}
.neu{background:rgba(11,37,69,.07);color:var(--tm);border:1px solid var(--bdr3)}

/* ── TWO COL ────────────────────────────────────────────── */
.row2{display:grid;grid-template-columns:1fr 280px;gap:16px;margin-bottom:20px}
.colr{display:flex;flex-direction:column;gap:14px}

/* ── PROGRAM CARD ───────────────────────────────────────── */
.prog-item{display:flex;align-items:center;gap:14px;padding:14px 18px;
  border-bottom:1px solid var(--bdr2);transition:background var(--t);cursor:default}
.prog-item:last-child{border-bottom:none}
.prog-item:hover{background:rgba(255,255,255,.50)}
.prog-ico{width:40px;height:40px;border-radius:11px;display:grid;place-items:center;font-size:16px;flex-shrink:0}
.prog-info{flex:1;min-width:0}
.prog-name{font-size:13px;font-weight:700;color:var(--th);margin-bottom:3px}
.prog-meta{font-size:11px;color:var(--tm);font-weight:500}
.prog-pct{font-size:11.5px;font-weight:800;color:var(--accent);flex-shrink:0}
.prog-bar{height:4px;background:var(--bdr3);border-radius:3px;margin-top:5px;overflow:hidden}
.prog-fill{height:100%;border-radius:3px;transition:width 1.2s cubic-bezier(.22,1,.36,1)}

/* ── PROFILE CARD ───────────────────────────────────────── */
.profile-card{text-align:center;padding:24px 20px}
.pf-av{width:72px;height:72px;border-radius:50%;object-fit:cover;
  border:3px solid var(--bdr);box-shadow:0 4px 16px rgba(11,37,69,.12);margin:0 auto 12px}
.pf-av-fb{width:72px;height:72px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--primary));
  display:grid;place-items:center;color:#fff;font-size:24px;font-weight:800;
  border:3px solid var(--bdr);box-shadow:0 4px 16px rgba(11,37,69,.12);margin:0 auto 12px}
.pf-name{font-family:'Epilogue',sans-serif;font-size:15px;font-weight:800;color:var(--th);margin-bottom:2px}
.pf-user{font-size:11.5px;color:var(--tm);margin-bottom:10px}
.pf-meta{display:flex;flex-direction:column;gap:7px;margin:14px 0}
.pf-row{display:flex;align-items:center;gap:9px;font-size:12px;color:var(--tb)}
.pf-row i{width:14px;text-align:center;color:var(--accent);font-size:11px}
.pf-link{display:block;padding:9px;border-radius:var(--rads);
  background:linear-gradient(130deg,var(--accent),var(--primary));
  color:#fff;font-family:'Epilogue',sans-serif;font-size:12.5px;font-weight:800;
  text-decoration:none;text-align:center;transition:all .2s;
  box-shadow:0 4px 16px rgba(255,106,0,.32)}
.pf-link:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(255,106,0,.42);color:#fff}

/* ── QUICK LINKS ────────────────────────────────────────── */
.ql{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.qla{display:flex;flex-direction:column;align-items:center;gap:5px;padding:12px 8px;
  border-radius:var(--rads);background:rgba(255,255,255,.55);border:1px solid var(--bdr2);
  font-size:11px;font-weight:700;color:var(--tb);text-decoration:none;text-align:center;
  transition:all var(--t)}
.qla:hover{background:rgba(255,255,255,.85);transform:translateY(-2px);box-shadow:var(--sh);color:var(--th)}
.qla i{font-size:15px}

/* ── NOTICE STRIP ───────────────────────────────────────── */
.notice{display:flex;align-items:center;gap:11px;padding:12px 18px;border-radius:12px;
  background:rgba(240,165,0,.10);border:1px solid rgba(240,165,0,.22);
  font-size:12.5px;font-weight:600;color:#92400E;margin-bottom:20px;
  animation:fadeUp .45s ease both;animation-delay:.05s}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media(max-width:1100px){.sg{grid-template-columns:repeat(2,1fr)}}
@media(max-width:900px){.row2{grid-template-columns:1fr}}
@media(max-width:700px){.sidebar{display:none}.content{padding:14px}}
@media(max-width:580px){.sg{grid-template-columns:1fr 1fr}}
</style>
</head>
<body>

<div class="scene"><div class="orb oa"></div><div class="orb ob"></div></div>

<div class="shell">

  <!-- ── SIDEBAR ──────────────────────────────────────────── -->
  <aside class="sidebar">
    <div class="sb-top">
      <div class="sb-logo">
        <img src="../assets/img/logo.png" alt="Wadata"
             onerror="this.parentElement.innerHTML='<div class=fb><i class=\'fas fa-graduation-cap\'></i></div>'"/>
      </div>
      <div class="sb-name"><strong>WADATA</strong><em>Skill Center</em></div>
    </div>

    <nav class="sb-nav">
      <div class="sbl">My Learning</div>
      <a class="sln on" href="dashboard.php"><i class="fas fa-gauge-high"></i> Dashboard</a>
      <a class="sln" href="profile.php"><i class="fas fa-circle-user"></i> My Profile</a>
      <a class="sln" href="#"><i class="fas fa-book-open"></i> My Programmes</a>
      <a class="sln" href="#"><i class="fas fa-certificate"></i> Certifications</a>
      <a class="sln" href="#"><i class="fas fa-calendar-check"></i> Schedule</a>

      <div class="sbl" style="margin-top:6px">Resources</div>
      <a class="sln" href="#"><i class="fas fa-chalkboard-user"></i> Instructors</a>
      <a class="sln" href="#"><i class="fas fa-comments"></i> Support</a>
      <a class="sln" href="#" style="color:#DC2626;margin-top:4px" onclick="return confirm('Sign out?') && (window.location='logout.php')">
        <i class="fas fa-right-from-bracket"></i> Sign Out
      </a>
    </nav>

    <div class="sb-foot">
      <a href="profile.php" class="sb-user" style="text-decoration:none">
        <?php if (!empty($user['avatar']) && $user['avatar'] !== 'default_avatar.png'): ?>
          <img src="<?= $avatar_src ?>" class="sb-av" alt=""/>
        <?php else: ?>
          <div class="sb-av-fb"><?= strtoupper(substr($user['full_name'], 0, 1)) ?></div>
        <?php endif; ?>
        <div class="sb-ui">
          <strong><?= htmlspecialchars($user['full_name']) ?></strong>
          <span>@<?= htmlspecialchars($user['username']) ?></span>
        </div>
        <i class="fas fa-ellipsis-v" style="color:var(--tm);font-size:11px;margin-left:auto"></i>
      </a>
    </div>
  </aside>

  <!-- ── MAIN ─────────────────────────────────────────────── -->
  <div class="main">

    <!-- TOPBAR -->
    <header class="topbar">
      <div class="tb-l">
        <div class="tb-bc">Wadata / <strong>My Dashboard</strong></div>
        <div class="tb-srch">
          <i class="fas fa-magnifying-glass"></i>
          <input type="text" placeholder="Search programmes, resources…"/>
        </div>
      </div>
      <div class="tb-r">
        <div class="tbb" title="Notifications"><i class="fas fa-bell"></i></div>
        <a href="profile.php" class="tb-prof">
          <?php if (!empty($user['avatar']) && $user['avatar'] !== 'default_avatar.png'): ?>
            <img src="<?= $avatar_src ?>" class="tb-pav" alt=""/>
          <?php else: ?>
            <div class="tb-pav-fb"><?= strtoupper(substr($user['full_name'], 0, 1)) ?></div>
          <?php endif; ?>
          <span><?= htmlspecialchars($first_name) ?></span>
          <i class="fas fa-chevron-down" style="font-size:9px;color:var(--tm)"></i>
        </a>
      </div>
    </header>

    <!-- CONTENT -->
    <div class="content">

      <!-- Pending notice -->
      <?php if ($user['status'] === 'pending'): ?>
        <div class="notice">
          <i class="fas fa-hourglass-half" style="color:#F59E0B;font-size:16px;flex-shrink:0"></i>
          <div>
            <strong>Account Pending Approval</strong> — Your account is under review by our admin team. You'll get full access once approved. Check back soon!
          </div>
        </div>
      <?php endif; ?>

      <!-- Welcome -->
      <div class="welcome">
        <div style="display:flex;align-items:center;gap:14px;z-index:1">
          <?php if (!empty($user['avatar']) && $user['avatar'] !== 'default_avatar.png'): ?>
            <img src="<?= $avatar_src ?>" class="wl-av" alt=""/>
          <?php else: ?>
            <div class="wl-av-fb"><?= strtoupper(substr($user['full_name'], 0, 1)) ?></div>
          <?php endif; ?>
          <div class="wl-t">
            <h2><?= $greeting ?>, <?= htmlspecialchars($first_name) ?> 👋</h2>
            <p>Member since <?= $member_since ?> · Last login: <?= $last_login ?></p>
          </div>
        </div>
        <div class="wl-a">
          <a href="#" class="wlb g"><i class="fas fa-book-open"></i> Browse Programmes</a>
          <a href="profile.php" class="wlb s"><i class="fas fa-circle-user"></i> My Profile</a>
        </div>
      </div>

      <!-- Stats -->
      <div class="sg">
        <div class="sc or" style="animation-delay:.04s">
          <div class="sc-row">
            <div><div class="sn">0</div><div class="sl">Enrolled Programmes</div></div>
            <div class="si" style="background:rgba(255,106,0,.13);color:var(--accent)"><i class="fas fa-book-open"></i></div>
          </div>
          <div class="sd neu"><i class="fas fa-plus"></i> Start learning</div>
        </div>
        <div class="sc gr" style="animation-delay:.08s">
          <div class="sc-row">
            <div><div class="sn">0</div><div class="sl">Completed</div></div>
            <div class="si" style="background:rgba(16,185,129,.12);color:#10B981"><i class="fas fa-circle-check"></i></div>
          </div>
          <div class="sd neu"><i class="fas fa-certificate"></i> No certs yet</div>
        </div>
        <div class="sc bl" style="animation-delay:.12s">
          <div class="sc-row">
            <div><div class="sn"><?= $days_since ?></div><div class="sl">Days at Wadata</div></div>
            <div class="si" style="background:rgba(26,111,232,.12);color:#1A6FE8"><i class="fas fa-calendar-days"></i></div>
          </div>
          <div class="sd neu"><i class="fas fa-clock"></i> Since <?= $member_since ?></div>
        </div>
        <div class="sc gd" style="animation-delay:.16s">
          <div class="sc-row">
            <div>
              <div class="sn" style="font-size:20px;letter-spacing:0;margin-top:4px">
                <span class="status-chip s-<?= $user['status'] ?>"><?= ucfirst($user['status']) ?></span>
              </div>
              <div class="sl" style="margin-top:4px">Account Status</div>
            </div>
            <div class="si" style="background:rgba(240,165,0,.12);color:#F0A500"><i class="fas fa-id-card"></i></div>
          </div>
          <div class="sd neu">
            <i class="fas fa-<?= $user['email_verified'] ? 'envelope-circle-check' : 'envelope' ?>"></i>
            <?= $user['email_verified'] ? 'Email verified' : 'Email unverified' ?>
          </div>
        </div>
      </div>

      <!-- Main row -->
      <div class="row2">

        <!-- Programmes -->
        <div class="gc" style="padding:0;overflow:hidden;animation-delay:.18s">
          <div class="gc-hd">
            <div><div class="gc-t">My Programmes</div><div class="gc-s">Enrolled learning paths</div></div>
            <a href="#" style="display:inline-flex;align-items:center;gap:5px;padding:6px 12px;border-radius:var(--radxs);
               background:rgba(255,106,0,.10);border:1px solid rgba(255,106,0,.18);
               font-size:11.5px;font-weight:700;color:var(--accent);text-decoration:none">
              Browse All <i class="fas fa-arrow-right" style="font-size:9px"></i>
            </a>
          </div>

          <!-- Empty state -->
          <div style="text-align:center;padding:48px 20px;color:var(--tm)">
            <div style="width:60px;height:60px;border-radius:16px;background:rgba(255,106,0,.10);
                 display:grid;place-items:center;margin:0 auto 14px;font-size:24px;color:var(--accent)">
              <i class="fas fa-graduation-cap"></i>
            </div>
            <div style="font-family:'Epilogue',sans-serif;font-size:15px;font-weight:800;color:var(--th);margin-bottom:6px">No programmes yet</div>
            <div style="font-size:12.5px;margin-bottom:18px;line-height:1.6">
              Explore our ICT, Tailoring, Culinary, Makeup, Hand Craft, and Counseling programmes.
            </div>
            <a href="../index.php#programs" style="display:inline-flex;align-items:center;gap:7px;padding:10px 20px;
               border-radius:var(--rads);background:linear-gradient(135deg,var(--accent),var(--primary));
               color:#fff;font-size:13px;font-weight:700;text-decoration:none;
               box-shadow:0 4px 16px rgba(255,106,0,.30);transition:all .2s"
               onmouseover="this.style.transform='translateY(-2px)'" onmouseout="this.style.transform='none'">
              <i class="fas fa-plus"></i> Browse Programmes
            </a>
          </div>
        </div>

        <!-- Right col -->
        <div class="colr">

          <!-- Profile card -->
          <div class="gc" style="padding:0;overflow:hidden;animation-delay:.20s">
            <div class="profile-card">
              <?php if (!empty($user['avatar']) && $user['avatar'] !== 'default_avatar.png'): ?>
                <img src="<?= $avatar_src ?>" class="pf-av" alt=""/>
              <?php else: ?>
                <div class="pf-av-fb"><?= strtoupper(substr($user['full_name'], 0, 1)) ?></div>
              <?php endif; ?>
              <div class="pf-name"><?= htmlspecialchars($user['full_name']) ?></div>
              <div class="pf-user">@<?= htmlspecialchars($user['username']) ?></div>
              <span class="status-chip s-<?= $user['status'] ?>"><?= ucfirst($user['status']) ?></span>
              <div class="pf-meta">
                <div class="pf-row"><i class="fas fa-envelope"></i><?= htmlspecialchars($user['email']) ?></div>
                <?php if ($user['phone']): ?>
                  <div class="pf-row"><i class="fas fa-phone"></i><?= htmlspecialchars($user['phone']) ?></div>
                <?php endif; ?>
                <div class="pf-row"><i class="fas fa-calendar"></i>Joined <?= $member_since ?></div>
              </div>
              <a href="profile.php" class="pf-link"><i class="fas fa-pen"></i> Edit Profile</a>
            </div>
          </div>

          <!-- Quick links -->
          <div class="gc" style="animation-delay:.24s">
            <div class="gc-hd"><div><div class="gc-t">Quick Actions</div></div></div>
            <div class="gc-bd">
              <div class="ql">
                <a class="qla" href="../index.php#programs"><i class="fas fa-book-open" style="color:var(--accent)"></i><span>Programmes</span></a>
                <a class="qla" href="profile.php"><i class="fas fa-circle-user" style="color:var(--primary)"></i><span>Profile</span></a>
                <a class="qla" href="#"><i class="fas fa-certificate" style="color:#10B981"></i><span>Certificates</span></a>
                <a class="qla" href="../index.php#contact"><i class="fas fa-headset" style="color:#1A6FE8"></i><span>Support</span></a>
                <a class="qla" href="../index.php"><i class="fas fa-house" style="color:#8B5CF6"></i><span>Website</span></a>
                <a class="qla" href="logout.php" onclick="return confirm('Sign out?')" style="color:#DC2626"><i class="fas fa-right-from-bracket" style="color:#DC2626"></i><span>Sign Out</span></a>
              </div>
            </div>
          </div>

        </div>
      </div>

      <!-- About WADATA info strip -->
      <div class="gc" style="animation-delay:.30s">
        <div class="gc-hd">
          <div><div class="gc-t">About WADATA</div><div class="gc-s">Our programmes at a glance</div></div>
          <a href="../index.php#programs" style="display:inline-flex;align-items:center;gap:5px;padding:6px 12px;border-radius:var(--radxs);
             background:rgba(11,37,69,.07);border:1px solid rgba(11,37,69,.12);
             font-size:11.5px;font-weight:700;color:var(--primary);text-decoration:none">
            View All <i class="fas fa-arrow-right" style="font-size:9px"></i>
          </a>
        </div>
        <div class="gc-bd">
          <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px">
            <?php
            $progs = [
              ['fas fa-laptop-code',   'ICT & Graphics',    'Web, UI/UX, Adobe, digital marketing',  'rgba(255,106,0,.12)', 'var(--accent)'],
              ['fas fa-cut',           'Fashion & Tailoring','Pattern making, garment construction',  'rgba(26,111,232,.12)','#1A6FE8'],
              ['fas fa-utensils',      'Culinary Arts',     'Professional cooking, baking, catering','rgba(16,185,129,.12)','#10B981'],
              ['fas fa-magic',         'Makeup & Salon',    'Hair, makeup, skincare, salon mgt',     'rgba(236,72,153,.12)','#EC4899'],
              ['fas fa-paint-brush',   'Hand Craft',        'Beadwork, decor, recycling art',        'rgba(240,165,0,.12)', '#F0A500'],
              ['fas fa-heart',         'Marriage Guidance', 'Counseling, conflict resolution',       'rgba(139,92,246,.12)','#8B5CF6'],
            ];
            foreach ($progs as [$ico, $name, $desc, $bg, $col]): ?>
              <div style="display:flex;flex-direction:column;align-items:flex-start;gap:8px;padding:14px;
                   background:rgba(255,255,255,.50);border:1px solid var(--bdr2);border-radius:12px;transition:all var(--t)"
                   onmouseover="this.style.transform='translateY(-2px)';this.style.boxShadow='var(--sh2)'"
                   onmouseout="this.style.transform='none';this.style.boxShadow='none'">
                <div style="width:36px;height:36px;border-radius:10px;background:<?= $bg ?>;color:<?= $col ?>;
                     display:grid;place-items:center;font-size:14px;flex-shrink:0">
                  <i class="<?= $ico ?>"></i>
                </div>
                <div>
                  <div style="font-size:12.5px;font-weight:700;color:var(--th);margin-bottom:2px"><?= $name ?></div>
                  <div style="font-size:10.5px;color:var(--tm)"><?= $desc ?></div>
                </div>
              </div>
            <?php endforeach; ?>
          </div>
        </div>
      </div>

    </div><!-- /content -->
  </div><!-- /main -->
</div><!-- /shell -->

</body>
</html>
