// Design tokens + i18n for the three directions.
// All values share the same premium dark vocabulary; differentiation
// is in palette, type scale, density, and navigation pattern.

const T_A = {
  name: 'Minimal',
  font: '"Be Vietnam Pro", "Helvetica Neue", system-ui, sans-serif',
  mono: '"JetBrains Mono", "SF Mono", ui-monospace, monospace',
  bg: '#0E0E10',
  surface: '#17171A',
  surface2: '#1F1F23',
  divider: 'rgba(255,255,255,0.06)',
  text: '#F4F4F6',
  textDim: 'rgba(244,244,246,0.62)',
  textMute: 'rgba(244,244,246,0.38)',
  accent: '#E03B3B',           // refined Mazda-ish red, slightly desaturated
  accentInk: '#FFFFFF',
  ok: '#5FBF77',
  warn: '#E6A23C',
  radius: 18,
  radiusSm: 10,
};

const T_B = {
  name: 'Bold Editorial',
  font: '"Be Vietnam Pro", "Helvetica Neue", system-ui, sans-serif',
  display: '"Be Vietnam Pro", "Helvetica Neue", system-ui, sans-serif',
  mono: '"JetBrains Mono", "SF Mono", ui-monospace, monospace',
  bg: '#08080A',
  surface: '#101013',
  surface2: '#1A1A1F',
  divider: 'rgba(245,235,220,0.08)',
  text: '#F5EBDC',             // warm cream
  textDim: 'rgba(245,235,220,0.6)',
  textMute: 'rgba(245,235,220,0.35)',
  accent: '#C9491F',           // burnt sienna / brick
  accentInk: '#F5EBDC',
  ok: '#7BBE8A',
  warn: '#E0A65C',
  radius: 4,                   // sharper, editorial
  radiusSm: 2,
};

const T_C = {
  name: 'Spatial Widget',
  font: '"Mazda Type", "Be Vietnam Pro", "Helvetica Neue", system-ui, sans-serif',
  mono: '"JetBrains Mono", "SF Mono", ui-monospace, monospace',
  bg: '#0A0F14',
  surface: 'rgba(255,255,255,0.04)',   // glass
  surface2: 'rgba(255,255,255,0.07)',
  divider: 'rgba(255,255,255,0.08)',
  text: '#EAEEF2',
  textDim: 'rgba(234,238,242,0.6)',
  textMute: 'rgba(234,238,242,0.38)',
  accent: '#D4A574',           // champagne / copper
  accent2: '#7CB7FF',          // cool secondary
  accentInk: '#0A0F14',
  ok: '#65D49A',
  warn: '#E8B872',
  radius: 24,
  radiusSm: 14,
};

const THEMES = { a: T_A, b: T_B, c: T_C };

