// Data for the Meridian STR portal. Realistic STR portfolio (Lisbon + Porto).
const PROPERTIES = [
  { id: 'p1', name: 'Casa das Flores', short: 'Flores', addr: 'R. das Flores 42, Lisbon', neigh: 'Chiado', beds: 2, color: '#2F4A2B' },
  { id: 'p2', name: 'Alfama Vista Loft', short: 'Alfama', addr: 'Largo Portas do Sol 8, Lisbon', neigh: 'Alfama', beds: 1, color: '#8C3A1E' },
  { id: 'p3', name: 'Príncipe Real Studio', short: 'P. Real', addr: 'R. da Escola Politécnica 27, Lisbon', neigh: 'Príncipe Real', beds: 1, color: '#B98A2E' },
  { id: 'p4', name: 'Douro River House', short: 'Douro', addr: 'R. do Infante 14, Porto', neigh: 'Ribeira', beds: 3, color: '#3F6787' },
  { id: 'p5', name: 'Graça Rooftop', short: 'Graça', addr: 'R. Damasceno Monteiro 112, Lisbon', neigh: 'Graça', beds: 2, color: '#4B6B43' },
  { id: 'p6', name: 'Bairro Alto Nº9', short: 'Bairro Alto', addr: 'R. do Diário de Notícias 9, Lisbon', neigh: 'Bairro Alto', beds: 2, color: '#1E3A7A' },
  { id: 'p7', name: 'Estrela Garden Flat', short: 'Estrela', addr: 'R. de São Bento 320, Lisbon', neigh: 'Estrela', beds: 2, color: '#6B4E7A' },
  { id: 'p8', name: 'Foz Seafront', short: 'Foz', addr: 'Av. do Brasil 42, Porto', neigh: 'Foz do Douro', beds: 3, color: '#2F6B6B' },
];

// Today's reservations (the timeline)
// time is decimal hours (0..24). status: stay | checkout | turnover | checkin
const TODAY_EVENTS = [
  { id: 'r1', guest: 'Helena Richter', party: 2, country: '🇩🇪', property: 'p1', status: 'checkout', from: 0, to: 10.5, nights: 5, payout: 1245, channel: 'Airbnb', rating: 5.0, key: '8821' },
  { id: 'r2', guest: 'Marcus Åberg', party: 4, country: '🇸🇪', property: 'p1', status: 'turnover', from: 11, to: 15.5, nights: 4, payout: 1180, channel: 'Airbnb', rating: null, key: '2047' },
  { id: 'r3', guest: 'Sofia Moretti', party: 2, country: '🇮🇹', property: 'p2', status: 'stay', from: 0, to: 24, nights: 3, payout: 620, channel: 'Direct', rating: null, key: '4410' },
  { id: 'r4', guest: 'David & Amara Okafor', party: 2, country: '🇬🇧', property: 'p3', status: 'checkin', from: 15, to: 24, nights: 6, payout: 1410, channel: 'Booking.com', rating: null, key: '9903' },
  { id: 'r5', guest: 'Hiroko Tanaka', party: 1, country: '🇯🇵', property: 'p4', status: 'stay', from: 0, to: 24, nights: 7, payout: 2010, channel: 'Direct', rating: null, key: '1177' },
  { id: 'r6', guest: 'Lucas Pereira', party: 3, country: '🇧🇷', property: 'p5', status: 'checkout', from: 0, to: 11, nights: 4, payout: 940, channel: 'Vrbo', rating: 4.8, key: '5523' },
  { id: 'r7', guest: 'Claire Dubois', party: 2, country: '🇫🇷', property: 'p5', status: 'checkin', from: 16, to: 24, nights: 3, payout: 710, channel: 'Airbnb', rating: null, key: '3388' },
  { id: 'r8', guest: 'Emma Wexler', party: 2, country: '🇺🇸', property: 'p6', status: 'stay', from: 0, to: 24, nights: 5, payout: 1380, channel: 'Airbnb', rating: null, key: '7716' },
  { id: 'r9', guest: 'Raj & Priya Sharma', party: 4, country: '🇮🇳', property: 'p7', status: 'checkin', from: 15.5, to: 24, nights: 4, payout: 1120, channel: 'Direct', rating: null, key: '2204' },
  { id: 'r10', guest: 'Tomás Silva', party: 2, country: '🇵🇹', property: 'p8', status: 'stay', from: 0, to: 24, nights: 2, payout: 520, channel: 'Booking.com', rating: null, key: '6645' },
];

