// cust-drawers-data.jsx — Customer Insights drawer data + i18n

const CUST_DRW_T = {
  ru: {
    breadcrumbs: { customers: 'Customers', guests: 'Guests', segments: 'Segments', cohorts: 'Cohorts', acq: 'Acquisition', atrisk: 'At-risk' },
    close: 'Закрыть',
    guest: {
      sections: {
        contact: 'Контактная информация',
        status: 'Статус и сегмент',
        history: 'История визитов',
        patterns: 'Предпочтения и паттерны',
        notes: 'Заметки и тэги',
        crossTab: 'Cross-tab references',
      },
      contactLabels: { email: 'Email', phone: 'Телефон', country: 'Страна', city: 'Город', dob: 'День рождения', firstStay: 'First stay anniversary', lang: 'Язык' },
      statusLabels: { current: 'Текущий сегмент', trajectory: 'Траектория', daysSince: 'Дней с last visit', predictNext: 'Предполагаемый следующий визит', risk: 'Risk score' },
      visit: 'Визит',
      reception: 'Заметка ресепшена',
      patternsLabels: { cabin: 'Любимый домик', season: 'Любимый сезон', alos: 'Avg ALOS', spa: 'SPA usage', fnb: 'F&B usage', lead: 'Lead time', channel: 'Channel preference' },
      tagsLbl: 'Тэги', notesLbl: 'Заметки', lastTouch: 'Last touchpoint',
      crossTabItems: { bookings: 'Все бронирования в Booking Analytics', acq: 'Acquisition journey в Marketing', reviews: 'Отзывы' },
      footer: { email: 'Send personal email', whatsapp: 'WhatsApp', addNote: 'Add note / tag', cloudbeds: 'Open in Cloudbeds ↗' },
      risk: { Low: 'Low', Medium: 'Medium', High: 'High' },
      noNotes: 'Заметок и тэгов пока нет.',
    },
    segment: {
      definition: 'Определение сегмента',
      profile: 'Профиль сегмента',
      profileCols: { metric: 'Метрика', seg: 'Сегмент', base: 'База avg', d: 'Δ' },
      guests: 'Список гостей сегмента',
      demo: 'Демографические особенности',
      reco: 'Рекомендации',
      footer: { export: 'Export segment list (CSV)', campaign: 'Create segment campaign', filter: 'View as filter on Booking Analytics →' },
    },
    cohort: {
      curve: 'Retention curve',
      ltv: 'LTV evolution',
      composition: 'Cohort composition',
      top: 'Top performers in cohort',
      dropoff: 'Drop-off analysis',
      footer: { export: 'Export cohort guest list (CSV)', compare: 'Compare with another cohort →' },
    },
    source: {
      detail: 'Источник детально',
      perf: 'Performance vs other channels',
      guests: 'Гости из этого источника',
      reco: 'Рекомендации',
      footer: { ref: 'Identify active referrers →', export: 'Export source guest list (CSV)' },
      noSub: 'Sub-categorization не отслеживается для этого источника.',
    },
    atrisk: {
      action: 'Action context',
      priority: 'Priority list',
      priorityCols: { p: '#', g: 'Гость', ltv: 'LTV', v: 'Visits', m: 'Months since', approach: 'Suggested approach' },
      templates: 'Suggested templates',
      tracking: 'Outreach tracking',
      noTracking: 'Outreach tracking не настроен. Включите в Settings → Communications для отслеживания success rate.',
      footer: { bulk: 'Bulk send "We miss you"', export: 'Export action list (CSV)' },
      send: 'Send outreach',
    },
  },
  en: {
    breadcrumbs: { customers: 'Customers', guests: 'Guests', segments: 'Segments', cohorts: 'Cohorts', acq: 'Acquisition', atrisk: 'At-risk' },
    close: 'Close',
    guest: {
      sections: {
        contact: 'Contact information',
        status: 'Status & segment',
        history: 'Visit history',
        patterns: 'Preferences & patterns',
        notes: 'Notes & tags',
        crossTab: 'Cross-tab references',
      },
      contactLabels: { email: 'Email', phone: 'Phone', country: 'Country', city: 'City', dob: 'Birthday', firstStay: 'First stay anniversary', lang: 'Language' },
      statusLabels: { current: 'Current segment', trajectory: 'Trajectory', daysSince: 'Days since last visit', predictNext: 'Predicted next visit', risk: 'Risk score' },
      visit: 'Visit',
      reception: 'Reception note',
      patternsLabels: { cabin: 'Preferred cabin', season: 'Preferred season', alos: 'Avg ALOS', spa: 'SPA usage', fnb: 'F&B usage', lead: 'Lead time', channel: 'Channel preference' },
      tagsLbl: 'Tags', notesLbl: 'Notes', lastTouch: 'Last touchpoint',
      crossTabItems: { bookings: 'View bookings in Booking Analytics', acq: 'View acquisition journey in Marketing', reviews: 'View reviews' },
      footer: { email: 'Send personal email', whatsapp: 'WhatsApp', addNote: 'Add note / tag', cloudbeds: 'Open in Cloudbeds ↗' },
      risk: { Low: 'Low', Medium: 'Medium', High: 'High' },
      noNotes: 'No notes or tags yet.',
    },
    segment: {
      definition: 'Segment definition',
      profile: 'Segment profile',
      profileCols: { metric: 'Metric', seg: 'Segment', base: 'Base avg', d: 'Δ' },
      guests: 'Guests in segment',
      demo: 'Demographic breakdown',
      reco: 'Recommendation',
      footer: { export: 'Export segment list (CSV)', campaign: 'Create segment campaign', filter: 'View as filter on Booking Analytics →' },
    },
    cohort: {
      curve: 'Retention curve',
      ltv: 'LTV evolution',
      composition: 'Cohort composition',
      top: 'Top performers in cohort',
      dropoff: 'Drop-off analysis',
      footer: { export: 'Export cohort guest list (CSV)', compare: 'Compare with another cohort →' },
    },
    source: {
      detail: 'Source detail',
      perf: 'Performance vs other channels',
      guests: 'Guests from this source',
      reco: 'Recommendation',
      footer: { ref: 'Identify active referrers →', export: 'Export source guest list (CSV)' },
      noSub: 'Sub-categorization not tracked for this source.',
    },
    atrisk: {
      action: 'Action context',
      priority: 'Priority list',
      priorityCols: { p: '#', g: 'Guest', ltv: 'LTV', v: 'Visits', m: 'Months since', approach: 'Suggested approach' },
      templates: 'Suggested templates',
      tracking: 'Outreach tracking',
      noTracking: 'Outreach tracking not yet enabled. Configure in Settings → Communications to track success rate.',
      footer: { bulk: 'Bulk send "We miss you"', export: 'Export action list (CSV)' },
      send: 'Send outreach',
    },
  },
};

