/* ============================================================
   Data layer — Evans Equipment Web Store
   Exposed on window for cross-script access.
   ============================================================ */

// Named colors used by swatches & garment tinting
const COLORS = {
  silver:   '#c7cbcb', maroon: '#7a2f3a', lightblue: '#9fc0dd', black: '#23282a',
  forest:   '#2f5d4f', charcoal: '#454b4d', navy: '#26344c', white: '#f3f5f4',
  steel:    '#7d8a8c', royal: '#2f5fa6', stone: '#b9b3a3', tan: '#c9bd9e',
  teal:     '#3f8f8a', cream: '#e9e3d4', brown: '#5e4b3a', sage: '#8a9a86',
  hivis:    '#d6e03a', orange: '#d8782f', khaki: '#b3a578', red: '#9a3326',
  slate:    '#5a6b72'
};

// Garment silhouettes (tintable). Each returns an SVG string given a fill + accent.
function garmentSVG(kind, fill) {
  const stroke = 'rgba(0,0,0,.16)';
  const shade = 'rgba(0,0,0,.10)';
  if (kind === 'jacket') {
    return `<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
      <path d="M64 34 L100 22 L136 34 L168 52 L156 86 L140 78 L140 176 L60 176 L60 78 L44 86 L32 52 Z" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
      <path d="M100 22 L100 176" stroke="${shade}" stroke-width="3" stroke-dasharray="2 5"/>
      <path d="M64 34 L100 60 L136 34" fill="none" stroke="${stroke}" stroke-width="2.5"/>
      <rect x="96" y="60" width="8" height="110" rx="3" fill="${shade}"/>
    </svg>`;
  }
  if (kind === 'cap') {
    return `<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
      <path d="M40 132 C40 80 80 58 110 58 C150 58 168 86 170 120 L170 132 Z" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
      <path d="M40 132 C24 132 16 140 14 150 L120 150 C120 138 112 132 100 132 Z" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
      <path d="M110 58 C140 60 160 84 170 120" fill="none" stroke="${shade}" stroke-width="3"/>
    </svg>`;
  }
  if (kind === 'tee') {
    return `<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
      <path d="M74 36 L100 30 L126 36 L170 58 L156 92 L142 84 L142 176 L58 176 L58 84 L44 92 L30 58 Z" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
      <path d="M74 36 C82 56 118 56 126 36" fill="none" stroke="${stroke}" stroke-width="2.5"/>
    </svg>`;
  }
  // default: polo / collared shirt
  return `<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
    <path d="M72 34 L100 28 L128 34 L168 56 L154 92 L138 84 L138 176 L62 176 L62 84 L46 92 L32 56 Z" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
    <path d="M84 34 L100 64 L116 34" fill="${fill}" stroke="${stroke}" stroke-width="2.5"/>
    <path d="M100 64 L100 104" stroke="${shade}" stroke-width="3"/>
    <path d="M100 64 L92 44 M100 64 L108 44" stroke="${shade}" stroke-width="2.5"/>
  </svg>`;
}

const LOCATIONS = [
  { id: 'hq',   name: 'Lafayette HQ',     addr: '212 N Luke St, Lafayette, LA 70506' },
  { id: 'yard', name: 'Broussard Yard',   addr: '418 Albertson Pkwy, Broussard, LA 70518' },
  { id: 'shop', name: 'New Iberia Shop',  addr: '2901 Hwy 90 E, New Iberia, LA 70560' },
];

// ---- Products ----
let _id = 0;
const P = (o) => ({ id: 'p' + (++_id), ...o });