// Upcoming / recent reservations list
const RESERVATIONS = [
  { id: 'R-2026-4471', guest: 'Helena Richter', property: 'p1', checkin: 'Apr 15', checkout: 'Apr 20', nights: 5, party: 2, total: 1245, status: 'checking-out', channel: 'Airbnb', country: '🇩🇪' },
  { id: 'R-2026-4472', guest: 'Marcus Åberg', property: 'p1', checkin: 'Apr 20', checkout: 'Apr 24', nights: 4, party: 4, total: 1180, status: 'arriving', channel: 'Airbnb', country: '🇸🇪' },
  { id: 'R-2026-4468', guest: 'Sofia Moretti', property: 'p2', checkin: 'Apr 18', checkout: 'Apr 21', nights: 3, party: 2, total: 620, status: 'in-house', channel: 'Direct', country: '🇮🇹' },
  { id: 'R-2026-4470', guest: 'David & Amara Okafor', property: 'p3', checkin: 'Apr 20', checkout: 'Apr 26', nights: 6, party: 2, total: 1410, status: 'arriving', channel: 'Booking.com', country: '🇬🇧' },
  { id: 'R-2026-4465', guest: 'Hiroko Tanaka', property: 'p4', checkin: 'Apr 15', checkout: 'Apr 22', nights: 7, party: 1, total: 2010, status: 'in-house', channel: 'Direct', country: '🇯🇵' },
  { id: 'R-2026-4473', guest: 'Lucas Pereira', property: 'p5', checkin: 'Apr 16', checkout: 'Apr 20', nights: 4, party: 3, total: 940, status: 'checking-out', channel: 'Vrbo', country: '🇧🇷' },
  { id: 'R-2026-4474', guest: 'Claire Dubois', property: 'p5', checkin: 'Apr 20', checkout: 'Apr 23', nights: 3, party: 2, total: 710, status: 'arriving', channel: 'Airbnb', country: '🇫🇷' },
  { id: 'R-2026-4475', guest: 'Emma Wexler', property: 'p6', checkin: 'Apr 18', checkout: 'Apr 23', nights: 5, party: 2, total: 1380, status: 'in-house', channel: 'Airbnb', country: '🇺🇸' },
  { id: 'R-2026-4476', guest: 'Raj & Priya Sharma', property: 'p7', checkin: 'Apr 20', checkout: 'Apr 24', nights: 4, party: 4, total: 1120, status: 'arriving', channel: 'Direct', country: '🇮🇳' },
  { id: 'R-2026-4464', guest: 'Tomás Silva', property: 'p8', checkin: 'Apr 19', checkout: 'Apr 21', nights: 2, party: 2, total: 520, status: 'in-house', channel: 'Booking.com', country: '🇵🇹' },
  { id: 'R-2026-4480', guest: 'Annika Voss', property: 'p2', checkin: 'Apr 22', checkout: 'Apr 27', nights: 5, party: 2, total: 1025, status: 'confirmed', channel: 'Airbnb', country: '🇩🇪' },
  { id: 'R-2026-4482', guest: 'Julian Park', property: 'p3', checkin: 'Apr 26', checkout: 'May 02', nights: 6, party: 2, total: 1560, status: 'confirmed', channel: 'Direct', country: '🇰🇷' },
  { id: 'R-2026-4484', guest: 'Bianca Rossi', property: 'p6', checkin: 'Apr 23', checkout: 'Apr 28', nights: 5, party: 3, total: 1380, status: 'confirmed', channel: 'Airbnb', country: '🇮🇹' },
  { id: 'R-2026-4486', guest: 'Oliver Hughes', property: 'p4', checkin: 'Apr 22', checkout: 'Apr 29', nights: 7, party: 4, total: 2240, status: 'pending', channel: 'Airbnb', country: '🇬🇧' },
  { id: 'R-2026-4490', guest: 'Natalia Kowalski', property: 'p5', checkin: 'Apr 24', checkout: 'Apr 28', nights: 4, party: 2, total: 920, status: 'confirmed', channel: 'Booking.com', country: '🇵🇱' },
];

const MESSAGES = [
  { id: 'm1', name: 'Marcus Åberg', initials: 'MÅ', property: 'Flores', time: '12:04', preview: 'Hej! We just landed. Any way we could get in 30 min early? Flight was quick.', tag: 'urgent', unread: true },
  { id: 'm2', name: 'David Okafor', initials: 'DO', property: 'P. Real', time: '11:42', preview: "Thanks for the WhatsApp — can't wait. One question on parking…", tag: null, unread: true },
  { id: 'm3', name: 'Meridian AI', initials: 'AI', property: 'Douro', time: '11:20', preview: 'Suggested reply drafted for Hiroko about late checkout. Review →', tag: 'ai', unread: true },
  { id: 'm4', name: 'Claire Dubois', initials: 'CD', property: 'Graça', time: '10:58', preview: 'Bonjour! Is there a small kitchen kettle? Just need for tea 🫖', tag: null, unread: false },
  { id: 'm5', name: 'Emma Wexler', initials: 'EW', property: 'Bairro Alto', time: '10:15', preview: 'Wifi is excellent, thanks. Enjoying the apartment!', tag: null, unread: false },
  { id: 'm6', name: 'Raj Sharma', initials: 'RS', property: 'Estrela', time: '09:40', preview: 'Car rental confirmed — should arrive around 4pm local.', tag: null, unread: false },
];

