<?php include 'include/header.php';?>
<?php include 'include/navbar.php';?>
<style type="text/css">
  
    .btn-apply {
      background-color: #00796B;
      color: #fff;
    }
    .btn-apply:hover {
      background-color: #00796B;
    }
    a{
        text-decoration:none !important;
    }
</style>
   <div class="home-banner">
    <div style="background:rgb(000, 000, 000,0.8)">
    <br><br>
<div class="container">
    <div class="row">
        <div class="col-lg-6">
            <br>
  <h1 style="font-size: 2.8rem; color: #fff; font-family: 'Montserrat', sans-serif;">
  Welcome to <?php echo $info['website_name']; ?>
</h1>
<p style="font-size: 1.1rem; color: white; max-width: 700px; margin: 20px auto; font-family: 'Montserrat', sans-serif;">
  <?php echo $info['home_banner_content']; ?>
</p>

  <a href="visas.php" class="btn text-white my-btn">
    Apply Now
  </a>
        </div>
        <div class="col-lg-6">
            <br>
            <img src="uploads/<?php echo $info['home_banner_image']; ?>" class="img-fluid">
        </div>
    </div>
</div>
<br><br>
    </div>
  </div>



<div class="container pt-5">
    <h1 class="text-center mb-4">Search Your Visa</h1>

 <form method="GET" action="visas.php" class="mb-4">
  <div class="row g-2">
    <div class="col-md mt-2">
      <input type="text" name="keyword" class="form-control" placeholder="Search visa title..." value="<?= isset($_GET['keyword']) ? htmlspecialchars($_GET['keyword']) : '' ?>">
    </div>

    <div class="col-md mt-2">
      <select name="country_id" class="form-control">
        <option value="">Choose Country</option>
        <?php
        $countries = mysqli_query($conn, "SELECT id, country_name FROM countries ORDER BY country_name ASC");
        while ($row = mysqli_fetch_assoc($countries)) {
            $selected = (isset($_GET['country_id']) && $_GET['country_id'] == $row['id']) ? 'selected' : '';
            echo "<option value=\"{$row['id']}\" $selected>{$row['country_name']}</option>";
        }
        ?>
      </select>
    </div>

    <div class="col-md  mt-2">
      <select name="visa_type" class="form-control">
        <option value="">Visa Type</option>
        <option value="Tourist" <?= (isset($_GET['visa_type']) && $_GET['visa_type'] == 'Tourist') ? 'selected' : '' ?>>Tourist Visa</option>
        <option value="Residential" <?= (isset($_GET['visa_type']) && $_GET['visa_type'] == 'Residential') ? 'selected' : '' ?>>Residential Visa</option>
      </select>
    </div>

    <div class="col-md  mt-2">
      <button type="submit" class="btn btn-apply w-100">Search</button>
    </div>

  </div>
</form>

  </div>




