<?php

/* VILLAGE DATA */
$village_name       = $village['village_name'] ?? 'Panchayat';
$village_name_hi    = $village['village_name_hi'] ?? '';

$final_village_name = ($village_name_hi != '') ? $village_name_hi : $village_name;

/* FETCH BLOCK + DISTRICT */
$block_name = '';
$district_name = '';

if(isset($village['id']))
{
$village_id = intval($village['id']);

$q = mysqli_query($conn,"
SELECT 
b.block_name, b.block_name_hi,
d.district_name, d.district_name_hi
FROM villages v
LEFT JOIN blocks b ON v.block_id = b.id
LEFT JOIN districts d ON v.district_id = d.id
WHERE v.id='$village_id'
");

$data = mysqli_fetch_assoc($q);

$block_name = ($data['block_name_hi'] != '') 
? $data['block_name_hi'] 
: $data['block_name'];

$district_name = ($data['district_name_hi'] != '') 
? $data['district_name_hi'] 
: $data['district_name'];
}

?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title><?php echo $final_village_name; ?></title>

<link rel="stylesheet" href="css/style.css">
<link href="https://cdn.jsdelivr.net/npm/lightbox2@2.11.4/dist/css/lightbox.min.css" rel="stylesheet">

<!-- UPDATED FONT AWESOME -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">

</head>

<body>

<header class="header">

<div class="header-inner">

<div class="header-left">
<i class="fa-solid fa-landmark"></i>
</div>

<div class="header-center">

<h1>ग्राम पंचायत <?php echo $final_village_name; ?></h1>

<span class="header-sub">
<?php 
if($block_name != '' && $district_name != '')
{
echo "खंड " . $block_name . " - ज़िला " . $district_name;
}
else
{
echo "Digital Village Portal";
}
?>
</span>

</div>

<div class="header-right">
<i class="fa-solid fa-flag"></i>
</div>

</div>

</header>

<nav class="menu">

<div class="menu-container">

<div class="logo">
<a href="index.php">
🏠 <?php echo $final_village_name; ?>
</a>
</div>

<div class="hamburger" onclick="toggleMenu()">
<i class="fa-solid fa-bars"></i>
</div>

<ul class="menu-links" id="mobileMenu">

<li><a href="/"><i class="fa-solid fa-house"></i> Home</a></li>

<li><a href="panchayat.php"><i class="fa-solid fa-users"></i> पंचायत</a></li>

<li>
<a href="/development.php?village=<?php echo $village['slug']; ?>">
<i class="fa-solid fa-screwdriver-wrench"></i> विकास कार्य
</a>
</li>

<li class="dropdown">
<a href="#"><i class="fa-solid fa-building"></i> भवन</a>
<ul class="submenu">
<li><a href="buildings.php?type=chaupals">🏛 चौपाल</a></li>
<li><a href="buildings.php?type=govt_buildings">🏢 सरकारी भवन</a></li>
<li><a href="buildings.php?type=anganwadi">👶 आंगनवाड़ी</a></li>
<li><a href="buildings.php?type=temples">🛕 मंदिर</a></li>
</ul>
</li>

<li><a href="schemes.php"><i class="fa-solid fa-hand-holding-dollar"></i> योजनाएं</a></li>

<li>
<a href="special_thanks.php">
<i class="fa-solid fa-handshake"></i> विशेष धन्यवाद
</a>
</li>

<li><a href="gallery.php"><i class="fa-solid fa-image"></i> फोटो</a></li>

<li><a href="contact.php"><i class="fa-solid fa-phone"></i> संपर्क</a></li>

</ul>

</div>

</nav>