<script>
	import { page } from '$app/stores';
	import { goto } from '$app/navigation';

	function handleLogout() {
		localStorage.removeItem('user');
		goto('/');
	}
</script>

<nav class="navbar">
	<div class="navbar-content">
		<div class="navbar-brand">
			<img src="/logo.png" alt="YTP Logo" class="brand-logo" />
			<span class="brand-text">YTP</span>
		</div>

		<div class="navbar-menu">
			<button
				class="logout-btn"
				on:click={handleLogout}
				title="Çıkış Yap"
				aria-label="Çıkış Yap"
			>
				<i class="fas fa-sign-out-alt"></i>
			</button>
		</div>
	</div>
</nav>

<style>
	.navbar {
		background-color: #2c3e50;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		position: sticky;
		top: 0;
		z-index: 1000;
		width: 100%;
	}

	.navbar-content {
		padding: 0 var(--page-horizontal-padding);
		margin-left: 25px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 70px;
		width: 100%;
		box-sizing: border-box;
	}

	.navbar-brand {
		display: flex;
		align-items: center;
		gap: 3px;
	}

	.brand-text {
		font-size: 45px;
		font-weight: bold;
		color: #ffffff;
		text-decoration: none;
	}

	.brand-logo {
		height: 47px;
		width: auto;
		object-fit: contain;
	}

	.navbar-menu {
		display: flex;
		align-items: center;
		gap: 30px;
		margin-right: 30px;
	}

	.nav-link {
		color: #ecf0f1;
		text-decoration: none;
		font-weight: 500;
		padding: 8px 16px;
		border-radius: 6px;
		transition: all 0.3s ease;
	}

	.nav-link:hover {
		background-color: #34495e;
		color: #ffffff;
	}

	.nav-link.active {
		background-color: #3498db;
		color: #ffffff;
	}

	.logout-btn {
		background: none;
		border: none;
		color: #ffffff;
		font-size: 18px;
		cursor: pointer;
		padding: 8px;
		border-radius: 6px;
		transition: all 0.3s ease;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.logout-btn:hover {
		background-color: #34495e;
		transform: scale(1.1);
	}

	@media (max-width: 768px) {
		.navbar-content {
			padding: 0 var(--page-horizontal-padding);
			height: 60px;
		}

		.navbar-brand {
			gap: 10px;
		}

		.brand-text {
			font-size: 20px;
		}

		.brand-logo {
			height: 30px;
		}

		.navbar-menu {
			gap: 15px;
		}

		.nav-link {
			padding: 6px 12px;
			font-size: 14px;
		}

		.logout-btn {
			font-size: 16px;
			padding: 6px;
		}
	}

	@media (max-width: 480px) {
		.navbar-content {
			flex-direction: column;
			height: auto;
			padding: 0 var(--page-horizontal-padding);
		}

		.navbar-brand {
			margin-bottom: 10px;
		}

		.navbar-menu {
			gap: 10px;
		}

		.nav-link {
			padding: 4px 8px;
			font-size: 12px;
		}

		.logout-btn {
			font-size: 14px;
			padding: 4px;
		}
	}
</style>