// Guest profiles (keyed by name)
const CUST_GUEST_PROFILES = {
  'Иванов Александр': {
    segment: 'champions',
    visits: 7, ltv: 4820, lastVisitAgo: 12,
    contact: { email: 'a.ivanov@example.com', phone: '+371 2456 7890', country: 'Латвия', city: 'Рига', dob: '14 May', firstStay: 'Mar 2022', lang: 'Russian' },
    trajectory: ['promising', 'loyal', 'champions'],
    predictNext: '~3-4 мес',
    risk: 'Low',
    history: [
      { n: 7, dates: '12–15 Apr 2026', cabin: '#2 Forest Premium', nights: 3, rev: 920, channel: 'Direct', spa: '✓ Couples massage', fnb: '✓ Wine dinner', note: 'Anniversary trip — preferred late check-out' },
      { n: 6, dates: '24–26 Dec 2025', cabin: '#2 Forest Premium', nights: 2, rev: 840, channel: 'Direct', spa: '✓ Sauna', fnb: '✓ Christmas dinner' },
      { n: 5, dates: '14–17 May 2025', cabin: '#1 Bay View', nights: 3, rev: 720, channel: 'Direct', spa: '✓ Couples massage', fnb: '✓ Breakfast' },
      { n: 4, dates: '20–22 Mar 2025', cabin: '#2 Forest Premium', nights: 2, rev: 560, channel: 'Direct', spa: '—', fnb: '✓ Dinner' },
      { n: 3, dates: '8–10 Sep 2024', cabin: '#3 Spa Suite', nights: 2, rev: 640, channel: 'Direct', spa: '✓ Spa package', fnb: '—' },
      { n: 2, dates: '22–25 May 2023', cabin: '#1 Bay View', nights: 3, rev: 580, channel: 'Direct', spa: '✓ Couples massage', fnb: '✓ Wine dinner' },
      { n: 1, dates: '12–15 Mar 2022', cabin: '#1 Bay View', nights: 3, rev: 560, channel: 'Booking.com', spa: '—', fnb: '—' },
    ],
    patterns: { cabin: '#2 Forest Premium (4/7)', season: 'Spring + Christmas', alos: '2.4 нт', spa: 'High (always +1)', fnb: 'Medium (50%)', lead: '7–12 дней', channel: 'Direct (always)' },
    tags: ['VIP', 'Wine enthusiast', 'Anniversary couple'],
    notes: 'Prefers cabin #2 with view of forest. Likes late check-out (until 14:00). Wife allergic to lavender — avoid lavender amenities.',
    lastTouch: 'Email · 18 Apr 2026 · Anniversary greeting',
    bookingsCount: 7, reviewsCount: 3,
  },
  'Champions sample': {
    segment: 'champions', visits: 5, ltv: 1840, lastVisitAgo: 28,
    contact: { email: '—', phone: '—', country: 'Латвия', city: 'Рига', dob: '—', firstStay: 'Sep 2023', lang: 'Russian' },
    trajectory: ['promising', 'loyal', 'champions'],
    predictNext: '~6 мес', risk: 'Low',
    history: [], patterns: {}, tags: [], notes: '', lastTouch: '—',
  },
};

