<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kategoriler</title>
<style>
/* Genel Sıfırlama */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html, body {
margin: 0;
padding: 0;
width: 100%;
min-height: 100%;
overflow-x: hidden; /* Yatay taşmayı engelle */
background-color: #121212;
font-family: 'Arial', sans-serif;
}

/* Sabit Yan Menü */
#nav-bar {
position: fixed;
top: 120px;
left: 0;
width: 250px;
height: calc(100% - 120px);
background-color: rgba(0, 0, 0, 0.8);
overflow-y: auto;
padding: 20px;
z-index: 1000;
transition: transform 0.3s ease-in-out;
}

/* Hamburger Menüsü */
#hamburger {
position: fixed;
top: 15px;
left: 15px;
z-index: 1100;
background-color: #343a40;
color: #fff;
border: none;
padding: 10px;
border-radius: 6px;
cursor: pointer;
display: none;
}

/* İçerik Konteyneri */
.container {
margin-left: 250px; /* Yan menüye yer bırak */
padding: 20px;
flex: 1;
}

main.content {
background-color: rgba(255, 255, 255, 0.05);
padding: 20px;
border-radius: 10px;
word-wrap: break-word;
overflow-wrap: break-word;
box-sizing: border-box;
}

/* Başlık ve Arama Alanı */
header {
display: flex;
flex-direction: column;
gap: 10px;
}

#search {
background-color: rgba(255, 255, 255, 0.1);
color: #fff;
border: 1px solid #555;
padding: 10px;
border-radius: 6px;
width: 100%;
max-width: 500px; /* Taşmayı engelle */
}

/* Nav İçeriği */
.nav-button {
margin-bottom: 15px;
}

.nav-button a {
display: flex;
align-items: center;
text-decoration: none;
color: #ccc;
padding: 10px;
border-radius: 6px;
transition: background-color 0.3s, color 0.3s;
}

.nav-button a:hover, .nav-button a.active {
background-color: #444;
color: #fff;
}

/* Mobil Uyum */
@media (max-width: 991px) {
#hamburger {
display: block;
}

#nav-bar {
transform: translateX(-100%);
}

#nav-bar.active {
transform: translateX(0);
}

.container {
margin-left: 0;
}
}
</style>
</head>
<body>
<button id="hamburger"><i class="fas fa-bars"></i></button>
<div id="nav-bar">
<div id="nav-header">
<a id="nav-title" href="#" style="color: white;">Kategoriler</a>
</div>

<div id="nav-content">
<!-- Dinamik Kategori Listesi -->
<?php foreach ($categories as $category): ?>
<div class="nav-button">
<a href="rolkitapcigi?category_id=<?= $category['id'] ?>"
class="<?= $currentCategoryId == $category['id'] ? 'active' : '' ?>">
<i class="fas fa-folder"></i><span> <?= htmlspecialchars($category['name']) ?></span>
</a>
</div>
<?php endforeach; ?>
</div>
</div>

<div class="container">
<main class="content">
<header>
<h1 style="color: white;"><strong><?= htmlspecialchars($categories[array_search($currentCategoryId, array_column($categories, 'id'))]['name']) ?></strong></h1>
<input type="text" id="search" placeholder="Ara...">
</header>

<?php foreach ($contents as $content): ?>
<article>
<h2 style="color: white;"><strong><?= htmlspecialchars($content['title']) ?></strong></h2>
<div style="color: white;"><?= htmlspecialchars($content['content']) ?></div>
</article>
<?php endforeach; ?>
</main>
</div>

<script>
document.getElementById('hamburger').addEventListe ner('click', function () {
const navBar = document.getElementById('nav-bar');
navBar.classList.toggle('active');
});
</script>
</body>
</html>