<?php
/**
 * @package     MefisAssetBridge
 * @subpackage  Joomla_Administrator_Component
 *
 * @copyright   Copyright (C) 2025 Goran Usljebrka. All rights reserved.
 * @license     Proprietary — No resale or incorporation into other projects without explicit written permission. see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

HTMLHelper::_('behavior.formvalidator');
HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('bootstrap.tab');
?>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-8 offset-md-2">

            <ul class="nav nav-tabs" id="auth-tabs" role="tablist">
                <li class="nav-item" role="presentation">
                    <button class="nav-link <?php echo $this->activeTab === 'login' ? 'active' : ''; ?>"
                        id="login-tab"
                        data-bs-toggle="tab"
                        data-bs-target="#login-content"
                        type="button"
                        role="tab"
                        aria-controls="login-content"
                        aria-selected="<?php echo $this->activeTab === 'login' ? 'true' : 'false'; ?>">
                        <?php echo Text::_('COM_MEFISASSETBRIDGE_AUTH_LOGIN_TAB'); ?>
                    </button>
                </li>
                <li class="nav-item" role="presentation">
                    <button class="nav-link <?php echo $this->activeTab === 'register' ? 'active' : ''; ?>"
                        id="register-tab"
                        data-bs-toggle="tab"
                        data-bs-target="#register-content"
                        type="button"
                        role="tab"
                        aria-controls="register-content"
                        aria-selected="<?php echo $this->activeTab === 'register' ? 'true' : 'false'; ?>">
                        <?php echo Text::_('COM_MEFISASSETBRIDGE_AUTH_REGISTER_TAB'); ?>
                    </button>
                </li>
                <li class="nav-item" role="presentation">
                    <button class="nav-link <?php echo $this->activeTab === 'reset' ? 'active' : ''; ?>"
                        id="reset-tab"
                        data-bs-toggle="tab"
                        data-bs-target="#reset-content"
                        type="button"
                        role="tab"
                        aria-controls="reset-content"
                        aria-selected="<?php echo $this->activeTab === 'reset' ? 'true' : 'false'; ?>">
                        <?php echo Text::_('COM_MEFISASSETBRIDGE_AUTH_RESET_TAB'); ?>
                    </button>
                </li>
            </ul>

            <div class="tab-content" id="auth-tab-content">
                <!-- Login Tab Content -->
                <div class="tab-pane fade <?php echo $this->activeTab === 'login' ? 'show active' : ''; ?>"
                    id="login-content" role="tabpanel" aria-labelledby="login-tab">
                    <div class="card">
                        <div class="card-body">
                            <?php echo $this->loadTemplate('login'); ?>
                        </div>
                    </div>
                </div>

                <!-- Register Tab Content -->
                <div class="tab-pane fade <?php echo $this->activeTab === 'register' ? 'show active' : ''; ?>"
                    id="register-content" role="tabpanel" aria-labelledby="register-tab">
                    <div class="card">
                        <div class="card-body">
                            <?php echo $this->loadTemplate('register'); ?>
                        </div>
                    </div>
                </div>

                <!-- Reset Tab Content -->
                <div class="tab-pane fade <?php echo $this->activeTab === 'reset' ? 'show active' : ''; ?>"
                    id="reset-content" role="tabpanel" aria-labelledby="reset-tab">
                    <div class="card">
                        <div class="card-body">
                            <?php echo $this->loadTemplate('reset'); ?>
                        </div>
                    </div>
                </div>

            </div>


        </div>
    </div>
</div>


<script>
// Show Reset Password content when the link is clicked, hide others
(function() {
    document.addEventListener('DOMContentLoaded', function() {
        var resetLink = document.getElementById('reset-password-link');
        if (resetLink) {
            resetLink.addEventListener('click', function(e) {
                e.preventDefault();
                document.getElementById('auth-section').style.display = 'none';
                document.getElementById('reset-section').style.display = 'block';
            });
        }
    });
})();
</script>