// Segment definitions
const CUST_SEG_DEFS = {
  champions: 'Champions = guests who visited within the last 2 months AND have 3+ lifetime stays AND total spent above €1,500.',
  loyal: 'Loyal = guests with 2+ stays in last 12 months OR 3+ lifetime stays.',
  promising: 'Promising = guests with 1 recent stay (last 6 months) showing potential to become Loyal.',
  atrisk: 'At Risk = previously active guests (2+ stays) who have not visited in 6–12 months.',
  lost: 'Lost = guests with no visit in 12+ months.',
  hibernating: 'Hibernating = guests with 1–2 stays who went 6–12 months without visit.',
};

// Segment profile (vs base)
const CUST_SEG_PROFILE = {
  champions: [
    { metric: 'Avg LTV', seg: 1840, base: 620, fmt: 'eur' },
    { metric: 'Avg visits', seg: 4.8, base: 1.6, fmt: 'dec1' },
    { metric: 'Avg ALOS, нт', seg: 2.6, base: 1.8, fmt: 'dec1' },
    { metric: 'Cross-sell SPA, %', seg: 84, base: 64, fmt: 'pct' },
    { metric: 'Direct booking, %', seg: 92, base: 54, fmt: 'pct' },
    { metric: 'Cancellation rate, %', seg: 4, base: 12, fmt: 'pct', invert: true },
  ],
  loyal: [
    { metric: 'Avg LTV', seg: 920, base: 620, fmt: 'eur' },
    { metric: 'Avg visits', seg: 2.6, base: 1.6, fmt: 'dec1' },
    { metric: 'Avg ALOS, нт', seg: 2.0, base: 1.8, fmt: 'dec1' },
    { metric: 'Cross-sell SPA, %', seg: 72, base: 64, fmt: 'pct' },
    { metric: 'Direct booking, %', seg: 68, base: 54, fmt: 'pct' },
    { metric: 'Cancellation rate, %', seg: 8, base: 12, fmt: 'pct', invert: true },
  ],
};

