<?php
require_once '../includes/config.php';
requireAdmin();
$admin_page = $admin_page ?? '';
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title><?= isset($admin_title) ? clean($admin_title).' — ' : '' ?>Yönetim Paneli</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/volker/admin/admin.css">
</head>
<body>
<div class="admin-layout">

<aside class="admin-sidebar" id="sidebar">
    <div class="sidebar-logo">
        <div class="sidebar-logo-inner">
            <div class="sidebar-logo-icon">V</div>
            <div class="sidebar-logo-text">
                VOLKER SAVUNMA
                <small>YÖNETİM PANELİ</small>
            </div>
        </div>
    </div>

    <nav class="sidebar-nav">
        <div class="sidebar-section">Genel</div>
        <a href="/volker/admin/" class="sidebar-link <?= $admin_page=='dashboard'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
            Dashboard
        </a>

        <div class="sidebar-section">Ürünler</div>
        <a href="/volker/admin/urunler.php" class="sidebar-link <?= $admin_page=='urunler'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4zM3 6h18M16 10a4 4 0 01-8 0"/></svg>
            Ürünler
        </a>
        <a href="/volker/admin/kategoriler.php" class="sidebar-link <?= $admin_page=='kategoriler'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>
            Kategoriler
        </a>

        <div class="sidebar-section">İçerik</div>
        <a href="/volker/admin/slider.php" class="sidebar-link <?= $admin_page=='slider'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 2l-4 5-4-5"/></svg>
            Hero / Slider
        </a>
        <a href="/volker/admin/haberler.php" class="sidebar-link <?= $admin_page=='haberler'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 22h16a2 2 0 002-2V4a2 2 0 00-2-2H8a2 2 0 00-2 2v16a4 4 0 01-4 4zm0 0a4 4 0 01-4-4v-1h4"/><path d="M8 6h8M8 10h8M8 14h4"/></svg>
            Haberler
        </a>

        <div class="sidebar-section">Sistem</div>
        <a href="/volker/admin/mesajlar.php" class="sidebar-link <?= $admin_page=='mesajlar'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>
            Mesajlar
            <?php
            try {
                $unread = db()->query("SELECT COUNT(*) FROM vs_messages WHERE is_read=0")->fetchColumn();
                if ($unread > 0) echo '<span style="background:var(--red);color:#fff;font-size:10px;padding:1px 7px;border-radius:100px;margin-left:auto;">'.$unread.'</span>';
            } catch(Exception $e) {}
            ?>
        </a>
        <a href="/volker/admin/ayarlar.php" class="sidebar-link <?= $admin_page=='ayarlar'?'active':'' ?>">
            <svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83 0 2 2 0 010-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0019.4 9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"/></svg>
            Site Ayarları
        </a>
    </nav>

    <div class="sidebar-footer">
        <a href="/volker/admin/logout.php">
            <svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4M16 17l5-5-5-5M21 12H9"/></svg>
            Çıkış Yap
        </a>
    </div>
</aside>

<main class="admin-main">
    <div class="admin-topbar">
        <div style="display:flex;align-items:center;gap:16px;">
            <h2 style="font-size:15px;font-weight:700;"><?= clean($admin_title ?? 'Dashboard') ?></h2>
        </div>
        <div style="display:flex;align-items:center;gap:16px;">
            <a href="/volker/" target="_blank" style="font-size:12px;color:var(--gray);display:flex;align-items:center;gap:6px;">
                <svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"/></svg>
                Siteyi Gör
            </a>
            <span style="font-size:12px;color:var(--gray);">Merhaba, <strong style="color:#fff;"><?= clean($_SESSION['vs_admin_name'] ?? 'Admin') ?></strong></span>
        </div>
    </div>
    <div class="admin-content">