const PRODUCTS = [
  // ---------- MEN'S ----------
  P({ cat:'mens', kind:'polo', name:"Port Authority Dry Zone UV Micro-Mesh Polo", brand:'Port Authority', sku:'K110', price:36,
      colors:['silver','maroon','lightblue','black','forest','charcoal','navy','white'],
      desc:"Snag-resistant micro-mesh polo with moisture-wicking UV protection. Embroidered Evans logo, left chest." }),
  P({ cat:'mens', kind:'polo', name:"Long Sleeve Nailhead Easy Care Shirt", brand:'Port Authority', sku:'W816', price:48,
      colors:['black','royal','steel','navy','white'],
      desc:"Wrinkle-resistant nailhead weave button-down. A professional staple that holds up on long days." }),
  P({ cat:'mens', kind:'jacket', name:"Hybrid Soft Shell Jacket", brand:'Port Authority', sku:'J787', price:78,
      colors:['black','charcoal'],
      desc:"Wind- and water-resistant soft shell with quilted body panels for cold mornings in the field." }),
  P({ cat:'mens', kind:'polo', name:"Eddie Bauer Short Sleeve Performance Fishing Shirt", brand:'Eddie Bauer', sku:'EB602', price:52,
      colors:['tan','steel','white'],
      desc:"Vented, quick-dry performance shirt with roll-up sleeve tabs. UPF protection built in." }),
  P({ cat:'mens', kind:'jacket', name:"Core Soft Shell Vest", brand:'Port Authority', sku:'J325', price:45,
      colors:['black','charcoal','navy'],
      desc:"Lightweight layering vest with zippered pockets. Embroidery-ready left chest." }),
  P({ cat:'mens', kind:'tee', name:"Force Cotton Delmont Short Sleeve Tee", brand:'Carhartt', sku:'CT104616', price:30,
      colors:['black','navy','charcoal','stone'],
      desc:"Sweat-wicking, fast-drying everyday tee with the Evans logo screen-printed left chest." }),

  // ---------- WOMEN'S ----------
  P({ cat:'womens', kind:'polo', name:"MERCER+METTLE Stretch Crepe 3/4-Sleeve Blouse", brand:'Mercer+Mettle', sku:'MM2011', price:44,
      colors:['black','navy','brown','cream','charcoal'],
      desc:"Refined stretch-crepe blouse with a relaxed drape. Office-ready and embroidery-friendly." }),
  P({ cat:'womens', kind:'polo', name:"OGIO Ladies Regain Polo", brand:'OGIO', sku:'LOG170', price:58,
      colors:['teal','navy','steel','white'],
      desc:"Performance knit polo with a tailored fit and four-way stretch. Embroidered Evans logo." }),
  P({ cat:'womens', kind:'polo', name:"Women's Long Sleeve Nailhead Easy Care Shirt", brand:'Port Authority', sku:'LW816', price:48,
      colors:['black','royal','white'],
      desc:"The easy-care nailhead button-down, cut for a women's fit. Wrinkle-resistant all day." }),
  P({ cat:'womens', kind:'jacket', name:"Ladies Value Fleece Jacket", brand:'Port Authority', sku:'L217', price:42,
      colors:['royal','black','steel','forest','red','navy','white'],
      desc:"Soft anti-pill fleece full-zip with on-seam pockets. A warm, affordable layer." }),
  P({ cat:'womens', kind:'tee', name:"Tri-Blend Wicking Draft Tee", brand:'Sport-Tek', sku:'LST405', price:28,
      colors:['black','navy','charcoal','teal'],
      desc:"Heathered tri-blend tee with a soft hand and moisture management. Screen-printed logo." }),

  // ---------- TECHNICIANS / WELDERS ----------
  P({ cat:'tech', kind:'polo', name:"Bulwark FR Long Sleeve Work Shirt", brand:'Bulwark FR', sku:'SLU2', price:64, fr:true,
      colors:['navy','khaki','steel'],
      desc:"Flame-resistant button-down rated for arc and flash hazards. Meets NFPA 2112. Two chest pockets." }),
  P({ cat:'tech', kind:'tee', name:"Flame-Resistant Force Cotton Tee", brand:'Carhartt FR', sku:'102905', price:42, fr:true,
      colors:['navy','charcoal'],
      desc:"FR knit tee with FastDry moisture wicking. Comfortable enough to wear all shift under a jacket." }),
  P({ cat:'tech', kind:'tee', name:"Hi-Vis Reflective Safety Tee — Class 2", brand:'CornerStone', sku:'CS408', price:28,
      colors:['hivis','orange'],
      desc:"ANSI/ISEA 107 Class 2 high-visibility tee with reflective taping. Logo heat-pressed left chest." }),
  P({ cat:'tech', kind:'jacket', name:"Insulated FR Welding Jacket", brand:'Bulwark FR', sku:'JEW2', price:96, fr:true,
      colors:['black'],
      desc:"Heavyweight flame-resistant insulated jacket built for welders. Storm flap and adjustable cuffs." }),
  P({ cat:'tech', kind:'jacket', name:"FR Cargo Work Pant", brand:'Wrangler FR', sku:'FR3W020', price:58, fr:true,
      colors:['khaki','navy'],
      desc:"Durable flame-resistant cargo pant with reinforced seams. Built for the shop and the field." }),
  P({ cat:'tech', kind:'cap', name:"Structured Logo Work Cap", brand:'Richardson', sku:'112', price:18,
      colors:['black','charcoal','navy'],
      desc:"Mid-profile trucker cap with embroidered Evans logo and snapback closure. One size." }),
];

