// FENIX UNIFORM — i18n / Language switching
// Provides window.useLang(), window.LangSwitch, window.Multi
const { useSyncExternalStore: useSyncExternalStoreI18n } = React;

const FENIX_LANG_KEY = 'fenix.lang';
const FENIX_LANG_DEFAULT = 'th';
const FENIX_LANGS = ['th', 'en'];

const langStore = (() => {
  let current = FENIX_LANG_DEFAULT;
  try {
    const saved = localStorage.getItem(FENIX_LANG_KEY);
    if (FENIX_LANGS.includes(saved)) current = saved;
  } catch (e) {}
  const listeners = new Set();
  return {
    get: () => current,
    set: (v) => {
      if (!FENIX_LANGS.includes(v) || v === current) return;
      current = v;
      try { localStorage.setItem(FENIX_LANG_KEY, v); } catch (e) {}
      try { document.documentElement.setAttribute('lang', v); } catch (e) {}
      listeners.forEach((fn) => fn());
    },
    subscribe: (fn) => { listeners.add(fn); return () => listeners.delete(fn); },
  };
})();

try { document.documentElement.setAttribute('lang', langStore.get()); } catch (e) {}

const TR = {
  th: {
    // Nav
    'nav.catalog': 'Catalog',
    'nav.portfolio': 'Portfolio',
    'nav.process': 'Process',
    'nav.about': 'About',
    'nav.contact': 'Contact',
    'cta.requestQuote': 'ขอใบเสนอราคา →',

    // Hero
    'hero.eyebrow': 'EST. 2014 · BANGKOK',
    'hero.h1.l1': 'BUILT TO',
    'hero.h1.l2': 'PERFORM',
    'hero.lede': 'โรงงานผลิตยูนิฟอร์ม เสื้อผ้า กางเกง และหมวก\nสั่งตัดตามแบบ คุณภาพระดับสากล ส่งตรงจากโรงงาน ไม่ผ่านคนกลาง ราคายุติธรรม จำนวนน้อย-มาก รับหมด',
    'hero.cta.catalog': 'ดู E-Catalog →',
    'hero.cta.contact': 'ติดต่อทีมขาย',
    'hero.clientsSuffix': 'ลูกค้าทั่วประเทศ',
    'hero.minOrder': 'MIN. ORDER',
    'hero.minOrderValue': '12 PCS',
    'hero.leadTime': 'LEAD TIME',
    'hero.leadTimeValue': '7-14 D',
    'hero.tag': 'SS-26 / TEAM JERSEY',
    'hero.live': 'LIVE PRODUCTION',
    'hero.heroProductLabel': 'HERO PRODUCT SHOT',

    // Catalog
    'catalog.section': 'E-CATALOG',
    'catalog.headline.l1': 'เลือกหมวด,',
    'catalog.headline.l2': 'ดูแบบ, สั่งผลิต',
    'catalog.subhead': 'ทุกแบบสามารถปรับแก้ ใส่โลโก้ เปลี่ยนสี เปลี่ยนผ้าได้ ดาวน์โหลดแคตตาล็อกเต็มเป็น PDF หรือทักไลน์เพื่อรับแบบใหม่ทุกเดือน',
    'catalog.downloadPdf': 'ดาวน์โหลด PDF →',
    'catalog.category': 'CATEGORY',
    'catalog.priceFrom': 'เริ่ม',
    'catalog.priceUnit': '฿',
    'catalog.tag.bestseller': 'BEST SELLER',
    'catalog.tag.new': 'NEW',
    'catalog.view': 'VIEW →',

    'catalog.uniform.label': 'ยูนิฟอร์ม',
    'catalog.uniform.desc': 'ชุดพนักงานออฟฟิศ โรงงาน องค์กร แบบสุภาพ ทนทาน',
    'catalog.shirt.label': 'เสื้อยืด/เสื้อทีม',
    'catalog.shirt.desc': 'เสื้อทีมกีฬา เสื้ออีเวนต์ เสื้อยืดสกรีน คอกลม คอวี',
    'catalog.pants.label': 'กางเกง',
    'catalog.pants.desc': 'กางเกงทำงาน กางเกงกีฬา กางเกงขาสั้น สั่งตัดได้ทุกไซส์',
    'catalog.cap.label': 'หมวก',
    'catalog.cap.desc': 'หมวกแก๊ป หมวกทรัคเกอร์ หมวกบักเก็ต ปักโลโก้-สกรีนได้',

    'process.01.title': 'ส่งแบบ/ไอเดีย',
    'process.01.subtitle': 'Brief & concept',
    'process.02.title': 'ทำตัวอย่าง',
    'process.02.subtitle': 'Sample 3-5 days',
    'process.03.title': 'ผลิตตามจำนวน',
    'process.03.subtitle': 'Production',
    'process.04.title': 'ส่งถึงมือ',
    'process.04.subtitle': 'Delivery & QC',

    // Portfolio
    'portfolio.section': 'CLIENT WORK',
    'portfolio.headline.l1': 'ตัวอย่างงาน',
    'portfolio.headline.l2': 'ลูกค้าจริง',
    'portfolio.case': 'CASE',
    'portfolio.featured': 'FEATURED CASE',
    'portfolio.pieces': 'PIECES',
    'portfolio.pieces.unit': 'pcs',
    'portfolio.projectType': 'PROJECT TYPE',
    'portfolio.delivery': 'DELIVERY',
    'portfolio.fabric': 'FABRIC',
    'portfolio.print': 'PRINT',
    'portfolio.deliveryValue': '12 days',
    'portfolio.fabricValue': 'Premium',
    'portfolio.printValue': 'DTG + Embroidery',

    'portfolio.0.client': 'เอสซี เทคโนโลยี',
    'portfolio.0.type': 'Shop coat + cap',
    'portfolio.0.quote': 'ทำตามแบบเป๊ะ ส่งไว ทีมงานช่วยแก้ pattern จนพอใจ',
    'portfolio.0.person': 'คุณนิติพล · HR Manager',
    'portfolio.1.client': 'ทีมฟุตซอล THUNDER',
    'portfolio.1.type': 'Pro jersey + shorts',
    'portfolio.1.quote': 'ผ้าระบายเหงื่อดี สีไม่ตก ใส่ทั้งฤดูยังเหมือนใหม่',
    'portfolio.1.person': 'พี่ช้าง · Captain',
    'portfolio.2.client': 'Café Naranja',
    'portfolio.2.type': 'Apron + tee + cap',
    'portfolio.2.quote': 'ดีไซน์ minimal ตามที่อยากได้ ทุกคนใส่แล้วดูโปร',
    'portfolio.2.person': 'K. Mint · Owner',
    'portfolio.3.client': 'โรงเรียนสาธิตฯ',
    'portfolio.3.type': 'P.E. uniform set',
    'portfolio.3.quote': 'ทนต่อการซักเครื่อง สีไม่ซีด ผู้ปกครองพอใจมาก',
    'portfolio.3.person': 'อ. ปิยวัฒน์ · ผอ.',

    // About
    'about.section': 'ABOUT FENIX',
    'about.headline.l1': '12 ปีที่',
    'about.headline.l2': 'เราเย็บ',
    'about.headline.l3': 'ความเชื่อใจ',
    'about.headline.l4': 'ลงไปในทุกตะเข็บ.',
    'about.body.p1.before': 'FENIX UNIFORM เริ่มต้นจากโรงงานเล็กๆ ในบางบอน ปี 2014 ด้วยจักรสองตัวและความตั้งใจที่จะทำชุดที่ ',
    'about.body.p1.highlight': '"ใส่จริงทนจริง"',
    'about.body.p2': 'วันนี้ เรามีโรงงานในเครือ 3 แห่ง กำลังการผลิต 80,000 ชิ้น/เดือน ดูแลทีมกีฬา องค์กร โรงเรียน ร้านค้าทั่วประเทศ พร้อมระบบ QC สามชั้นและทีมดีไซน์ภายในบ้าน',

    'about.stat.years': 'ปีในวงการ',
    'about.stat.clients': 'ลูกค้าทั่วประเทศ',
    'about.stat.capacity': 'ชิ้น/เดือน',
    'about.stat.ontime': 'ส่งตรงเวลา',

    'about.value.01.title': 'ผ้าคุณภาพ',
    'about.value.01.body': 'นำเข้าและคัดเลือกจากผู้ผลิตชั้นนำ ผ่าน lab test ก่อนใช้จริง',
    'about.value.02.title': 'ทีมดีไซน์ภายใน',
    'about.value.02.body': 'นักออกแบบ 6 คน ปรับแก้ไม่จำกัดจนกว่าคุณจะพอใจ',
    'about.value.03.title': 'QC สามชั้น',
    'about.value.03.body': 'ตรวจคุณภาพทุกชิ้น ก่อนตัด ก่อนเย็บ และก่อนส่ง',

    // Contact
    'contact.section': 'GET IN TOUCH',
    'contact.headline.l1': 'พร้อมเริ่ม',
    'contact.headline.l2': 'งานคุณ',
    'contact.headline.l3': 'วันนี้',
    'contact.subhead': 'เลือกช่องทางที่สะดวก หรือกรอกฟอร์มขอใบเสนอราคาแบบละเอียด ทีมเราตอบกลับภายใน 30 นาที (จันทร์–เสาร์ 09:00–18:00)',
    'contact.cta': 'ขอใบเสนอราคา',
    'contact.formCode': 'FORM-26-A · ใช้เวลากรอก ~ 90 วินาที',
    'contact.openChannel': 'เปิดช่องทาง',

    'contact.line.label': 'LINE OFFICIAL',
    'contact.line.sub': 'ทักได้ตลอด ตอบเร็วสุด',
    'contact.phone.label': 'PHONE',
    'contact.phone.sub': 'จ–ส 09:00–18:00',
    'contact.email.label': 'EMAIL',
    'contact.email.sub': 'ส่งไฟล์แบบได้เลย',
    'contact.factory.label': 'FACTORY',
    'contact.factory.value': 'บางบอน, กรุงเทพฯ',
    'contact.factory.sub': 'นัดเข้าชมโรงงานได้',

    // Footer
    'footer.tagline': 'โรงงานผลิตยูนิฟอร์มและเสื้อผ้าสำเร็จรูป สั่งตัดตามแบบ ส่งตรงจากโรงงานสู่ลูกค้า ไม่ผ่านคนกลาง',
    'footer.catalog.uniform': 'ยูนิฟอร์มองค์กร',
    'footer.catalog.shirt': 'เสื้อยืด/เสื้อทีม',
    'footer.catalog.pants': 'กางเกง',
    'footer.catalog.cap': 'หมวก',
    'footer.address': 'บางบอน, กทม.',

    // Quote page
    'quote.back': '← กลับหน้าหลัก',
    'quote.eyebrow': 'FORM-26-A · QUOTE REQUEST',
    'quote.headline.l1': 'ขอใบเสนอ',
    'quote.headline.l2': 'ราคา',
    'quote.responseTime': 'RESPONSE TIME',
    'quote.responseTimeValue': '≤ 30 นาที',
    'quote.responseHours': 'จันทร์–เสาร์ 09:00–18:00',

    'quote.step.0': 'ประเภทงาน',
    'quote.step.1': 'รายละเอียด',
    'quote.step.2': 'ติดต่อกลับ',

    'quote.q1.title': 'คุณอยากได้สินค้าประเภทใด',
    'quote.q1.subtitle': 'เลือกได้มากกว่า 1 ประเภท',
    'quote.types.uniform': 'ยูนิฟอร์มองค์กร',
    'quote.types.uniform.desc': 'ชุดพนักงาน โรงงาน ร้าน',
    'quote.types.shirt': 'เสื้อยืด/เสื้อทีม',
    'quote.types.shirt.desc': 'เสื้อทีม กีฬา อีเวนต์',
    'quote.types.pants': 'กางเกง',
    'quote.types.pants.desc': 'ขายาว ขาสั้น คาร์โก',
    'quote.types.cap': 'หมวก',
    'quote.types.cap.desc': 'แก๊ป ทรัคเกอร์ บักเก็ต',

    'quote.q2.title': 'จำนวนที่ต้องการ',
    'quote.qty.unit': 'ชิ้น',

    'quote.q3.title': 'ต้องการระยะเวลา',
    'quote.timeline.urgent': 'ด่วน (≤7 วัน)',
    'quote.timeline.normal': 'ปกติ (7-14 วัน)',
    'quote.timeline.relaxed': 'ไม่รีบ (14-30 วัน)',
    'quote.timeline.none': 'ยังไม่กำหนด',

    'quote.q4.title': 'เทคนิคการพิมพ์/ปัก',
    'quote.q4.subtitle': 'เลือกได้มากกว่า 1 ข้อ (หรือเว้นว่างให้ทีมเราแนะนำ)',
    'quote.print.screen': 'สกรีน (Screen)',
    'quote.print.embroidery': 'ปัก (Embroidery)',
    'quote.print.dtg': 'DTG',
    'quote.print.sublimation': 'Sublimation',
    'quote.print.unsure': 'ยังไม่แน่ใจ',

    'quote.q5.title': 'รายละเอียดเพิ่มเติม',
    'quote.q5.placeholder': 'เช่น โลโก้ที่อยากให้ติด ขนาดที่ต้องการ สีที่ชอบ ผ้าที่อยากใช้ หรือลิงก์ภาพอ้างอิง',
    'quote.q5.tip': '💡 ยิ่งให้รายละเอียดเยอะ ใบเสนอราคาจะแม่นยำขึ้น',

    'quote.q6.title': 'ข้อมูลติดต่อกลับ',
    'quote.field.name': 'ชื่อ-นามสกุล',
    'quote.field.namePlaceholder': 'คุณ...',
    'quote.field.phone': 'เบอร์โทร',
    'quote.field.email': 'Email',
    'quote.field.company': 'บริษัท/หน่วยงาน',
    'quote.field.companyPlaceholder': '(ถ้ามี)',

    'quote.contactPref.label': 'ช่องทางที่สะดวกให้ติดต่อกลับ',
    'quote.contactPref.line': 'LINE',
    'quote.contactPref.phone': 'โทรศัพท์',
    'quote.contactPref.email': 'Email',

    'quote.summary.title': 'REQUEST SUMMARY',
    'quote.summary.type': 'ประเภท',
    'quote.summary.qty': 'จำนวน',
    'quote.summary.timeline': 'เวลา',
    'quote.summary.print': 'พิมพ์/ปัก',
    'quote.summary.empty': '—',

    'quote.nav.back': '← ย้อนกลับ',
    'quote.nav.next': 'ถัดไป →',
    'quote.nav.submit': 'ส่งคำขอ →',
    'quote.nav.sending': 'กำลังส่ง...',
    'quote.step.indicator': 'STEP',
    'quote.questionPrefix': 'QUESTION',
    'quote.error.title': 'ส่งคำขอไม่สำเร็จ',
    'quote.error.body': 'เกิดข้อผิดพลาดชั่วคราว กรุณาลองอีกครั้ง หรือทัก LINE @fenixuniform โดยตรง',
    'quote.error.retry': 'ลองอีกครั้ง',

    'quote.foot.free.label': 'FREE',
    'quote.foot.free.body': 'ใบเสนอราคาฟรี ไม่มีข้อผูกมัด',
    'quote.foot.secure.label': 'SECURE',
    'quote.foot.secure.body': 'ข้อมูลของคุณจะไม่ถูกเปิดเผย',
    'quote.foot.fast.label': 'FAST',
    'quote.foot.fast.body': 'ตอบกลับภายใน 30 นาที',

    'quote.success.eyebrow': 'REQUEST RECEIVED',
    'quote.success.headline': 'ส่งคำขอเรียบร้อย',
    'quote.success.thanks.prefix': 'ขอบคุณ ',
    'quote.success.thanks.suffix': ' ครับ',
    'quote.success.message.prefix': 'ทีมเราจะติดต่อกลับทาง ',
    'quote.success.message.suffix': ' ภายใน 30 นาที',
    'quote.success.backHome': 'กลับหน้าหลัก',
    'quote.success.lineNow': 'ทัก LINE ทันที →',
  },

  en: {
    // Nav
    'nav.catalog': 'Catalog',
    'nav.portfolio': 'Portfolio',
    'nav.process': 'Process',
    'nav.about': 'About',
    'nav.contact': 'Contact',
    'cta.requestQuote': 'Get a Quote →',

    // Hero
    'hero.eyebrow': 'EST. 2014 · BANGKOK',
    'hero.h1.l1': 'BUILT TO',
    'hero.h1.l2': 'PERFORM',
    'hero.lede': 'A factory making uniforms, apparel, pants, and caps.\nMade-to-spec, world-class quality, shipped straight from our floor — no middlemen, fair pricing, small or large runs welcome.',
    'hero.cta.catalog': 'View Catalog →',
    'hero.cta.contact': 'Talk to Sales',
    'hero.clientsSuffix': 'clients nationwide',
    'hero.minOrder': 'MIN. ORDER',
    'hero.minOrderValue': '12 PCS',
    'hero.leadTime': 'LEAD TIME',
    'hero.leadTimeValue': '7-14 D',
    'hero.tag': 'SS-26 / TEAM JERSEY',
    'hero.live': 'LIVE PRODUCTION',
    'hero.heroProductLabel': 'HERO PRODUCT SHOT',

    // Catalog
    'catalog.section': 'E-CATALOG',
    'catalog.headline.l1': 'Pick a category,',
    'catalog.headline.l2': 'view styles, order',
    'catalog.subhead': 'Every style is customizable — add your logo, change colors, swap fabrics. Download the full catalog as PDF, or message us on LINE for monthly drops.',
    'catalog.downloadPdf': 'Download PDF →',
    'catalog.category': 'CATEGORY',
    'catalog.priceFrom': 'from',
    'catalog.priceUnit': '฿',
    'catalog.tag.bestseller': 'BEST SELLER',
    'catalog.tag.new': 'NEW',
    'catalog.view': 'VIEW →',

    'catalog.uniform.label': 'Uniforms',
    'catalog.uniform.desc': 'Office, factory, and corporate workwear — sharp and durable.',
    'catalog.shirt.label': 'T-shirts / Team',
    'catalog.shirt.desc': 'Sport jerseys, event tees, screen-printed shirts — crew or v-neck.',
    'catalog.pants.label': 'Pants',
    'catalog.pants.desc': 'Workpants, athletic shorts, tactical — every size, made to order.',
    'catalog.cap.label': 'Caps',
    'catalog.cap.desc': 'Caps, truckers, buckets — embroidered or screen-printed.',

    'process.01.title': 'Brief & Concept',
    'process.01.subtitle': 'Send specs / ideas',
    'process.02.title': 'Sample',
    'process.02.subtitle': '3-5 days turnaround',
    'process.03.title': 'Production',
    'process.03.subtitle': 'Made to order',
    'process.04.title': 'Delivery',
    'process.04.subtitle': 'QC & ship',

    // Portfolio
    'portfolio.section': 'CLIENT WORK',
    'portfolio.headline.l1': 'Real client',
    'portfolio.headline.l2': 'projects',
    'portfolio.case': 'CASE',
    'portfolio.featured': 'FEATURED CASE',
    'portfolio.pieces': 'PIECES',
    'portfolio.pieces.unit': 'pcs',
    'portfolio.projectType': 'PROJECT TYPE',
    'portfolio.delivery': 'DELIVERY',
    'portfolio.fabric': 'FABRIC',
    'portfolio.print': 'PRINT',
    'portfolio.deliveryValue': '12 days',
    'portfolio.fabricValue': 'Premium',
    'portfolio.printValue': 'DTG + Embroidery',

    'portfolio.0.client': 'SC Technology',
    'portfolio.0.type': 'Shop coat + cap',
    'portfolio.0.quote': 'Spot-on to spec, fast delivery — and the team patiently iterated on the pattern with us.',
    'portfolio.0.person': 'Nitipon · HR Manager',
    'portfolio.1.client': 'Futsal THUNDER',
    'portfolio.1.type': 'Pro jersey + shorts',
    'portfolio.1.quote': 'Breathable fabric, colors do not fade — full season in and they still look new.',
    'portfolio.1.person': 'Chang · Captain',
    'portfolio.2.client': 'Café Naranja',
    'portfolio.2.type': 'Apron + tee + cap',
    'portfolio.2.quote': 'Minimal design exactly as we wanted — every staff member looks proper in them.',
    'portfolio.2.person': 'K. Mint · Owner',
    'portfolio.3.client': 'Satit School',
    'portfolio.3.type': 'P.E. uniform set',
    'portfolio.3.quote': 'Survives machine wash, no fading — parents love them.',
    'portfolio.3.person': 'Mr. Piyawat · Principal',

    // About
    'about.section': 'ABOUT FENIX',
    'about.headline.l1': '12 years',
    'about.headline.l2': 'stitching',
    'about.headline.l3': 'trust',
    'about.headline.l4': 'into every seam.',
    'about.body.p1.before': 'FENIX UNIFORM started as a small workshop in Bang Bon in 2014, with two sewing machines and a stubborn commitment to making clothes that ',
    'about.body.p1.highlight': '"actually wear and last."',
    'about.body.p2': 'Today, we run 3 affiliated factories with 80,000 pcs/month capacity — serving sports teams, corporates, schools, and shops nationwide. Triple-layer QC and an in-house design team back every order.',

    'about.stat.years': 'years in business',
    'about.stat.clients': 'clients nationwide',
    'about.stat.capacity': 'pcs / month',
    'about.stat.ontime': 'on-time delivery',

    'about.value.01.title': 'Premium fabric',
    'about.value.01.body': 'Sourced from top mills, lab-tested before every production run.',
    'about.value.02.title': 'In-house design',
    'about.value.02.body': '6 designers on staff. Unlimited revisions until you are happy.',
    'about.value.03.title': 'Triple QC',
    'about.value.03.body': 'Every piece is inspected — before cutting, before stitching, before shipping.',

    // Contact
    'contact.section': 'GET IN TOUCH',
    'contact.headline.l1': 'Ready to start',
    'contact.headline.l2': 'your project',
    'contact.headline.l3': 'today',
    'contact.subhead': 'Pick the channel that works for you, or fill out the detailed quote form. We reply within 30 minutes (Mon–Sat, 9:00 AM – 6:00 PM).',
    'contact.cta': 'Get a Quote',
    'contact.formCode': 'FORM-26-A · ~90 seconds to complete',
    'contact.openChannel': 'Open channel',

    'contact.line.label': 'LINE OFFICIAL',
    'contact.line.sub': 'Always on, fastest reply',
    'contact.phone.label': 'PHONE',
    'contact.phone.sub': 'Mon–Sat 9:00–18:00',
    'contact.email.label': 'EMAIL',
    'contact.email.sub': 'Send specs / files directly',
    'contact.factory.label': 'FACTORY',
    'contact.factory.value': 'Bang Bon, Bangkok',
    'contact.factory.sub': 'Schedule a factory tour',

    // Footer
    'footer.tagline': 'A factory making uniforms and ready-to-wear apparel — made to spec and shipped straight to clients. No middlemen.',
    'footer.catalog.uniform': 'Corporate uniforms',
    'footer.catalog.shirt': 'T-shirts / Team',
    'footer.catalog.pants': 'Pants',
    'footer.catalog.cap': 'Caps',
    'footer.address': 'Bang Bon, Bangkok',

    // Quote page
    'quote.back': '← Back to home',
    'quote.eyebrow': 'FORM-26-A · QUOTE REQUEST',
    'quote.headline.l1': 'Request a',
    'quote.headline.l2': 'quote',
    'quote.responseTime': 'RESPONSE TIME',
    'quote.responseTimeValue': '≤ 30 min',
    'quote.responseHours': 'Mon–Sat 9:00–18:00',

    'quote.step.0': 'Product type',
    'quote.step.1': 'Details',
    'quote.step.2': 'Contact',

    'quote.q1.title': 'What products are you looking for?',
    'quote.q1.subtitle': 'Pick one or more',
    'quote.types.uniform': 'Corporate uniforms',
    'quote.types.uniform.desc': 'Staff, factory, retail',
    'quote.types.shirt': 'T-shirts / Team',
    'quote.types.shirt.desc': 'Team, sports, events',
    'quote.types.pants': 'Pants',
    'quote.types.pants.desc': 'Long, short, cargo',
    'quote.types.cap': 'Caps',
    'quote.types.cap.desc': 'Cap, trucker, bucket',

    'quote.q2.title': 'How many do you need?',
    'quote.qty.unit': 'pcs',

    'quote.q3.title': 'Timeline?',
    'quote.timeline.urgent': 'Urgent (≤7 days)',
    'quote.timeline.normal': 'Normal (7-14 days)',
    'quote.timeline.relaxed': 'Flexible (14-30 days)',
    'quote.timeline.none': 'Not set yet',

    'quote.q4.title': 'Print / embroidery technique',
    'quote.q4.subtitle': 'Pick more than one (or leave blank and we will suggest)',
    'quote.print.screen': 'Screen print',
    'quote.print.embroidery': 'Embroidery',
    'quote.print.dtg': 'DTG',
    'quote.print.sublimation': 'Sublimation',
    'quote.print.unsure': 'Not sure yet',

    'quote.q5.title': 'Anything else?',
    'quote.q5.placeholder': 'Logo placement, sizing, colors, fabric, or reference image links — anything that helps.',
    'quote.q5.tip': '💡 The more detail, the more accurate the quote.',

    'quote.q6.title': 'How can we reach you?',
    'quote.field.name': 'Full name',
    'quote.field.namePlaceholder': 'Your name',
    'quote.field.phone': 'Phone',
    'quote.field.email': 'Email',
    'quote.field.company': 'Company / org',
    'quote.field.companyPlaceholder': '(if any)',

    'quote.contactPref.label': 'Preferred reply channel',
    'quote.contactPref.line': 'LINE',
    'quote.contactPref.phone': 'Phone',
    'quote.contactPref.email': 'Email',

    'quote.summary.title': 'REQUEST SUMMARY',
    'quote.summary.type': 'Type',
    'quote.summary.qty': 'Qty',
    'quote.summary.timeline': 'Timeline',
    'quote.summary.print': 'Print',
    'quote.summary.empty': '—',

    'quote.nav.back': '← Back',
    'quote.nav.next': 'Next →',
    'quote.nav.submit': 'Submit →',
    'quote.nav.sending': 'Sending...',
    'quote.step.indicator': 'STEP',
    'quote.questionPrefix': 'QUESTION',
    'quote.error.title': 'Submission failed',
    'quote.error.body': 'Something went wrong. Please try again, or message us on LINE @fenixuniform.',
    'quote.error.retry': 'Try again',

    'quote.foot.free.label': 'FREE',
    'quote.foot.free.body': 'Free quote, no obligation',
    'quote.foot.secure.label': 'SECURE',
    'quote.foot.secure.body': 'Your info stays private',
    'quote.foot.fast.label': 'FAST',
    'quote.foot.fast.body': 'Reply within 30 minutes',

    'quote.success.eyebrow': 'REQUEST RECEIVED',
    'quote.success.headline': 'Request submitted',
    'quote.success.thanks.prefix': 'Thanks ',
    'quote.success.thanks.suffix': '.',
    'quote.success.message.prefix': 'We will get back to you on ',
    'quote.success.message.suffix': ' within 30 minutes.',
    'quote.success.backHome': 'Back to home',
    'quote.success.lineNow': 'Message LINE now →',
  },
};

