<?php
$cur = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$isActive = function($s) use ($cur) {
    return (strpos($cur, '/admin/'.$s) !== false) ? 'active' : '';
};
$adminUser = (new \App\Core\Session())->get('admin_user');
$adminName = htmlspecialchars($adminUser['name'] ?? 'Admin');
?>
<!DOCTYPE html>
<html lang="tr" data-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($title ?? 'Yönetim Paneli'); ?> - Çözüm Merkezi</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="<?php echo $baseUrl; ?>/assets/css/admin.css?v=20260710">
</head>
<body class="admin-body">

<!-- Sidebar Overlay (mobile) -->
<div class="sidebar-overlay" id="sidebarOverlay" onclick="closeSidebar()"></div>

<div class="admin-layout">
    <!-- Sidebar -->
    <aside class="admin-sidebar" id="adminSidebar">
        <div class="sidebar-brand">
            <div class="sidebar-logo"><i class="fa fa-wrench"></i></div>
            <span class="sidebar-brand-text">Çözüm M.</span>
            <span class="sidebar-brand-badge">admin</span>
        </div>
        
        <div class="sidebar-scroll">
            <div class="nav-label">Yönetim Menüsü</div>
            <nav class="admin-nav">
                <a href="<?php echo $baseUrl; ?>/admin/dashboard" class="admin-nav-item <?php echo $isActive('dashboard'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-dashboard"></i> Panel
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/articles" class="admin-nav-item <?php echo $isActive('articles'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-file-text"></i> Makaleler &amp; Resetler
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/categories" class="admin-nav-item <?php echo $isActive('categories'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-tags"></i> Kategoriler
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/brands" class="admin-nav-item <?php echo $isActive('brands'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-print"></i> Markalar
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/compatibility" class="admin-nav-item <?php echo $isActive('compatibility'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-table"></i> Uyumluluk Tabloları
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/settings" class="admin-nav-item <?php echo $isActive('settings'); ?>" onclick="closeSidebar()">
                    <i class="fa fa-cogs"></i> Sistem Ayarları
                </a>
            </nav>
        </div>
        
        <div class="sidebar-footer">
            <nav class="admin-nav">
                <?php $everestAdminUrl = rtrim(str_replace('/cozummerkezi', '', $baseUrl), '/'); ?>
                <a href="<?php echo $everestAdminUrl; ?>/admin/dashboard" class="admin-nav-item">
                    <i class="fa fa-cogs"></i> Everest Admin
                </a>
                <a href="<?php echo $baseUrl; ?>/" target="_blank" class="admin-nav-item">
                    <i class="fa fa-external-link"></i> Siteyi Görüntüle
                </a>
                <a href="<?php echo $baseUrl; ?>/admin/logout" class="admin-nav-item danger">
                    <i class="fa fa-sign-out"></i> Çıkış Yap
                </a>
            </nav>
        </div>
    </aside>

    <!-- Main -->
    <main class="admin-main">
        <header class="admin-header">
            <button class="mobile-sidebar-toggle" onclick="openSidebar()">
                <i class="fa fa-bars"></i>
            </button>
            <span class="admin-page-title"><?php echo htmlspecialchars($title ?? 'Yönetim Paneli'); ?></span>
            <div class="header-spacer"></div>
            <div class="admin-header-actions">
                <div class="admin-profile">
                    <div class="admin-profile-avatar"><i class="fa fa-user"></i></div>
                    <span><?php echo $adminName; ?></span>
                </div>
            </div>
        </header>
        
        <div class="admin-content">