const TASKS = [
  { id: 't1', title: 'Turnover clean — Casa das Flores', assignee: 'Célia M.', due: '11:00', status: 'in-progress', priority: 'high' },
  { id: 't2', title: 'Replace kitchen bulb — Alfama Vista', assignee: 'Rui P.', due: '14:00', status: 'todo', priority: 'low' },
  { id: 't3', title: 'Linen delivery — Graça + Estrela', assignee: 'BrancoLimpo Co.', due: '13:30', status: 'todo', priority: 'med' },
  { id: 't4', title: 'Welcome gift restock — all units', assignee: 'You', due: 'Today', status: 'todo', priority: 'med' },
  { id: 't5', title: 'Deep clean — Douro River House', assignee: 'Célia M.', due: 'Apr 21', status: 'scheduled', priority: 'med' },
  { id: 't6', title: 'Photo shoot follow-up — Foz Seafront', assignee: 'You', due: 'Apr 23', status: 'todo', priority: 'low' },
];

const REVIEWS = [
  { id: 'rv1', guest: 'Helena Richter', property: 'Casa das Flores', rating: 5, date: 'Apr 20', text: "Immaculate apartment in the heart of Chiado. The host's recommendations were spot-on. Would absolutely return." },
  { id: 'rv2', guest: 'Lucas Pereira', property: 'Graça Rooftop', rating: 5, date: 'Apr 20', text: "Vista incrível. Espaço limpíssimo, anfitrião atencioso. Very smooth self-check-in." },
  { id: 'rv3', guest: 'Claudia Weiss', property: 'Foz Seafront', rating: 4, date: 'Apr 18', text: "Stunning views and great beds. Minor issue with hot water on day one, sorted quickly." },
  { id: 'rv4', guest: 'Tom Larsen', property: 'Alfama Vista Loft', rating: 5, date: 'Apr 17', text: "A jewel box. The morning light is unreal. Everything the listing promised and more." },
];

// Finance — last 6 months revenue
const REVENUE_SERIES = [
  { m: 'Nov', gross: 28400, net: 22100, nights: 142 },
  { m: 'Dec', gross: 24100, net: 18600, nights: 118 },
  { m: 'Jan', gross: 19800, net: 15200, nights: 98  },
  { m: 'Feb', gross: 26700, net: 20800, nights: 128 },
  { m: 'Mar', gross: 34200, net: 27100, nights: 162 },
  { m: 'Apr', gross: 38900, net: 31200, nights: 178 },
];

const PAYOUTS = [
  { date: 'Apr 18', channel: 'Airbnb',      gross: 4820, fees: -482, net: 4338, count: 7 },
  { date: 'Apr 15', channel: 'Booking.com', gross: 2140, fees: -321, net: 1819, count: 3 },
  { date: 'Apr 12', channel: 'Direct',      gross: 3610, fees: -108, net: 3502, count: 4 },
  { date: 'Apr 08', channel: 'Airbnb',      gross: 6120, fees: -612, net: 5508, count: 9 },
  { date: 'Apr 04', channel: 'Vrbo',        gross: 1890, fees: -190, net: 1700, count: 2 },
  { date: 'Apr 01', channel: 'Direct',      gross: 2440, fees: -73,  net: 2367, count: 3 },
];

// Heatmap — 30 days occupancy across properties (0 empty, 1 booked, 2 soft-hold, 3 blocked)
function makeHeatmap() {
  const days = 30;
  const today = 8; // index of "today" column
  return PROPERTIES.map((p, pi) => {
    const row = [];
    let cur = Math.random() > 0.5 ? 'booked' : 'empty';
    let stayLen = 0;
    for (let d = 0; d < days; d++) {
      if (stayLen === 0) {
        const r = Math.random();
        if (r < 0.62) { cur = 'booked'; stayLen = 2 + Math.floor(Math.random() * 5); }
        else if (r < 0.72) { cur = 'soft'; stayLen = 2 + Math.floor(Math.random() * 3); }
        else if (r < 0.78) { cur = 'blocked'; stayLen = 1 + Math.floor(Math.random() * 2); }
        else { cur = 'empty'; stayLen = 1 + Math.floor(Math.random() * 3); }
      }
      row.push(cur);
      stayLen--;
    }
    return { property: p, row, today };
  });
}

const propertyById = id => PROPERTIES.find(p => p.id === id);

Object.assign(window, { PROPERTIES, TODAY_EVENTS, RESERVATIONS, MESSAGES, TASKS, REVIEWS, REVENUE_SERIES, PAYOUTS, makeHeatmap, propertyById });
