/* SAFRI — data layer: reads from window.SAFRI_DATA (injected by WordPress/PHP).
   Falls back to hardcoded defaults so the page still works if SAFRI_DATA is missing. */

const _D = window.SAFRI_DATA || {};

const WA_NUMBER = _D.waNumber || "923391172374";
function waLink(msg){ return `https://wa.me/${WA_NUMBER}?text=${encodeURIComponent(msg)}`; }
function openWA(msg){ window.open(waLink(msg), "_blank"); }

/* ---------- Stroke icon components ---------- */
const I = ({d, size=22, sw=1.6, fill="none", color="currentColor", extra}) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill={fill} stroke={color}
       strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">{extra||(<path d={d}/>)}</svg>
);
const Icons = {
  plane:   p => <I {...p} d="M21 16v-2l-8-5V3.5a1.5 1.5 0 0 0-3 0V9l-8 5v2l8-2.5V19l-2 1.5V22l3.5-1 3.5 1v-1.5L13 19v-5.5z"/>,
  car:     p => <I {...p} extra={<><path d="M5 13l1.5-4.5A2 2 0 0 1 8.4 7h7.2a2 2 0 0 1 1.9 1.5L19 13"/><path d="M3 17v-2.5A1.5 1.5 0 0 1 4.5 13h15a1.5 1.5 0 0 1 1.5 1.5V17a1 1 0 0 1-1 1h-1a1 1 0 0 1-1-1v-1H6v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"/><circle cx="7" cy="15.5" r=".6"/><circle cx="17" cy="15.5" r=".6"/></>}/>,
  mountain:p => <I {...p} extra={<><path d="M3 19h18L14 7l-3 5-2-3-6 10z"/><path d="M11 12l3-5"/></>}/>,
  kaaba:   p => <I {...p} extra={<><path d="M12 3l7 4v9l-7 4-7-4V7l7-4z"/><path d="M5 7l7 4 7-4M12 11v9"/></>}/>,
  compass: p => <I {...p} extra={<><circle cx="12" cy="12" r="9"/><path d="M15.5 8.5l-2 5-5 2 2-5 5-2z"/></>}/>,
  check:   p => <I {...p} d="M20 6L9 17l-5-5"/>,
  spark:   p => <I {...p} d="M12 3v4M12 17v4M3 12h4M17 12h4M6.3 6.3l2.8 2.8M14.9 14.9l2.8 2.8M17.7 6.3l-2.8 2.8M9.1 14.9l-2.8 2.8"/>,
  shield:  p => <I {...p} extra={<><path d="M12 3l7 3v5c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6l7-3z"/><path d="M9 12l2 2 4-4"/></>}/>,
  clock:   p => <I {...p} extra={<><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></>}/>,
  star:    p => <I {...p} fill={p.color||"currentColor"} d="M12 3l2.6 5.3 5.9.9-4.3 4.1 1 5.8L12 16.9 6.8 19.2l1-5.8L3.5 9.2l5.9-.9L12 3z"/>,
  pin:     p => <I {...p} extra={<><path d="M12 21s7-6 7-11a7 7 0 1 0-14 0c0 5 7 11 7 11z"/><circle cx="12" cy="10" r="2.5"/></>}/>,
  phone:   p => <I {...p} d="M5 4h3l2 5-2 1.5a11 11 0 0 0 5 5L16 13l5 2v3a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2z"/>,
  mail:    p => <I {...p} extra={<><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></>}/>,
  wa: ({size=22, color="currentColor"}) => (
    <svg width={size} height={size} viewBox="0 0 24 24" fill={color} stroke="none">
      <path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 0 0 5.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413z"/>
    </svg>
  ),
  arrow:   p => <I {...p} d="M5 12h14M13 6l6 6-6 6"/>,
  cal:     p => <I {...p} extra={<><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 9h18M8 3v4M16 3v4"/></>}/>,
  users:   p => <I {...p} extra={<><circle cx="9" cy="8" r="3"/><path d="M3 20a6 6 0 0 1 12 0M16 6a3 3 0 0 1 0 6M21 20a6 6 0 0 0-4-5.6"/></>}/>,
  quote:   p => <I {...p} fill={p.color||"currentColor"} extra={<path d="M7 7h4v6c0 2.5-1.5 4-4 4.5V15c1-.3 1.5-1 1.5-2H7V7zm8 0h4v6c0 2.5-1.5 4-4 4.5V15c1-.3 1.5-1 1.5-2H15V7z"/>}/>,
};

/* ---------- Content arrays — populated from SAFRI_DATA, with hardcoded fallbacks ---------- */

const UMRAH = _D.umrahPackages && _D.umrahPackages.length ? _D.umrahPackages : [
  { tier:"Economy",  name:"Sukoon Economy",  nights:"14 nights", feature:false,
    pts:["Saudi Umrah visa + insurance","Return flights (PIA / Saudia)","Comfortable hotels near the Haram","Shared AC ground transfers","Ziyarat in Makkah & Madinah","Urdu / English-speaking Muallim"] },
  { tier:"Standard", name:"Barakah Standard", nights:"14 nights", feature:true,
    pts:["Saudi Umrah visa + insurance","Return flights from Lahore / Islamabad","4★ hotels — short walk to the Haram","Private AC transfers","Guided Ziyarat in both cities","Dedicated Muallim + 24/7 group lead","Daily breakfast & dinner"] },
  { tier:"Premium",  name:"Noor Premium 5★",  nights:"12 nights", feature:false,
    pts:["Priority Saudi visa + insurance","Premium airlines (Emirates / Qatar)","5★ hotels overlooking the Haram","Private SUV transfers","Full guided Ziyarat + historic sites","Personal Muallim concierge","Full board + Zamzam allowance"] },
];

const TOURS = _D.tours && _D.tours.length ? _D.tours : [
  { name:"Hunza Valley",    days:"6 days", color:"#186060" },
  { name:"Skardu & Shigar", days:"7 days", color:"#00A8F0" },
  { name:"Naran Kaghan",    days:"4 days", color:"#F04800" },
  { name:"Swat & Kalam",    days:"4 days", color:"#1FB7AE" },
  { name:"Fairy Meadows",   days:"5 days", color:"#186060" },
  { name:"Neelum Valley",   days:"5 days", color:"#00A8F0" },
  { name:"Khunjerab Pass",  days:"7 days", color:"#F04800" },
  { name:"Deosai Plains",   days:"6 days", color:"#1FB7AE" },
  { name:"Kumrat Valley",   days:"5 days", color:"#186060" },
  { name:"Chitral & Kalash",days:"8 days", color:"#00A8F0" },
  { name:"Gilgit & Astore", days:"6 days", color:"#F04800" },
  { name:"Rama Meadows",    days:"5 days", color:"#1FB7AE" },
];

const VEHICLES = _D.vehicles && _D.vehicles.length ? _D.vehicles : [
  { name:"City Sedan",     seats:4,  ex:"Corolla / City class" },
  { name:"Premium SUV",    seats:6,  ex:"Fortuner / Sportage" },
  { name:"Land Cruiser",   seats:6,  ex:"V8 · mountain-graded" },
  { name:"Hiace (Grand)",  seats:12, ex:"family / group" },
  { name:"Coaster",        seats:22, ex:"large groups" },
];

const CITIES = _D.cities && _D.cities.length ? _D.cities
  : ["Lahore","Islamabad","Karachi","Peshawar","Multan","Faisalabad"];

const WHY = _D.why && _D.why.length ? _D.why : [
  { icon:"star",   t:"4.9★ across 1,200+ reviews",       d:"Years of five-star journeys on Google — booked, guided and delivered by real people in Lahore." },
  { icon:"shield", t:"Drivers on payroll, not apps",      d:"Background-checked, English-speaking drivers we employ directly — never anonymous freelancers." },
  { icon:"mountain",t:"Mountain-graded vehicles",         d:"Land Cruisers and 4×4 jeeps built for the Karakoram — the right machine for northern roads." },
  { icon:"kaaba",  t:"Hotels chosen for the Haram",       d:"We pick stays for proximity to the Haram and your comfort — never for referral fees." },
  { icon:"phone",  t:"24/7 WhatsApp on every trip",       d:"One thread, one number, the whole journey. Someone always answers — day or night." },
  { icon:"compass",t:"IATA-accredited & PIA-registered",  d:"A licensed, registered tour operator — your visa, flights and details handled correctly." },
];

const STATS = _D.stats && _D.stats.length ? _D.stats : [
  { n:"12,000+", l:"travellers since 2018" },
  { n:"1,800+",  l:"Umrah pilgrims in 2025" },
  { n:"4.9★",    l:"average Google rating" },
  { n:"8 yrs",   l:"on the road" },
];

const STEPS = _D.steps && _D.steps.length ? _D.steps : [
  { t:"Tell us the brief",    d:"Tap any button or message us on WhatsApp with your dates, group size and dream destination." },
  { t:"Get a draft in 24h",   d:"A real Lahore-based consultant replies within a day with a tailored itinerary — no obligation." },
  { t:"Lock it in",           d:"We confirm visas, flights, hotels and vehicles and share the exact package once you're happy." },
  { t:"From Safri to Sukoon", d:"Show up and travel. We stay on WhatsApp through the whole journey, 24/7." },
];

const REVIEWS = _D.reviews && _D.reviews.length ? _D.reviews : [
  { name:"Ayesha Khalid",   trip:"Premium Umrah · Family of 6", initials:"AK", color:"#186060",
    text:"Our four-generation family Umrah was flawless. The hotel was a two-minute walk from the Haram and the Muallim never left our side. From Safri to Sukoon is exactly what it felt like." },
  { name:"Hamza Tariq",     trip:"Hunza & Khunjerab · 7 days",  initials:"HT", color:"#F04800",
    text:"Booked a private Hunza trip on a whim over WhatsApp. The Land Cruiser handled the Karakoram like nothing and our driver knew every viewpoint. Easily the smoothest northern trip I've done." },
  { name:"Sana Mirza",      trip:"Rent a Car · Lahore",          initials:"SM", color:"#00A8F0",
    text:"Needed an SUV with a driver for a week across Punjab. Fuel and tolls were all sorted, the driver was polite and professional, and there were genuinely no surprises on the bill." },
  { name:"Bilal Ahmed",     trip:"Custom Honeymoon · Skardu",    initials:"BA", color:"#1FB7AE",
    text:"I shared a one-line brief and got a full honeymoon itinerary back the next morning. They thought of details we hadn't even considered. Responsive on WhatsApp the entire time." },
  { name:"Fatima Noor",     trip:"Standard Umrah · 2 pilgrims",  initials:"FN", color:"#D84800",
    text:"As first-time pilgrims we were nervous about the visa and logistics. Safri handled every step and explained everything in Urdu. We just had to focus on our ibadah. Allah bless this team." },
];

Object.assign(window, { WA_NUMBER, waLink, openWA, Icons,
  UMRAH, TOURS, VEHICLES, CITIES, WHY, STATS, STEPS, REVIEWS });
