// Catalogue Indigo & Safran — données produits réelles
// Palettes de couleurs pour les vignettes panier & fallback SVG

const PALETTES = {
  indigo:   { base: "#1f3a52", deep: "#102433", soft: "#cfd9e3", paper: "#f4ede0" },
  terre:    { base: "#b85c3f", deep: "#7a3622", soft: "#efd2c3", paper: "#faf3e8" },
  safran:   { base: "#c98a2a", deep: "#8a5c14", soft: "#f1ddb6", paper: "#fdf6e6" },
  rose:     { base: "#c4567a", deep: "#86304f", soft: "#f3d2dd", paper: "#fbede9" },
  vert:     { base: "#5b7a4a", deep: "#34492a", soft: "#d4dec4", paper: "#f1ede0" },
  noir:     { base: "#2a2a2a", deep: "#0e0e0e", soft: "#dcdcd6", paper: "#f6f3ec" },
  bleuPaon: { base: "#1f6878", deep: "#0e3742", soft: "#cfdfe1", paper: "#eef0e6" },
  ocre:     { base: "#a87832", deep: "#6a4a18", soft: "#e9d6ad", paper: "#f7efde" },
};

function svgURL(svg) {
  return `data:image/svg+xml;utf8,${encodeURIComponent(svg).replace(/'/g, "%27")}`;
}
function makePattern(kind, p) {
  const { base, deep, paper } = p;
  if (kind === "buti") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'><rect width='80' height='80' fill='${paper}'/><g fill='${base}'><circle cx='20' cy='20' r='4'/><circle cx='60' cy='60' r='4'/><circle cx='60' cy='20' r='2.5'/><circle cx='20' cy='60' r='2.5'/></g><g fill='${deep}' opacity='0.55'><circle cx='40' cy='40' r='1.6'/><circle cx='0' cy='40' r='1.6'/><circle cx='80' cy='40' r='1.6'/><circle cx='40' cy='0' r='1.6'/><circle cx='40' cy='80' r='1.6'/></g></svg>`);
  }
  if (kind === "jaali") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='60' height='60' viewBox='0 0 60 60'><rect width='60' height='60' fill='${paper}'/><g stroke='${base}' stroke-width='1.4' fill='none'><path d='M0 30 L30 0 L60 30 L30 60 Z'/><path d='M15 30 L30 15 L45 30 L30 45 Z'/></g><circle cx='30' cy='30' r='2' fill='${deep}'/></svg>`);
  }
  if (kind === "stripes") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'><rect width='40' height='40' fill='${paper}'/><g fill='${base}'><rect y='6' width='40' height='2'/><rect y='14' width='40' height='1'/><rect y='22' width='40' height='2'/><rect y='30' width='40' height='1'/></g><g fill='${deep}'><rect y='10' width='40' height='1'/><rect y='26' width='40' height='1'/></g></svg>`);
  }
  if (kind === "fleur") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90' viewBox='0 0 90 90'><rect width='90' height='90' fill='${paper}'/><g fill='${base}' opacity='0.85'><circle cx='45' cy='45' r='3'/><circle cx='45' cy='30' r='4'/><circle cx='45' cy='60' r='4'/><circle cx='30' cy='45' r='4'/><circle cx='60' cy='45' r='4'/></g><g fill='${deep}' opacity='0.4'><circle cx='10' cy='10' r='1.5'/><circle cx='80' cy='10' r='1.5'/><circle cx='10' cy='80' r='1.5'/><circle cx='80' cy='80' r='1.5'/></g></svg>`);
  }
  if (kind === "diamants") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 50 50'><rect width='50' height='50' fill='${paper}'/><g fill='${base}'><path d='M25 8 L34 25 L25 42 L16 25 Z'/></g><g fill='${deep}'><path d='M0 25 L4 21 L8 25 L4 29 Z'/><path d='M42 25 L46 21 L50 25 L46 29 Z'/></g></svg>`);
  }
  if (kind === "etoiles") {
    return svgURL(`<svg xmlns='http://www.w3.org/2000/svg' width='70' height='70' viewBox='0 0 70 70'><rect width='70' height='70' fill='${paper}'/><g fill='${base}'><path d='M20 10 L23 18 L31 20 L23 22 L20 30 L17 22 L9 20 L17 18 Z'/><path d='M50 40 L53 48 L61 50 L53 52 L50 60 L47 52 L39 50 L47 48 Z'/></g><g fill='${deep}' opacity='0.5'><circle cx='50' cy='15' r='1.8'/><circle cx='20' cy='55' r='1.8'/></g></svg>`);
  }
  return null;
}

