<?php
/**
 * Agent Sidebar Component (Property Detail Page)
 * 
 * Expected variables:
 *   $sidebarPrice     — formatted price
 *   $sidebarPriceLabel — e.g. "Prix de vente"
 *   $sidebarSurface   — m²
 *   $sidebarRooms     — number of rooms
 *   $sidebarBedrooms  — number of bedrooms
 *   $sidebarFloor     — floor info (optional)
 *   $sidebarBathrooms — number of bathrooms
 *   $sidebarYear      — year built (optional)
 *   $sidebarPropertyId — for contact link
 *   $sidebarPropertyTitle — for whatsapp link
 */

$sidebarPrice     = $sidebarPrice     ?? 'Prix sur demande';
$sidebarPriceLabel = $sidebarPriceLabel ?? 'Prix de vente';
$sidebarSurface   = $sidebarSurface   ?? null;
$sidebarRooms     = $sidebarRooms     ?? null;
$sidebarBedrooms  = $sidebarBedrooms  ?? null;
$sidebarBathrooms = $sidebarBathrooms ?? null;
$sidebarYear      = $sidebarYear      ?? null;
$sidebarPropertyId = $sidebarPropertyId ?? null;
$sidebarPropertyTitle = $sidebarPropertyTitle ?? '';
?>

<aside class="w-full lg:w-80 flex-shrink-0">
  <div class="sticky top-24 border border-gray-200 bg-white shadow-sm">

    <!-- Black accent bar -->
    <div class="h-0.5 w-full bg-black"></div>

    <div class="p-6">

      <!-- Price -->
      <p class="text-2xl font-serif font-light mb-1"><?= htmlspecialchars($sidebarPrice) ?></p>
      <p class="text-[11px] text-gray-400 tracking-[0.2em] uppercase mb-6 font-sans"><?= htmlspecialchars($sidebarPriceLabel) ?></p>

      <!-- Key Details -->
      <ul class="space-y-3 mb-8 border-t border-gray-100 pt-6">
        <?php if ($sidebarSurface): ?>
        <li class="flex justify-between text-sm font-sans">
          <span class="text-gray-500">Surface</span>
          <span class="font-medium text-black"><?= htmlspecialchars($sidebarSurface) ?> m²</span>
        </li>
        <?php endif; ?>
        <?php if ($sidebarRooms): ?>
        <li class="flex justify-between text-sm font-sans">
          <span class="text-gray-500">Pièces</span>
          <span class="font-medium text-black"><?= htmlspecialchars($sidebarRooms) ?></span>
        </li>
        <?php endif; ?>
        <?php if ($sidebarBedrooms): ?>
        <li class="flex justify-between text-sm font-sans">
          <span class="text-gray-500">Chambres</span>
          <span class="font-medium text-black"><?= htmlspecialchars($sidebarBedrooms) ?></span>
        </li>
        <?php endif; ?>
        <?php if ($sidebarBathrooms): ?>
        <li class="flex justify-between text-sm font-sans">
          <span class="text-gray-500">Salles de bain</span>
          <span class="font-medium text-black"><?= htmlspecialchars($sidebarBathrooms) ?></span>
        </li>
        <?php endif; ?>
        <?php if ($sidebarYear): ?>
        <li class="flex justify-between text-sm font-sans">
          <span class="text-gray-500">Année</span>
          <span class="font-medium text-black"><?= htmlspecialchars($sidebarYear) ?></span>
        </li>
        <?php endif; ?>
      </ul>

      <!-- Agent Card -->
      <div class="flex items-center gap-3 mb-8 pb-6 border-b border-gray-100">
        <img src="<?= SITE_URL ?>/assets/img/hind-ajouamai.jpg" class="w-12 h-12 rounded-full object-cover" alt="Hind Ajouamai" />
        <div>
          <p class="text-sm font-medium text-black font-sans">Hind Ajouamai</p>
          <p class="text-xs text-gray-400 font-sans">Agent Immobilier</p>
        </div>
      </div>

      <!-- CTAs -->
      <a href="<?= SITE_URL ?>/pages/contact<?= $sidebarPropertyId ? '?property_id=' . $sidebarPropertyId : '' ?>" class="block w-full bg-black text-white text-center text-xs tracking-[0.15em] uppercase py-4 hover:bg-gray-900 transition-colors mb-3 font-sans">
        Demander une visite
      </a>
      <a href="https://wa.me/212600000000?text=<?= urlencode('Bonjour, je suis intéressé(e) par: ' . $sidebarPropertyTitle) ?>" target="_blank" class="block w-full border border-black text-black text-center text-xs tracking-[0.15em] uppercase py-4 hover:bg-black hover:text-white transition-all duration-200 font-sans">
        Contacter l'agent
      </a>

    </div>
  </div>
</aside>
