#!/bin/bash

CAT_ID=21

# Image attachment IDs from the earlier import
IMG_ROYAL=94
IMG_IMPERION=95
IMG_ASSAULT_MODE=96
IMG_ASSAULT_SLASH=97
IMG_BES=98

create_product() {
  local name="$1"
  local price="$2"
  local sale="$3"
  local desc="$4"
  local short="$5"
  local img_id="$6"
  local sku="$7"
  local stock=$((RANDOM % 60 + 5))

  local sale_arg=""
  if [ -n "$sale" ]; then
    sale_arg="--sale_price=$sale"
  fi

  local pid=$(wp wc product create \
    --name="$name" \
    --regular_price="$price" \
    $sale_arg \
    --categories="[{\"id\":$CAT_ID}]" \
    --description="$desc" \
    --short_description="$short" \
    --sku="$sku" \
    --manage_stock=true \
    --stock_quantity=$stock \
    --allow-root --user=admin --porcelain 2>/dev/null)

  if [ -n "$pid" ]; then
    wp post meta update "$pid" _thumbnail_id "$img_id" --allow-root 2>/dev/null >/dev/null
    echo "Created: $name (ID: $pid)"
  else
    echo "FAILED: $name"
  fi
}

echo "=== Seeding Card Variations ==="

# --- Royal Penguins Garden variations ---

create_product \
  "Royal Penguins Garden - Ultra Rare" "8.99" "6.99" \
  "Near Mint 1st Edition Royal Penguins Garden (BPRO-AEC64) in Ultra Rare foil. This continuous Spell Card lets you add any Penguin card from your Deck to your hand when activated, and once per turn decrease the Level of a Penguin monster by 1. A key engine piece for any Penguin archetype deck." \
  "NM 1st Ed Royal Penguins Garden Ultra Rare. Essential Penguin archetype support." \
  "$IMG_ROYAL" "CARD-001"

create_product \
  "Royal Penguins Garden - Prismatic Secret Rare" "24.99" "19.99" \
  "Collector's grade Prismatic Secret Rare edition of Royal Penguins Garden. Features the stunning rainbow prismatic foil treatment across the entire card face. Graded PSA 9 Mint condition. Comes in a protective top-loader with UV-resistant sleeve. A rare pull that elevates any collection." \
  "PSA 9 Prismatic Secret Rare Royal Penguins Garden. Rainbow foil, UV-protected." \
  "$IMG_ROYAL" "CARD-002"

create_product \
  "Royal Penguins Garden Playmat" "24.99" "" \
  "Premium rubber-backed playmat featuring expanded artwork from Royal Penguins Garden. The elegant palace and garden artwork is printed edge-to-edge in vibrant detail. Smooth cloth surface provides excellent card sliding. Non-slip rubber base. 24 x 14 inches. Comes in a protective tube." \
  "Royal Penguins Garden full-art playmat. Rubber-backed, 24x14 inches." \
  "$IMG_ROYAL" "CARD-003"

create_product \
  "Royal Penguins Garden - Card Sleeves (60 Pack)" "9.99" "7.99" \
  "Protect your deck in style with these card sleeves featuring the Royal Penguins Garden artwork. High-clarity front with full-art matte back. Acid-free polypropylene, tournament legal for official Yu-Gi-Oh events. Fits standard small-size Yu-Gi-Oh cards. 60 sleeves per pack." \
  "60-pack Royal Penguins Garden art sleeves. Tournament legal, matte back." \
  "$IMG_ROYAL" "CARD-004"

create_product \
  "Penguin Archetype Deck Core" "34.99" "29.99" \
  "Complete Penguin archetype deck core built around Royal Penguins Garden. Includes 3x Royal Penguins Garden, 3x Penguin Soldier, 2x The Great Emperor Penguin, 3x Nopenguin, 2x Penguin Brave, 3x Penguin Squire, plus key spell and trap support. 30 cards total, all Near Mint. Just add staples and you are ready to duel." \
  "30-card Penguin deck core. 3x Royal Penguins Garden plus full archetype lineup." \
  "$IMG_ROYAL" "CARD-005"

# --- Imperion Magnum variations ---

create_product \
  "Imperion Magnum the Superconductive Battlebot - Super Rare" "12.99" "9.99" \
  "Near Mint Imperion Magnum the Superconductive Battlebot (BPRO-AES09) in Super Rare. This devastating Level 10 Rock/Fusion/Effect monster boasts 4000 ATK and 4000 DEF. Once per turn, negate any Spell, Trap, or monster effect and destroy it. A powerhouse boss monster for Magnet Warrior decks." \
  "NM Super Rare Imperion Magnum. ATK/4000 DEF/4000 fusion boss monster." \
  "$IMG_IMPERION" "CARD-006"