const PRODUCTS = [
  // ─── NAPPES — Collection DELHI · UNIS ───────────────────────────
  // ─── NAPPES — Collection BOMBAY ─────────────────────────────────
  {
    id: "bombay-01", name: "Nappe Bombay B1", collection: "Bombay",
    category: "nappes", pattern: "stripes", palette: "indigo",
    img: "/images/bombay-1.jpg",
    gallery: ["/images/bombay-1.jpg", "/images/bombay-5.jpg", "/images/bombay-1-b.jpg", "/images/bombay-1-c.jpg"],
    desc: "Collection Bombay — imprimé blockprint sur coton épais. Finitions à la main, motifs géométriques. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m. Pour une nappe 8 couverts, les dimensions sont 1,5 m × 3 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
    ],
    tag: "Best-seller",
  },
  {
    id: "bombay-02", name: "Nappe Bombay B2", collection: "Bombay",
    category: "nappes", pattern: "stripes", palette: "terre",
    img: "/images/bombay-2.jpg",
    gallery: ["/images/bombay-2.jpg", "/images/bombay-2-b.jpg", "/images/bombay-2-c.jpg", "/images/bombay-2-d.jpg"],
    desc: "Collection Bombay — imprimé blockprint sur coton épais. Finitions à la main, motifs géométriques. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m. Pour une nappe 8 couverts, les dimensions sont 1,5 m × 3 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
      { label: "1,5 × 2,3 m — 8 pers.", price: 39 },
    ],
  },
  {
    id: "bombay-04", name: "Nappe Bombay B4", collection: "Bombay",
    category: "nappes", pattern: "buti", palette: "safran",
    img: "/images/bombay-4.jpg",
    desc: "Collection Bombay — imprimé blockprint sur coton épais. Finitions à la main, motifs géométriques. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m. Pour une nappe 8 couverts, les dimensions sont 1,5 m × 3 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
      { label: "8 pers.", price: 39 },
    ],
  },
  {
    id: "bombay-06", name: "Nappe Bombay B6", collection: "Bombay",
    category: "nappes", pattern: "fleur", palette: "rose",
    img: "/images/bombay-6.jpg",
    gallery: ["/images/bombay-6.jpg", "/images/bombay-8-e.jpg", "/images/bombay-8-f.jpg", "/images/bombay-8-g.jpg", "/images/bombay-8-h.jpg", "/images/bombay-8-i.jpg", "/images/bombay-8-j.jpg"],
    desc: "Collection Bombay — imprimé blockprint sur coton épais. Finitions à la main, motifs géométriques. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m. Pour une nappe 8 couverts, les dimensions sont 1,5 m × 3 m. Pour une nappe 10 couverts, les dimensions sont 1,5 m × 3,55 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
      { label: "10 pers.", price: 44 },
    ],
  },
  {
    id: "bombay-08", name: "Nappe Bombay B8", collection: "Bombay",
    category: "nappes", pattern: "jaali", palette: "indigo",
    img: "/images/bombay-8.jpg",
    gallery: ["/images/bombay-8.jpg", "/images/bombay-8-b.jpg", "/images/bombay-8-c.jpg", "/images/bombay-8-d.jpg"],
    desc: "Collection Bombay Pat — imprimé blockprint sur coton épais. Motif patchwork géométrique. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m. Pour une nappe 8 couverts, les dimensions sont 1,5 m × 3 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
      { label: "1,5 × 2,3 m — 8 pers.", price: 39 },
    ],
  },
  {
    id: "bombay-14", name: "Nappe Bombay B14", collection: "Bombay",
    category: "nappes", pattern: "fleur", palette: "indigo",
    img: "/images/nappe Bombay 14.jpg",
    desc: "Collection Bombay — imprimé blockprint sur coton épais. Finitions à la main, motifs géométriques. Pour une nappe 6 couverts, les dimensions sont 1,5 m × 2,3 m.",
    sizes: [
      { label: "6 pers.", price: 34 },
    ],
  },
  // ─── NAPPES — Collection JAIPUR ─────────────────────────────────
  // ─── CHEMINS DE TABLE ───────────────────────────────────────────
  {
    id: "chemin-02", name: "Chemin de table Modèle B",
    category: "chemins", pattern: "buti", palette: "terre",
    img: "/images/chemins-2.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-04", name: "Chemin de table Modèle D",
    category: "chemins", pattern: "jaali", palette: "vert",
    img: "/images/chemins-4.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-09", name: "Chemin de table Modèle I",
    category: "chemins", pattern: "fleur", palette: "indigo",
    img: "/images/chemins-9.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-11", name: "Chemin de table Modèle K",
    category: "chemins", pattern: "stripes", palette: "rose",
    img: "/images/chemins-11.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-13", name: "Chemin de table Modèle M",
    category: "chemins", pattern: "etoiles", palette: "vert",
    img: "/images/chemins-13.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-14", name: "Chemin de table Modèle N",
    category: "chemins", pattern: "diamants", palette: "bleuPaon",
    img: "/images/chemins-14.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  {
    id: "chemin-15", name: "Chemin de table Modèle O",
    category: "chemins", pattern: "fleur", palette: "ocre",
    img: "/images/chemins-15.jpg",
    desc: "Chemin de table 100% coton imprimé blockprint, finitions à la main par les artisans du Rajasthan.",
    sizes: [{ label: "Taille unique", price: 28 }],
  },
  // ─── POCHETTES ──────────────────────────────────────────────────
  {
    id: "pochette-jaipur", name: "Pochette Jaipur",
    category: "pochettes", pattern: "fleur", palette: "safran",
    img: "/images/POchette Jaipur.jpg",
    gallery: ["/images/POchette Jaipur.jpg", "/images/POchette Jaipur1.jpg", "/images/POchette Jaipur2.jpg"],
    desc: "Pochette 100% coton imprimé blockprint.\nFermeture zippée.\nDoublée intérieur coton imperméable.\nDeux poches intérieures.\nRésiste à l'eau et aux produits liquides qui ont coulé !\nDimensions : 21 × 10 × 12 cm.",
    sizes: [{ label: "Taille unique", price: 12 }],
  },
  {
    id: "bourse-sari", name: "Bourse sari",
    category: "pochettes", pattern: "fleur", palette: "terre",
    img: "/images/Bourse Sari.jpg",
    gallery: ["/images/Bourse Sari.jpg", "/images/Bourse Sari1.jpg", "/images/Bourse Sari2.jpg"],
    desc: "Pochette 100% coton imprimé blockprint.\nFermeture zippée.\nDoublée intérieur coton imperméable.\nDeux poches intérieures.\nRésiste à l'eau et aux produits liquides qui ont coulé !\nDimensions : 25 × 20 × 17 cm.",
    sizes: [{ label: "Taille unique", price: 12 }],
  },
  {
    id: "pochette-delhi", name: "Pochette Delhi",
    category: "pochettes", pattern: "fleur", palette: "indigo",
    img: "/images/Pochette Delhi4.jpg",
    gallery: ["/images/Pochette Delhi.jpg", "/images/Pochette Delhi2.jpg", "/images/Pochette Delhi3.jpg", "/images/Pochette Delhi4.jpg", "/images/Pochette Delhi5.jpg"],
    desc: "Pochette 100% coton imprimé blockprint.\nFermeture zippée.\nDoublée intérieur coton imperméable.\nDeux poches intérieures.\nRésiste à l'eau et aux produits liquides qui ont coulé !\nDimensions : 21 × 10 × 12 cm.",
    optionLabel: "Choisir une couleur",
    sizes: [{ label: "Jaune", price: 12 }, { label: "Bleue", price: 12 }],
  },
  {
    id: "mini-pochette", name: "Mini pochette",
    category: "pochettes", pattern: "fleur", palette: "safran",
    img: "/images/mini pochette.jpg",
    gallery: ["/images/mini pochette.jpg", "/images/mini pochette 2.jpg"],
    sizes: [{ label: "Taille unique", price: 6 }],
  },
  // ─── SACS ───────────────────────────────────────────────────────
  // ─── SACS ───────────────────────────────────────────────────────
  {
    id: "shopping-bag", name: "Shopping bag",
    category: "sacs", pattern: "fleur", palette: "terre",
    img: "/images/shopping-bag-1.jpg",
    gallery: ["/images/shopping-bag-1.jpg", "/images/shopping-bag-2.jpg", "/images/shopping-bag-3.jpg", "/images/shopping-bag-4.jpg", "/images/shopping-bag-5.jpg"],
    desc: "Extérieur 100% coton imprimé à la main.\nDouble poche intérieure avec zip.\nDimensions : 40 × 38 × 13 cm.",
    sizes: [{ label: "Taille unique", price: 20 }],
    tag: "Nouveauté",
  },
  {
    id: "travel-bag", name: "Sac de voyage",
    category: "sacs", pattern: "buti", palette: "indigo",
    img: "/images/travel-bag-1.jpg",
    gallery: ["/images/travel-bag-1.jpg", "/images/travel-bag-2.jpg", "/images/travel-bag-3.jpg", "/images/travel-bag-4.jpg", "/images/travel-bag-5.jpg", "/images/travel-bag-6.jpg"],
    desc: "Extérieur 100% coton imprimé à la main. Doublure coton. Fermeture par un zip. Double poche intérieure avec zip. Poche extérieure.",
    sizes: [{ label: "Taille unique", price: 29 }],
    tag: "Nouveauté",
  },
  {
    id: "market-bag", name: "Sac de marché",
    category: "sacs", pattern: "fleur", palette: "terre",
    img: "/images/market-bag-1.jpg",
    gallery: ["/images/market-bag-1.jpg", "/images/market-bag-2.jpg", "/images/market-bag-3.jpg"],
    desc: "Extérieur 100% coton imprimé à la main. Doublure intérieure coton. 8 poches intérieures.",
    sizes: [{ label: "Taille unique", price: 20 }],
    tag: "Nouveauté",
  },
  // ─── TROUSSES PERSONNALISABLES ───────────────────────────────────
  {
    id: "perso-02", name: "Trousse de bijoux personnalisable",
    category: "pochettes", pattern: "buti", palette: "safran",
    img: "/images/perso-2.jpg",
    desc: "Trousse à bijoux 100% coton blockprint. Personnalisable au prénom, idéale en cadeau.",
    sizes: [{ label: "Taille unique", price: 18 }],
    custom: true, tag: "Personnalisable",
  },
  // ─── MATELAS DE VOYAGE ──────────────────────────────────────────
];

const CATEGORIES = [
  { id: "nappes",    label: "Nappes",             lead: "Trois collections — Delhi, Bombay, Jaipur" },
{ id: "pochettes", label: "Trousses et pochettes", lead: "Pochettes et trousses blockprint, fermeture zippée" },

{ id: "sacs",      label: "Sacs",                 lead: "Sacs blockprint, fait main au Rajasthan" },
];

const COLLECTIONS = [
  { id: "Delhi", label: "Delhi", lead: "Motifs géométriques et unis" },
  { id: "Bombay", label: "Bombay", lead: "Motifs géométriques contemporains" },
  { id: "Jaipur", label: "Jaipur", lead: "Motifs floraux, inspiration moghole" },
];

Object.assign(window, { PRODUCTS, CATEGORIES, COLLECTIONS, PALETTES, makePattern });