// ─────────────────────────────────────────────────────────────
// i18n strings (en + vi)
// ─────────────────────────────────────────────────────────────
const STRINGS = {
  en: {
    appName: 'M·Connect',
    welcomeBack: 'Welcome back',
    signIn: 'Sign in',
    signInVietnam: 'Sign in to Mazda Vietnam',
    phone: 'Phone number',
    pwd: 'Password',
    email: 'Email',
    continueWith: 'Or continue with',
    forgot: 'Forgot password?',
    noAccount: 'Don’t have an account?',
    signUp: 'Sign up',
    useFaceId: 'Use Face ID',
    or: 'or',
    loginPhoneTab: 'Phone',
    loginEmailTab: 'Email',
    loginPwdTab: 'Password',
    loginOtpTab: 'OTP',
    rememberMe: 'Stay signed in',
    showPwd: 'Show',
    hidePwd: 'Hide',
    byContinuing: 'By continuing you agree to the Terms and Privacy Policy.',

    onbTitle: 'Your car, in your pocket',
    onbDesc: 'Lock, locate, and look after your Mazda from anywhere in Vietnam.',
    onbNext: 'Get started',
    skip: 'Skip',

    goodMorning: 'Good morning',
    goodAfternoon: 'Good afternoon',
    goodEvening: 'Good evening',
    yourCar: 'Your car',

    locked: 'Locked',
    unlocked: 'Unlocked',
    parkedAt: 'Parked at',
    lastUpdated: 'Updated',
    minAgo: 'min ago',

    range: 'Range',
    fuel: 'Fuel',
    odometer: 'Odometer',
    battery: 'Battery',
    tires: 'Tires',
    psi: 'kPa',

    quickActions: 'Quick actions',
    lock: 'Lock',
    unlock: 'Unlock',
    horn: 'Horn',
    flash: 'Flash lights',
    climate: 'Climate',
    engine: 'Start engine',
    engineRunning: 'Engine running',

    remote: 'Remote',
    remoteControl: 'Remote control',
    holdToConfirm: 'Hold to confirm',
    pinPrompt: 'Enter 4-digit PIN',
    confirmLockQ: 'Lock all doors?',
    confirmUnlockQ: 'Unlock all doors?',
    confirmLockBody: 'This will arm the alarm and lock all four doors.',
    confirmUnlockBody: 'This will disarm the alarm and unlock all four doors.',

    cabinTemp: 'Cabin',
    setTemp: 'Set temperature',

    findCar: 'Find my car',
    navigate: 'Navigate',
    walkHere: 'Walk here',
    distance: 'km away',

    service: 'Service',
    bookService: 'Book a service',
    nextService: 'Next service',
    dealer: 'Dealer',
    chooseDealer: 'Choose dealer',
    chooseService: 'What needs doing?',
    chooseDate: 'Pick a date',
    chooseTime: 'Pick a time',
    confirm: 'Confirm booking',
    estimate: 'Estimated cost',

    notifications: 'Notifications',
    markAllRead: 'Mark all read',

    profile: 'Profile',
    vehicles: 'My vehicles',
    documents: 'Documents',
    payment: 'Payment methods',
    language: 'Language',
    settings: 'Settings',
    signOut: 'Sign out',
    help: 'Help & owner\u2019s manual',
    sos: 'Emergency assistance',
    sosLine: '24/7 Thaco Roadside',

    home: 'Home',
    vehicle: 'Vehicle',
    more: 'More',

    holidayBadge: 'Tết schedule',
    fuelToday: 'RON95 today',
    perL: '/ L',
    weatherHN: 'Hanoi · 24°C',
    weatherHCM: 'HCMC · 31°C',
  },
  vi: {
    appName: 'M·Connect',
    welcomeBack: 'Chào mừng trở lại',
    signIn: 'Đăng nhập',
    signInVietnam: 'Đăng nhập Mazda Việt Nam',
    phone: 'Số điện thoại',
    pwd: 'Mật khẩu',
    email: 'Email',
    continueWith: 'Hoặc tiếp tục bằng',
    forgot: 'Quên mật khẩu?',
    noAccount: 'Chưa có tài khoản?',
    signUp: 'Đăng ký',
    useFaceId: 'Dùng Face ID',
    or: 'hoặc',
    loginPhoneTab: 'Điện thoại',
    loginEmailTab: 'Email',
    loginPwdTab: 'Mật khẩu',
    loginOtpTab: 'Mã OTP',
    rememberMe: 'Duy trì đăng nhập',
    showPwd: 'Hiện',
    hidePwd: 'Ẩn',
    byContinuing: 'Bằng việc tiếp tục, bạn đồng ý với Điều khoản và Chính sách.',

    onbTitle: 'Xe của bạn, ngay trong túi',
    onbDesc: 'Khóa, định vị và chăm sóc chiếc Mazda của bạn ở bất kỳ đâu tại Việt Nam.',
    onbNext: 'Bắt đầu',
    skip: 'Bỏ qua',

    goodMorning: 'Chào buổi sáng',
    goodAfternoon: 'Chào buổi chiều',
    goodEvening: 'Chào buổi tối',
    yourCar: 'Xe của bạn',

    locked: 'Đã khóa',
    unlocked: 'Đã mở khóa',
    parkedAt: 'Đỗ tại',
    lastUpdated: 'Cập nhật',
    minAgo: 'phút trước',

    range: 'Quãng đường',
    fuel: 'Nhiên liệu',
    odometer: 'Số km đã đi',
    battery: 'Ắc-quy',
    tires: 'Lốp xe',
    psi: 'kPa',

    quickActions: 'Thao tác nhanh',
    lock: 'Khóa',
    unlock: 'Mở khóa',
    horn: 'Còi',
    flash: 'Đèn pha',
    climate: 'Điều hòa',
    engine: 'Khởi động máy',
    engineRunning: 'Máy đang nổ',

    remote: 'Điều khiển',
    remoteControl: 'Điều khiển từ xa',
    holdToConfirm: 'Giữ để xác nhận',
    pinPrompt: 'Nhập mã PIN 4 số',
    confirmLockQ: 'Khóa tất cả các cửa?',
    confirmUnlockQ: 'Mở khóa tất cả các cửa?',
    confirmLockBody: 'Hệ thống sẽ kích hoạt còi báo và khóa cả 4 cửa.',
    confirmUnlockBody: 'Hệ thống sẽ tắt còi báo và mở khóa cả 4 cửa.',

    cabinTemp: 'Trong xe',
    setTemp: 'Đặt nhiệt độ',

    findCar: 'Tìm xe của tôi',
    navigate: 'Chỉ đường',
    walkHere: 'Đi bộ đến',
    distance: 'km',

    service: 'Bảo dưỡng',
    bookService: 'Đặt lịch bảo dưỡng',
    nextService: 'Lần bảo dưỡng tới',
    dealer: 'Đại lý',
    chooseDealer: 'Chọn đại lý Thaco',
    chooseService: 'Bạn cần gì?',
    chooseDate: 'Chọn ngày',
    chooseTime: 'Chọn giờ',
    confirm: 'Xác nhận đặt lịch',
    estimate: 'Chi phí dự kiến',

    notifications: 'Thông báo',
    markAllRead: 'Đánh dấu đã đọc',

    profile: 'Tài khoản',
    vehicles: 'Xe của tôi',
    documents: 'Giấy tờ xe',
    payment: 'Phương thức thanh toán',
    language: 'Ngôn ngữ',
    settings: 'Cài đặt',
    signOut: 'Đăng xuất',
    help: 'Trợ giúp & Sách hướng dẫn',
    sos: 'Cứu hộ khẩn cấp',
    sosLine: 'Cứu hộ Thaco 24/7',

    home: 'Trang chủ',
    vehicle: 'Xe',
    more: 'Thêm',

    holidayBadge: 'Lịch Tết',
    fuelToday: 'RON95 hôm nay',
    perL: '/ Lít',
    weatherHN: 'Hà Nội · 24°C',
    weatherHCM: 'TP.HCM · 31°C',
  },
};

