<?php
$content = (new \App\Settings('content'))->getAll();
$headerLogo = json_decode($content['header-logo'] ?? '{}', true);
$menuItems = json_decode($content['menu'] ?? '[]', true);
?>
<header class="header">
    <div class="container">
        <!-- Logo -->
        <div class="header__logo">
            <?php if (!empty($headerLogo['src'])): ?>
                <a href="<?= $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ?>" class="header__logo-link">
                    <img src="<?= htmlspecialchars($headerLogo['src']) ?>" alt="<?= $headerLogo['alt'] ?? '' ?>" title="<?= $headerLogo['title'] ?? '' ?>">
                </a>
            <?php endif; ?>
        </div>

        <!-- Navigation -->
        <?php if (!empty($menuItems[0]['title'])): ?>
            <nav class="header__nav">
                <ul class="header__menu">
                    <?php foreach ($menuItems as $menuItem): ?>
                        <li class="header__menu-item">
                            <a href="<?= htmlspecialchars($menuItem['anchor'] ?? '') ?>" class="header__menu-link">
                                <?= htmlspecialchars($menuItem['title'] ?? '') ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </nav>
        <?php endif; ?>

        <!-- Buttons -->
        <div class="header__actions">
            <?php if (empty($content['hide-btns'])): ?>
                <button class="header__btn header__btn--primary redirect-js">
                    <?= htmlspecialchars($content['header_btn_1'] ?? 'Button 1') ?>
                </button>
                <button class="header__btn header__btn--secondary redirect-js">
                    <?= htmlspecialchars($content['header_btn_2'] ?? 'Button 2') ?>
                </button>
            <?php endif; ?>

            <!-- Burger Menu -->
            <button class="header__burger" aria-label="Toggle menu">
                <span class="header__burger-line"></span>
                <span class="header__burger-line"></span>
                <span class="header__burger-line"></span>
            </button>
        </div>
    </div>
</header>