create_product \
  "Imperion Magnum - Starlight Rare" "89.99" "74.99" \
  "The crown jewel for Magnet Warrior collectors. Starlight Rare Imperion Magnum the Superconductive Battlebot with its distinctive textured diagonal foil pattern. PSA 10 Gem Mint condition. One of the hardest pulls in the set. Ships double-sleeved in a magnetic one-touch case with padded mailer." \
  "PSA 10 Starlight Rare Imperion Magnum. Gem Mint, magnetic case included." \
  "$IMG_IMPERION" "CARD-007"

create_product \
  "Imperion Magnum Framed Art Print" "44.99" "39.99" \
  "Dynamic full-bleed art print of Imperion Magnum the Superconductive Battlebot in its iconic battle stance. Printed on heavyweight 300gsm archival matte paper with museum-quality pigment inks. Black wood frame with anti-glare glass. 12 x 16 inches. Limited edition numbered print." \
  "Limited edition framed Imperion Magnum print. 12x16 archival quality." \
  "$IMG_IMPERION" "CARD-008"

create_product \
  "Magnet Warrior Fusion Deck Core" "42.99" "36.99" \
  "Complete Magnet Warrior deck core centered on summoning Imperion Magnum. Includes 3x Valkyrion the Magna Warrior, 3x Berserkion the Electromagna Warrior, 2x Imperion Magnum, full Alpha/Beta/Gamma Electromagnet Warrior playsets, and Polymerization support. 35 cards, all Near Mint." \
  "35-card Magnet Warrior deck core. Everything you need to summon Imperion Magnum." \
  "$IMG_IMPERION" "CARD-009"

create_product \
  "Imperion Magnum Deck Box" "16.99" "" \
  "Hard-shell deck box showcasing Imperion Magnum artwork on all panels. Magnetic snap closure with soft microfiber lining. Holds up to 100 single-sleeved or 80 double-sleeved cards. Includes a removable divider for separating main and extra deck. Reinforced corners for durability." \
  "Imperion Magnum deck box. Magnetic closure, holds 100 cards, microfiber lined." \
  "$IMG_IMPERION" "CARD-010"

# --- Assault Mode Activate variations ---

create_product \
  "Assault Mode Activate - Ultra Rare" "5.99" "4.49" \
  "Near Mint Assault Mode Activate (BPRO-AES16) Ultra Rare. This powerful Trap Card lets you tribute a Synchro Monster to Special Summon its Assault Mode counterpart directly from the Deck in Attack Position. The key card that unlocks devastating Assault Mode boss monsters like Stardust Dragon Assault Mode." \
  "NM Ultra Rare Assault Mode Activate. Tribute Synchro, summon Assault Mode from Deck." \
  "$IMG_ASSAULT_MODE" "CARD-011"

create_product \
  "Assault Mode Activate - Ghost Rare" "54.99" "44.99" \
  "Extremely rare Ghost Rare printing of Assault Mode Activate. Features the haunting 3D holographic effect unique to Ghost Rares, with the duelist figure appearing to leap from the card surface. PSA 8 Near Mint condition. A true collector's piece. Ships in a rigid top-loader with tracking." \
  "PSA 8 Ghost Rare Assault Mode Activate. 3D holographic effect. Collector grade." \
  "$IMG_ASSAULT_MODE" "CARD-012"

create_product \
  "Assault Mode Activate Playmat" "24.99" "21.99" \
  "Full-art playmat featuring the dramatic Assault Mode Activate artwork with the duelist powering up amid swirling energy. Extended background art fills the entire play surface. Stitched edges prevent fraying. High-density rubber base with smooth polyester top. 24 x 14 inches." \
  "Assault Mode Activate full-art playmat. Stitched edges, 24x14 inches." \
  "$IMG_ASSAULT_MODE" "CARD-013"

create_product \
  "Assault Mode Complete Deck" "59.99" "49.99" \
  "Tournament-ready Assault Mode deck featuring all key pieces. Includes 3x Assault Mode Activate, 3x Assault Slash, Stardust Dragon and Stardust Dragon Assault Mode, Red Dragon Archfiend Assault Mode, Psi-Reflector engine, and full Synchro toolbox. 45 cards main deck plus 15 card extra deck. Deck list included." \
  "Complete 60-card Assault Mode deck. Tournament ready with Synchro toolbox." \
  "$IMG_ASSAULT_MODE" "CARD-014"

create_product \
  "Assault Mode Card Sleeves (60 Pack)" "9.99" "" \
  "Sleek card sleeves featuring the Assault Mode Activate artwork. The dramatic energy burst design looks incredible fanned across the table. High-clarity front, full-art glossy back. Durable 120-micron thickness prevents splitting. Tournament legal. Pack of 60." \
  "60-pack Assault Mode Activate sleeves. Glossy back, tournament legal." \
  "$IMG_ASSAULT_MODE" "CARD-015"

# --- Assault Slash variations ---

create_product \
  "Assault Slash - Ultra Rare" "4.99" "3.49" \
  "Near Mint Assault Slash (BPRO-AES17) Ultra Rare. When you control an Assault Mode monster, this Trap Card destroys all face-up monsters on the field. A devastating board wipe that punishes your opponent for overextending. Essential side deck or main deck tech for any Assault Mode strategy." \
  "NM Ultra Rare Assault Slash. Board wipe when you control Assault Mode monster." \
  "$IMG_ASSAULT_SLASH" "CARD-016"

