<?php
require __DIR__.'/app/bootstrap.php'; require __DIR__.'/app/layout.php';
$page=$_GET['page']??'home'; $l=lang();
function hotel_card_slides(PDO $pdo, array $hotel): array {
  static $cache=[];
  $id=(int)($hotel['id']??0);
  if(isset($GLOBALS['hotel_card_slide_map'][$id]))return $GLOBALS['hotel_card_slide_map'][$id];
  if(isset($cache[$id])) return $cache[$id];
  $images=[];
  $cover=trim((string)($hotel['cover_image']??''));
  if($cover!==''){$local=local_media_path($cover,'');if($local!=='')$images[]=$local;}
  if($id>0){
    $query=$pdo->prepare("SELECT image_path FROM media WHERE entity_type='hotel' AND entity_id=? ORDER BY sort_order,id LIMIT 8");
    $query->execute([$id]);
    foreach($query->fetchAll(PDO::FETCH_COLUMN) as $path){$path=local_media_path((string)$path,'');if($path!==''&&!in_array($path,$images,true))$images[]=$path;}
  }
  if(!$images)$images[]='assets/media/luxury-villa.jpg';
  return $cache[$id]=array_slice(array_map('card_media_path',$images),0,3);
}
function prime_hotel_card_slides(PDO $pdo,array $hotels): void {
  $ids=array_values(array_unique(array_filter(array_map(static fn($row)=>(int)($row['id']??0),$hotels))));$map=[];
  foreach($hotels as $hotel){$id=(int)($hotel['id']??0);$cover=trim((string)($hotel['cover_image']??''));$local=$cover!==''?local_media_path($cover,''):'';$map[$id]=$local!==''?[$local]:[];}
  if($ids){$marks=implode(',',array_fill(0,count($ids),'?'));$q=$pdo->prepare("SELECT entity_id,image_path FROM media WHERE entity_type='hotel' AND entity_id IN ($marks) ORDER BY entity_id,sort_order,id");$q->execute($ids);foreach($q->fetchAll() as $row){$id=(int)$row['entity_id'];$path=local_media_path((string)$row['image_path'],'');if($path!==''&&!in_array($path,$map[$id]??[],true)&&count($map[$id]??[])<3)$map[$id][]=$path;}}
  foreach($map as $id=>$paths){if(!$paths)$map[$id]=['assets/media/luxury-villa.jpg'];$map[$id]=array_slice(array_map('card_media_path',$map[$id]),0,3);}
  $GLOBALS['hotel_card_slide_map']=$map;
}
if($page==='assistant-api'){require __DIR__.'/app/assistant-api.php';exit;}
if(in_array($page,['visa','company','guide','about','booking-process','trust'],true)){$_GET['slug']=$page==='about'?'about':$page;$page='content';}
if($_SERVER['REQUEST_METHOD']==='POST' && ($_POST['form']??'')==='booking'){
  verify_csrf(); $type=($_GET['page']??'')==='hotel'?'hotel':'tour'; $id=(int)($_POST['item_id']??0); $name=mb_substr(trim($_POST['name']??''),0,160); $phone=mb_substr(trim($_POST['phone']??''),0,80);$phoneDigits=preg_replace('/\D+/','',$phone);$from=trim($_POST['travel_from']??'');$to=$type==='hotel'?trim($_POST['travel_to']??''):'';$guestInput=filter_var($_POST['guests']??null,FILTER_VALIDATE_INT);$table=$type==='hotel'?'hotels':'tours';$st=$pdo->prepare("SELECT id,slug,name_fa,name_en FROM $table WHERE id=? AND slug=? AND active=1");$st->execute([$id,$_GET['slug']??'']);$bookingItem=$st->fetch();$baliTimezone=new DateTimeZone('Asia/Makassar');$todayBali=(new DateTimeImmutable('today',$baliTimezone))->format('Y-m-d');$validDate=static function(string $value)use($baliTimezone):bool{$d=DateTimeImmutable::createFromFormat('!Y-m-d',$value,$baliTimezone);return $d instanceof DateTimeImmutable&&$d->format('Y-m-d')===$value;};
  if($name===''||strlen($phoneDigits)<8||strlen($phoneDigits)>15||!$bookingItem||$guestInput===false||$guestInput===null||$guestInput<1||$guestInput>50){$error=tr('نام، شماره تماس، تعداد مسافران (۱ تا ۵۰ نفر) و مورد معتبر را بررسی کنید','Please check your name, phone, traveller count (1–50) and selected item');}
  elseif(!$validDate($from)||$from<$todayBali||($type==='hotel'&&(!$validDate($to)||$to<$todayBali))||($to!==''&&$to<=$from)){$error=tr('تاریخ‌های گذشته قابل ثبت نیستند؛ تاریخ ورود و خروج را بررسی کنید','Past dates cannot be submitted; please check arrival and departure dates');}
  else { $stmt=$pdo->prepare('INSERT INTO booking_requests(type,item_id,item_name_fa,item_name_en,customer_name,phone,travel_from,travel_to,guests,notes,status,created_at) VALUES(?,?,?,?,?,?,?,?,?,?,\'new\',NOW())'); $guests=(int)$guestInput;$notes=mb_substr(trim($_POST['notes']??''),0,1800);$roomChoice=trim((string)($_POST['room_preference']??''));$roomChoices=['studios'=>['استودیوهای Potato Head','Potato Head Studios'],'suites'=>['سوئیت‌های Potato Head','Potato Head Suites'],'either'=>['هنوز مطمئن نیستم','Not sure yet']];if($type==='hotel'&&($bookingItem['slug']??'')==='desa-potato-head-seminyak'&&isset($roomChoices[$roomChoice]))$notes=mb_substr(trim($notes."\n".tr('ترجیح اقامت: '.$roomChoices[$roomChoice][0],'Room preference: '.$roomChoices[$roomChoice][1])),0,2000);$stmt->execute([$type,$id,$bookingItem['name_fa'],$bookingItem['name_en'],$name,$phone,$from?:null,$to?:null,$guests,$notes]);$requestId=(int)$pdo->lastInsertId();$requestCode='KT-R-'.str_pad((string)$requestId,7,'0',STR_PAD_LEFT);
    $itemName=$bookingItem[$l==='fa'?'name_fa':'name_en']??'-';
    $msg=$type==='tour'?tr("سلام، برای تور «$itemName» درخواست دارم.\nکد پیگیری: $requestCode\nنام: $name\nتلفن: $phone\nتاریخ اجرای تور: $from\nتعداد نفرات: $guests\nتوضیحات: ".($notes?:'-'),"Hello, I am enquiring about the “$itemName” tour.\nRequest reference: $requestCode\nName: $name\nPhone: $phone\nTour date: $from\nTravellers: $guests\nNotes: ".($notes?:'-')):tr("سلام، برای رزرو «$itemName» درخواست دارم.\nکد پیگیری: $requestCode\nنام: $name\nتلفن: $phone\nاز تاریخ: ".($from?:'-')."\nتا تاریخ: ".($to?:'-')."\nتعداد نفرات: $guests\nتوضیحات: ".($notes?:'-'),"Hello, I would like to book “$itemName”.\nRequest reference: $requestCode\nName: $name\nPhone: $phone\nFrom: ".($from?:'-')."\nTo: ".($to?:'-')."\nGuests: $guests\nNotes: ".($notes?:'-'));
    header('Location: '.wa_link($msg)); exit;
  }
}
if($page==='tour' || $page==='hotel'){
  $type=$page==='hotel'?'hotel':'tour'; $table=$type==='hotel'?'hotels':'tours'; $st=$pdo->prepare("SELECT x.*,r.name_fa region_fa,r.name_en region_en FROM $table x LEFT JOIN regions r ON r.id=x.region_id WHERE x.slug=? AND x.active=1");$st->execute([$_GET['slug']??'']);$item=$st->fetch(); if(!$item){http_response_code(404);page_top('404');echo '<section class="empty">'.tr('این مورد پیدا نشد','Not found').'</section>';page_bottom();exit;}if($type==='tour')$item['duration']=localized_tour_duration($item);
  $name=$item[$l==='fa'?'name_fa':'name_en'];$desc=$item[$l==='fa'?'description_fa':'description_en'];$short=$item[$l==='fa'?'short_fa':'short_en'];
  $imgs=$pdo->prepare('SELECT image_path,alt_fa,alt_en FROM media WHERE entity_type=? AND entity_id=? ORDER BY sort_order,id');$imgs->execute([$type,$item['id']]);$gallery=$imgs->fetchAll();$isPotatoHead=$type==='hotel'&&$item['slug']==='desa-potato-head-seminyak';if($isPotatoHead){$preferredGallery=['uploads/potato-head-desa-studio-interior.webp','uploads/potato-head-studio-amenities.webp','uploads/potato-head-studio-design.webp','uploads/potato-head-stay-property.webp','uploads/potato-head-seminyak-aerial.webp','uploads/potato-head-beach-club-terrace.webp','uploads/potato-head-beachfront-exterior.webp','uploads/potato-head-pool-courtyard.webp','uploads/potato-head-infinity-pool-beach-view.webp','uploads/potato-head-beach-club-space.webp'];$gallery=array_values(array_filter($gallery,static fn($photo)=>in_array($photo['image_path'],$preferredGallery,true)));}
  if($isPotatoHead){$item['latitude']=-8.6792173;$item['longitude']=115.1500396;}
  $imageUrls=[];if(!empty($item['cover_image']))$imageUrls[]=url($item['cover_image']);foreach($gallery as $photo)if(!empty($photo['image_path']))$imageUrls[]=url($photo['image_path']);
  $GLOBALS['seo_entity']=['@type'=>$type==='hotel'?'Hotel':'TouristTrip','name'=>$name,'description'=>$short,'image'=>$imageUrls?:url($item['cover_image']?:'assets/media/'.($type==='hotel'?'luxury-villa.jpg':'bali-gate.jpg'))];
  if($type==='tour'){$GLOBALS['is_tour_detail']=true;$GLOBALS['seo_entity']['url']=url('?page=tour&slug='.rawurlencode($item['slug']).'&lang='.$l);$GLOBALS['seo_entity']['provider']=['@type'=>'TravelAgency','name'=>'Kousha Travel','url'=>url()];$GLOBALS['seo_entity']['touristType']=['Leisure','Family','Group travel'];$GLOBALS['seo_breadcrumbs']=[['name'=>tr('خانه','Home'),'url'=>url('?lang='.$l)],['name'=>tr('تورهای بالی','Bali tours'),'url'=>url('?page=tours&lang='.$l)],['name'=>$item[$l==='fa'?'region_fa':'region_en']??'Bali','url'=>url('?page=tours&region='.(int)($item['region_id']??0).'&lang='.$l)],['name'=>$name,'url'=>url('?page=tour&slug='.rawurlencode($item['slug']).'&lang='.$l)]];}
  if($type==='hotel'){
    if($item['latitude']&&$item['longitude'])$GLOBALS['seo_entity']['geo']=['@type'=>'GeoCoordinates','latitude'=>(float)$item['latitude'],'longitude'=>(float)$item['longitude']];
    $address=$item[$l==='fa'?'address_fa':'address_en']??'';if($isPotatoHead){$GLOBALS['seo_entity']['geo']=['@type'=>'GeoCoordinates','latitude'=>-8.6792173,'longitude'=>115.1500396];$GLOBALS['seo_entity']['address']=['@type'=>'PostalAddress','streetAddress'=>'Jl. Petitenget No. 51B','addressLocality'=>'Seminyak','addressRegion'=>'Bali','postalCode'=>'80361','addressCountry'=>'ID'];}elseif($address!=='')$GLOBALS['seo_entity']['address']=['@type'=>'PostalAddress','streetAddress'=>$address,'addressRegion'=>$item[$l==='fa'?'region_fa':'region_en']??'Bali','addressCountry'=>'ID'];
    $GLOBALS['seo_entity']['url']=url('?page=hotel&slug='.rawurlencode($item['slug']).'&lang='.$l);
    if($item['slug']==='desa-potato-head-seminyak'){$GLOBALS['seo_entity']['sameAs']='https://seminyak.potatohead.co/';$GLOBALS['seo_entity']['hasMap']='https://seminyak.potatohead.co/desa-map';}
    $amenities=$item[$l==='fa'?'amenities_fa':'amenities_en']??'';if(trim($amenities)!=='')$GLOBALS['seo_entity']['amenityFeature']=array_map(static fn($feature)=>['@type'=>'LocationFeatureSpecification','name'=>trim($feature),'value'=>true],array_values(array_filter(preg_split('/\R/u',$amenities),static fn($feature)=>trim($feature)!=='')));
    $GLOBALS['seo_breadcrumbs']=[['name'=>tr('خانه','Home'),'url'=>url('?lang='.$l)],['name'=>tr('هتل‌های بالی','Bali hotels'),'url'=>url('?page=hotels&lang='.$l)],['name'=>$item[$l==='fa'?'region_fa':'region_en']??'Bali','url'=>url('?page=hotels&region='.(int)($item['region_id']??0).'&lang='.$l)],['name'=>$name,'url'=>url('?page=hotel&slug='.rawurlencode($item['slug']).'&lang='.$l)]];
  }
  $seoTitle=trim((string)($item['seo_title_'.$l]??''));$seoDescription=trim((string)($item['seo_description_'.$l]??''));if($seoTitle!=='')$GLOBALS['seo_title']=$seoTitle;$GLOBALS['seo_image']=url($item['cover_image']?:'assets/media/luxury-villa.jpg');$GLOBALS['og_image_alt']=trim((string)($item['cover_alt_'.$l]??''))?:$name;
  page_top($seoTitle?:$name,$seoDescription?:$short);
  ?>
  <?php if($type==='hotel'):?><nav class="hotel-breadcrumb" aria-label="<?=tr('مسیر صفحه','Breadcrumb')?>"><a href="<?=url('?lang='.$l)?>"><?=tr('خانه','Home')?></a><span>›</span><a href="<?=url('?page=hotels&lang='.$l)?>"><?=tr('هتل‌های بالی','Bali hotels')?></a><span>›</span><span><?=e($name)?></span></nav><?php endif;?>
  <?php $detailCover=card_image($item,$type==='hotel'?'luxury-villa.jpg':'bali-gate.jpg');?><section class="detail-hero"><div><a class="back" href="<?=url('?page='.$type.'s&lang='.$l)?>">← <?=tr('بازگشت به فهرست','Back to list')?></a><span class="eyebrow"><?=e($item[$l==='fa'?'region_fa':'region_en']??'Bali')?></span><h1><?=e($name)?></h1><p><?=e($short)?></p><div class="tags"><?php if($type==='hotel'):?><span aria-label="<?=e(tr('رده‌بندی هتل: '.$item['star_rating'].' ستاره',$item['star_rating'].'-star hotel category'))?>"><?=str_repeat('★',(int)$item['star_rating'])?> <?=tr('رده هتل','Hotel category')?></span><?php else:?><span><?=e($item['duration'])?></span><?php endif;?><span><?=tr('نرخ همکاری مستقیم','Direct partner rate')?></span></div></div><img src="<?=$detailCover?>" <?=responsive_image_attributes($detailCover,'(max-width: 800px) 100vw, 50vw')?> alt="<?=e(trim((string)($item['cover_alt_'.$l]??''))?:$name)?>" fetchpriority="high" decoding="async"></section>
  <?php if($gallery):?><section class="gallery<?=$isPotatoHead?' hotel-gallery':''?>" aria-label="<?=tr('گالری تصاویر هتل','Hotel photo gallery')?>"><?php foreach($gallery as $photoIndex=>$g):$galleryThumb=url(card_media_path(local_media_path((string)$g['image_path'],'assets/media/luxury-villa.jpg')));?><a class="gallery-lightbox" href="<?=url($g['image_path'])?>" data-gallery-image="<?=e($g[$l==='fa'?'alt_fa':'alt_en'])?>" aria-label="<?=e($g[$l==='fa'?'alt_fa':'alt_en'])?>"><img src="<?=$galleryThumb?>" <?=responsive_image_attributes($galleryThumb,'(max-width: 700px) 88vw, (max-width: 1100px) 42vw, 520px')?> alt="<?=e($g[$l==='fa'?'alt_fa':'alt_en'])?>" loading="<?=$photoIndex===0?'eager':'lazy'?>" decoding="async" <?=$photoIndex===0?'fetchpriority="high"':''?>></a><?php endforeach;?></section><?php endif;?>
  <?php if($isPotatoHead):?><section class="hotel-resources"><h2><?=tr('اطلاعات اقامت و امکانات','Stay and facilities')?></h2><p><?=tr('جزئیات اتاق‌ها، موقعیت، امکانات و مراحل استعلام را همین‌جا ببینید. سیاست‌های روز هتل ممکن است تغییر کند؛ برای موارد وابسته به تاریخ سفر، شرایط را در پیشنهاد نهایی تأیید می‌کنیم.','Room details, location, facilities and enquiry steps are covered here. Hotel policies can change; we confirm date-specific terms in your final proposal.')?></p><div class="hotel-resource-links"><a href="https://seminyak.potatohead.co/faq" target="_blank" rel="noopener noreferrer"><?=tr('راهنمای رسمی هتل و سیاست‌های روز','Official hotel guide & current policies')?> ↗</a><a href="<?=url('?page=blog&slug=desa-potato-head-bali-stay-beach-club-guide&lang='.$l)?>"><?=tr('راهنمای کامل اقامت و Beach Club','Full stay & Beach Club guide')?> ←</a><a href="<?=url('?page=content&slug=guide&lang='.$l)?>"><?=tr('راهنمای سفر بالی','Bali travel guide')?> ←</a><a href="<?=url('?page=hotels&lang='.$l)?>"><?=tr('مقایسه با هتل‌های دیگر بالی','Compare other Bali hotels')?> ←</a></div></section><?php endif;?>
  <section class="detail-grid"><article class="rich"><h2><?=tr('آنچه باید بدانید','What to know')?></h2><?=nl2br(e($desc))?><?php if($type==='hotel'&&trim($item[$l==='fa'?'amenities_fa':'amenities_en']??'')!==''):?><h3><?=tr('امکانات','Amenities')?></h3><ul><?php foreach(preg_split('/\R/u',$item[$l==='fa'?'amenities_fa':'amenities_en']) as $amenity):if(trim($amenity)!==''):?><li><?=e(trim($amenity))?></li><?php endif;endforeach;?></ul><?php endif;?><?php if($type==='hotel'&&(trim($item[$l==='fa'?'address_fa':'address_en']??'')!==''||($item['latitude']&&$item['longitude']))):?><h3><?=tr('موقعیت هتل','Hotel location')?></h3><?php if(trim($item[$l==='fa'?'address_fa':'address_en']??'')!==''):?><p><?=e($item[$l==='fa'?'address_fa':'address_en'])?></p><?php endif;?><?php if($item['latitude']&&$item['longitude']):?><div class="map"><iframe title="<?=e($name)?> map" loading="lazy" src="https://maps.google.com/maps?q=<?=rawurlencode($item['latitude'].','.$item['longitude'])?>&z=14&output=embed"></iframe></div><?php endif;?><?php endif;?><h3><?=tr('رزرو با اطلاعات روشن','Book with clear information')?></h3><p><?=tr('پیش از تأیید، نوع اتاق، تاریخ، خدمات شامل، هزینه‌های جداگانه و شرایط تغییر یا کنسلی را با شما مرور می‌کنیم. نرخ و ظرفیت برای تاریخ درخواستی بررسی می‌شود و رزرو پس از تأیید نهایی و دریافت تأییدیه تأمین‌کننده قطعی خواهد شد.','Before confirmation, we review the room type, dates, inclusions, additional charges and change or cancellation terms with you. Rates and availability are checked for your dates; the booking is confirmed only after final approval and supplier confirmation.')?></p><h3><?=tr('چرا از کوشا تراول استعلام بگیرم؟','Why enquire with Kousha Travel?')?></h3><p><?=tr('با همکاران محلی برای تاریخ واقعی سفر شما استعلام می‌گیریم و جزئیات را شفاف توضیح می‌دهیم. اگر قیمت معتبر پایین‌تری برای گزینه‌ای کاملاً مشابه پیدا کرده‌اید، لینک و شرایطش را بفرستید تا مقایسه کنیم.','We check with local partners for your actual travel dates and explain the details clearly. If you find a lower valid price for a truly comparable option, send its link and terms so we can review it.')?></p></article><aside class="booking"><span><?=tr('استعلام رایگان قیمت و ظرفیت','Free rate & availability check')?></span><h2><?=tr($type==='tour'?'درخواست استعلام تور':'درخواست استعلام اقامت',$type==='tour'?'Request a tour enquiry':'Request a stay quote')?></h2><?php if(!empty($error)):?><p class="error"><?=e($error)?></p><?php endif;?><form method="post"><input type="hidden" name="csrf" value="<?=csrf()?>"><input type="hidden" name="form" value="booking"><input type="hidden" name="type" value="<?=$type?>"><input type="hidden" name="item_id" value="<?=$item['id']?>"><label><?=tr('نام و نام خانوادگی','Full name')?><input name="name" autocomplete="name" required></label><label><?=tr('شماره تماس / واتس‌اپ','Phone / WhatsApp')?><input name="phone" dir="ltr" inputmode="tel" autocomplete="tel" required></label><div class="form-row"><label><?=tr($type==='tour'?'تاریخ اجرای تور':'از تاریخ',$type==='tour'?'Tour date':'Check-in')?><input type="date" name="travel_from" required></label><?php if($type==='hotel'):?><label><?=tr('تا تاریخ','Check-out')?><input type="date" name="travel_to" required></label><?php endif;?></div><label><?=tr('تعداد مسافران','Guests')?><input type="number" name="guests" value="2" min="1" max="50" required></label><?php if($type==='hotel'&&$item['slug']==='desa-potato-head-seminyak'):?><label><?=tr('ترجیح نوع اقامت (اختیاری)','Preferred stay type (optional)')?><select name="room_preference"><option value="either"><?=tr('هنوز مطمئن نیستم','Not sure yet')?></option><option value="studios"><?=tr('Potato Head Studios','Potato Head Studios')?></option><option value="suites"><?=tr('Potato Head Suites','Potato Head Suites')?></option></select></label><?php endif;?><label><?=tr('درخواست یا نکته‌ی دیگر (اختیاری)','Any other request (optional)')?><textarea name="notes" rows="3" maxlength="1800" placeholder="<?=tr('مثلاً سن کودکان یا نیاز ویژه','For example, children’s ages or an accessibility request')?>"></textarea></label><button class="btn primary" type="submit"><?=tr($type==='tour'?'استعلام این تور در واتس‌اپ':'ثبت درخواست و ادامه در واتس‌اپ',$type==='tour'?'Enquire about this tour on WhatsApp':'Send enquiry & continue to WhatsApp')?></button><a class="booking-call" href="tel:<?=e(preg_replace('/[^0-9+]/','',setting('phone','+62 361 361 3032')))?>"><?=tr('یا تماس مستقیم','Or call us')?> · <?=e(setting('phone','+62 361 361 3032'))?></a><small><?=tr('درخواست پیش از بازشدن واتس‌اپ در پنل ثبت می‌شود؛ این مرحله پرداخت یا تأیید قطعی رزرو نیست.','Your enquiry is saved in our admin before WhatsApp opens; this does not take payment or confirm a booking.')?></small></form></aside></section><?php if($type==='hotel'&&$item['slug']==='desa-potato-head-seminyak'):?><section class="hotel-faq"><h2><?=tr('پیش از استعلام اقامت در Desa Potato Head','Before enquiring about Desa Potato Head')?></h2><div><?php $hotelFaq=$l==='fa'?[['چه نوع اتاق‌هایی در مجموعه وجود دارد؟','وب‌سایت رسمی مجموعه، استودیوهایی مانند Desa Studio، Sunrise Studio و Bamboo Studio و نیز دسته‌های متنوعی از سوئیت‌ها را معرفی می‌کند. ظرفیت، چشم‌انداز و امکانات هر واحد متفاوت است؛ نوع دقیق را برای تاریخ سفر استعلام کنید.'],['ساعت ورود و خروج چه زمانی است؟','راهنمای رسمی مهمانان در حال حاضر ورود را از ساعت ۱۵ و خروج را تا ساعت ۱۲ اعلام می‌کند. امکان ورود زودتر یا خروج دیرتر به ظرفیت و تأیید هتل بستگی دارد؛ هنگام رزرو دوباره بررسی کنید.'],['آیا صبحانه شامل قیمت اتاق است؟','ساعت معمول سرو صبحانه در راهنمای رسمی ۷ تا ۱۱ صبح اعلام شده، اما شامل‌بودن آن به نوع نرخ و رزرو شما بستگی دارد. پیش از تأیید پیشنهاد، این مورد را مشخص کنید.'],['آیا دسترسی به استخر و Beach Club برای همه اتاق‌ها یکسان است؟','خیر؛ دسترسی و شرایط استفاده می‌تواند با نوع اقامت و سیاست روز تفاوت داشته باشد. مواردی مثل استخر، تخت ساحلی، رزرو قبلی و هزینه‌های احتمالی را در پیشنهاد نهایی و تأییدیه‌ی خود بررسی کنید.'],['برای استعلام چه اطلاعاتی بفرستم؟','تاریخ ورود و خروج، تعداد بزرگسالان و کودکان، تعداد اتاق‌ها و ترجیح خود میان استودیو یا سوئیت را وارد کنید. اگر هنوز انتخاب نکرده‌اید، گزینه‌ی «مطمئن نیستم» را بزنید تا همراه با نرخ و ظرفیت راهنمایی شوید.']]:[['What room types are available?','The official site lists studios such as Desa Studio, Sunrise Studio and Bamboo Studio, as well as several suite categories. Occupancy, views and inclusions differ, so enquire about the exact room for your dates.'],['What are the usual check-in and check-out times?','Current official guest information lists check-in from 3 pm and check-out by noon. Early arrival or late departure depends on availability and hotel approval, so reconfirm it for your booking.'],['Is breakfast included in the room rate?','The official guest information currently lists breakfast from 7 to 11 am, but whether it is included depends on the rate and booking. Confirm this in the final proposal.'],['Do all room bookings include the same pool and Beach Club access?','Access and conditions can vary by stay type and current policy. Check pool access, beach seating, advance reservations and any extra charges in the written offer and confirmation.'],['What should I send for a quote?','Share your arrival and departure dates, adults and children, room count and whether you prefer a studio or suite. If you are unsure, choose “Not sure yet” and we can check suitable options.']];foreach($hotelFaq as [$question,$answer]):?><details><summary><?=e($question)?></summary><p><?=e($answer)?></p></details><?php endforeach;?></div><p class="hotel-faq-note"><?=tr('جزئیات زمانی و دسترسی بر اساس اطلاعات فعلی رسمی است و ممکن است تغییر کند؛ شرایط نهایی را برای تاریخ سفر خود تأیید کنید.','Times and access notes reflect current official information and may change; confirm final terms for your dates.')?></p></section><?php endif;?><?php page_bottom();exit;
}
if($page==='blog'){
  $slug=trim((string)($_GET['slug']??''));
  $tourBlogRelations=['bali-tours-planner'=>'bali-south-coast-uluwatu-tour','bali-south-coast-uluwatu-tour-guide'=>'bali-south-coast-uluwatu-tour','nusa-penida-day-trip-guide'=>'nusa-penida-island-snorkelling-tour','ubud-monkey-forest-temple-waterfall-guide'=>'ubud-temples-waterfalls-rice-terraces','ayung-river-rafting-bali-guide'=>'ayung-river-rafting-and-ubud-tour','alas-harum-atv-tirta-empul-guide'=>'alas-harum-atv-tirta-empul-tour'];
  $relatedTourSlug=$tourBlogRelations[$slug]??'';
  $GLOBALS['related_tour_slug']=$relatedTourSlug;
  if($slug!==''){
    $st=$pdo->prepare("SELECT * FROM blog_posts WHERE slug=? AND status='published' AND published_at<=NOW()");$st->execute([$slug]);$post=$st->fetch();
    if(!$post){http_response_code(404);page_top(tr('مطلب پیدا نشد','Article not found'));echo '<section class="empty">'.tr('این مطلب در دسترس نیست.','This article is not available.').'</section>';page_bottom();exit;}
    $title=$post['title_'.$l];$description=trim((string)($post['seo_description_'.$l]?:$post['excerpt_'.$l]));$GLOBALS['seo_title']=trim((string)($post['seo_title_'.$l]?:$title));$articleImage=$post['cover_image']?:'assets/media/rice-fields.jpg';$GLOBALS['seo_image']=url($articleImage);$articleImages=[$GLOBALS['seo_image']];
    $articlePhotos=[];$potatoPhotoSets=['desa-potato-head-bali-stay-beach-club-guide'=>[['uploads/potato-head-desa-studio-interior.webp',tr('اتاق استودیو در Desa Potato Head بالی','Studio room at Desa Potato Head Bali')],['uploads/potato-head-studio-amenities.webp',tr('جزئیات فضای داخلی استودیو','Studio interior details')],['uploads/potato-head-studio-design.webp',tr('طراحی اتاق در Potato Head Studios','Room design at Potato Head Studios')],['uploads/potato-head-seminyak-aerial.webp',tr('نمای هوایی مجموعه در امتداد ساحل سمینیاک','Aerial view of the property along Seminyak beach')],['uploads/potato-head-beachfront-exterior.webp',tr('نمای بیرونی مجموعه در کنار ساحل','Exterior of the beachfront property')],['uploads/potato-head-stay-property.webp',tr('معماری و حیاط مجموعه','Property architecture and courtyard')],['uploads/potato-head-pool-courtyard.webp',tr('حیاط و فضای استخر مجموعه','Courtyard and pool spaces')],['uploads/potato-head-beach-club-terrace.webp',tr('نمای معماری Beach Club','Beach Club architecture')],['uploads/potato-head-beach-club-space.webp',tr('فضای باز Beach Club','Open-air Beach Club')],['uploads/potato-head-infinity-pool-beach-view.webp',tr('استخر و چشم‌انداز ساحل پتیتنگت','Pool and Petitenget Beach view')]],'desa-potato-head-studios-vs-suites'=>[['uploads/potato-head-desa-studio-interior.webp',tr('فضای داخلی استودیو در Desa Potato Head','Studio interior at Desa Potato Head')],['uploads/potato-head-studio-amenities.webp',tr('جزئیات اتاق استودیو','Studio room details')],['uploads/potato-head-studio-design.webp',tr('طراحی داخلی استودیو','Studio interior design')],['uploads/potato-head-stay-property.webp',tr('معماری و حیاط مجموعه','Property architecture and courtyard')],['uploads/potato-head-seminyak-aerial.webp',tr('موقعیت مجموعه در ساحل سمینیاک','The property along Seminyak beach')]],'potato-head-beach-club-stay-guide'=>[['uploads/potato-head-beach-club-terrace.webp',tr('فضای معماری Beach Club','Beach Club architecture')],['uploads/potato-head-beach-club-space.webp',tr('فضای باز مجموعه','Open-air spaces at the Desa')],['uploads/potato-head-infinity-pool-beach-view.webp',tr('استخر با چشم‌انداز ساحل','Pool overlooking the beach')],['uploads/potato-head-pool-courtyard.webp',tr('فضای استخر و حیاط','Pool and courtyard')],['uploads/potato-head-seminyak-aerial.webp',tr('نمای ساحلی مجموعه در سمینیاک','Beachfront view of the Seminyak property')]]];$articlePhotos=$potatoPhotoSets[$slug]??[];
    $articleSchemaImages=array_merge([$GLOBALS['seo_image']],array_map(static fn($photo)=>url($photo[0]),$articlePhotos));
    $GLOBALS['seo_entity']=['@type'=>'BlogPosting','headline'=>$title,'description'=>$description,'image'=>$articleSchemaImages,'author'=>['@type'=>'Organization','name'=>$post['author_name']?:'Kousha Travel'],'publisher'=>['@type'=>'Organization','name'=>'Kousha Travel','logo'=>['@type'=>'ImageObject','url'=>url('assets/media/logo.png')]],'datePublished'=>date(DATE_W3C,strtotime($post['published_at'])),'dateModified'=>date(DATE_W3C,strtotime($post['updated_at'])),'mainEntityOfPage'=>url('?page=blog&slug='.rawurlencode($slug).'&lang='.$l),'inLanguage'=>$l];
    page_top($GLOBALS['seo_title'],$description);$body=$post['body_'.$l]??'';
    ?><article class="blog-article"><div class="blog-crumb"><a href="<?=url('?page=blog&lang='.$l)?>"><?=tr('بلاگ کوشا تراول','Kousha Travel blog')?></a><span>·</span><?=tr('راهنمای سفر بالی و اندونزی','Bali & Indonesia travel insights')?></div><header class="blog-article-head"><span class="eyebrow"><?=tr('راهنمای سفر · کوشا تراول','TRAVEL NOTES · KOUSHA TRAVEL')?></span><h1><?=e($title)?></h1><p class="lead"><?=e($post['excerpt_'.$l])?></p><div class="blog-byline"><span>✦ <?=e($post['author_name']?:'Kousha Travel')?></span><time datetime="<?=e(date('c',strtotime($post['published_at'])))?>"><?=e(date($l==='fa'?'Y/m/d':'M j, Y',strtotime($post['published_at'])))?></time></div></header><figure class="blog-article-cover"><img src="<?=e($GLOBALS['seo_image'])?>" alt="<?=e($title)?>" fetchpriority="high"></figure><div class="blog-reading"><div class="blog-reading-aside"><span>✧</span><p><?=tr('یادداشت‌هایی برای انتخاب آگاهانه‌تر و سفر آرام‌تر','Thoughtful notes for better choices and smoother journeys')?></p></div><div class="long-copy blog-copy"><?=render_blog_body((string)$body)?></div></div><?php if($articlePhotos):?><section class="article-photos" aria-label="<?=tr('تصاویر Desa Potato Head','Desa Potato Head photos')?>"><h2><?=tr('نگاهی به فضاهای مجموعه','A closer look around the Desa')?></h2><div><?php foreach($articlePhotos as [$photoPath,$photoAlt]):?><figure><img src="<?=url($photoPath)?>" alt="<?=e($photoAlt)?>" loading="lazy"><figcaption><?=e($photoAlt)?></figcaption></figure><?php endforeach;?></div></section><section class="blog-article-cta hotel-article-cta"><div><span class="eyebrow"><?=tr('برای سفر خودتان برنامه دارید؟','PLANNING YOUR OWN TRIP?')?></span><h2><?=tr('تاریخ سفرتان را بفرستید تا موجودی و نرخ را بررسی کنیم','Share your dates and we’ll check availability and rates')?></h2><p><?=tr('پیش از پرداخت، نوع اتاق، خدمات شامل و شرایط رزرو را روشن می‌کنیم. برای دیدن جزئیات اتاق‌ها و ثبت درخواست، به صفحه‌ی اختصاصی هتل بروید.','We clarify the room type, inclusions and booking terms before payment. Visit the hotel page for room details and to send an enquiry.')?></p></div><div class="article-cta-actions"><a class="btn primary" href="<?=url('?page=hotel&slug=desa-potato-head-seminyak&lang='.$l)?>"><?=tr('جزئیات هتل و استعلام رزرو','Hotel details & booking enquiry')?> ↗</a><a class="btn glass" href="<?=wa_link(tr('سلام، درباره مطلب «'.$title.'» سؤال دارم و برای سفرم راهنمایی می‌خواهم.','Hello, I have a question about “'.$title.'” and would like help planning my trip.'))?>" target="_blank" rel="noopener noreferrer"><?=tr('گفت‌وگو در واتس‌اپ','Chat on WhatsApp')?></a></div></section><?php else:?><section class="blog-article-cta"><div><span class="eyebrow"><?=tr('برای سفر خودتان برنامه دارید؟','PLANNING YOUR OWN TRIP?')?></span><h2><?=tr('پرسش‌هایتان را با تیم محلی ما در میان بگذارید','Talk through your plans with our local team')?></h2><p><?=tr('تاریخ، تعداد مسافران و سلیقه‌تان را بگویید تا مسیر مناسب را با هم بررسی کنیم.','Share your dates, group size and travel style so we can explore the right options together.')?></p></div><a class="btn primary" href="<?=wa_link(tr('سلام، درباره مطلب «'.$title.'» سؤال دارم و برای سفرم راهنمایی می‌خواهم.','Hello, I have a question about “'.$title.'” and would like help planning my trip.'))?>" target="_blank" rel="noopener noreferrer"><?=tr('گفت‌وگو در واتس‌اپ','Chat on WhatsApp')?></a></section><?php endif;?></article><?php page_bottom();exit;
  }
  $q=mb_substr(trim((string)($_GET['q']??'')),0,100);$sql="SELECT id,slug,title_fa,title_en,excerpt_fa,excerpt_en,cover_image,author_name,published_at FROM blog_posts WHERE status='published' AND published_at<=NOW()";$args=[];if($q!==''){$sql.=' AND (title_fa LIKE ? OR title_en LIKE ? OR excerpt_fa LIKE ? OR excerpt_en LIKE ?)';$args=array_fill(0,4,'%'.$q.'%');}$sql.=' ORDER BY published_at DESC,id DESC LIMIT 60';$st=$pdo->prepare($sql);$st->execute($args);$posts=$st->fetchAll();$desc=tr('راهنماها و یادداشت‌های کوشا تراول درباره برنامه‌ریزی سفر به بالی و اندونزی، انتخاب منطقه و اقامت، فرهنگ محلی و نکته‌های کاربردی سفر.','Practical Kousha Travel articles on planning a Bali and Indonesia trip, choosing an area and stay, local culture and useful travel tips.');$GLOBALS['seo_entity']=['@type'=>'Blog','name'=>tr('بلاگ کوشا تراول','Kousha Travel Blog'),'description'=>$desc,'url'=>url('?page=blog&lang='.$l)];page_top(tr('بلاگ سفر بالی و اندونزی','Bali & Indonesia Travel Blog'),$desc);
  ?><section class="blog-index"><div class="blog-index-hero"><div class="blog-index-copy"><span class="eyebrow">KOUSHA TRAVEL · JOURNAL</span><h1><?=tr('برای سفری که با فکر شروع می‌شود','A better journey starts with a little insight')?></h1><p><?=tr('راهنماهای کوتاه و کاربردی برای شناخت بالی، انتخاب محل اقامت و چیدن برنامه‌ای متناسب با روزهای سفر شما؛ نوشته‌هایی از تجربه‌ی مقصد، نه فهرستی از توصیه‌های کلی.','Useful guides to Bali, choosing where to stay and planning days that fit your trip—grounded in destination experience, not generic checklists.')?></p><form class="blog-search" method="get" role="search"><input type="hidden" name="page" value="blog"><input type="hidden" name="lang" value="<?=$l?>"><label class="sr-only" for="blog-q"><?=tr('جست‌وجو در مطالب','Search articles')?></label><input id="blog-q" name="q" value="<?=e($q)?>" placeholder="<?=tr('مثلاً اوبود، اقامت یا برنامه سفر','e.g. Ubud, accommodation or itinerary')?>"><button aria-label="<?=tr('جست‌وجو','Search')?>">⌕</button></form><div class="blog-topics"><span>⌖ <?=tr('شناخت مناطق','Areas')?></span><span>⌂ <?=tr('هتل و اقامت','Stays')?></span><span>✧ <?=tr('نکته‌های سفر','Travel tips')?></span></div></div><div class="blog-index-art"><img src="<?=url('assets/media/rice-fields.jpg')?>" alt="<?=tr('شالیزارهای سرسبز اوبود در بالی','Lush rice terraces in Ubud, Bali')?>" fetchpriority="high"><span class="blog-stamp">BALI<br><b>NOTES</b></span></div></div><div class="blog-section-head"><div><span class="eyebrow"><?=tr('از دفترچه‌ی سفر ما','FROM OUR TRAVEL JOURNAL')?></span><h2><?=tr('تازه‌ترین راهنماها','Latest guides & stories')?></h2></div><span class="blog-count"><?=count($posts)?> <?=tr('مطلب','articles')?></span></div><div class="blog-grid"><?php $blogFallback=['assets/media/uluwatu.jpg','assets/media/luxury-villa.jpg','assets/media/bali-gate.jpg','assets/media/goa-gajah.jpg'];foreach($posts as $i=>$p):$postTitle=$p['title_'.$l];$postExcerpt=$p['excerpt_'.$l];$img=$p['cover_image']?:$blogFallback[$i%count($blogFallback)];?><article class="blog-card"><a class="blog-card-image" href="<?=url('?page=blog&slug='.rawurlencode($p['slug']).'&lang='.$l)?>"><img src="<?=url($img)?>" alt="<?=e($postTitle)?>" loading="lazy"><span class="blog-card-icon" aria-hidden="true"><?=['✦','⌖','⌂','◉'][$i%4]?></span></a><div class="blog-card-copy"><div class="blog-card-meta"><span><?=tr('یادداشت سفر','TRAVEL NOTE')?></span><time datetime="<?=e(date('c',strtotime($p['published_at'])))?>"><?=e(date($l==='fa'?'Y/m/d':'M j, Y',strtotime($p['published_at'])))?></time></div><h3><a href="<?=url('?page=blog&slug='.rawurlencode($p['slug']).'&lang='.$l)?>"><?=e($postTitle)?></a></h3><p><?=e($postExcerpt)?></p><a class="blog-read-more" href="<?=url('?page=blog&slug='.rawurlencode($p['slug']).'&lang='.$l)?>"><?=tr('خواندن مطلب','Read article')?> <span aria-hidden="true">←</span></a></div></article><?php endforeach;?><?php if(!$posts):?><div class="blog-empty"><span>✧</span><h3><?=tr($q!==''?'مطلبی با این عبارت پیدا نشد':'به‌زودی اینجا می‌خوانید','No matching stories yet')?></h3><p><?=tr($q!==''?'با عبارت دیگری جست‌وجو کنید یا از دستیار سفر راهنمایی بگیرید.':'راهنماهای تازه‌ی سفر به بالی به‌زودی در این بخش منتشر می‌شوند.','Try another search or ask our travel assistant for help.')?></p></div><?php endif;?></div></section><?php page_bottom();exit;
}
if($page==='content'){
  $requestedKey=trim((string)($_GET['slug']??''));$content=content_page($requestedKey);$seedPage=null;$seedPages=require __DIR__.'/install/content-seed.php';
  foreach($seedPages as $seed){if(($seed['page_key']??'')===$requestedKey){$seedPage=$seed;break;}}
  if(!$content&&$seedPage)$content=$seedPage;
  elseif($content&&$seedPage){foreach(['title_fa','title_en','description_fa','description_en','body_fa','body_en'] as $field){if(trim((string)($content[$field]??''))==='')$content[$field]=$seedPage[$field]??'';}}
  if(!$content){http_response_code(404);page_top(tr('صفحه پیدا نشد','Page not found'));echo '<section class="empty">'.tr('این صفحه پیدا نشد','This page could not be found').'</section>';page_bottom();exit;}
  $title=$content[$l==='fa'?'title_fa':'title_en'];$description=$content[$l==='fa'?'description_fa':'description_en'];$body=$content[$l==='fa'?'body_fa':'body_en'];page_top($title,$description);
  $pageImage=match($content['page_key']){'guide'=>'rice-fields.jpg','visa'=>'bali-gate.jpg','company'=>'artist-production.jpg','about'=>'uluwatu.jpg','booking-process'=>'luxury-villa.jpg',default=>'goa-gajah.jpg'};$pageAlt=match($content['page_key']){'guide'=>tr('شالیزارهای سرسبز اوبود برای برنامه‌ریزی سفر به بالی','Ubud rice terraces for Bali travel planning'),'visa'=>tr('دروازه معبد در بالی','A temple gate in Bali'),'company'=>tr('تولید و فعالیت خلاقانه در بالی','Creative production in Bali'),'about'=>tr('ساحل و صخره‌های اولوواتو','Uluwatu coast and cliffs'),default=>tr('اقامتگاه در بالی','A Bali stay')};$editorialText=$l==='fa'?match($content['page_key']){'guide'=>'انتخاب منطقه و زمان‌بندی مسیرها می‌تواند تفاوت زیادی در یک سفر کوتاه ایجاد کند. نکته‌های این راهنما کمک می‌کند پیش از رزرو، تصویر روشن‌تری از مقصد داشته باشید.','visa'=>'شرایط ویزا به هدف، مدت حضور و ملیت وابسته است. بهتر است پیش از خرید بلیت، مسیر مناسب پرونده‌تان را با اطلاعات به‌روز بررسی کنید.','company'=>'راه‌اندازی کسب‌وکار در اندونزی از انتخاب ساختار و حوزه فعالیت شروع می‌شود؛ تصمیمی که روی مجوزها و مراحل بعدی اثر می‌گذارد.','booking-process'=>'پیش از پرداخت، مشخصات خدمات، قیمت، مهلت اعتبار پیشنهاد و شرایط تغییر یا لغو را یک‌جا دریافت کنید.','about'=>'تیم محلی کوشا تراول برای هماهنگی خدمات سفر و شناخت بهتر جزیره در کنار مسافران و همکاران تجاری است.',default=>'پیش از رزرو، مشخص کنید چه انتظاری از اقامت دارید و جزئیات خدمات را با برنامه‌ی سفرتان بسنجید.'}:match($content['page_key']){'guide'=>'Area choice and realistic travel times can make a real difference on a short trip. Use this guide to build a clearer picture before you book.','visa'=>'Visa routes depend on purpose, length of stay and nationality. Review the appropriate path before purchasing tickets.','company'=>'Setting up in Indonesia starts with choosing a structure and business activity—decisions that shape later licensing steps.','booking-process'=>'Before paying, review the service details, price, quote validity and change or cancellation terms together.','about'=>'Kousha Travel’s local team helps travellers and business partners coordinate services and understand the island.','default'=>'Start with what you need from your stay, then compare the service details against your actual travel plans.'};$contentHighlights=$l==='fa'?[['⌖','شناخت مقصد','پیشنهادها با توجه به منطقه و زمان واقعی رفت‌وآمد در بالی'],['◇','اطلاعات روشن','جزئیات، محدودیت‌ها و شرایط را پیش از تصمیم مرور کنید'],['✦','برنامه متناسب','انتخاب‌ها را با بودجه و سبک سفر خود هماهنگ کنید']]:[['⌖','Local insight','Recommendations reflect Bali’s areas and real travel times'],['◇','Clear details','Review inclusions, limitations and terms before deciding'],['✦','A plan that fits','Shape your choices around your budget and travel style']];
  ?><section class="content-page"><div class="crumbs"><a href="<?=url('?lang='.$l)?>"><?=tr('خانه','Home')?></a> / <?=e($title)?></div><span class="eyebrow">KOUSHA TRAVEL · BALI</span><h1><?=e($title)?></h1><p class="lead"><?=e($description)?></p><div class="editorial-hero"><img src="<?=url('assets/media/'.$pageImage)?>" alt="<?=e($pageAlt)?>" loading="lazy"><div><span class="eyebrow"><?=tr('راهنمای کوشا تراول','KOUSHA TRAVEL GUIDE')?></span><h2><?=tr('دانستن چند نکته، انتخاب‌های سفر را ساده‌تر می‌کند','A little local context makes travel choices easier')?></h2><p><?=e($editorialText)?></p><div class="editorial-icons"><?php foreach($contentHighlights as [$icon,$label,$copy]):?><div><span aria-hidden="true"><?=$icon?></span><b><?=e($label)?></b><small><?=e($copy)?></small></div><?php endforeach;?></div></div></div><article class="long-copy"><?php foreach(preg_split('/\R\s*\R/u',trim($body)) as $paragraph):?><p><?=nl2br(e($paragraph))?></p><?php endforeach;?></article><?php if($content['page_key']==='booking-process'):$faqs=$l==='fa'?[['آیا استعلام قیمت و موجودی به معنای تأیید رزرو است؟','خیر. استعلام فقط آغاز بررسی است. رزرو زمانی قطعی می‌شود که پیشنهاد نهایی تأیید، پرداخت طبق توافق انجام و تأییدیه تأمین‌کننده دریافت شده باشد.'],['آژانس‌ها و گروه‌های خصوصی هم می‌توانند درخواست بدهند؟','بله. درخواست‌های مسافران، خانواده‌ها، گروه‌ها و آژانس‌ها بررسی می‌شود و پیشنهاد بر اساس تعداد مسافر، تاریخ و خدمات موردنیاز تنظیم خواهد شد.'],['اگر آب‌وهوا یا محدودیت محلی برنامه را عوض کند چه می‌شود؟','در صورت امکان زمان یا ترتیب برنامه تغییر می‌کند یا گزینه جایگزین پیشنهاد می‌شود. هرگونه تغییر یا بازپرداخت تابع شرایط تأمین‌کننده و رزرو شماست.'],['چه اطلاعاتی برای دریافت پیشنهاد لازم است؟','تاریخ سفر، تعداد و سن مسافران، مدت اقامت، بودجه تقریبی، منطقه یا نوع هتل و خدماتی مثل ترانسفر و تور را بفرستید.']]:[['Does an availability enquiry confirm a booking?','No. An enquiry starts the review. A booking is confirmed after approval of the final proposal, agreed payment and supplier confirmation.'],['Can agencies and private groups enquire?','Yes. We review requests from travellers, families, groups and agencies, then prepare a proposal around group size, dates and requested services.'],['What if weather or local restrictions affect a plan?','Where possible, timing or sequence can be adjusted or an alternative suggested. Changes and refunds follow supplier and booking terms.'],['What details are needed for a proposal?','Share your travel dates, traveller numbers and ages, length of stay, budget range, preferred area or hotel style, and services such as transfers or tours.']];?><section class="faq"><h2><?=tr('پرسش‌های متداول درباره رزرو','Booking questions')?></h2><?php foreach($faqs as $f):?><details><summary><?=e($f[0])?></summary><p><?=e($f[1])?></p></details><?php endforeach;?></section><script type="application/ld+json"><?=json_encode(['@context'=>'https://schema.org','@type'=>'FAQPage','mainEntity'=>array_map(fn($f)=>['@type'=>'Question','name'=>$f[0],'acceptedAnswer'=>['@type'=>'Answer','text'=>$f[1]]],$faqs)],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_HEX_TAG|JSON_HEX_AMP)?></script><?php endif;?></section><?php page_bottom();exit;
}
if($page==='search'){
  $q=mb_substr(trim((string)($_GET['q']??'')),0,120);$results=[];
  if(mb_strlen($q)>=2){$terms=array_slice(preg_split('/\s+/u',$q,-1,PREG_SPLIT_NO_EMPTY)?:[$q],0,5);$fields=['name_fa','name_en','short_fa','short_en','description_fa','description_en'];$parts=[];$values=[];foreach($terms as $term){$parts[]='('.implode(' OR ',array_map(fn($field)=>$field.' LIKE ?',$fields)).')';foreach($fields as $_)$values[]='%'.$term.'%';}$productWhere=implode(' OR ',$parts);foreach(['hotels'=>'hotel','tours'=>'tour'] as $table=>$type){$st=$pdo->prepare("SELECT id,slug,name_fa,name_en,short_fa,short_en,cover_image,featured FROM $table WHERE active=1 AND ($productWhere) ORDER BY featured DESC,id DESC LIMIT 30");$st->execute($values);foreach($st->fetchAll() as $row)$results[]=['kind'=>$type,'item'=>$row];}$contentParts=[];$contentValues=[];foreach($terms as $term){$contentParts[]='(title_fa LIKE ? OR title_en LIKE ? OR description_fa LIKE ? OR description_en LIKE ? OR body_fa LIKE ? OR body_en LIKE ?)';for($i=0;$i<6;$i++)$contentValues[]='%'.$term.'%';}$st=$pdo->prepare('SELECT page_key,title_fa,title_en,description_fa,description_en FROM content_pages WHERE '.implode(' OR ',$contentParts).' ORDER BY page_key LIMIT 30');$st->execute($contentValues);foreach($st->fetchAll() as $row)$results[]=['kind'=>'content','item'=>$row];$blogParts=[];$blogValues=[];foreach($terms as $term){$blogParts[]='(title_fa LIKE ? OR title_en LIKE ? OR excerpt_fa LIKE ? OR excerpt_en LIKE ? OR body_fa LIKE ? OR body_en LIKE ?)';for($i=0;$i<6;$i++)$blogValues[]='%'.$term.'%';}$st=$pdo->prepare("SELECT slug,title_fa,title_en,excerpt_fa,excerpt_en,cover_image FROM blog_posts WHERE status='published' AND published_at<=NOW() AND (".implode(' OR ',$blogParts).') ORDER BY published_at DESC LIMIT 30');$st->execute($blogValues);foreach($st->fetchAll() as $row)$results[]=['kind'=>'blog','item'=>$row];}
  page_top(tr('جست‌وجوی کوشا تراول','Search Kousha Travel'),tr('جست‌وجو در هتل‌ها، تورها و راهنماهای سفر بالی.','Search Bali hotels, tours and travel guides.'));
  ?><section class="listing-head"><span class="eyebrow">KOUSHA TRAVEL · SEARCH</span><h1><?=tr('چی توی برنامه سفرته؟','What are you looking for?')?></h1><p><?=tr('نام هتل، منطقه، نوع تور یا موضوع موردنظرتان را بنویسید.','Search by hotel, area, tour type or topic.')?></p><form class="filters search-form" method="get"><input type="hidden" name="page" value="search"><input type="hidden" name="lang" value="<?=$l?>"><input name="q" value="<?=e($q)?>" minlength="2" maxlength="120" placeholder="<?=tr('مثلاً اوبود، ترانسفر یا ویزا','e.g. Ubud, transfer or visa')?>" required><button class="btn dark"><?=tr('جست‌وجو','Search')?></button></form></section><section class="catalog search-results"><?php foreach($results as $result):$x=$result['item'];$kind=$result['kind'];if($kind==='content'){$title=$x[$l==='fa'?'title_fa':'title_en'];$href=url('?page=content&slug='.rawurlencode($x['page_key']).'&lang='.$l);$image='assets/media/rice-fields.jpg';$meta=tr('راهنمای سفر و خدمات','Travel guide & services');$desc=$x[$l==='fa'?'description_fa':'description_en'];}elseif($kind==='blog'){$title=$x[$l==='fa'?'title_fa':'title_en'];$href=url('?page=blog&slug='.rawurlencode($x['slug']).'&lang='.$l);$image=$x['cover_image']?:'assets/media/rice-fields.jpg';$meta=tr('مطلب بلاگ','Blog article');$desc=$x[$l==='fa'?'excerpt_fa':'excerpt_en'];}else{$title=$x[$l==='fa'?'name_fa':'name_en'];$href=url('?page='.$kind.'&slug='.rawurlencode($x['slug']).'&lang='.$l);$image=$x['cover_image']?:'assets/media/'.($kind==='hotel'?'luxury-villa.jpg':'bali-gate.jpg');$meta=$kind==='hotel'?tr('هتل و اقامتگاه','Hotel & stay'):tr('تور بالی','Bali tour');$desc=$x[$l==='fa'?'short_fa':'short_en'];}?><a class="product" href="<?=$href?>"><div class="product-media"><img src="<?=url($image)?>" alt="<?=e($title)?>" loading="lazy"></div><div class="product-body"><small><?=e($meta)?></small><h2><?=e($title)?></h2><p><?=e($desc)?></p><span><?=tr('مشاهده جزئیات','View details')?> ←</span></div></a><?php endforeach;?><?php if($q!==''&&!$results):?><div class="empty"><?=tr('نتیجه‌ای پیدا نشد؛ از دستیار سفر کمک بگیرید یا درخواستتان را در واتس‌اپ بفرستید.','No matches found. Use the travel assistant or send your request on WhatsApp.')?> <a href="<?=wa_link(tr('سلام، در سایت گزینه‌ای برای درخواست من پیدا نکردم. لطفاً راهنمایی‌ام کنید.','Hello, I could not find a suitable option on the website. Please help me.'))?>" target="_blank" rel="noopener"><?=tr('درخواست در واتس‌اپ','Ask on WhatsApp')?></a></div><?php elseif($q===''):?><div class="empty"><?=tr('برای شروع، دست‌کم دو حرف بنویسید.','Enter at least two characters to search.')?></div><?php endif;?></section><?php page_bottom();exit;
}
if($page==='tours'||$page==='hotels'){
  $type=$page==='hotels'?'hotel':'tour';$table=$type==='hotel'?'hotels':'tours';$region=(int)($_GET['region']??0);$q=mb_substr(trim((string)($_GET['q']??'')),0,120);$where=['x.active=1'];$args=[];if($region){$where[]='x.region_id=?';$args[]=$region;}if($q!==''){$where[]='(x.name_fa LIKE ? OR x.name_en LIKE ?)';$args[]="%$q%";$args[]="%$q%";}$whereSql=implode(' AND ',$where);$countStmt=$pdo->prepare("SELECT COUNT(*) FROM $table x WHERE $whereSql");$countStmt->execute($args);$totalItems=(int)$countStmt->fetchColumn();$perPage=12;$currentPage=max(1,(int)($_GET['p']??1));$totalPages=max(1,(int)ceil($totalItems/$perPage));$currentPage=min($currentPage,$totalPages);$offset=($currentPage-1)*$perPage;$st=$pdo->prepare("SELECT x.*,r.name_fa region_fa,r.name_en region_en FROM $table x LEFT JOIN regions r ON r.id=x.region_id WHERE $whereSql ORDER BY x.featured DESC,x.id DESC LIMIT $perPage OFFSET $offset");$st->execute($args);$items=$st->fetchAll();if($type==='hotel')prime_hotel_card_slides($pdo,$items);$regions=$pdo->query('SELECT * FROM regions WHERE active=1 ORDER BY sort_order,name_en')->fetchAll();$listingBase=url('?page='.$page.'&lang='.$l.($region?'&region='.$region:'').($q!==''?'&q='.rawurlencode($q):''));page_top(tr($type==='hotel'?'رزرو هتل در بالی':'تورهای بالی',$type==='hotel'?'Bali hotels':'Bali tours'),tr($type==='hotel'?'فهرست هتل‌ها و اقامتگاه‌های بالی را بر اساس منطقه بررسی کنید و برای تاریخ سفر، قیمت و ظرفیت بگیرید.':'تورهای خصوصی و گروهی بالی را با توجه به منطقه، مدت و برنامه سفر انتخاب و برای تاریخ دلخواه استعلام کنید.',$type==='hotel'?'Browse Bali hotels and stays by area, then request rates and availability for your dates.':'Explore private and group Bali tours by area and duration, then enquire for your dates.'));?>
  <section class="listing-head"><span class="eyebrow">BALI · DIRECT BOOKING</span><h1><?=tr($type==='hotel'?'هتل مناسب را با نرخ همکاری پیدا کنید':'بالی را با یک برنامه درست تجربه کنید',$type==='hotel'?'Find the right stay at a partner rate':'Experience Bali with a well-planned tour')?></h1><p><?=tr($type==='hotel'?'تاریخ و منطقه را انتخاب کنید؛ تیم ما ظرفیت، شرایط اتاق و نرخ قابل‌ارائه را برای تاریخ شما بررسی می‌کند.':'تورهای خصوصی و گروهی با مسیر منطقی، زمان‌بندی واقعی و پشتیبانی تیم محلی.',$type==='hotel'?'Choose your dates and area; our team will check availability, room terms and the rate available for your stay.':'Private and group tours with sensible routes, realistic timing and local support.')?></p><form class="filters"><input type="hidden" name="page" value="<?=$page?>"><input type="hidden" name="lang" value="<?=$l?>"><input name="q" value="<?=e($q)?>" placeholder="<?=tr('جست‌وجو','Search')?>"><select name="region"><option value="0"><?=tr('همه مناطق','All regions')?></option><?php foreach($regions as $r):?><option value="<?=$r['id']?>" <?=$region===$r['id']?'selected':''?>><?=e($r[$l==='fa'?'name_fa':'name_en'])?></option><?php endforeach;?></select><button class="btn dark"><?=tr('نمایش','Show')?></button></form></section><section class="catalog"><?php foreach($items as $x):$name=$x[$l==='fa'?'name_fa':'name_en'];$slides=$type==='hotel'?hotel_card_slides($pdo,$x):[card_image($x,'bali-gate.jpg')];?> <a class="product" href="<?=url('?page='.$type.'&slug='.rawurlencode($x['slug']).'&lang='.$l)?>"><div class="product-media<?=$type==='hotel'?' hotel-card-carousel':''?>"<?=$type==='hotel'&&count($slides)>1?' data-hotel-carousel role="group" aria-roledescription="carousel" aria-label="'.e(tr('تصاویر هتل '.$name,'Photos of '.$name)).'"':''?>><?php foreach($slides as $slideIndex=>$slide):$slideUrl=url($slide);?><img class="<?=$type==='hotel'?'hotel-slide'.($slideIndex===0?' is-active':''):'tour-cover'?>" src="<?=$slideUrl?>" <?=responsive_image_attributes($slideUrl)?> alt="<?=e($name.($type==='hotel'?' — '.tr('تصویر '.($slideIndex+1).' از '.count($slides),'photo '.($slideIndex+1).' of '.count($slides)):''))?>" loading="lazy" decoding="async"><?php endforeach;?><?php if($type==='hotel'&&count($slides)>1):?><span class="hotel-slide-count" aria-hidden="true">01 / <?=str_pad((string)count($slides),2,'0',STR_PAD_LEFT)?></span><?php endif;?><?php if($x['featured']):?><b><?=tr('پیشنهاد کوشا','Kousha pick')?></b><?php endif;?></div><div class="product-body"><small><?=e($x[$l==='fa'?'region_fa':'region_en']??'Bali')?> · <?=$type==='hotel'?str_repeat('★',(int)$x['star_rating']):e($x['duration'])?></small><h2><?=e($name)?></h2><p><?=e($x[$l==='fa'?'short_fa':'short_en'])?></p><span><?=tr('دیدن جزئیات و استعلام','View details & enquire')?> ←</span></div></a><?php endforeach;?><?php if(!$items):?><div class="empty"><?=tr('موردی با این فیلتر پیدا نشد','No results for these filters')?></div><?php endif;?></section><?=pagination_links($listingBase,$currentPage,$totalPages,$l)?><?php page_bottom();exit;
}
if($page==='services') { page_top(tr('خدمات کوشا تراول','Kousha Travel services'),tr('رزرو هتل و تور، ترانسفر، خدمات گروهی، راهنمایی ویزا و هماهنگی کسب‌وکار در بالی.','Hotel and tour bookings, transfers, group services, visa guidance and business coordination in Bali.')); $services=[['transfer','ترانسفر فرودگاهی و خودروی خصوصی','Airport transfers & private cars','استقبال فرودگاهی، ترانسفر بین هتل‌ها و خودرو با راننده برای برنامه‌های روزانه؛ با زمان‌بندی متناسب با ترافیک بالی.','Airport pickup, hotel transfers and chauffeured cars, planned around Bali traffic.','bali-gate.jpg'],['visa','ویزا و اقامت اندونزی','Indonesia visas & residency','از ویزای توریستی و تجاری تا مسیرهای مناسب هنرمندان، سرمایه‌گذاران و اقامت‌های بلندمدت؛ پرونده شما ابتدا بررسی می‌شود تا مسیر اشتباه انتخاب نکنید.','From tourist and business visas to routes for artists, investors and longer stays; we review your case before recommending a path.','artist-production.jpg'],['business','ثبت شرکت و شروع کسب‌وکار','Company setup & business support','برای انتخاب ساختار شرکت، مدارک، مجوزهای مرتبط و هماهنگی مراحل اجرایی کنار شما هستیم. جزئیات دقیق پس از شناخت فعالیت و ترکیب سهام‌داران مشخص می‌شود.','Support with company structure, documents, relevant permits and execution. Exact requirements depend on your activity and shareholders.','rice-fields.jpg'],['events','گروه، رویداد و تولید محتوا','Groups, events & production','هماهنگی هتل، رفت‌وآمد، لوکیشن، برنامه اجرایی، عکاسی و فیلم‌برداری برای گروه‌های شرکتی، جشن‌ها و پروژه‌های محتوایی.','Hotels, transport, venues, run sheets and production support for corporate groups, celebrations and content projects.','artist-production.jpg']];?><section class="listing-head"><span class="eyebrow">LOCAL TEAM · CLEAR PROCESS</span><h1><?=tr('خدمات سفر و پشتیبانی در بالی','Travel and destination support in Bali')?></h1><p><?=tr('خدمت‌ها را جداگانه رزرو کنید یا همه را در یک برنامه منسجم کنار هم بگذارید.','Book services separately or combine them into one coordinated plan.')?></p></section><section class="service-stack"><?php foreach($services as $i=>$s):$titleFa=setting('service_'.$s[0].'_title_fa',$s[1]);$titleEn=setting('service_'.$s[0].'_title_en',$s[2]);$textFa=setting('service_'.$s[0].'_text_fa',$s[3]);$textEn=setting('service_'.$s[0].'_text_en',$s[4]);?><article id="<?=$s[0]?>"><img src="<?=url('assets/media/'.$s[5])?>" alt=""><div><small>0<?=$i+1?></small><h2><?=e($l==='fa'?$titleFa:$titleEn)?></h2><p><?=e($l==='fa'?$textFa:$textEn)?></p><?php if($s[0]==='visa'||$s[0]==='business'):?><a class="btn ghost" href="<?=url('?page=content&slug='.($s[0]==='visa'?'visa':'company').'&lang='.$l)?>"><?=tr('جزئیات بیشتر','Read more')?></a><?php endif;?> <a class="btn ghost" href="<?=wa_link(tr('سلام، درباره '.$titleFa.' راهنمایی می‌خواهم.','Hello, I need information about '.$titleEn.'.'))?>" target="_blank" rel="noopener"><?=tr('مشاوره در واتس‌اپ','Ask on WhatsApp')?></a></div></article><?php endforeach;?></section><?php page_bottom();exit; }
if($page==='contact'){$contactTitle=setting('contact_title_'.$l,tr('برای شروع، چند خط درباره برنامه‌تان بگویید','Tell us a little about your travel plans'));$contactText=setting('contact_text_'.$l,tr('تاریخ تقریبی سفر، تعداد و سن مسافران، مدت اقامت، بودجه حدودی، منطقه یا سبک هتل و خدمات موردنیاز را بفرستید. برای درخواست‌های گروهی، تعطیلات شلوغ و خدمات اختصاصی بهتر است زودتر تماس بگیرید. استعلام قیمت و موجودی به‌تنهایی رزرو را قطعی نمی‌کند؛ تأیید نهایی پس از بررسی تأمین‌کننده انجام می‌شود.','Share your approximate dates, traveller numbers and ages, length of stay, budget range, preferred area or hotel style, and requested services. Contact us early for groups, peak dates and bespoke arrangements. An enquiry does not confirm a booking; final confirmation follows the supplier check.'));$contactMeta=setting('contact_meta_'.$l,tr('برای استعلام هتل، تور، ترانسفر، سفر گروهی یا خدمات مقصد در بالی با تیم محلی کوشا تراول در تماس باشید.','Contact the local Kousha Travel team for Bali hotel, tour, transfer, group and destination service enquiries.'));page_top(tr('تماس با کوشا تراول برای برنامه‌ریزی سفر به بالی','Contact Kousha Travel to plan your Bali trip'),$contactMeta);$officeAddress=$l==='fa'?setting('address_fa','خیابان Jl. Raya Kampus Unud، پلاک ۲۳A، جیمباران، کوتا سلاتان، بادونگ، بالی ۸۰۳۶۱، اندونزی'):setting('address_en','Jl. Raya Kampus Unud No.23A, Jimbaran, Kec. Kuta Selatan, Kabupaten Badung, Bali 80361, Indonesia');?><section class="content-page"><span class="eyebrow">KOUSHA TRAVEL · BALI</span><h1><?=e($contactTitle)?></h1><p><?=e($contactText)?></p><div class="contact-cards"><a href="<?=wa_link(tr('سلام، برای برنامه‌ریزی سفر بالی راهنمایی می‌خواهم.','Hello, I would like help planning a Bali trip.'))?>"><b>WhatsApp</b><span dir="ltr"><?=e(setting('whatsapp'))?></span></a><a href="mailto:<?=e(setting('email'))?>"><b>Email</b><span><?=e(setting('email'))?></span></a></div><h2><?=tr('نشانی دفتر کوشا تراول','Kousha Travel office')?></h2><p dir="ltr"><?=e($officeAddress)?></p><div class="map"><iframe title="Kousha Travel office in Jimbaran, Bali" loading="lazy" src="https://maps.google.com/maps?q=<?=rawurlencode('Jl. Raya Kampus Unud No.23A, Jimbaran, Kec. Kuta Selatan, Kabupaten Badung, Bali 80361')?>&z=16&output=embed"></iframe><small><?=tr('برای نمایش نقشه اتصال اینترنت لازم است.','An internet connection is required to display the map.')?></small></div></section><?php page_bottom();exit;}

