<?php $current_page = basename($_SERVER['PHP_SELF']); ?>

<nav class="navbar navbar-expand-lg navbar-dark sgla-navbar fixed-top px-4 px-lg-5">
    <a href="index.php" class="navbar-brand d-flex align-items-center gap-2" aria-label="Página inicial">
        <img src="img/logo-moz-removebg-preview.png" alt="Logo DNMC" style="max-height:48px; min-width:40px;">
        <span class="brand-text">
            Direcção Nacional do<br><strong>Ambiente e Mudanças Climáticas</strong>
        </span>
    </a>

    <button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse"
            data-bs-target="#navbarCollapse" aria-controls="navbarCollapse"
            aria-expanded="false" aria-label="Abrir menu">
        <i class="fa fa-bars text-white"></i>
    </button>

    <div class="collapse navbar-collapse" id="navbarCollapse">
        <ul class="navbar-nav ms-auto align-items-lg-center gap-lg-1 py-2 py-lg-0">

            <li class="nav-item">
                <a href="index.php" class="nav-link <?= $current_page=='index.php'?'active':'' ?>">
                    <i class="bi bi-house-door me-1 d-lg-none"></i>Início
                </a>
            </li>

            <li class="nav-item dropdown">
                <a href="#" class="nav-link dropdown-toggle <?= in_array($current_page,['projectos_aia.php','contrabalancos.php'])?'active':'' ?>" data-bs-toggle="dropdown">
                    <i class="bi bi-folder me-1 d-lg-none"></i>Projectos
                </a>
                <ul class="dropdown-menu sgla-dropdown">
                    <li><a href="projectos_aia.php" class="dropdown-item <?= $current_page=='projectos_aia.php'?'active':'' ?>">
                        <i class="bi bi-file-earmark-check me-2"></i>Projectos Licenciados
                    </a></li>
                    <li><a href="contrabalancos.php" class="dropdown-item <?= $current_page=='contrabalancos.php'?'active':'' ?>">
                        <i class="bi bi-arrow-left-right me-2"></i>Projectos com PCGB
                    </a></li>
                </ul>
            </li>

            <li class="nav-item dropdown">
                <a href="#" class="nav-link dropdown-toggle <?= in_array($current_page,['documento_aia.php','ficha_inscricao.php'])?'active':'' ?>" data-bs-toggle="dropdown">
                    <i class="bi bi-file-text me-1 d-lg-none"></i>Documentos
                </a>
                <ul class="dropdown-menu sgla-dropdown">
                    <li><a href="documento_aia.php" class="dropdown-item <?= $current_page=='documento_aia.php'?'active':'' ?>">
                        <i class="bi bi-journal-bookmark me-2"></i>Legislação
                    </a></li>
                    <li><a href="ficha_inscricao.php" class="dropdown-item <?= $current_page=='ficha_inscricao.php'?'active':'' ?>">
                        <i class="bi bi-clipboard-check me-2"></i>Fichas de Inscrição
                    </a></li>
                </ul>
            </li>

            <li class="nav-item">
                <a href="consulta_publica.php" class="nav-link <?= $current_page=='consulta_publica.php'?'active':'' ?>">
                    <i class="bi bi-people me-1 d-lg-none"></i>Consultas Públicas
                </a>
            </li>

            <li class="nav-item dropdown">
                <a href="#" class="nav-link dropdown-toggle <?= in_array($current_page,['consultor_individual.php','consultor_empresa.php'])?'active':'' ?>" data-bs-toggle="dropdown">
                    <i class="bi bi-person-badge me-1 d-lg-none"></i>Consultores
                </a>
                <ul class="dropdown-menu sgla-dropdown">
                    <li><a href="consultor_individual.php" class="dropdown-item <?= $current_page=='consultor_individual.php'?'active':'' ?>">
                        <i class="bi bi-person me-2"></i>Individual
                    </a></li>
                    <li><a href="consultor_empresa.php" class="dropdown-item <?= $current_page=='consultor_empresa.php'?'active':'' ?>">
                        <i class="bi bi-building me-2"></i>Empresa
                    </a></li>
                </ul>
            </li>

            <li class="nav-item dropdown">
                <a href="#" class="nav-link dropdown-toggle <?= in_array($current_page,['auditor_individual.php','auditor_empresa.php'])?'active':'' ?>" data-bs-toggle="dropdown">
                    <i class="bi bi-shield-check me-1 d-lg-none"></i>Auditores
                </a>
                <ul class="dropdown-menu sgla-dropdown">
                    <li><a href="auditor_individual.php" class="dropdown-item <?= $current_page=='auditor_individual.php'?'active':'' ?>">
                        <i class="bi bi-person me-2"></i>Individual
                    </a></li>
                    <li><a href="auditor_empresa.php" class="dropdown-item <?= $current_page=='auditor_empresa.php'?'active':'' ?>">
                        <i class="bi bi-building me-2"></i>Empresa
                    </a></li>
                </ul>
            </li>

            <li class="nav-item">
                <a href="contact.php" class="nav-link <?= $current_page=='contact.php'?'active':'' ?>">
                    <i class="bi bi-envelope me-1 d-lg-none"></i>Contactos
                </a>
            </li>

            <!-- ── Separador ── -->
            <li class="nav-item d-none d-lg-block">
                <div style="width:1px;height:22px;background:rgba(255,255,255,.20);margin:0 .25rem;"></div>
            </li>

            <!-- ── Botão Login ── -->
            <li class="nav-item">
                <a href="admin/login" class="nav-btn-login">
                    <i class="bi bi-box-arrow-in-right"></i>
                    <span>Entrar</span>
                </a>
            </li>

            <!-- ── Botão Registar ── -->
            <li class="nav-item">
                <a href="#" class="nav-btn-register" data-bs-toggle="modal" data-bs-target="#modalRegisto">
                    <i class="bi bi-person-plus-fill"></i>
                    <span>Registar</span>
                </a>
            </li>

        </ul>
    </div>
</nav>

<style>
/* ── Nav buttons — Login & Registar ── */
.nav-btn-login {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .42rem 1rem;
    border: 1.5px solid rgba(255,255,255,.40);
    border-radius: 8px;
    color: rgba(255,255,255,.90) !important;
    font-size: .80rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .22s ease;
    background: rgba(255,255,255,.08);
    white-space: nowrap;
}
.nav-btn-login:hover {
    background: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.65);
    color: #fff !important;
    transform: translateY(-1px);
}

.nav-btn-register {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    padding: .42rem 1.1rem;
    border: none;
    border-radius: 8px;
    color: var(--v800, #24571A) !important;
    font-size: .80rem;
    font-weight: 700;
    text-decoration: none;
    transition: all .22s ease;
    background: linear-gradient(135deg, var(--v50, #DAEAC5), #fff);
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    white-space: nowrap;
}
.nav-btn-register:hover {
    background: #fff;
    box-shadow: 0 4px 18px rgba(0,0,0,.20);
    color: var(--v700, #2E5A1A) !important;
    transform: translateY(-1px);
}

/* Mobile — stack buttons nicely */
@media (max-width: 991.98px) {
    .nav-btn-login,
    .nav-btn-register {
        display: flex;
        justify-content: center;
        width: 100%;
        margin-top: .35rem;
        padding: .55rem 1rem;
        border-radius: 10px;
    }
    .nav-btn-login {
        background: rgba(255,255,255,.10);
    }
    .nav-btn-register {
        background: linear-gradient(135deg, var(--v50, #DAEAC5), #fff);
    }
}
</style>