create_product \
  "Assault Slash - Secret Rare 1st Edition" "18.99" "14.99" \
  "1st Edition Secret Rare Assault Slash in Near Mint condition. The diagonal holographic foil beautifully highlights the fiery destruction effect depicted in the artwork. One of the more sought-after Assault Mode support cards. Double-sleeved and shipped in a top-loader." \
  "NM 1st Ed Secret Rare Assault Slash. Holographic foil, double-sleeved." \
  "$IMG_ASSAULT_SLASH" "CARD-017"

create_product \
  "Assault Slash Framed Art Print" "39.99" "34.99" \
  "Dramatic art print capturing the explosive moment of Assault Slash's effect activation. The fiery energy and dragon artwork are rendered in stunning detail on premium giclée paper. Matte black frame with museum glass. 11 x 14 inches. Each print is individually numbered in a limited run of 500." \
  "Limited run Assault Slash giclée print. 11x14, numbered edition of 500." \
  "$IMG_ASSAULT_SLASH" "CARD-018"

create_product \
  "Assault Slash Metal Card Replica" "19.99" "16.99" \
  "Premium metal card replica of Assault Slash crafted from brushed stainless steel with full-color UV printing. Weighs approximately 30 grams with a satisfying heft. Dimensions match a standard Yu-Gi-Oh card. Comes in a black velvet display pouch. A unique collectible that stands out in any display." \
  "Stainless steel Assault Slash metal card replica. Full-color UV print, velvet pouch." \
  "$IMG_ASSAULT_SLASH" "CARD-019"

# --- B.E.S. Big Core variations ---

create_product \
  "B.E.S. Big Core - Super Rare" "6.99" "4.99" \
  "Near Mint B.E.S. Big Core (BPRO-AEC50) Super Rare. This Level 6 DARK Machine monster enters the field with 3 counters and cannot be destroyed by battle. At 2300 ATK, it serves as a persistent threat that your opponent must answer with card effects. A nostalgic fan favorite from the B.E.S. archetype." \
  "NM Super Rare B.E.S. Big Core. ATK/2300 DEF/1100, battle indestructible with counters." \
  "$IMG_BES" "CARD-020"

create_product \
  "B.E.S. Big Core - Collector's Rare" "32.99" "27.99" \
  "Collector's Rare edition of B.E.S. Big Core featuring the distinctive embossed foil texture across the card name and artwork border. The space battleship artwork pops with added depth and dimension. PSA 9 Mint. A premium version of this beloved Machine-type monster for serious collectors." \
  "PSA 9 Collector's Rare B.E.S. Big Core. Embossed foil texture, premium grade." \
  "$IMG_BES" "CARD-021"

create_product \
  "B.E.S. Big Core Playmat" "24.99" "19.99" \
  "Cruise through your duels on this B.E.S. Big Core playmat featuring the space battleship soaring past planets in expanded panoramic artwork. Deep space background with stunning nebula details. Premium stitched edges with high-grip rubber base. 24 x 14 inches." \
  "B.E.S. Big Core panoramic space playmat. Stitched edges, 24x14 inches." \
  "$IMG_BES" "CARD-022"

create_product \
  "B.E.S. Fleet Deck Core" "28.99" "24.99" \
  "Full B.E.S. (Bacterian Empire Ship) archetype deck core. Includes 3x B.E.S. Big Core, 2x B.E.S. Big Core MK-2, 2x B.E.S. Big Core MK-3, 3x B.E.S. Tetran, 3x Boss Rush, and supporting spell and trap cards. 25 cards total, all Near Mint. Build the ultimate machine armada." \
  "25-card B.E.S. fleet deck core. Full archetype with Boss Rush engine." \
  "$IMG_BES" "CARD-023"

create_product \
  "B.E.S. Big Core Enamel Pin" "11.99" "9.99" \
  "Detailed enamel pin of the B.E.S. Big Core space battleship. Hard enamel with polished nickel plating and screen-printed detail. Dual rubber clutch backing for secure wear. Approximately 1.5 inches wide. Comes on a branded collector's backing card featuring the original card text." \
  "B.E.S. Big Core enamel pin. Hard enamel, nickel plated, 1.5 inches." \
  "$IMG_BES" "CARD-024"

create_product \
  "B.E.S. Big Core Metal Card Replica" "19.99" "" \
  "Heavyweight metal replica of B.E.S. Big Core in brushed aluminum with full-color printing. Card stats ATK/2300 DEF/1100 are etched into the metal surface. Standard Yu-Gi-Oh card dimensions. Presented in a magnetic display case with clear window. Makes a striking desk piece or shelf display." \
  "Aluminum B.E.S. Big Core metal replica with etched stats. Magnetic display case." \
  "$IMG_BES" "CARD-025"

echo ""
echo "=== Done! Card variations seeded ==="
