<?php
/*
|--------------------------------------------------------------------------
| RadyoHost.BiZ / Profesyonel Radyo Hosting ve Web Tasarım Hizmetleri
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| Okey Platformu / Premium Okey ve Sohbet Platformu
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| Okey Platformu / Premium Okey Tanıtım ve Üyelik Sistemi
|--------------------------------------------------------------------------
*/

/*
|--------------------------------------------------------------------------
| ADMİN ÜST MENÜ DOSYASI
|--------------------------------------------------------------------------
| admin-header.php
| Okey Platformu Yönetim Paneli Üst Menü Modülü
| Developed By VoLKaN75
|--------------------------------------------------------------------------
*/

declare(strict_types=1);

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$pageTitle = $pageTitle ?? 'Yönetim Paneli';
$pageDescription = $pageDescription ?? 'Premium Okey Yönetim Merkezi';

$adminName  = $_SESSION['admin_name'] ?? 'Yönetici';
$adminRole  = $_SESSION['admin_role'] ?? 'Admin';
$adminImage = $_SESSION['admin_image'] ?? '';

if ($adminImage === '') {
    $adminImage = 'assets/images/admin-default.png';
}

if (!function_exists('admin_e')) {
    function admin_e($value): string
    {
        return htmlspecialchars((string)$value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
    }
}
?>

<style>
.admin-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:20px;
    margin-bottom:25px;
    padding:22px 26px;
    border-radius:24px;
    background:
        linear-gradient(
            135deg,
            rgba(245,182,66,.12),
            rgba(185,0,0,.08)
        );
    border:1px solid rgba(255,255,255,.08);
    backdrop-filter:blur(12px);
}

.header-left h1{
    margin:0;
    color:#fff;
    font-size:30px;
    font-weight:900;
}

.header-left p{
    margin:8px 0 0;
    color:#aaa;
    font-size:14px;
    font-weight:700;
}

.header-right{
    display:flex;
    align-items:center;
    gap:14px;
}

.header-btn{
    width:46px;
    height:46px;
    border-radius:14px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:rgba(255,255,255,.05);
    border:1px solid rgba(255,255,255,.08);
    color:#f5b642;
    text-decoration:none;
    font-size:18px;
    transition:.2s;
}

.header-btn:hover{
    transform:translateY(-2px);
    border-color:#f5b642;
}

.header-profile{
    display:flex;
    align-items:center;
    gap:12px;
    padding:8px 12px;
    border-radius:18px;
    background:rgba(255,255,255,.05);
    border:1px solid rgba(255,255,255,.08);
}

.header-profile img{
    width:48px;
    height:48px;
    object-fit:cover;
    border-radius:50%;
    border:2px solid #f5b642;
}

.profile-text strong{
    display:block;
    color:#fff;
    font-size:14px;
    font-weight:900;
}

.profile-text span{
    display:block;
    color:#aaa;
    font-size:12px;
}

.header-clock{
    text-align:right;
    padding-left:10px;
}

.header-clock strong{
    display:block;
    color:#f5b642;
    font-size:15px;
}

.header-clock span{
    display:block;
    color:#999;
    font-size:12px;
}

@media(max-width:900px){

    .admin-header{
        flex-direction:column;
        align-items:flex-start;
    }

    .header-right{
        width:100%;
        flex-wrap:wrap;
    }

}
</style>

<div class="admin-header">

    <div class="header-left">
        <h1><?= admin_e($pageTitle) ?></h1>
        <p><?= admin_e($pageDescription) ?></p>
    </div>

    <div class="header-right">

        <a href="#" class="header-btn" title="Bildirimler">
            🔔
        </a>

        <a href="settings.php" class="header-btn" title="Ayarlar">
            ⚙️
        </a>

        <div class="header-clock">
            <strong id="adminClock">00:00:00</strong>
            <span><?= date('d.m.Y') ?></span>
        </div>

        <div class="header-profile">
            <img src="<?= admin_e($adminImage) ?>" alt="Admin">

            <div class="profile-text">
                <strong><?= admin_e($adminName) ?></strong>
                <span><?= admin_e($adminRole) ?></span>
            </div>
        </div>

    </div>

</div>

<script>
function updateAdminClock()
{
    const now = new Date();

    const time =
        String(now.getHours()).padStart(2,'0') + ':' +
        String(now.getMinutes()).padStart(2,'0') + ':' +
        String(now.getSeconds()).padStart(2,'0');

    document.getElementById('adminClock').innerHTML = time;
}

setInterval(updateAdminClock,1000);
updateAdminClock();
</script>