// Segment demographic breakdowns
const CUST_SEG_DEMO = {
  champions: [
    { lbl: 'Couples', seg: 76, base: 62 },
    { lbl: 'Latvia', seg: 82, base: 48 },
    { lbl: 'Female contact', seg: 64, base: 58 },
    { lbl: 'Repeat lead time <14d', seg: 88, base: 42 },
  ],
  loyal: [
    { lbl: 'Couples', seg: 68, base: 62 },
    { lbl: 'Latvia', seg: 64, base: 48 },
    { lbl: 'Friends/Families', seg: 28, base: 27 },
    { lbl: 'Repeat lead time <14d', seg: 72, base: 42 },
  ],
};

// Segment recommendations
const CUST_SEG_RECO = {
  champions: [
    'Champions = 11% базы, 32% выручки. Программа удержания критична.',
    'Персональные коммуникации: каждому 2 раза в год.',
    'VIP-привилегии: гарантированный любимый домик.',
    'Birthday + anniversary знаки.',
    'Referral program: они приводят гостей.',
    'Exclusive events 2 раза в год.',
  ],
  loyal: [
    'Loyal = 15% базы, 21% выручки. Цель — конверсия в Champions.',
    'Triggered upgrade offers после 3-го визита.',
    'Personalized cross-sell based on preferences.',
    'Mid-cycle birthday touchpoint.',
    'Track для Champions promotion.',
  ],
};

// Cohort details
const CUST_COHORT_DETAILS = {
  'Mar 2025': {
    size: 24,
    retention12: 38,
    avgLtv12: 640,
    composition: { channels: [{ k: 'Direct', n: 10 }, { k: 'Booking.com', n: 6 }, { k: 'Instagram', n: 5 }, { k: 'Word of mouth', n: 3 }],
                   countries: [{ k: 'Латвия', pct: 58 }, { k: 'Эстония', pct: 21 }, { k: 'Other', pct: 21 }],
                   guestType: { couples: 71, families: 17, other: 12 },
                   firstBookingAvg: 320 },
    retentionLine: [100, 42, 38, 32, 28, null, null, null],
    avgGray: [100, 30, 24, 18, 22, 28, 32, null],
    bestLine: [100, 48, 44, 38, null, null, null, null],
    worstLine: [100, 22, 16, 10, null, null, null, null],
    ltvLine: [180, 280, 380, 470, 540, null, null, null],
    ltvAvgGray: [160, 220, 280, 340, 420, 510, 620, null],
    topPerformers: [
      { name: 'Smith Robert', visits: 3, ltv: 1240 },
      { name: 'Wagner Anna', visits: 3, ltv: 1080 },
      { name: 'Соколова Елена', visits: 2, ltv: 920 },
      { name: 'Brown Michael', visits: 2, ltv: 840 },
      { name: 'Lebedev Сергей', visits: 2, ltv: 780 },
    ],
    dropoff: { lostPct: 12, lostAvgLtv: 240, reason: 'Single-stay из Booking.com доминирует в lost — channel mix предсказуемая proxy.' },
  },
};

