<?php

/**
 * This file is part of JohnCMS Content Management System.
 *
 * @copyright JohnCMS Community
 * @license   https://opensource.org/licenses/GPL-3.0 GPL-3.0
 * @link      https://johncms.com JohnCMS Project
 */

/**
 * @var string $unread_count
 * @var string $files_url
 * @var string $files_name
 * @var string $files_count
 */

?>
<?php if (! $config['mod_forum']): ?>
    <div class="bg-red-50 border border-red-200 rounded-lg p-4 mb-4 text-red-800">
        <?= __('Forum is closed') ?>
    </div>
<?php elseif ($config['mod_forum'] == 3): ?>
    <div class="bg-red-50 border border-red-200 rounded-lg p-4 mb-4 text-red-800">
        <?= __('Read only') ?>
    </div>
<?php endif; ?>

<!-- Forum Navigation -->
<div class="border-t border-b border-gray-200 py-3 mb-6">
    <div class="flex flex-col sm:flex-row items-center justify-between gap-4">
        <!-- Left Navigation Links -->
        <div class="flex items-center gap-4 flex-wrap">
            <?php if ($user->isValid()): ?>
                <?php if (! empty($unread_count)): ?>
                    <div class="flex items-center">
                        <a href="?act=new" class="flex items-center text-gray-700 hover:text-blue-600 transition-colors">
                            <span class="hidden sm:inline"><?= __('Unread') ?></span>
                            <div class="flex items-center sm:ml-1">
                                <svg class="w-5 h-5 sm:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/>
                                </svg>
                                <span class="sm:hidden ml-1 bg-red-500 text-white text-xs rounded-full px-2 py-1"><?= $unread_count ?></span>
                                <span class="hidden sm:inline text-red-600 font-medium ml-1">+<?= $unread_count ?></span>
                            </div>
                        </a>
                    </div>
                <?php endif; ?>
                
                <div class="flex items-center">
                    <a href="?act=new&amp;do=period" class="flex items-center text-gray-700 hover:text-blue-600 transition-colors">
                        <span class="hidden sm:inline"><?= __('Show for Period') ?></span>
                        <svg class="w-5 h-5 sm:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                        </svg>
                    </a>
                </div>
            <?php else: ?>
                <div class="flex items-center">
                    <a href="?act=new" class="flex items-center text-gray-700 hover:text-blue-600 transition-colors">
                        <span class="hidden sm:inline"><?= __('Last activity') ?></span>
                        <svg class="w-5 h-5 sm:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
                        </svg>
                    </a>
                </div>
            <?php endif; ?>
            
            <!-- Files Link -->
            <div class="flex items-center">
                <a href="<?= $files_url ?>" class="flex items-center text-gray-700 hover:text-blue-600 transition-colors">
                    <span class="hidden sm:inline"><?= $files_name ?></span>
                    <div class="flex items-center sm:ml-1 relative">
                        <svg class="w-5 h-5 sm:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
                        </svg>
                        <?php if ($files_count > 0): ?>
                            <span class="absolute -top-2 -right-2 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 sm:hidden">
                                <?= $files_count ?>
                            </span>
                            <span class="hidden sm:inline bg-green-100 text-green-800 text-sm font-medium px-2 py-1 rounded-full">
                                <?= $files_count ?>
                            </span>
                        <?php endif ?>
                    </div>
                </a>
            </div>
        </div>

        <!-- Search Form -->
        <form class="w-full sm:w-auto" action="?act=search" method="post">
            <div class="relative">
                <input type="search" 
                       name="search" 
                       minlength="4" 
                       placeholder="<?= __('Search') ?>" 
                       class="w-full pl-4 pr-12 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors">
                <button type="submit" 
                        name="submit" 
                        value="1" 
                        class="absolute right-2 top-1/2 transform -translate-y-1/2 p-1 text-gray-400 hover:text-blue-600 transition-colors">
                    <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                    </svg>
                </button>
            </div>
        </form>
    </div>
</div>