<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,initial-scale=1,viewport-fit=cover">

<style>
:root{
 --bg:#f4f5f7;
 --card:rgba(255,255,255,.72);
 --text:#222;
 --shadow:0 8px 24px rgba(0,0,0,.15);
}

body.dark{
 --bg:#0f1116;
 --card:rgba(25,25,28,.7);
 --text:#fff;
}

body{
 margin:0;
 min-height:220vh;
 background:var(--bg);
 font-family:-apple-system,Arial,sans-serif;
 color:var(--text);
 transition:.25s;
 overflow-x:hidden;
}

/* ===== TOP BAR ===== */
.topbar{
 position:fixed;
 top:10px;
 left:50%;
 transform:translateX(-50%);
 width:95%;
 max-width:520px;
 display:flex;
 justify-content:space-between;
 z-index:2000;
}

.menu-btn,.switch{
 background:var(--card);
 backdrop-filter:blur(18px);
 box-shadow:var(--shadow);
}

.menu-btn{
 width:42px;height:42px;
 border-radius:50%;
 display:flex;
 align-items:center;
 justify-content:center;
 font-size:20px;
 cursor:pointer;
 transition:.2s;
}
.menu-btn:active{transform:scale(.9);}

/* DARK SWITCH */
.switch{
 width:62px;height:34px;
 border-radius:20px;
 position:relative;
 cursor:pointer;
}

.knob{
 width:28px;height:28px;
 border-radius:50%;
 background:#fff;
 position:absolute;
 top:3px;left:3px;
 display:flex;
 align-items:center;
 justify-content:center;
 transition:.4s cubic-bezier(.34,1.56,.64,1);
}

body.dark .knob{
 left:31px;
 background:#222;
 color:#fff;
}

/* ===== SIDEBAR PREMIUM GLASS ===== */
.sidebar{
 position:fixed;
 top:0;
 left:-85%;
 width:82%;
 max-width:340px;
 height:100%;

 background:rgba(255,255,255,.18);
 backdrop-filter:blur(30px) saturate(140%);
 -webkit-backdrop-filter:blur(30px);

 border-right:1px solid rgba(255,255,255,.35);
 box-shadow:0 20px 40px rgba(0,0,0,.25);

 transition:left .42s cubic-bezier(.22,1,.36,1);
 padding-top:80px;
 z-index:1500;
}

body.dark .sidebar{
 background:rgba(20,20,20,.45);
}

.sidebar.show{ left:0; }

.sidebar a{
 display:flex;
 align-items:center;
 gap:12px;
 padding:14px 18px;
 margin:4px 10px;
 border-radius:14px;
 text-decoration:none;
 color:#fff;
 font-weight:600;
 transition:.25s;
}

.sidebar a.active{
 background:rgba(70,150,255,.45);
}

.sidebar a:hover{
 background:rgba(255,255,255,.15);
}

/* OVERLAY */
.overlay{
 position:fixed;
 inset:0;
 background:rgba(0,0,0,.25);
 opacity:0;
 pointer-events:none;
 transition:.3s;
 z-index:1400;
}
.overlay.show{
 opacity:1;
 pointer-events:auto;
}

/* ===== NAVBAR PREMIUM ===== */
.bottom-nav{
 position:fixed;
 bottom:calc(10px + env(safe-area-inset-bottom));
 left:50%;
 transform:translateX(-50%);
 width:95%;
 max-width:520px;
 height:clamp(58px,9vh,72px);

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

 border-radius:34px;
 background:var(--card);
 backdrop-filter:blur(18px);

 box-shadow:var(--shadow);
 transition:transform .35s ease;
 z-index:2000;
}

.bottom-nav.hide{
 transform:translateX(-50%) translateY(110px);
}

/* CAPSULE PREMIUM */
.slider{
 position:absolute;
 height:42px;
 width:clamp(70px,22vw,140px);
 border-radius:24px;
 background:#e7f2ff;

 transition:.35s cubic-bezier(.34,1.56,.64,1);
 z-index:0;
}

/* NAV ITEM */
.nav-item{
 flex:1;
 text-align:center;
 font-size:clamp(10px,2.3vw,13px);
 font-weight:600;
 cursor:pointer;
 color:var(--text);
 z-index:2;
 user-select:none;
}

.icon{
 display:block;
 font-size:clamp(16px,4.5vw,21px);
 transition:.3s cubic-bezier(.34,1.56,.64,1);
}

.nav-item.active{
 color:#0a84ff;
}

.nav-item.active .icon{
 transform:translateY(-5px) scale(1.08);
}