const translateKey = (lang, key) => {
  const tr = TR[lang] && TR[lang][key];
  if (tr != null) return tr;
  const fb = TR[FENIX_LANG_DEFAULT][key];
  return fb != null ? fb : key;
};

window.useLang = () => {
  const lang = useSyncExternalStoreI18n(langStore.subscribe, langStore.get, () => FENIX_LANG_DEFAULT);
  const t = (key) => translateKey(lang, key);
  return { lang, setLang: langStore.set, t };
};

window.Multi = ({ text }) => {
  if (text == null) return null;
  const lines = String(text).split('\n');
  return lines.map((line, i) => (
    <React.Fragment key={i}>
      {i > 0 && <br />}
      {line}
    </React.Fragment>
  ));
};

window.LangSwitch = ({ accent, compact }) => {
  const { lang, setLang } = window.useLang();
  return (
    <div
      className="flex items-center gap-1 font-mono text-[10px] tracking-[0.2em] uppercase select-none"
      role="group"
      aria-label="Language"
    >
      {FENIX_LANGS.map((code) => {
        const active = lang === code;
        return (
          <button
            key={code}
            type="button"
            onClick={() => setLang(code)}
            aria-pressed={active}
            aria-label={code === 'th' ? 'ภาษาไทย' : 'English'}
            className={`px-2.5 ${compact ? 'py-1' : 'py-1.5'} border transition uppercase`}
            style={{
              background: active ? accent : 'transparent',
              color: active ? '#0a0a0a' : 'rgba(255,255,255,0.7)',
              borderColor: active ? accent : 'rgba(255,255,255,0.18)',
              fontWeight: active ? 700 : 500,
            }}
          >
            {code}
          </button>
        );
      })}
    </div>
  );
};