$tours=$pdo->query('SELECT x.*,r.name_fa region_fa,r.name_en region_en FROM tours x LEFT JOIN regions r ON r.id=x.region_id WHERE x.active=1 ORDER BY x.featured DESC,x.id DESC LIMIT 3')->fetchAll();$hotels=$pdo->query('SELECT x.*,r.name_fa region_fa,r.name_en region_en FROM hotels x LEFT JOIN regions r ON r.id=x.region_id WHERE x.active=1 ORDER BY x.featured DESC,x.id DESC LIMIT 3')->fetchAll();prime_hotel_card_slides($pdo,$hotels);$homeCopy=content_page('home');page_top($homeCopy[$l==='fa'?'title_fa':'title_en']??tr('رزرو هتل و تور بالی با تیم محلی','Book Bali hotels and tours with a local team'),$homeCopy[$l==='fa'?'description_fa':'description_en']??tr('رزرو هتل، تور، ترانسفر و خدمات بالی با نرخ همکاری مستقیم و پشتیبانی فارسی‌زبان','Hotels, tours, transfers and Bali services with direct partner rates and local support'));?>
<section class="hero"><div class="hero-copy"><span class="eyebrow">BALI · INDONESIA · LOCAL TEAM</span><h1><?=e(setting('hero_title_'.$l,tr('بالی را گران‌تر از چیزی که هست رزرو نکنید','Do not overpay for Bali')))?></h1><p><?=e(setting('hero_text_'.$l,tr('هتل و تور را با نرخ همکاری مستقیم، بررسی واقعی ظرفیت و پشتیبانی تیمی که در بالی زندگی می‌کند رزرو کنید.','Book hotels and tours at direct partner rates, with real availability checks and support from a team based in Bali.')))?></p><div class="hero-actions"><a class="btn primary" href="<?=url('?page=hotels&lang='.$l)?>"><?=tr('دیدن هتل‌ها','Explore hotels')?></a><a class="btn glass" href="<?=url('?page=tours&lang='.$l)?>"><?=tr('انتخاب تور','Choose a tour')?></a></div><div class="proof"><div><b><?=tr('نرخ مستقیم','Direct rates')?></b><span><?=tr('بدون واسطه‌های متعدد','Fewer middlemen')?></span></div><div><b><?=tr('تیم مستقر در بالی','Bali-based team')?></b><span><?=tr('پیگیری نزدیک و واقعی','Real local support')?></span></div><div><b><?=tr('فارسی و انگلیسی','Persian & English')?></b><span><?=tr('از درخواست تا رزرو','From enquiry to booking')?></span></div></div></div><div class="hero-visual"><img class="hero-main" src="<?=url('assets/media/uluwatu-home.jpg')?>" alt="ساحل اولوواتو در بالی" width="1200" height="797" fetchpriority="high" decoding="async"><img class="hero-mini" src="<?=url('assets/media/rice-fields-home.jpg')?>" alt="شالیزارهای سرسبز اوبود" width="900" height="600" loading="lazy" decoding="async"><span class="price-card"><i>✓</i><?=e(setting('price_note_'.$l,tr('اگر قیمت معتبر پایین‌تری دارید، برای بررسی بفرستید','Found a lower valid price? Send it for review')))?></span><div class="orbit"></div></div></section><div class="ticker"><div><?=str_repeat(tr('هتل با نرخ همکاری · تور خصوصی · پشتیبانی محلی · رزرو شفاف · ','Partner hotel rates · Private tours · Local support · Clear booking · '),4)?></div></div>
<section class="price-advantage" aria-labelledby="price-advantage-title"><div class="price-advantage-copy"><span class="price-advantage-kicker"><i aria-hidden="true">✦</i> <?=tr('مزیت نرخ همکاری کوشا تراول','THE KOUSHA RATE ADVANTAGE')?></span><h2 id="price-advantage-title"><?=tr('قبل از رزرو، قیمت هتل را با ما مقایسه کنید','Compare your hotel rate before you book')?></h2><p><?=tr('به‌واسطه همکاری مستقیم با هتل‌ها، در بسیاری از درخواست‌ها می‌توانیم نرخی رقابتی‌تر از قیمت‌های عمومی سایت‌هایی مثل Booking.com پیشنهاد کنیم. تاریخ، نوع اتاق، تعداد مهمان، خدمات و قوانین کنسلی را یکسان می‌سنجیم تا مقایسه منصفانه باشد.','Through direct hotel partnerships, we can often offer rates more competitive than public listings on platforms such as Booking.com. We compare the same dates, room type, guest count, inclusions and cancellation terms for a fair match.')?></p><div class="price-check-points"><span><b aria-hidden="true">01</b><?=tr('استعلام برای تاریخ واقعی سفر','Quote for your actual travel dates')?></span><span><b aria-hidden="true">02</b><?=tr('مقایسه اتاق و شرایط یکسان','Like-for-like room and terms')?></span><span><b aria-hidden="true">03</b><?=tr('هزینه‌ها پیش از تأیید شفاف','Clear costs before confirmation')?></span></div><div class="price-advantage-actions"><a class="btn primary" href="<?=url('?page=hotels&lang='.$l)?>"><?=tr('بررسی هتل‌ها و نرخ‌ها','Browse hotels & rates')?></a><a class="price-compare-link" href="<?=wa_link(tr('سلام، یک پیشنهاد هتل برای تاریخ و شرایط مشخص دارم. لطفاً نرخ و شرایط مشابه را برایم بررسی کنید.','Hello, I have a hotel offer for specific dates and terms. Please check a comparable rate and conditions for me.'))?>" target="_blank" rel="noopener noreferrer"><?=tr('مقایسه پیشنهاد در واتس‌اپ','Compare an offer on WhatsApp')?> ↗</a></div><small class="price-advantage-note"><?=tr('نرخ و ظرفیت با توجه به تاریخ و موجودی تغییر می‌کند. مقایسه نهایی پس از تأیید یکسان بودن اتاق، مالیات، خدمات و قوانین رزرو انجام می‌شود.','Rates and availability vary by date. Final comparisons require matching room details, taxes, inclusions and booking terms.')?></small></div><div class="price-advantage-card" aria-hidden="true"><span class="price-card-orbit"></span><small><?=tr('نرخ مستقیم هتل','DIRECT HOTEL RATE')?></small><strong><?=tr('مقایسه کن','COMPARE')?></strong><span><?=tr('پیش از نهایی‌کردن رزرو','BEFORE YOU CONFIRM')?></span><i>↔</i></div></section>
<section class="promise"><small><?=e(setting('promise_kicker_'.$l,tr('اول قیمت را بررسی کنید، بعد تصمیم بگیرید','Check the rate before you decide')))?></small><h2><?=e(setting('promise_title_'.$l,tr('قیمت خوب مهم است؛ خیال راحت بعد از رزرو مهم‌تر','A good price matters. Confidence after booking matters more.')))?></h2><p><?=e(setting('promise_text_'.$l,tr('ما برای تاریخ واقعی سفر شما استعلام می‌گیریم، شرایط اتاق یا تور را روشن می‌کنیم و بعد پیشنهاد می‌دهیم. قیمت‌های تبلیغاتیِ بدون ظرفیت یا با شرایط مبهم، معیار مقایسه ما نیستند.','We check your actual dates, clarify room or tour terms, and only then make an offer. Unavailable promotional prices or unclear conditions are not a fair comparison.')))?></p></section>
<?php foreach([['tours',$tours,'تورهای منتخب بالی','Selected Bali tours','bali-gate.jpg'],['hotels',$hotels,'هتل‌هایی که ارزش بررسی دارند','Hotels worth checking','luxury-villa.jpg']] as $group):?><section class="featured"><div class="section-title"><div><small><?=strtoupper($group[0])?></small><h2><?=tr($group[2],$group[3])?></h2></div><a href="<?=url('?page='.$group[0].'&lang='.$l)?>"><?=tr('مشاهده همه','View all')?> ←</a></div><div class="catalog"><?php foreach($group[1] as $x):$type=$group[0]==='hotels'?'hotel':'tour';$name=$x[$l==='fa'?'name_fa':'name_en'];$slides=$type==='hotel'?hotel_card_slides($pdo,$x):[card_image($x,$group[4])];?><a class="product" href="<?=url('?page='.$type.'&slug='.$x['slug'].'&lang='.$l)?>"><div class="product-media<?=$type==='hotel'?' hotel-card-carousel':''?>"<?=$type==='hotel'&&count($slides)>1?' data-hotel-carousel role="group" aria-roledescription="carousel" aria-label="'.e(tr('تصاویر هتل '.$name,'Photos of '.$name)).'"':''?>><?php foreach($slides as $slideIndex=>$slide):?><img class="<?=$type==='hotel'?'hotel-slide'.($slideIndex===0?' is-active':''):'tour-cover'?>" src="<?=url($slide)?>" alt="<?=e($name.($type==='hotel'?' — '.tr('تصویر '.($slideIndex+1).' از '.count($slides),'photo '.($slideIndex+1).' of '.count($slides)):''))?>" loading="lazy" decoding="async"><?php endforeach;?><?php if($type==='hotel'&&count($slides)>1):?><span class="hotel-slide-count" aria-hidden="true">01 / <?=str_pad((string)count($slides),2,'0',STR_PAD_LEFT)?></span><?php endif;?><b><?=tr('استعلام سریع','Quick enquiry')?></b></div><div class="product-body"><small><?=e($x[$l==='fa'?'region_fa':'region_en'])?></small><h2><?=e($name)?></h2><p><?=e($x[$l==='fa'?'short_fa':'short_en'])?></p><span><?=tr('جزئیات و رزرو','Details & booking')?> ←</span></div></a><?php endforeach;?></div></section><?php endforeach;?>
<section class="journey"><div class="section-title"><div><small><?=tr('سه گام روشن','THREE CLEAR STEPS')?></small><h2><?=tr('از انتخاب تا تأیید رزرو','From shortlist to confirmation')?></h2></div></div><div class="steps" aria-label="<?=tr('مراحل ثبت و تأیید رزرو','Booking and confirmation steps')?>"><article><b>1</b><h3><?=tr('انتخاب کنید','Choose')?></h3><p><?=tr('هتل یا تور را ببینید و تاریخ و تعداد نفرات را وارد کنید.','Select a hotel or tour and add your dates and group size.')?></p></article><article><b>2</b><h3><?=tr('استعلام می‌گیریم','We check')?></h3><p><?=tr('ظرفیت، قیمت و شرایط همان تاریخ را با همکار محلی بررسی می‌کنیم.','We verify availability, rate and terms for your dates.')?></p></article><article><b>3</b><h3><?=tr('شفاف مقایسه کنید','Compare clearly')?></h3><p><?=tr('می‌دانید قیمت دقیقاً شامل چه چیزهایی است و با خیال راحت تصمیم می‌گیرید.','You see exactly what is included before making a decision.')?></p></article></div></section>
<?php $homePosts=$pdo->query("SELECT slug,title_fa,title_en,excerpt_fa,excerpt_en,cover_image,published_at FROM blog_posts WHERE status='published' AND published_at<=NOW() ORDER BY published_at DESC LIMIT 3")->fetchAll();if($homePosts):?><section class="featured home-blog-feature"><div class="section-title"><div><small><?=tr('دفترچه‌ی سفر','TRAVEL JOURNAL')?></small><h2><?=tr('چند نکته پیش از بستن چمدان','A few notes before you pack')?></h2></div><a href="<?=url('?page=blog&lang='.$l)?>"><?=tr('همه‌ی نوشته‌ها','All articles')?> ←</a></div><div class="blog-grid"><?php foreach($homePosts as $i=>$post):$postTitle=$post['title_'.$l];?><article class="blog-card"><a class="blog-card-image" href="<?=url('?page=blog&slug='.rawurlencode($post['slug']).'&lang='.$l)?>"><img src="<?=url($post['cover_image']?:['assets/media/rice-fields.jpg','assets/media/uluwatu.jpg','assets/media/luxury-villa.jpg'][$i])?>" alt="<?=e($postTitle)?>" loading="lazy"><span class="blog-card-icon" aria-hidden="true">✦</span></a><div class="blog-card-copy"><div class="blog-card-meta"><span><?=tr('یادداشت سفر','TRAVEL NOTE')?></span><time datetime="<?=e(date('c',strtotime($post['published_at'])))?>"><?=e(date($l==='fa'?'Y/m/d':'M j, Y',strtotime($post['published_at'])))?></time></div><h3><a href="<?=url('?page=blog&slug='.rawurlencode($post['slug']).'&lang='.$l)?>"><?=e($postTitle)?></a></h3><p><?=e($post['excerpt_'.$l])?></p><a class="blog-read-more" href="<?=url('?page=blog&slug='.rawurlencode($post['slug']).'&lang='.$l)?>"><?=tr('خواندن مطلب','Read article')?> ←</a></div></article><?php endforeach;?></div></section><?php endif;?>
<section class="home-seo"><div><span class="eyebrow"><?=tr('از کوشا تراول','A note from Kousha Travel')?></span><h2><?=e($homeCopy[$l==='fa'?'title_fa':'title_en']??tr('سفری متناسب با حال‌وهوای شما','A trip shaped around you'))?></h2><?php if($homeCopy):foreach(preg_split('/\R\s*\R/u',trim($homeCopy[$l==='fa'?'body_fa':'body_en'])) as $paragraph):if(trim($paragraph)!==''):?><p><?=nl2br(e(trim($paragraph)))?></p><?php endif;endforeach;endif;?><div class="quick-links"><a href="<?=url('?page=content&slug=guide&lang='.$l)?>"><?=tr('راهنمای سفر بالی','Bali travel guide')?> →</a><a href="<?=url('?page=content&slug=visa&lang='.$l)?>"><?=tr('ویزا و اقامت اندونزی','Indonesia visas & residency')?> →</a><a href="<?=url('?page=content&slug=company&lang='.$l)?>"><?=tr('ثبت شرکت در بالی','Company setup in Bali')?> →</a><a href="<?=url('?page=content&slug=booking-process&lang='.$l)?>"><?=tr('شرایط و مراحل رزرو','Booking steps & terms')?> →</a></div></div><div class="faq"><h2><?=tr('پرسش‌های پیش از سفر','Before you travel')?></h2><?php $homeFaq=$l==='fa'?[['آیا استعلام، رزرو را قطعی می‌کند؟','خیر. ابتدا قیمت و ظرفیت بررسی می‌شود. رزرو پس از تأیید شما، پرداخت توافق‌شده و تأیید نهایی تأمین‌کننده قطعی خواهد شد.'],['برای دریافت پیشنهاد چه اطلاعاتی بفرستم؟','تاریخ سفر، تعداد و سن مسافران، مدت اقامت، بودجه حدودی، منطقه یا سبک هتل و خدماتی مثل ترانسفر و تور را اعلام کنید.'],['کوشا تراول پایین‌ترین قیمت را تضمین می‌کند؟','قیمت به تاریخ، نوع اتاق و شرایط رزرو وابسته است و پایین‌ترین نرخ برای همه گزینه‌ها تضمین نمی‌شود. اگر پیشنهاد معتبر و کاملاً مشابهی دارید، برای بررسی بفرستید.'],['چه زمانی برای سفر گروهی تماس بگیرم؟','برای تعطیلات شلوغ، گروه‌ها، ویلاهای خصوصی و درخواست‌های خاص زودتر تماس بگیرید تا فرصت بیشتری برای بررسی ظرفیت و هماهنگی باشد.']]:[['Does an enquiry confirm a booking?','No. We first check price and availability. A booking is confirmed after your approval, the agreed payment and final supplier confirmation.'],['What should I include in a travel enquiry?','Share your dates, traveller numbers and ages, length of stay, budget range, preferred area or hotel style, and services such as transfers or tours.'],['Does Kousha Travel guarantee the lowest price?','Rates depend on dates, room type and booking terms, so the lowest rate cannot be guaranteed for every option. Send a valid, truly comparable offer for review.'],['When should a group contact you?','Contact us early for peak dates, groups, private villas and special requests so there is more time to check availability and coordinate details.']];foreach($homeFaq as $f):?><details><summary><?=e($f[0])?></summary><p><?=e($f[1])?></p></details><?php endforeach;?></div><script type="application/ld+json"><?=json_encode(['@context'=>'https://schema.org','@type'=>'FAQPage','mainEntity'=>array_map(fn($f)=>['@type'=>'Question','name'=>$f[0],'acceptedAnswer'=>['@type'=>'Answer','text'=>$f[1]]],$homeFaq)],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_HEX_TAG|JSON_HEX_AMP)?></script></section>
<?php page_bottom();
