"""Troubleshooting tips and 'frequently bought together' rules per product type."""

TROUBLE = {
    "ram": [("Computer beeps or won't start after installing", "Reseat the module firmly until the clips lock; try one stick at a time to find a faulty one."),
            ("Windows shows less RAM than installed", "The module may not be seated, or the generation/speed isn't supported. Check in Task Manager and reseat."),
            ("Random blue screens", "Run Windows Memory Diagnostic. If errors appear, the module or slot is faulty: we replace faulty modules under warranty.")],
    "storage": [("New drive not visible in File Explorer", "Open Disk Management, initialise the disk (GPT) and create a new volume."),
                ("Laptop doesn't boot after swapping drives", "Set the new drive as the first boot device in BIOS, or let us clone your old drive."),
                ("Drive slower than expected", "Check it's in the correct slot/port (NVMe slot, SATA III port) and that AHCI mode is enabled in BIOS.")],
    "printer": [("Printer shows offline", "Check the cable or Wi-Fi connection, restart the printer and set it as default in Windows Printers & scanners."),
                ("Faded or streaky prints", "Run a nozzle check and head clean (ink) or replace the toner/ribbon (laser/dot matrix)."),
                ("Paper jams", "Use dry, flat paper of the right size and don't overfill the tray.")],
    "pos": [("Receipt printer not printing from POS", "Check the printer is selected in POS settings and the paper roll is loaded with the coated side to the head."),
            ("Cash drawer won't open", "Confirm the RJ11 cable is in the printer's drawer port and 'open drawer' is enabled in your POS."),
            ("Scanner types wrong characters", "Scan the keyboard-language configuration barcode in the manual to match your Windows keyboard layout.")],
    "labels": [("Printer skips labels or prints across gaps", "Run label calibration so the sensor detects the gaps."),
               ("Barcodes won't scan", "Increase print darkness slightly and check the label size matches your template."),
               ("Print fades over time", "Direct-thermal labels fade with heat and light; use thermal-transfer labels with a ribbon for long life.")],
    "security": [("Alarm sounds on paid items", "The tag wasn't removed or the label wasn't deactivated at the till; re-check the item."),
                 ("False alarms with no tagged items", "Move metal displays and electronics away from the antennas and have the system re-tuned."),
                 ("Tag won't release", "Place the tag dome fully in the detacher cup; super-lock tags need a stronger detacher.")],
    "access": [("Fingerprint not recognised", "Clean the sensor and re-enrol the finger with 2–3 samples; dry or worn fingers do better on face models."),
               ("Door doesn't lock", "Check power to the maglock and that the plate aligns fully with the magnet."),
               ("Reports missing records", "Sync the device with the software or check the network connection.")],
    "power": [("UPS beeps continuously", "It's on battery or overloaded: check mains power and unplug non-essential devices."),
              ("Backup time is very short", "The battery has aged; batteries typically need replacing every 2–3 years."),
              ("Extension trips the breaker", "The total load is too high; move heaters, kettles or irons to a separate socket.")],
    "business": [("Machine stops counting or jams", "Remove damaged or folded notes and clean the rollers and sensors."),
                 ("Counterfeit alarm on genuine notes", "Clean the sensors and update the firmware for the latest note series."),
                 ("Display or printer shows errors", "Restart the unit and check cables and paper; contact us with the error code.")],
    "audio": [("Device won't pair", "Turn Bluetooth off and on, forget the device on your phone and pair again in pairing mode."),
              ("Short battery life", "Charge fully before first use and avoid leaving it completely flat for long periods."),
              ("Sound cuts in and out", "Keep within about 10 m of your phone, away from walls and microwaves.")],
    "cable": [("No picture on the screen", "Select the correct input on the screen and press Win + P on Windows to choose Duplicate or Extend."),
              ("HDMI from USB-C doesn't work", "Your laptop's USB-C port may not support video; look for a DisplayPort or Thunderbolt symbol."),
              ("Flickering picture", "Try a shorter or higher-quality cable and make sure connectors are pushed fully in.")],
    "accessory": [("Device not detected", "Try another USB port and restart the computer."),
                  ("Charger not charging", "Check the connector and wattage match your device, and inspect the cable for damage."),
                  ("Poor fit", "Check the size or model compatibility in the product name; we'll exchange unused items in original condition.")],
    "monitor": [("No signal", "Check the cable at both ends and choose the correct input source on the monitor."),
                ("Blurry text", "Set Windows to the monitor's native resolution in Display settings."),
                ("Screen goes black randomly", "Check the power cable and try a different video cable.")],
    "cctv": [("Camera offline in the app", "Check Wi-Fi signal at the camera location and battery level."),
             ("Poor night image", "Clean the lens and avoid pointing it at bright lights."),
             ("Battery drains fast", "Reduce motion sensitivity and make sure the solar panel gets direct sun.")],
}

