<?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 LAYOUT DOSYASI
|--------------------------------------------------------------------------
| admin-layout.php
| Okey Platformu Yönetim Paneli Ortak Sayfa İskeleti Modülü
| Developed By VoLKaN75
|--------------------------------------------------------------------------
*/

declare(strict_types=1);

require_once __DIR__ . '/../../config/config.php';
require_once __DIR__ . '/../../config/db.php';
require_once __DIR__ . '/auth.php';

require_admin();

if (!isset($pdo) && isset($db) && $db instanceof PDO) {
    $pdo = $db;
}

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

$pageTitle       = $pageTitle ?? 'Yönetim Paneli';
$pageDescription = $pageDescription ?? 'Okey Platformu Premium Yönetim Merkezi';
$siteName        = defined('SITE_NAME') ? SITE_NAME : 'Okey Platformu';
?>
<!doctype html>
<html lang="tr">
<head>
    <meta charset="utf-8">
    <title><?= admin_e($pageTitle) ?> | <?= admin_e($siteName) ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <style>
        *{
            box-sizing:border-box;
        }

        body{
            margin:0;
            font-family:Arial,Helvetica,sans-serif;
            background:#070707;
            color:#fff;
        }

        .admin-app{
            min-height:100vh;
            display:grid;
            grid-template-columns:290px 1fr;
            background:
                radial-gradient(circle at top right,rgba(245,182,66,.12),transparent 32%),
                linear-gradient(135deg,#070707,#101827 50%,#050505);
        }

        .admin-main{
            min-width:0;
            padding:28px;
        }

        .admin-content{
            min-height:calc(100vh - 220px);
        }

        .admin-card{
            padding:26px;
            border-radius:26px;
            background:rgba(255,255,255,.055);
            border:1px solid rgba(255,255,255,.09);
            box-shadow:0 20px 60px rgba(0,0,0,.22);
        }

        .admin-grid{
            display:grid;
            gap:18px;
        }

        .admin-grid-2{
            grid-template-columns:repeat(2,1fr);
        }

        .admin-grid-3{
            grid-template-columns:repeat(3,1fr);
        }

        .admin-grid-4{
            grid-template-columns:repeat(4,1fr);
        }

        .admin-btn{
            display:inline-flex;
            align-items:center;
            justify-content:center;
            gap:8px;
            min-height:44px;
            padding:0 18px;
            border-radius:14px;
            border:0;
            text-decoration:none;
            cursor:pointer;
            font-weight:900;
            color:#111;
            background:linear-gradient(135deg,#f5b642,#ff6b6b);
            transition:.2s;
        }

        .admin-btn:hover{
            transform:translateY(-1px);
            filter:brightness(1.06);
        }

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

        .admin-btn-red{
            color:#fff;
            background:linear-gradient(135deg,#b90000,#ff5d5d);
        }

        .admin-table-wrap{
            width:100%;
            overflow:auto;
            border-radius:22px;
            border:1px solid rgba(255,255,255,.08);
            background:rgba(255,255,255,.04);
        }

        .admin-table{
            width:100%;
            border-collapse:collapse;
            min-width:800px;
        }

        .admin-table th,
        .admin-table td{
            padding:15px 16px;
            border-bottom:1px solid rgba(255,255,255,.07);
            text-align:left;
            color:#ddd;
            font-size:14px;
        }

        .admin-table th{
            color:#f5b642;
            background:rgba(0,0,0,.22);
            font-weight:900;
        }

        .admin-table tr:hover td{
            background:rgba(255,255,255,.035);
        }

        .admin-form{
            display:grid;
            gap:16px;
        }

        .admin-form label{
            display:block;
            margin-bottom:7px;
            color:#ddd;
            font-size:14px;
            font-weight:900;
        }

        .admin-form input,
        .admin-form select,
        .admin-form textarea{
            width:100%;
            min-height:48px;
            border-radius:14px;
            border:1px solid rgba(255,255,255,.12);
            background:rgba(0,0,0,.22);
            color:#fff;
            outline:none;
            padding:0 14px;
        }

        .admin-form textarea{
            min-height:130px;
            padding:14px;
            resize:vertical;
        }

        .admin-form input:focus,
        .admin-form select:focus,
        .admin-form textarea:focus{
            border-color:#f5b642;
            box-shadow:0 0 0 4px rgba(245,182,66,.12);
        }

        .admin-alert{
            padding:15px 18px;
            border-radius:16px;
            margin-bottom:18px;
            font-weight:800;
        }

        .admin-alert.success{
            background:rgba(0,170,80,.18);
            border:1px solid rgba(0,255,140,.25);
            color:#b9ffd8;
        }

        .admin-alert.error{
            background:rgba(185,0,0,.20);
            border:1px solid rgba(255,80,80,.30);
            color:#ffdede;
        }

        @media(max-width:1000px){
            .admin-app{
                grid-template-columns:1fr;
            }

            .admin-main{
                padding:20px;
            }

            .admin-grid-2,
            .admin-grid-3,
            .admin-grid-4{
                grid-template-columns:1fr;
            }
        }
    </style>
</head>
<body>

<div class="admin-app">

    <?php require_once __DIR__ . '/admin-sidebar.php'; ?>

    <main class="admin-main">

        <?php require_once __DIR__ . '/admin-header.php'; ?>

        <section class="admin-content">