<?php
/**
 * Header template — sayfa başlangıcı.
 * Kullanım: $page_title set edip require_once.
 */
if (!defined('APP_PATH')) exit;
$current_user = User::current();
$page_title = $page_title ?? __('site_title');
?>
<!DOCTYPE html>
<html lang="<?= e(Lang::current()) ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= e($page_title) ?> - BiteFight</title>
    <link rel="stylesheet" href="<?= APP_URL ?>/assets/css/style.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body>

<div class="site-banner">
    <img src="<?= APP_URL ?>/assets/img/home_head.jpg" alt="BiteFight" class="site-banner-img">
</div>

<header class="header" style="max-width:1200px; margin:0 auto;">
    <a href="<?= APP_URL ?>/index.php" class="logo">⚔ BiteFight</a>
    <div class="header-info">
        <?php if ($current_user): ?>
            <span><?= __('character') ?>: <b><?= e($current_user['name']) ?></b></span>
            <span><?= __('level') ?>: <b><?= (int)$current_user['level'] ?></b></span>
            <span class="hp">❤ <?= (int)$current_user['hp_now'] ?>/<?= (int)$current_user['hp_max'] ?></span>
            <span>💰 <b><?= format_number((int)$current_user['gold']) ?></b></span>
            <span>🔥 <b><?= format_number((int)$current_user['hellstones']) ?></b></span>
        <?php endif; ?>
        <div class="lang-switcher">
            <?php foreach (Lang::available() as $l): ?>
                <a href="?lang=<?= $l ?>" class="<?= $l === Lang::current() ? 'active' : '' ?>"><?= $l ?></a>
            <?php endforeach; ?>
        </div>
        <?php if ($current_user): ?>
            <a href="<?= APP_URL ?>/logout.php" class="btn btn-sm btn-secondary"><?= __('logout') ?></a>
        <?php endif; ?>
    </div>
</header>

<main class="layout">
    <?php if ($current_user && empty($hide_menu)): ?>
        <aside class="menu">
            <h3><?= __('menu_main') ?></h3>
            <ul>
                <li><a href="<?= APP_URL ?>/main.php"><?= __('character') ?></a></li>
                <li><a href="<?= APP_URL ?>/hideout.php"><?= __('menu_hideout') ?></a></li>
            </ul>
            <h3><?= __('menu_city') ?></h3>
            <ul>
                <li><a href="<?= APP_URL ?>/shop.php">
                    <img src="<?= APP_URL ?>/assets/img/symbol_shop.gif" alt="" class="menu-icon">
                    <?= __('menu_shop') ?>
                </a></li>
                <li><a href="<?= APP_URL ?>/market.php">
                    <img src="<?= APP_URL ?>/assets/img/symbol_market.gif" alt="" class="menu-icon">
                    <?= __('menu_market') ?>
                </a></li>
            </ul>
            <h3><?= __('menu_fight') ?></h3>
            <ul>
                <li><a href="<?= APP_URL ?>/fight.php"><?= __('menu_fight') ?></a></li>
                <li><a href="<?= APP_URL ?>/ranking.php"><?= __('menu_ranking') ?></a></li>
            </ul>
            <h3><?= __('menu_settings') ?></h3>
            <ul>
                <li><a href="<?= APP_URL ?>/settings.php"><?= __('menu_settings') ?></a></li>
                <?php if (is_admin()): ?>
                    <li><a href="<?= APP_URL ?>/admin/index.php" class="admin-link"><?= __('menu_admin') ?></a></li>
                <?php endif; ?>
            </ul>
        </aside>
        <section class="content">
    <?php else: ?>
        <section class="content" style="grid-column: 1 / -1;">
    <?php endif; ?>

    <?= flash_render() ?>