TYPE_GROUP = {
    "ram": "ram", "nvme": "storage", "m2sata": "storage", "msata": "storage", "sata25": "storage", "hdd": "storage",
    "storage_adapter": "storage", "monitor": "monitor", "inktank": "printer", "laser": "printer", "inkjet": "printer",
    "dotmatrix": "printer", "dotpaper": "printer", "pos_terminal": "pos", "pos_screen": "pos", "barcode_scanner": "pos",
    "receipt_printer": "pos", "barcode_printer": "labels", "cash_drawer": "pos", "msr": "pos", "power_adapter": "accessory",
    "labels": "labels", "ribbon": "labels", "thermal_roll": "pos", "coding_ink": "business", "tape": "accessory",
    "mag_cards": "pos", "eas_tag": "security", "eas_label": "security", "detacher": "security", "deactivator": "security",
    "eas_system": "security", "safe": "security", "site_security": "security", "fingerprint_reader": "access",
    "attendance": "access", "hotel_lock": "access", "door_hw": "access", "ups": "power", "extension": "power",
    "power_cable": "power", "money_counter": "business", "queue": "business", "label_maker": "labels",
    "price_labeler": "labels", "card_printer": "business", "batch_coder": "business", "projector": "cable",
    "office_tool": "accessory", "speaker": "audio", "earphones": "audio", "tablet": "audio", "tv_stick": "audio",
    "creator": "audio", "video_cable": "cable", "usbc_hub": "cable", "network": "cable", "bag": "accessory",
    "charger": "accessory", "keyboard_repl": "accessory", "webcam": "accessory", "presenter": "accessory",
    "ergonomic": "monitor", "input": "accessory", "cctv_cam": "cctv", "general": "accessory",
}