const SIZES = ['XS','S','M','L','XL','2XL','3XL'];

const CATEGORIES = [
  { id:'mens',   label:"Men's Apparel",        short:"Men's",        kind:'polo',   blurb:'Polos, button-downs, jackets & tees' },
  { id:'womens', label:"Women's Apparel",      short:"Women's",      kind:'polo',   blurb:'Blouses, polos, fleece & tees' },
  { id:'tech',   label:"Technicians & Welders",short:"Technicians",  kind:'jacket', blurb:'FR-rated, hi-vis & shop gear' },
];

// ---- Current signed-in employee ----
const CURRENT_USER = {
  name: 'Marcus Hebert', first: 'Marcus', email: 'm.hebert@evansequip.com',
  role: 'Field Technician', categories: ['mens','tech'], // role-based access
  pointsTotal: 300, pointsUsed: 36, resetDate: 'Jan 1, 2027', empId: 'EV-1042',
};

// ---- Order history (for account page) ----
const ORDER_HISTORY = [
  { id:'EV-20461', date:'May 22, 2026', items:2, points:84, status:'Delivered' },
  { id:'EV-20388', date:'Apr 03, 2026', items:1, points:36, status:'Delivered' },
  { id:'EV-20120', date:'Feb 14, 2026', items:1, points:48, status:'Delivered' },
];

// ---- Admin data ----
const ADMIN_EMPLOYEES = [
  { name:'Marcus Hebert',  email:'m.hebert@evansequip.com',  role:'Employee', dept:'Field Tech', used:36,  total:300, status:'Active' },
  { name:'Olivia Trahan',  email:'o.trahan@evansequip.com',  role:'HR Admin', dept:'HR',         used:0,   total:300, status:'Active' },
  { name:'Brent Guidry',   email:'b.guidry@evansequip.com',  role:'Employee', dept:'Welding',    used:312, total:300, status:'Active' },
  { name:'Dana Comeaux',   email:'d.comeaux@evansequip.com', role:'Employee', dept:'Office',      used:150, total:300, status:'Active' },
  { name:'Travis Landry',  email:'t.landry@evansequip.com',  role:'Employee', dept:'Field Tech', used:268, total:300, status:'Active' },
  { name:'Renee Broussard',email:'r.broussard@evansequip.com',role:'Employee',dept:'Office',      used:0,   total:300, status:'Invited' },
  { name:'Cole Theriot',   email:'c.theriot@evansequip.com', role:'Employee', dept:'Welding',    used:96,  total:300, status:'Active' },
  { name:'Jacob Romero',   email:'j.romero@evansequip.com',  role:'Employee', dept:'Field Tech', used:340, total:300, status:'Active' },
];

const ADMIN_ORDERS = [
  { id:'EV-20488', emp:'Brent Guidry',  date:'Jun 08, 2026', items:3, points:138, over:true },
  { id:'EV-20487', emp:'Travis Landry', date:'Jun 08, 2026', items:1, points:42,  over:false },
  { id:'EV-20485', emp:'Jacob Romero',  date:'Jun 07, 2026', items:2, points:130, over:true },
  { id:'EV-20482', emp:'Dana Comeaux',  date:'Jun 06, 2026', items:1, points:58,  over:false },
  { id:'EV-20461', emp:'Marcus Hebert', date:'May 22, 2026', items:2, points:84,  over:false },
];

Object.assign(window, {
  COLORS, garmentSVG, LOCATIONS, PRODUCTS, SIZES, CATEGORIES,
  CURRENT_USER, ORDER_HISTORY, ADMIN_EMPLOYEES, ADMIN_ORDERS,
});