/* CONTENT */
.content{
 padding-top:calc(60px + env(safe-area-inset-top));
 padding-left:20px;
 padding-right:20px;
}

        /* Konten */
        .glass-card {
            backdrop-filter: blur(20px);
            background: rgba(255, 255, 255, 0.25);
            border-radius: 20px;
            padding: 22px;
            max-width: 420px;
            width: 100%;
            color: #222;
            box-shadow: 0 8px 24px rgba(0,0,0,0.15);
            margin: 20px auto;
        }
        h2 {
            text-align: center;
            font-size: 20px;
            margin-bottom: 6px;
            font-weight: 600;
            color: #111;
        }
        .owner {
            text-align: center;
            font-size: 14px;
            color: #555;
            margin-bottom: 20px;
        }
        .account {
            background: rgba(255,255,255,0.6);
            padding: 14px 16px;
            border-radius: 14px;
            margin-bottom: 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: inset 0 0 6px rgba(0,0,0,0.05);
        }
        .label {
            font-size: 13px;
            font-weight: 500;
            color: #666;
            margin-bottom: 2px;
        }
        .number {
            font-size: 16px;
            font-weight: 600;
            color: #000;
            letter-spacing: 0.5px;
        }
       .copy-btn {
        background: rgba(0,0,0,0.05);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 16px;
        padding: 6px 10px;
        color: #007aff;
        transition: all 0.25s ease;
    }
    .copy-btn:hover {
        background: rgba(0,0,0,0.1);
    }
    .upload-box {
        text-align: center;
        margin-top: 15px;
        padding: 15px;
        background: rgba(255,255,255,0.6);
        border-radius: 14px;
        cursor: pointer;
        border: 2px dashed rgba(0,0,0,0.1);
        transition: all 0.25s ease;
        font-size: 14px;
        color: #555;
    }
    .upload-box:hover {
        background: rgba(255,255,255,0.8);
    }
    .upload-box input {
        display: none;
    }
    .preview-img {
        max-width: 100%;
        margin-top: 10px;
        border-radius: 12px;
        display: none;
    }
    textarea {
        width: 100%;
        margin-top: 12px;
        padding: 12px;
        border-radius: 12px;
        border: 1px solid rgba(0,0,0,0.1);
        resize: none;
        font-family: inherit;
        font-size: 14px;
        background: rgba(255,255,255,0.6);
        transition: border 0.2s ease;
    }
    textarea:focus {
        border: 1px solid #007aff;
        outline: none;
    }
    button.send {
        margin-top: 15px;
        width: 100%;
        padding: 14px;
        border: none;
        border-radius: 12px;
        background: linear-gradient(135deg, #007aff, #0051c3);
        color: white;
        font-size: 16px;
        font-weight: 500;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0,122,255,0.3);
        transition: all 0.3s ease;
    }
    button.send:hover {
        background: linear-gradient(135deg, #0066d6, #003e99);
        box-shadow: 0 6px 16px rgba(0,122,255,0.4);
    }

        /* Table Styles */
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
            background: rgba(255,255,255,0.15);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }
        table th, table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid rgba(255,255,255,0.2);
        }
        table th {
            background: rgba(0,0,0,0.3);
            font-weight: bold;
        }
        table tr:hover {
            background: rgba(255,255,255,0.1);
        }
</style>
</head>

<body>

<!-- TOP -->
<div class="topbar">
 <div class="menu-btn" onclick="toggleMenu()">☰</div>
 <div class="switch" onclick="toggleDark()">
   <div class="knob" id="icon">☀️</div>
 </div>
</div>

<!-- SIDEBAR -->
<div class="sidebar" id="sidebar">
        <li><a href="/siap/index"><i class="fas fa-th-large"></i> Home</a></li>
        <li><a href="/siap/warta"><i class="fa-solid fa-person-praying"></i> Warta</a></li>
        <li><a href="/siap/khotbah"><i class="fa-brands fa-youtube"></i> Khotbah mingguan</a></li>
         <li><a href="/siap/ppt"><i class="fa-brands fa-youtube"></i> ppt mingguan</a></li>
        <li><a href="/siap/informasi"><i class="fa-solid fa-bell"></i> Informasi</a></li>
        <li><a href="/siap/youth"><i class="fa-solid fa-church"></i> Peserta Youth</a></li>
        <li><a href="/id/starkids/starkids"><i class="fas fa-heart"></i> star kids</a></li>
        <li><a href="/siap/jadwal"><i class="fa-solid fa-user"></i> jadwal ibadah</a></li>
        <li><a href="/siap/youth/jadwal"><i class="fa-solid fa-user"></i> jadwal youth</a></li>
         <li><a href="/siap/youth/ppt" class="active"><i class="fa-solid fa-user"></i> ppt youth</a></li>
         <li><a href="/siap/youth/id"><i class="fa-solid fa-user"></i> edit web youth</a></li>
         <li><a href="/siap/gambar"><i class="fa-solid fa-user"></i> edit gambar</a></li>
        <li><a href="javascript:window.close()"><i class="fas fa-sign-out-alt"></i> Logout</a></li>

