<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Protal Berita Codeigniter</title>

	<!-- Bootstrap CSS -->
	<link rel="stylesheet" href="<?= base_url('css/bootstrap.min.css') ?>" />
</head>

<body>

    <?= $this->include('layout/navbar') ?>
    <?= $this->include('layout/header') ?>
    
    <?= $this->renderSection('content') ?>
    
    <?= $this->include('layout/footer') ?>

	<!-- Jquery dan Bootsrap JS -->
	<script src="<?= base_url('js/jquery.min.js') ?>"></script>
	<script src="<?= base_url('js/bootstrap.min.js') ?>"></script>
	
	<!-- Script untuk hamburger menu mobile -->
	<script>
	(function() {
		'use strict';
		
		function initNavbarToggle() {
			var toggler = document.querySelector('.navbar-toggler');
			var collapse = document.querySelector('#navbarNav');
			
			if (!toggler || !collapse) return;
			
			function toggleMenu() {
				var isExpanded = collapse.classList.contains('show');
				if (isExpanded) {
					collapse.classList.remove('show');
					toggler.setAttribute('aria-expanded', 'false');
				} else {
					collapse.classList.add('show');
					toggler.setAttribute('aria-expanded', 'true');
				}
			}
			
			toggler.addEventListener('click', function(e) {
				e.preventDefault();
				e.stopPropagation();
				toggleMenu();
			});
			
			toggler.addEventListener('touchend', function(e) {
				e.preventDefault();
				e.stopPropagation();
				toggleMenu();
			});
			
			document.addEventListener('click', function(e) {
				if (window.innerWidth <= 991.98) {
					if (!toggler.contains(e.target) && !collapse.contains(e.target)) {
						collapse.classList.remove('show');
						toggler.setAttribute('aria-expanded', 'false');
					}
				}
			});
			
			var navLinks = collapse.querySelectorAll('.nav-link');
			navLinks.forEach(function(link) {
				link.addEventListener('click', function() {
					if (window.innerWidth <= 991.98) {
						collapse.classList.remove('show');
						toggler.setAttribute('aria-expanded', 'false');
					}
				});
			});
		}
		
		if (document.readyState === 'loading') {
			document.addEventListener('DOMContentLoaded', initNavbarToggle);
		} else {
			initNavbarToggle();
		}
	})();
	</script>

</body>

</html>