"""Vietnamese / English strings."""

T = {
    "vi": {
        "welcome": (
            "👋 Chào mừng bạn đến với <b>{shop}</b>\n\n"
            "⚡ Giao dịch siêu tốc\n💎 Bảo hành trọn đời\n🛡 Nạp tiền tự động 24/7\n\n"
            "👇 Chọn chức năng bên dưới:"
        ),
        "menu_products": "🛒 Danh sách sản phẩm",
        "menu_search": "🔍 Tìm sản phẩm",
        "menu_topup": "💰 Nạp tiền",
        "menu_balance": "👛 Số dư",
        "menu_lang": "🌐 Ngôn ngữ",
        "menu_ref": "🎁 Giới thiệu bạn bè",
        "menu_support": "💬 Hỗ trợ",
        "menu_coupon": "🎟 Nhập mã giảm giá",
        "menu_orders": "📦 Đơn hàng của tôi",
        "menu_back": "◀️ Quay lại",
        "menu_home": "🏠 Trang chủ",
        "lang_chosen": "✅ Đã chọn Tiếng Việt.",
        "categories": "👑 <b>DANH MỤC SẢN PHẨM</b> 👑\n<i>Uy tín · Nhanh chóng · Hỗ trợ tận tâm</i>\n\nChọn danh mục:",
        "no_categories": "Shop chưa có danh mục nào.",
        "products_title": "🛍 <b>{cat}</b>\nTrang {page}/{pages} · {total} sản phẩm",
        "no_products": "Danh mục này chưa có sản phẩm.",
        "product_card": (
            "🏷 <b>{name}</b>\n\n"
            "💵 Giá: <b>{price}</b>\n"
            "📦 Còn: <b>{stock}</b>\n\n"
            "{desc}"
        ),
        "buy_now": "🛒 Mua ngay",
        "out_of_stock": "❌ Hết hàng",
        "prev": "◀️ Trước",
        "next": "Sau ▶️",
        "back_cat": "◀️ Danh mục",
        "search_prompt": "🔍 Nhập tên sản phẩm bạn muốn tìm:",
        "search_empty": "Không tìm thấy sản phẩm nào với từ khóa <b>{q}</b>.",
        "search_result": "🔍 Kết quả cho <b>{q}</b>:",
        "balance": (
            "👛 <b>TÀI KHOẢN</b>\n\n"
            "🆔 ID: <code>{uid}</code>\n"
            "💠 Cấp bậc: {tier}\n"
            "💰 Số dư: <b>{balance}</b>\n"
            "📦 Đơn hàng: {orders}\n"
            "🎁 Đã giới thiệu: {refs} người"
        ),
        "tier_new": "Thành viên",
        "tier_vip": "VIP",
        "topup_title": "💰 <b>NẠP TIỀN VÀO VÍ</b>\n\nChọn mệnh giá hoặc nhập số tiền:",
        "topup_custom": "✏️ Nhập số tiền khác",
        "topup_enter": "Nhập số tiền muốn nạp (tối thiểu {min}đ):",
        "topup_invalid": "❌ Số tiền không hợp lệ. Nhập lại (tối thiểu {min}đ):",
        "topup_too_small": "❌ Số tiền tối thiểu là {min}đ.",
        "topup_invoice": (
            "🧾 <b>THÔNG TIN CHUYỂN KHOẢN</b>\n\n"
            "💵 Số tiền: <b>{amount}</b>\n"
            "🏦 Ngân hàng: <b>{bank}</b>\n"
            "🔢 Số tài khoản: <code>{account}</code>\n"
            "👤 Chủ tài khoản: <b>{holder}</b>\n"
            "📝 Nội dung CK: <code>{code}</code>\n\n"
            "⚠️ Chuyển <b>đúng số tiền</b> và <b>đúng nội dung</b>.\n"
            "{note}\n\n"
            "⏳ Sau khi chuyển, bấm nút bên dưới nếu quá 2 phút chưa thấy tiền."
        ),
        "topup_note_default": "Hệ thống tự động cộng tiền sau 10-60 giây.",
        "topup_check": "🔄 Tôi đã chuyển khoản",
        "topup_check_sent": "⏳ Đã ghi nhận. Hệ thống đang kiểm tra, tiền sẽ vào ví ngay khi giao dịch được xác nhận.",
        "topup_no_bank": "⚠️ Shop chưa cấu hình tài khoản nhận tiền. Vui lòng liên hệ hỗ trợ.",
        "topup_paid": "✅ <b>Nạp tiền thành công!</b>\n\n💵 +{amount}\n👛 Số dư mới: <b>{balance}</b>",
        "topup_pending": "⏳ Bạn đang có lệnh nạp <b>{amount}</b> chưa thanh toán.\nMã: <code>{code}</code>\n\nChuyển khoản xong tiền sẽ tự vào ví.",
        "coupon_prompt": "🎟 Nhập mã giảm giá của bạn:",
        "coupon_ok": "✅ Đã lưu mã <b>{code}</b>. Mã sẽ được áp dụng khi bạn mua hàng.",
        "coupon_bad": "❌ Mã không hợp lệ hoặc đã hết lượt.",
        "coupon_none": "Bạn chưa có mã giảm giá nào.",
        "confirm_buy": (
            "🧾 <b>XÁC NHẬN ĐƠN HÀNG</b>\n\n"
            "🏷 {name}\n"
            "💵 Giá: {price}\n"
            "{discount_line}"
            "💰 Thanh toán: <b>{total}</b>\n"
            "👛 Số dư hiện tại: {balance}\n\n"
            "Xác nhận mua?"
        ),
        "discount_line": "🎟 Giảm giá: -{discount}\n",
        "buy_ok": "✅ <b>Mua thành công!</b>\n\n🏷 {name}\n🧾 Mã đơn: <b>#{oid}</b>\n\n📦 <b>Sản phẩm của bạn:</b>\n<code>{content}</code>\n\n💎 Bảo hành trọn đời. Cần hỗ trợ bấm 💬 Hỗ trợ.",
        "buy_no_money": "❌ Số dư không đủ.\n\nCần: <b>{need}</b>\nĐang có: <b>{have}</b>\n\n👇 Nạp thêm tiền để mua ngay.",
        "buy_oos": "❌ Sản phẩm đã hết hàng. Vui lòng chọn sản phẩm khác.",
        "buy_cancel": "Đã huỷ đơn.",
        "ref_info": (
            "🎁 <b>GIỚI THIỆU BẠN BÈ</b>\n\n"
            "Mời bạn bè vào shop bằng link dưới đây.\n"
            "Mỗi người bạn mua hàng, bạn nhận <b>{percent}%</b> giá trị đơn.\n\n"
            "🔗 Link của bạn:\n<code>{link}</code>\n\n"
            "👥 Đã giới thiệu: <b>{count}</b> người"
        ),
        "ref_new_user": "🎉 Bạn được mời bởi <b>{name}</b>.",
        "ref_earn": "🎉 <b>Hoa hồng giới thiệu!</b>\n\n👤 {name} vừa mua hàng.\n💰 Bạn nhận: <b>+{amount}</b>",
        "support_prompt": "💬 Nhập nội dung cần hỗ trợ, shop sẽ phản hồi sớm nhất:",
        "support_sent": "✅ Đã gửi tới shop. Vui lòng chờ phản hồi.",
        "support_none": "Shop chưa cấu hình kênh hỗ trợ.",
        "orders_title": "📦 <b>ĐƠN HÀNG CỦA BẠN</b>\n",
        "orders_empty": "Bạn chưa có đơn hàng nào.",
        "order_line": "#{oid} · {name} · {total} · {date}\n",
        "banned": "⛔ Tài khoản của bạn đang bị tạm khoá.",
        "unknown": "Mình chưa hiểu ý bạn. Bấm /start để mở menu nhé.",
        "cancelled": "Đã huỷ.",
        "yes": "✅ Xác nhận",
        "no": "❌ Huỷ",
    },
    "en": {
        "welcome": (
            "👋 Welcome to <b>{shop}</b>\n\n"
            "⚡ Instant delivery\n💎 Lifetime warranty\n🛡 24/7 auto top-up\n\n"
            "👇 Choose an option below:"
        ),
        "menu_products": "🛒 Products",
        "menu_search": "🔍 Search product",
        "menu_topup": "💰 Top up",
        "menu_balance": "👛 Balance",
        "menu_lang": "🌐 Language",
        "menu_ref": "🎁 Refer friends",
        "menu_support": "💬 Support",
        "menu_coupon": "🎟 Enter coupon",
        "menu_orders": "📦 My orders",
        "menu_back": "◀️ Back",
        "menu_home": "🏠 Home",
        "lang_chosen": "✅ English selected.",
        "categories": "👑 <b>PRODUCT CATEGORIES</b> 👑\n\nChoose a category:",
        "no_categories": "No categories yet.",
        "products_title": "🛍 <b>{cat}</b>\nPage {page}/{pages} · {total} products",
        "no_products": "No products in this category.",
        "product_card": "🏷 <b>{name}</b>\n\n💵 Price: <b>{price}</b>\n📦 In stock: <b>{stock}</b>\n\n{desc}",
        "buy_now": "🛒 Buy now",
        "out_of_stock": "❌ Out of stock",
        "prev": "◀️ Prev",
        "next": "Next ▶️",
        "back_cat": "◀️ Categories",
        "search_prompt": "🔍 Type the product name:",
        "search_empty": "No product found for <b>{q}</b>.",
        "search_result": "🔍 Results for <b>{q}</b>:",
        "balance": (
            "👛 <b>MY ACCOUNT</b>\n\n"
            "🆔 ID: <code>{uid}</code>\n"
            "💠 Tier: {tier}\n"
            "💰 Balance: <b>{balance}</b>\n"
            "📦 Orders: {orders}\n"
            "🎁 Referred: {refs}"
        ),
        "tier_new": "Member",
        "tier_vip": "VIP",
        "topup_title": "💰 <b>TOP UP WALLET</b>\n\nPick an amount or enter your own:",
        "topup_custom": "✏️ Custom amount",
        "topup_enter": "Enter amount (min {min}):",
        "topup_invalid": "❌ Invalid amount. Try again (min {min}):",
        "topup_too_small": "❌ Minimum amount is {min}.",
        "topup_invoice": (
            "🧾 <b>BANK TRANSFER DETAILS</b>\n\n"
            "💵 Amount: <b>{amount}</b>\n"
            "🏦 Bank: <b>{bank}</b>\n"
            "🔢 Account: <code>{account}</code>\n"
            "👤 Holder: <b>{holder}</b>\n"
            "📝 Content: <code>{code}</code>\n\n"
            "⚠️ Transfer the <b>exact amount</b> with the <b>exact content</b>.\n"
            "{note}\n\n"
            "⏳ If money does not arrive within 2 minutes, press the button below."
        ),
        "topup_note_default": "Funds are credited automatically within 10-60 seconds.",
        "topup_check": "🔄 I have transferred",
        "topup_check_sent": "⏳ Noted. We are checking; your balance will update once confirmed.",
        "topup_no_bank": "⚠️ Bank details are not configured yet. Please contact support.",
        "topup_paid": "✅ <b>Top-up successful!</b>\n\n💵 +{amount}\n👛 New balance: <b>{balance}</b>",
        "topup_pending": "⏳ You have a pending top-up of <b>{amount}</b>.\nCode: <code>{code}</code>",
        "coupon_prompt": "🎟 Enter your coupon code:",
        "coupon_ok": "✅ Coupon <b>{code}</b> saved. It will apply on your next purchase.",
        "coupon_bad": "❌ Invalid or expired coupon.",
        "coupon_none": "You have no coupon.",
        "confirm_buy": (
            "🧾 <b>ORDER CONFIRMATION</b>\n\n"
            "🏷 {name}\n💵 Price: {price}\n{discount_line}"
            "💰 Total: <b>{total}</b>\n👛 Balance: {balance}\n\nConfirm?"
        ),
        "discount_line": "🎟 Discount: -{discount}\n",
        "buy_ok": "✅ <b>Purchase successful!</b>\n\n🏷 {name}\n🧾 Order: <b>#{oid}</b>\n\n📦 <b>Your product:</b>\n<code>{content}</code>\n\n💎 Lifetime warranty.",
        "buy_no_money": "❌ Insufficient balance.\n\nNeed: <b>{need}</b>\nHave: <b>{have}</b>",
        "buy_oos": "❌ Out of stock. Please choose another product.",
        "buy_cancel": "Order cancelled.",
        "ref_info": "🎁 <b>REFER FRIENDS</b>\n\nShare your link. You earn <b>{percent}%</b> of every order your friends make.\n\n🔗 <code>{link}</code>\n\n👥 Referred: <b>{count}</b>",
        "ref_new_user": "🎉 You were invited by <b>{name}</b>.",
        "ref_earn": "🎉 <b>Referral commission!</b>\n\n👤 {name} just purchased.\n💰 You earned: <b>+{amount}</b>",
        "support_prompt": "💬 Type your message for support:",
        "support_sent": "✅ Sent to the shop. Please wait for a reply.",
        "support_none": "Support channel is not configured.",
        "orders_title": "📦 <b>MY ORDERS</b>\n",
        "orders_empty": "You have no orders yet.",
        "order_line": "#{oid} · {name} · {total} · {date}\n",
        "banned": "⛔ Your account is temporarily blocked.",
        "unknown": "I did not get that. Send /start to open the menu.",
        "cancelled": "Cancelled.",
        "yes": "✅ Confirm",
        "no": "❌ Cancel",
    },
}


def t(lang, key, **kw):
    table = T.get(lang) or T["vi"]
    s = table.get(key) or T["vi"].get(key) or key
    try:
        return s.format(**kw)
    except Exception:
        return s


def money(v):
    try:
        return "{:,}".format(int(v)).replace(",", ".") + "đ"
    except Exception:
        return str(v)
