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

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

/*
|--------------------------------------------------------------------------
| ADMİN SOL MENÜ DOSYASI
|--------------------------------------------------------------------------
| admin-sidebar.php
| Okey Platformu Yönetim Paneli Premium Sol Menü Modülü
| Developed By VoLKaN75
|--------------------------------------------------------------------------
*/

declare(strict_types=1);

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

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

if (!function_exists('sidebar_active')) {
    function sidebar_active(array $pages, string $currentPage): string
    {
        return in_array($currentPage, $pages, true) ? 'active' : '';
    }
}

$currentPage = basename($_SERVER['PHP_SELF'] ?? 'index.php');

$siteName  = defined('SITE_NAME') ? SITE_NAME : 'Okey Platformu';
$adminName = $_SESSION['admin_name'] ?? 'Yönetici';
$adminRole = $_SESSION['admin_role'] ?? 'admin';

$adminImage = $_SESSION['admin_image'] ?? '';
$defaultImage = 'assets/images/admin-default.png';

if ($adminImage === '') {
    $adminImage = $defaultImage;
}
?>

<style>
.admin-sidebar{
    width:290px;
    min-height:100vh;
    padding:24px;
    background:
        radial-gradient(circle at top left,rgba(245,182,66,.16),transparent 34%),
        linear-gradient(180deg,#101014,#050506);
    border-right:1px solid rgba(255,255,255,.08);
    position:sticky;
    top:0;
}

.sidebar-brand{
    display:flex;
    align-items:center;
    gap:13px;
    margin-bottom:24px;
}

.brand-icon{
    width:48px;
    height:48px;
    border-radius:16px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,#f5b642,#b90000);
    color:#111;
    font-size:25px;
    font-weight:900;
    box-shadow:0 14px 34px rgba(185,0,0,.28);
}

.brand-text strong{
    display:block;
    color:#f5b642;
    font-size:21px;
    line-height:1.1;
}

.brand-text span{
    display:block;
    margin-top:5px;
    color:#aaa;
    font-size:12px;
    font-weight:700;
}

.sidebar-profile{
    padding:18px;
    border-radius:24px;
    background:rgba(255,255,255,.055);
    border:1px solid rgba(255,255,255,.10);
    margin-bottom:24px;
    text-align:center;
}

.profile-img{
    width:82px;
    height:82px;
    margin:0 auto 12px;
    border-radius:50%;
    padding:3px;
    background:linear-gradient(135deg,#f5b642,#b90000);
}

.profile-img img{
    width:100%;
    height:100%;
    object-fit:cover;
    border-radius:50%;
    background:#111;
}

.profile-name{
    display:block;
    color:#fff;
    font-size:16px;
    font-weight:900;
}

.profile-role{
    display:inline-block;
    margin-top:7px;
    padding:6px 12px;
    border-radius:999px;
    background:rgba(245,182,66,.12);
    color:#ffd37a;
    font-size:12px;
    font-weight:800;
    border:1px solid rgba(245,182,66,.25);
}

.sidebar-section-title{
    margin:20px 0 10px;
    padding-left:4px;
    color:#777;
    font-size:11px;
    font-weight:900;
    letter-spacing:1px;
    text-transform:uppercase;
}

.sidebar-menu{
    display:grid;
    gap:9px;
}

.sidebar-menu a{
    display:flex;
    align-items:center;
    gap:12px;
    padding:13px 15px;
    border-radius:16px;
    color:#d8d8d8;
    text-decoration:none;
    background:rgba(255,255,255,.035);
    border:1px solid rgba(255,255,255,.065);
    font-size:14px;
    font-weight:850;
    transition:.18s ease;
}

.sidebar-menu a span{
    width:24px;
    text-align:center;
    font-size:17px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active{
    color:#111;
    background:linear-gradient(135deg,#f5b642,#ff6b6b);
    border-color:rgba(245,182,66,.55);
    transform:translateX(3px);
}

.sidebar-menu a.logout{
    margin-top:14px;
    color:#ffdede;
    background:rgba(185,0,0,.20);
    border-color:rgba(255,80,80,.25);
}

.sidebar-menu a.logout:hover{
    color:#fff;
    background:linear-gradient(135deg,#b90000,#ff5d5d);
}

@media(max-width:1000px){
    .admin-sidebar{
        width:100%;
        min-height:auto;
        position:relative;
    }
}
</style>

<aside class="admin-sidebar">

    <div class="sidebar-brand">
        <div class="brand-icon">♠</div>

        <div class="brand-text">
            <strong><?= admin_e($siteName) ?></strong>
            <span>Premium Okey Yönetim Paneli</span>
        </div>
    </div>

    <div class="sidebar-profile">
        <div class="profile-img">
            <img src="<?= admin_e($adminImage) ?>" alt="Yönetici">
        </div>

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

    <div class="sidebar-section-title">Genel Yönetim</div>

    <nav class="sidebar-menu">

        <a href="index.php" class="<?= sidebar_active(['index.php'], $currentPage) ?>">
            <span>🏠</span> Ana Panel
        </a>

        <a href="users.php" class="<?= sidebar_active(['users.php','user-view.php','user-edit.php','user-detail.php'], $currentPage) ?>">
            <span>👥</span> Üye Yönetimi
        </a>

        <a href="memberships.php" class="<?= sidebar_active(['memberships.php','membership-view.php','membership-edit.php'], $currentPage) ?>">
            <span>🎫</span> Üyelikler
        </a>

        <a href="packages.php" class="<?= sidebar_active(['packages.php','package-view.php','package-edit.php'], $currentPage) ?>">
            <span>👑</span> Paketler
        </a>

        <a href="announcements.php" class="<?= sidebar_active(['announcements.php','announcement-view.php','announcement-edit.php'], $currentPage) ?>">
            <span>📢</span> Duyurular
        </a>

        <a href="ads.php" class="<?= sidebar_active(['ads.php','ad-view.php','ad-edit.php'], $currentPage) ?>">
            <span>📣</span> Reklamlar
        </a>

        <a href="downloads.php" class="<?= sidebar_active(['downloads.php','download-view.php','download-edit.php'], $currentPage) ?>">
            <span>⬇️</span> İndirme Yönetimi
        </a>

        <div class="sidebar-section-title">Sistem</div>

        <a href="contact-messages.php" class="<?= sidebar_active(['contact-messages.php','contact-message-view.php'], $currentPage) ?>">
            <span>📨</span> Mesajlar
        </a>

        <a href="managers.php" class="<?= sidebar_active(['managers.php','manager-view.php','manager-edit.php'], $currentPage) ?>">
            <span>👨‍💼</span> Yöneticiler
        </a>

        <a href="okey-managers.php" class="<?= sidebar_active(['okey-managers.php','okey-manager-view.php','okey-manager-edit.php'], $currentPage) ?>">
            <span>👑</span> Okey Yöneticileri
        </a>

        <a href="settings.php" class="<?= sidebar_active(['settings.php'], $currentPage) ?>">
            <span>⚙️</span> Ayarlar
        </a>

        <a href="../index.php" target="_blank">
            <span>🌐</span> Siteyi Görüntüle
        </a>

        <a href="logout.php" class="logout">
            <span>🚪</span> Çıkış Yap
        </a>

    </nav>

</aside>