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

/*
|--------------------------------------------------------------------------
| ANA SİTE HEADER / MENÜ
|--------------------------------------------------------------------------
| includes/site-header.php
| RadyoHost Okey Premium Ana Site Menü Sistemi
| Developed By VoLKaN75
|--------------------------------------------------------------------------
*/

declare(strict_types=1);

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

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

$siteName = 'RadyoHost Okey';

try {
    if (isset($pdo) && $pdo instanceof PDO) {
        $settingsCheck = $pdo->query("SHOW TABLES LIKE 'settings'");
        if ($settingsCheck && $settingsCheck->fetchColumn()) {
            $stmt = $pdo->prepare("SELECT setting_value FROM settings WHERE setting_key = ? LIMIT 1");
            $stmt->execute(['site_name']);
            $dbSiteName = $stmt->fetchColumn();

            if ($dbSiteName) {
                $siteName = (string)$dbSiteName;
            }
        }
    }
} catch (Throwable $e) {
    $siteName = 'RadyoHost Okey';
}
?>

<header class="site-topbar">
    <div class="site-container site-nav">

        <a href="index.php" class="site-logo">
            <span class="site-logo-icon">
                <img src="assets/images/okey-hero.png" alt="<?= site_e($siteName) ?>">
            </span>

            <span class="site-logo-text">
                <strong><?= site_e($siteName) ?></strong>
                <small>Premium Okey Platformu</small>
            </span>
        </a>

        <nav class="site-menu">
            <a href="index.php" class="<?= $currentPage === 'index.php' ? 'active' : '' ?>">
                <span>🏠</span> Ana Sayfa
            </a>

            <a href="announcements.php" class="<?= $currentPage === 'announcements.php' ? 'active' : '' ?>">
                <span>📢</span> Duyurular
            </a>

            <a href="downloads.php" class="<?= $currentPage === 'downloads.php' ? 'active' : '' ?>">
                <span>⬇️</span> İndir
            </a>

            <a href="packages.php" class="<?= $currentPage === 'packages.php' ? 'active' : '' ?>">
                <span>👑</span> Paketler
            </a>

            <a href="contact.php" class="<?= $currentPage === 'contact.php' ? 'active' : '' ?>">
                <span>☎️</span> İletişim
            </a>
        </nav>

        <div class="site-actions">
            <a href="login.php" class="site-btn site-btn-dark">Giriş Yap</a>
            <a href="register.php" class="site-btn site-btn-gold">Kayıt Ol</a>
        </div>

    </div>
</header>

<style>
.site-container{
    width:min(1180px,92%);
    margin:auto;
}

.site-topbar{
    position:sticky;
    top:0;
    z-index:999;
    backdrop-filter:blur(22px);
    background:
        linear-gradient(135deg,rgba(7,9,17,.92),rgba(16,19,31,.86)),
        rgba(7,9,17,.88);
    border-bottom:1px solid rgba(255,255,255,.09);
    box-shadow:0 18px 60px rgba(0,0,0,.25);
}

.site-nav{
    min-height:86px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:22px;
}

.site-logo{
    display:flex;
    align-items:center;
    gap:14px;
    min-width:240px;
}

.site-logo-icon{
    width:58px;
    height:58px;
    border-radius:22px;
    overflow:hidden;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,#f5b642,#b90000);
    box-shadow:
        0 14px 35px rgba(245,182,66,.22),
        inset 0 0 0 1px rgba(255,255,255,.16);
}

.site-logo-icon img{
    width:100%;
    height:100%;
    object-fit:cover;
}

.site-logo-text strong{
    display:block;
    color:#fff;
    font-size:20px;
    font-weight:1000;
    letter-spacing:.2px;
}

.site-logo-text small{
    display:block;
    color:#f5b642;
    font-size:12px;
    font-weight:900;
    margin-top:4px;
}

.site-menu{
    flex:1;
    display:flex;
    justify-content:center;
    align-items:center;
    gap:8px;
    padding:8px;
    border-radius:24px;
    background:rgba(255,255,255,.045);
    border:1px solid rgba(255,255,255,.07);
}

.site-menu a{
    height:46px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    padding:0 15px;
    border-radius:17px;
    color:#dce3ef;
    font-size:14px;
    font-weight:900;
    transition:.25s;
    white-space:nowrap;
}

.site-menu a:hover{
    color:#fff;
    background:rgba(245,182,66,.12);
    transform:translateY(-2px);
}

.site-menu a.active{
    color:#111;
    background:linear-gradient(135deg,#f5b642,#ffcf6a);
    box-shadow:0 12px 28px rgba(245,182,66,.22);
}

.site-actions{
    display:flex;
    align-items:center;
    gap:10px;
}

.site-btn{
    min-height:48px;
    padding:0 18px;
    border-radius:17px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-weight:1000;
    font-size:14px;
    transition:.25s;
    white-space:nowrap;
}

.site-btn:hover{
    transform:translateY(-2px);
}

.site-btn-dark{
    color:#fff;
    background:rgba(255,255,255,.06);
    border:1px solid rgba(255,255,255,.10);
}

.site-btn-gold{
    color:#111;
    background:linear-gradient(135deg,#f5b642,#ffcf6a);
    border:1px solid rgba(255,255,255,.12);
    box-shadow:0 15px 34px rgba(245,182,66,.22);
}

@media(max-width:1100px){
    .site-nav{
        flex-wrap:wrap;
        padding:14px 0;
    }

    .site-logo{
        min-width:auto;
    }

    .site-menu{
        order:3;
        width:100%;
        overflow-x:auto;
        justify-content:flex-start;
    }

    .site-menu::-webkit-scrollbar{
        height:0;
    }
}

@media(max-width:620px){
    .site-actions{
        display:none;
    }

    .site-logo-text strong{
        font-size:17px;
    }

    .site-logo-icon{
        width:50px;
        height:50px;
    }
}
</style>