</div>

<div class="overlay" id="overlay" onclick="toggleMenu()"></div>

<div class="content">
<div class="glass-card">

<?php
// Koneksi database (wajib database youth sendiri)
$host = "localhost";
$user = "mdcc5937_mdc";
$pass = "mdcc5937_mdc";
$db   = "mdcc5937_mdc";

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) { die("Koneksi gagal: " . $conn->connect_error); }

// Hitung jumlah peserta
$stmt_total = $conn->prepare("SELECT COUNT(*) as jml FROM kehadiran");
$stmt_total->execute();
$result_total = $stmt_total->get_result();
$total = $result_total->fetch_assoc()['jml'];
$stmt_total->close();

// Ambil data peserta
$stmt_data = $conn->prepare("SELECT nama, nomor, gender, scan_time FROM kehadiran ORDER BY scan_time DESC");
$stmt_data->execute();
$result_data = $stmt_data->get_result();
$stmt_data->close();
?>

    <h1 class="text-center">📋 Panel Admin</h1>
    <div class="total-box">Jumlah Peserta Hadir: <?= htmlspecialchars($total); ?></div>
    <div class="text-center mb-3">
        <a href="export.php" class="btn-export">📥 Export ke Excel</a>
    </div>

    <table>
        <tr>
            <th>Nama</th>
            <th>Nomor</th>
            <th>Gender</th>
            <th>Jam Terakhir Hadir</th>
        </tr>
        <?php if ($result_data->num_rows > 0): ?>
            <?php while($row = $result_data->fetch_assoc()): ?>
            <tr>
                <td><?= htmlspecialchars($row['nama']); ?></td>
                <td><?= htmlspecialchars($row['nomor']); ?></td>
                <td><?= htmlspecialchars($row['gender']); ?></td>
                <td><?= htmlspecialchars($row['scan_time']); ?></td>
            </tr>
            <?php endwhile; ?>
        <?php else: ?>
            <tr>
                <td colspan="4">Tidak ada data peserta.</td>
            </tr>
        <?php endif; ?>
    </table>

<?php $conn->close(); ?>
</div>

<!-- NAV -->
<div class="bottom-nav" id="nav">
 <div class="slider" id="slider"></div>

<a href="/siap/" class="nav-item active" onclick="selectTab(this)">
  <span class="icon">🏠</span>Home
</a>

<a href="/siap/ppt" class="nav-item" onclick="selectTab(this)">
  <span class="icon">🙏</span>PPT
</a>

<a href="/siap/youtube" class="nav-item" onclick="selectTab(this)">
  <span class="icon">▶️</span>YouTube
</a>

<a href="/siap/alkitab" class="nav-item" onclick="selectTab(this)">
  <span class="icon">📖</span>Alkitab
</a>

<script>
const sidebar=document.getElementById("sidebar");
const overlay=document.getElementById("overlay");
const slider=document.getElementById("slider");
const items=document.querySelectorAll(".nav-item");
const nav=document.getElementById("nav");
const icon=document.getElementById("icon");

/* MENU */
function toggleMenu(){
 sidebar.classList.toggle("show");
 overlay.classList.toggle("show");
}

/* DARK */
function toggleDark(){
 document.body.classList.toggle("dark");
 icon.innerHTML=document.body.classList.contains("dark")?"🌙":"☀️";
}

/* PREMIUM CAPSULE */
function moveSlider(el){
 slider.style.left =
 (el.offsetLeft + el.offsetWidth/2 - slider.offsetWidth/2)+"px";
}

function selectTab(el){
 items.forEach(i=>i.classList.remove("active"));
 el.classList.add("active");
 moveSlider(el);
}

window.onload=()=>{
 moveSlider(document.querySelector(".nav-item.active"));
}

/* AUTO HIDE */
let last=0,timer;
window.addEventListener("scroll",()=>{
 let cur=window.pageYOffset;
 if(cur>last+5) nav.classList.add("hide");
 else if(cur<last-5) nav.classList.remove("hide");
 last=cur;
 clearTimeout(timer);
 timer=setTimeout(()=>nav.classList.remove("hide"),220);
});

/* IOS SWIPE */
let sx=0,ex=0;
document.addEventListener("touchstart",e=>sx=e.touches[0].clientX);
document.addEventListener("touchmove",e=>ex=e.touches[0].clientX);
document.addEventListener("touchend",()=>{
 if(sx<40 && ex>100){sidebar.classList.add("show");overlay.classList.add("show");}
 if(sx>120 && (sx-ex)>60){sidebar.classList.remove("show");overlay.classList.remove("show");}
 sx=ex=0;
});
</script>

</body>
</html>