<div class="container">
    <div class="row">
        <?php
        $limit = 6; // 3 left + 3 right
        $countries_query = "SELECT DISTINCT c.id, c.country_name FROM countries c ORDER BY c.id DESC LIMIT $limit";
        $countries_result = mysqli_query($conn, $countries_query);

        // Fetch all countries into an array
        $countries = [];
        while ($row = mysqli_fetch_assoc($countries_result)) {
            $countries[] = $row;
        }

        // Split into 2 chunks: left and right
        $chunks = array_chunk($countries, ceil(count($countries) / 2));

        foreach ($chunks as $chunkIndex => $chunk) {
            echo '<div class="col-lg-6">';
            echo '<div class="container my-5">';
            foreach ($chunk as $country) {
                echo '<section class="country-section mb-5">';
            echo '<a href="country-visas.php?keyword=&country_id=' . urlencode($country['id']) . '" class="text-decoration-none">';
echo '<div class="country-header text-white py-3 px-4 mb-4">';
echo '<h3><i class="fas fa-flag me-2"></i> ' . htmlspecialchars($country['country_name']) . '</h3>';
echo '</div>';
echo '</a>';

                echo '<div class="row g-4">';

                $visas_query = "SELECT v.id, v.title, v.short_detail, v.apply_link FROM visas v
                                WHERE v.country_id = {$country['id']}
                                ORDER BY v.id DESC
                                LIMIT 2";
                $visas_result = mysqli_query($conn, $visas_query);

                if (mysqli_num_rows($visas_result) > 0) {
                    while ($visa = mysqli_fetch_assoc($visas_result)) {
                        // (same iconClass & btnClass logic as before...)

                        $title = strtolower($visa['title']); // convert to lowercase for easier matching

$title = strtolower($visa['title']); // Normalize input
$iconClass = 'fas fa-passport';      // Default icon
$btnClass = 'btn-dark';              // Default button

if (strpos($title, 'student') !== false) {
    $iconClass = 'fas fa-graduation-cap';
    $btnClass = 'btn-primary';
} elseif (strpos($title, 'work') !== false || strpos($title, 'employment') !== false) {
    $iconClass = 'fas fa-briefcase';
    $btnClass = 'btn-success';
} elseif (strpos($title, 'tourist') !== false || strpos($title, 'travel') !== false) {
    $iconClass = 'fas fa-plane-departure';
    $btnClass = 'btn-info';
} elseif (strpos($title, 'business') !== false) {
    $iconClass = 'fas fa-building';
    $btnClass = 'btn-warning';
} elseif (strpos($title, 'family') !== false || strpos($title, 'spouse') !== false) {
    $iconClass = 'fas fa-users';
    $btnClass = 'btn-secondary';
} elseif (strpos($title, 'medical') !== false || strpos($title, 'health') !== false) {
    $iconClass = 'fas fa-heartbeat';
    $btnClass = 'btn-danger';
} elseif (strpos($title, 'diplomatic') !== false || strpos($title, 'official') !== false) {
    $iconClass = 'fas fa-university';
    $btnClass = 'btn-light';
} elseif (strpos($title, 'religious') !== false || strpos($title, 'missionary') !== false) {
    $iconClass = 'fas fa-praying-hands';
    $btnClass = 'btn-outline-primary';
} elseif (strpos($title, 'refugee') !== false || strpos($title, 'asylum') !== false) {
    $iconClass = 'fas fa-hand-holding-heart';
    $btnClass = 'btn-outline-danger';
} elseif (strpos($title, 'retirement') !== false || strpos($title, 'retired') !== false) {
    $iconClass = 'fas fa-user-clock';
    $btnClass = 'btn-outline-secondary';
} elseif (strpos($title, 'investment') !== false || strpos($title, 'investor') !== false) {
    $iconClass = 'fas fa-chart-line';
    $btnClass = 'btn-outline-success';
} elseif (strpos($title, 'transit') !== false) {
    $iconClass = 'fas fa-exchange-alt';
    $btnClass = 'btn-outline-dark';
} elseif (strpos($title, 'digital nomad') !== false || strpos($title, 'remote') !== false) {
    $iconClass = 'fas fa-laptop-house';
    $btnClass = 'btn-info';
} elseif (strpos($title, 'residence') !== false || strpos($title, 'permanent') !== false) {
    $iconClass = 'fas fa-home';
    $btnClass = 'btn-outline-warning';
} elseif (strpos($title, 'schengen') !== false) {
    $iconClass = 'fas fa-european-union';
    $btnClass = 'btn-outline-info';
}

                        echo '<div class="col-md-6">';
                        echo '<div class="card visa-card h-100 border-0 shadow-lg">';
                        echo '<div class="card-body text-center">';
                        echo '<i class="' . $iconClass . ' fa-2x mb-3 my-color"></i>';
                        echo '<h5 class="card-title">' . htmlspecialchars($visa['title']) . '</h5>';
                        echo '<p class="card-text">' . htmlspecialchars($visa['short_detail']) . '</p>';
                        echo '<a href="visa-details.php?id=' . htmlspecialchars($visa['id']) . '" class="btn ' . $btnClass . ' w-100">Apply Now</a>';
                        echo '</div></div></div>';
                    }
                } else {
                    echo '<p class="text-muted">No visas found for this country.</p>';
                }

                echo '</div>'; // row
                echo '</section>'; // country-section
            }
            echo '</div>';
            echo '</div>'; // col-lg-6
        }
        ?>
    </div>

    <br>
    <center>
        <a href="visas.php" class="btn my-btn">More Visa Categories</a>
    </center>
</div>










 


<section class="why-gulf py-5 bg-light">
  <div class="container">
      <h2 class="mb-4 text-center">Why Choose <?php echo $info['website_name']; ?>?</h2>
    <div class="row text-center">
      <div class="col-md-4">
        <i class="fa fa-globe fa-3x mb-3 my-color"></i>
        <h5>Global Access</h5>
        <p>One platform to apply for visas to 20+ countries.</p>
      </div>
      <div class="col-md-4">
        <i class="fa fa-lock fa-3x mb-3 my-color"></i>
        <h5>Secure Process</h5>
        <p>Your details are handled with full data security.</p>
      </div>
      <div class="col-md-4">
        <i class="fa fa-users fa-3x mb-3 my-color"></i>
        <h5>User Friendly</h5>
        <p>Simple and fast application redirection to trusted partners.</p>
      </div>
    </div>
  </div>
</section>


<section class="cta text-center py-5" style="background-color: rgb(0, 121, 107,0.8);">
  <div class="container text-white">
    <h3>Start your visa journey now!</h3>
    <p>Choose your destination and apply through trusted providers</p>
    <a href="visas.php" class="btn btn-light btn-lg mt-3">Explore All Countries</a>
  </div>
</section>










 <?php include 'include/footer.php';?>