// Acquisition source details
const CUST_SOURCE_DETAILS = {
  'Word of mouth': {
    n: 12, ltv: 920, repeat: 58, base: { ltv: 620, repeat: 28 },
    sub: [
      { k: 'Friend referral', n: 7 },
      { k: 'Family member', n: 3 },
      { k: 'Workplace', n: 2 },
    ],
    guests: [
      { name: 'Иванова Анна', referredBy: 'Иванов Александр', ltv: 720 },
      { name: 'Петрова Лена', referredBy: 'Петрова Мария', ltv: 480 },
      { name: 'Smith Sarah', referredBy: 'Smith Robert', ltv: 920 },
      { name: 'Müller Frank', referredBy: 'Müller Klaus', ltv: 540 },
      { name: 'Соколов Иван', referredBy: 'Соколова Елена', ltv: 380 },
    ],
    reco: [
      'Word of mouth = highest-LTV source (€920 vs €620 база).',
      'Identify active referrers — 8 гостей привели 12 новых.',
      'Formalize referral program: €40 credit за приведённого друга.',
      'Track referrals systematically через post-stay form.',
      'Champion-referrers получают signature gestures.',
    ],
  },
  'Booking.com': {
    n: 22, ltv: 380, repeat: 18, base: { ltv: 620, repeat: 28 },
    sub: null,
    guests: [
      { name: 'Romano Giulia', ltv: 320 },
      { name: 'Hoffmann Dieter', ltv: 280 },
      { name: 'Klein Sabine', ltv: 240 },
      { name: 'Berg Henrik', ltv: 480 },
      { name: 'Olsen Karl', ltv: 360 },
    ],
    reco: [
      'Booking.com = highest volume, lowest LTV (€380 vs €620 база).',
      'Repeat rate 18% vs 28% база — гости single-stay.',
      'Post-stay nurture: предлагать direct rate для повторного визита.',
      'Capture email при check-in для direct relationship.',
      'Не наращивать спрос — лучше заменять на Direct.',
    ],
  },
};

// At-risk filter views
const CUST_ATRISK_VIEWS = {
  default: {
    title: { ru: '14 high-value гостей at risk', en: '14 high-value guests at risk' },
    sub: { ru: 'LTV > €500 · 6+ мес без визита', en: 'LTV > €500 · 6+ mo without visit' },
    n: 14, totalRev: 18400, avgMonths: 9.2,
    motivation: { ru: 'Эти гости значимо потратили (avg LTV €1,310), но не возвращались 6+ месяцев. Personal outreach от менеджера часто возвращает 20–30%.',
                  en: 'These guests have spent significantly (avg LTV €1,310) but have not returned in 6+ months. Personal outreach from the manager typically wins back 20–30%.' },
    list: [
      { name: 'Иванова Светлана', ltv: 3240, visits: 4, months: 19, approach: 'Personal note + return offer' },
      { name: 'Berg Henrik',       ltv: 2840, visits: 4, months: 17, approach: 'WhatsApp + cabin upgrade' },
      { name: 'Петров Николай',    ltv: 2480, visits: 3, months: 16, approach: 'Personal call' },
      { name: 'Romano Giulia',     ltv: 1920, visits: 3, months: 14, approach: 'Email + anniversary' },
      { name: 'Семёнова Ирина',    ltv: 1680, visits: 3, months: 13, approach: 'WhatsApp + spa offer' },
      { name: 'Olsen Karl',        ltv: 1480, visits: 2, months: 12, approach: 'Email + special weekend' },
      { name: 'Захарова Юлия',     ltv: 1240, visits: 2, months: 11, approach: 'Birthday touchpoint' },
      { name: 'Hoffmann Dieter',   ltv: 1080, visits: 2, months: 10, approach: 'Email + cabin preference' },
    ],
    templates: [
      { id: 't1', title: 'We miss you', desc: 'Generic warm re-engagement' },
      { id: 't2', title: 'Anniversary of first stay', desc: 'Personal — uses first-stay date' },
      { id: 't3', title: 'Special return offer', desc: '15% discount on chosen cabin' },
    ],
    tracking: null, // null = empty state
  },
};

window.CUST_DRW_T = CUST_DRW_T;
window.CUST_GUEST_PROFILES = CUST_GUEST_PROFILES;
window.CUST_SEG_DEFS = CUST_SEG_DEFS;
window.CUST_SEG_PROFILE = CUST_SEG_PROFILE;
window.CUST_SEG_DEMO = CUST_SEG_DEMO;
window.CUST_SEG_RECO = CUST_SEG_RECO;
window.CUST_COHORT_DETAILS = CUST_COHORT_DETAILS;
window.CUST_SOURCE_DETAILS = CUST_SOURCE_DETAILS;
window.CUST_ATRISK_VIEWS = CUST_ATRISK_VIEWS;