// ─────────────────────────────────────────────────────────────
// Vehicle catalog (Vietnam market)
// ─────────────────────────────────────────────────────────────
const VEHICLES = {
  cx5:    { id: 'cx5',   name: 'Mazda CX-5',  trim: 'Premium Exclusive', plate: '30K-128.99', color: '#7B1B1B' },
  cx30:   { id: 'cx30',  name: 'Mazda CX-30', trim: 'Premium',           plate: '51K-882.04', color: '#1B2A3A' },
  mazda3: { id: 'mazda3',name: 'Mazda3 Sport',trim: 'Signature Premium', plate: '29A-471.62', color: '#A9A9AD' },
};

// Format number with Vietnamese thousands separator.
const fmtVND = (n) => new Intl.NumberFormat('vi-VN').format(n) + '\u00A0₫';
const fmtKm  = (n) => new Intl.NumberFormat('vi-VN').format(n);

// Inline translation helper for ad-hoc strings that don't merit a full STRINGS entry.
// Usage: T(lang, 'English text', 'Vietnamese text')
const T = (lang, en, vi) => lang === 'vi' ? vi : en;

// Hour-of-day greeting key.
const greetKey = () => {
  const h = new Date().getHours();
  if (h < 12) return 'goodMorning';
  if (h < 18) return 'goodAfternoon';
  return 'goodEvening';
};

Object.assign(window, { THEMES, STRINGS, VEHICLES, fmtVND, fmtKm, greetKey, T });
