<?php
/**
 * Search Bar Component — Refined Search Interface
 */

$searchZones = function_exists('getZones') ? getZones() : ['Dar Bouazza', 'Casablanca', 'Sidi Rahal'];
$searchTypes = function_exists('getPropertyTypes') ? getPropertyTypes() : [];
$siteUrl = defined('SITE_URL') ? SITE_URL : '';
$isHero = isset($searchStyle) && $searchStyle === 'hero';
?>

<div class="w-full">
  <form method="GET" action="<?= $siteUrl ?>/pages/properties" class="bg-white/95 backdrop-blur-md border border-gray-200/80 shadow-2xl p-4 sm:p-6 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4 items-end">
    
    <!-- 1. Transaction / Status -->
    <div>
      <label class="block text-[10px] tracking-[0.2em] uppercase font-sans text-gray-500 font-medium mb-2">Transaction</label>
      <select name="status" class="select-underline text-xs uppercase tracking-wider font-sans font-medium text-black">
        <option value="">Toutes les options</option>
        <option value="vente">Acheter (Vente)</option>
        <option value="location">Louer (Location)</option>
      </select>
    </div>

    <!-- 2. Zone / Lieu -->
    <div>
      <label class="block text-[10px] tracking-[0.2em] uppercase font-sans text-gray-500 font-medium mb-2">Localisation</label>
      <select name="city" class="select-underline text-xs uppercase tracking-wider font-sans font-medium text-black">
        <option value="">Toutes les zones</option>
        <?php foreach ($searchZones as $zone): ?>
          <option value="<?= htmlspecialchars($zone) ?>"><?= htmlspecialchars($zone) ?></option>
        <?php endforeach; ?>
      </select>
    </div>

    <!-- 3. Type de Bien -->
    <div>
      <label class="block text-[10px] tracking-[0.2em] uppercase font-sans text-gray-500 font-medium mb-2">Type de bien</label>
      <select name="type" class="select-underline text-xs uppercase tracking-wider font-sans font-medium text-black">
        <option value="">Tous les types</option>
        <?php foreach ($searchTypes as $slug => $label): ?>
          <option value="<?= htmlspecialchars($slug) ?>"><?= htmlspecialchars($label) ?></option>
        <?php endforeach; ?>
      </select>
    </div>

    <!-- 4. Submit Button -->
    <div>
      <button type="submit" class="w-full btn-lemonde-consultation justify-center text-center">
        <span>Rechercher</span>
        <svg class="w-4 h-4 ml-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/></svg>
      </button>
    </div>

  </form>
</div>