# type key -> list of (category, keyword in name) to suggest as add-ons
BUNDLES = {
    "ram": [("storage", "2.5"), ("cables-networking", "sata")],
    "nvme": [("cables-networking", "enclosure"), ("ram", "laptop ram")],
    "m2sata": [("ram", "laptop ram"), ("cables-networking", "enclosure")],
    "msata": [("ram", "laptop ram"), ("cables-networking", "sata")],
    "sata25": [("cables-networking", "sata"), ("ram", "ram")],
    "hdd": [("cables-networking", "enclosure"), ("storage", "ssd")],
    "monitor": [("cables-networking", "hdmi"), ("accessories", "stand"), ("ups-power", "ups")],
    "inktank": [("ups-power", "extension"), ("cables-networking", "usb")],
    "laser": [("ups-power", "extension"), ("printers", "smart tank")],
    "inkjet": [("ups-power", "extension")],
    "dotmatrix": [("printers", "carbonless"), ("pos-supplies", "carbonless"), ("ups-power", "ups")],
    "dotpaper": [("printers", "dot matrix"), ("printers", "lq-350")],
    "pos_terminal": [("pos-systems", "receipt printer"), ("pos-systems", "barcode scanner"), ("pos-systems", "cash drawer"), ("ups-power", "ups")],
    "pos_screen": [("pos-systems", "pos terminal"), ("pos-systems", "receipt printer")],
    "barcode_scanner": [("pos-systems", "receipt printer"), ("pos-supplies", "barcode labels"), ("pos-systems", "cash drawer")],
    "receipt_printer": [("pos-supplies", "thermal"), ("pos-systems", "cash drawer"), ("pos-systems", "barcode scanner")],
    "barcode_printer": [("pos-supplies", "labels"), ("pos-supplies", "ribbon"), ("pos-systems", "barcode scanner")],
    "cash_drawer": [("pos-systems", "receipt printer"), ("pos-systems", "pos terminal")],
    "msr": [("pos-supplies", "stripe cards"), ("business-equipment", "card printer")],
    "labels": [("pos-systems", "barcode printer"), ("pos-supplies", "ribbon"), ("pos-systems", "barcode scanner")],
    "ribbon": [("pos-supplies", "labels"), ("pos-systems", "barcode printer")],
    "thermal_roll": [("pos-systems", "receipt printer"), ("pos-systems", "cash drawer")],
    "coding_ink": [("business-equipment", "expiry")],
    "mag_cards": [("pos-systems", "msr"), ("business-equipment", "card printer")],
    "eas_tag": [("security-equipment", "detacher"), ("security-equipment", "antitheft system")],
    "eas_label": [("security-equipment", "deactivator"), ("security-equipment", "antitheft system")],
    "detacher": [("security-equipment", "hard tag"), ("security-equipment", "bottle")],
    "deactivator": [("security-equipment", "soft labels"), ("security-equipment", "antitheft system")],
    "eas_system": [("security-equipment", "hard tag"), ("security-equipment", "detacher"), ("security-equipment", "deactivator")],
    "safe": [("business-equipment", "money counter")],
    "fingerprint_reader": [("biometric-time-attendance", "attendance")],
    "attendance": [("biometric-time-attendance", "maglock"), ("biometric-time-attendance", "push to exit"), ("ups-power", "ups")],
    "hotel_lock": [("biometric-time-attendance", "hotel"), ("pos-supplies", "stripe cards")],
    "door_hw": [("biometric-time-attendance", "attendance"), ("biometric-time-attendance", "door")],
    "ups": [("ups-power", "extension"), ("ups-power", "power cable")],
    "extension": [("ups-power", "ups")],
    "power_cable": [("ups-power", "extension")],
    "money_counter": [("security-equipment", "safe")],
    "queue": [("business-equipment", "qms"), ("pos-supplies", "thermal paper")],
    "label_maker": [("pos-supplies", "labels")],
    "price_labeler": [("pos-supplies", "price labels")],
    "card_printer": [("pos-supplies", "stripe cards"), ("pos-systems", "msr")],
    "projector": [("cables-networking", "hdmi"), ("accessories", "presentation remote")],
    "speaker": [("audio-gadgets", "earbuds"), ("audio-gadgets", "tv")],
    "earphones": [("accessories", "power bank"), ("audio-gadgets", "speaker")],
    "tablet": [("accessories", "power bank"), ("audio-gadgets", "earbuds")],
    "tv_stick": [("cables-networking", "hdmi"), ("audio-gadgets", "speaker")],
    "creator": [("accessories", "power bank")],
    "video_cable": [("cables-networking", "adapter"), ("monitors", "monitor")],
    "usbc_hub": [("cables-networking", "hdmi"), ("monitors", "monitor")],
    "network": [("cables-networking", "rj45"), ("business-equipment", "crimping")],
    "storage_adapter": [("storage", "ssd"), ("storage", "hard disk")],
    "bag": [("accessories", "mouse"), ("accessories", "charger")],
    "charger": [("accessories", "bag"), ("accessories", "power bank")],
    "keyboard_repl": [("accessories", "mouse"), ("accessories", "charger")],
    "webcam": [("accessories", "presentation remote"), ("accessories", "stand")],
    "presenter": [("business-equipment", "projector"), ("cables-networking", "hdmi")],
    "ergonomic": [("monitors", "monitor"), ("accessories", "mouse")],
    "input": [("accessories", "stand"), ("monitors", "monitor")],
    "cctv_cam": [("storage", "hard disk"), ("ups-power", "ups")],
    "office_tool": [("cables-networking", "rj45")],
    "power_adapter": [("ups-power", "extension")],
    "site_security": [("security-equipment", "safe")],
}
