// ========================================
// EVENTOS DATA - Configuración de eventos
// ========================================
var CRC_TO_USD = 0.0022;

var EVENTS_DB = {
  "9175": {
    name: "ARJONA - SECO TOUR-14 AGOSTO",
    date: "viernes, 14 de agosto de 2026 — 19:00 HRS",
    venue: "ESTADIO NACIONAL",
    location: "Mata Redonda, San José, Costa Rica",
    mapImage: "https://api.eticket.co.cr/v2/structures/mappingImage/9175",
    poster: "https://cdn.eticket.cr/imagenes/imgEventos/260407124215101_poster_CARTEL.jpg",
    localities: [
      { name: "SECO NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 156400, color: "#E63946" },
      { name: "BAC NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 139000, color: "#F77F00" },
      { name: "VIP NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 127400, color: "#FCBF49" },
      { name: "PREFERENCIAL NUMERADA", type: "MAYOR 18AÑOS", priceCRC: 92700, color: "#2A9D8F" },
      { name: "PLATEA ESTE", type: "REGULAR", priceCRC: 75300, color: "#264653" },
      { name: "BALCON ESTE", type: "REGULAR", priceCRC: 63700, color: "#457B9D" },
      { name: "SOMBRA ESTE", type: "REGULAR", priceCRC: 51600, color: "#6D6875" },
      { name: "GRAMILLA DE PIE", type: "MAYOR 18AÑOS", priceCRC: 40600, color: "#8D99AE" }
    ]
  },
  "9189": {
    name: "ARJONA - SECO TOUR-15 AGOSTO",
    date: "sábado, 15 de agosto de 2026 — 19:00 HRS",
    venue: "ESTADIO NACIONAL",
    location: "Mata Redonda, San José, Costa Rica",
    mapImage: "https://api.eticket.co.cr/v2/structures/mappingImage/9189",
    poster: "https://cdn.eticket.cr/imagenes/imgEventos/260407124215101_poster_CARTEL.jpg",
    localities: [
      { name: "SECO NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 156400, color: "#E63946" },
      { name: "BAC NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 139000, color: "#F77F00" },
      { name: "VIP NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 127400, color: "#FCBF49" },
      { name: "PREFERENCIAL NUMERADA", type: "MAYOR 18AÑOS", priceCRC: 92700, color: "#2A9D8F" },
      { name: "PLATEA ESTE", type: "REGULAR", priceCRC: 75300, color: "#264653" },
      { name: "BALCON ESTE", type: "REGULAR", priceCRC: 63700, color: "#457B9D" },
      { name: "SOMBRA ESTE", type: "REGULAR", priceCRC: 51600, color: "#6D6875" },
      { name: "GRAMILLA DE PIE", type: "MAYOR 18AÑOS", priceCRC: 40600, color: "#8D99AE" }
    ]
  },
  "9190": {
    name: "ARJONA - SECO TOUR - 2",
    date: "Fecha por confirmar — 19:00 HRS",
    venue: "ESTADIO NACIONAL",
    location: "Mata Redonda, San José, Costa Rica",
    mapImage: "https://api.eticket.co.cr/v2/structures/mappingImage/9190",
    poster: "https://cdn.eticket.cr/imagenes/imgEventos/260407124215101_poster_CARTEL.jpg",
    localities: [
      { name: "SECO NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 156400, color: "#E63946" },
      { name: "BAC NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 139000, color: "#F77F00" },
      { name: "VIP NUMERADO", type: "MAYOR 18AÑOS", priceCRC: 127400, color: "#FCBF49" },
      { name: "PREFERENCIAL NUMERADA", type: "MAYOR 18AÑOS", priceCRC: 92700, color: "#2A9D8F" },
      { name: "PLATEA ESTE", type: "REGULAR", priceCRC: 75300, color: "#264653" },
      { name: "BALCON ESTE", type: "REGULAR", priceCRC: 63700, color: "#457B9D" },
      { name: "SOMBRA ESTE", type: "REGULAR", priceCRC: 51600, color: "#6D6875" },
      { name: "GRAMILLA DE PIE", type: "MAYOR 18AÑOS", priceCRC: 40600, color: "#8D99AE" }
    ]
  },
  "9249": {
    name: "CHAYANNE 2026 - BAILEMOS OTRA VEZ TOUR",
    date: "viernes, 22 de mayo de 2026 — 19:00 HRS",
    venue: "ESTADIO NACIONAL",
    location: "Mata Redonda, San José, Costa Rica",
    mapImage: "https://api.eticket.co.cr/v2/structures/mappingImage/9249",
    poster: "https://cdn.eticket.cr/imagenes/imgEventos/260130193803631_poster_500x715.jpg",
    localities: [
      { name: "EXPERIENCIA", type: "REGULAR", priceCRC: 174000, color: "#E63946" },
      { name: "SILLA ORO", type: "REGULAR", priceCRC: 144500, color: "#F77F00" },
      { name: "SILLA PLATA", type: "REGULAR", priceCRC: 108500, color: "#FCBF49" },
      { name: "SILLA BRONCE", type: "REGULAR", priceCRC: 70500, color: "#2A9D8F" },
      { name: "PALCOS B1", type: "PREFERENCIAL", priceCRC: 150500, color: "#264653" },
      { name: "PLATEA PREFERENCIAL", type: "PREFERENCIAL", priceCRC: 64500, color: "#457B9D" },
      { name: "PLATEA ESTE", type: "REGULAR", priceCRC: 58500, color: "#6D6875" },
      { name: "PLATEA OESTE", type: "REGULAR", priceCRC: 58500, color: "#8D99AE" },
      { name: "BALCON ESTE", type: "REGULAR", priceCRC: 51500, color: "#1D3557" },
      { name: "BALCON OESTE", type: "REGULAR", priceCRC: 51500, color: "#E63946" },
      { name: "SOMBRA ESTE", type: "REGULAR", priceCRC: 44000, color: "#F77F00" },
      { name: "SOMBRA OESTE", type: "REGULAR", priceCRC: 44000, color: "#FCBF49" },
      { name: "ZONA BACHATA DE PIE", type: "REGULAR", priceCRC: 30000, color: "#2A9D8F" },
      { name: "GRADERIA SUR SIN NUMERAR", type: "REGULAR", priceCRC: 34500, color: "#264653" },
      { name: "SOMBRA PREFERENCIAL", type: "PREFERENCIAL", priceCRC: 51500, color: "#457B9D" }
    ]
  },
  "9384": {
    name: "KAROL G - TROPITOUR 2026",
    date: "viernes, 27 de noviembre de 2026 — 19:00 HRS",
    venue: "ESTADIO NACIONAL",
    location: "Mata Redonda, San José, Costa Rica",
    mapImage: "https://api.eticket.co.cr/v2/structures/mappingImage/9384",
    poster: "assets/images/karolg_poster.png",
    localities: [
      { name: "200 COPAS PIT A", type: "MAYOR 18AÑOS", priceCRC: 170700, color: "#E63946" },
      { name: "200 COPAS PIT B", type: "MAYOR 18AÑOS", priceCRC: 170700, color: "#F77F00" },
      { name: "TROPICOQUETA", type: "MAYOR 18AÑOS", priceCRC: 73500, color: "#FCBF49" },
      { name: "PALCOS", type: "MAYOR 12AÑOS", priceCRC: 110000, color: "#2A9D8F" },
      { name: "PLATEA ESPECIAL", type: "MAYOR 12AÑOS", priceCRC: 97800, color: "#264653" },
      { name: "PLATEA ESTE", type: "MAYOR 12AÑOS", priceCRC: 61300, color: "#457B9D" },
      { name: "PLATEA OESTE", type: "MAYOR 12AÑOS", priceCRC: 61300, color: "#6D6875" },
      { name: "BALCON ESTE", type: "MAYOR 12AÑOS", priceCRC: 61300, color: "#8D99AE" },
      { name: "BALCON OESTE", type: "MAYOR 12AÑOS", priceCRC: 61300, color: "#1D3557" },
      { name: "SOMBRA ESTE", type: "MAYOR 12AÑOS", priceCRC: 45600, color: "#E63946" },
      { name: "SOMBRA OESTE", type: "MAYOR 12AÑOS", priceCRC: 45600, color: "#F77F00" },
      { name: "GRADERIA SUR 1ER/N", type: "MAYOR 12AÑOS", priceCRC: 33400, color: "#FCBF49" },
      { name: "GRADERIA SUR 2DO/N", type: "MAYOR 12AÑOS", priceCRC: 33400, color: "#2A9D8F" },
      { name: "GRADERIA SUR VISIB/LIM", type: "VISIBILIDAD LIMITADA +12", priceCRC: 33400, color: "#264653" },
      { name: "PLATEA ESTE VISIB/LIM", type: "VISIBILIDAD LIMITADA +12", priceCRC: 61300, color: "#457B9D" },
      { name: "PLATEA OESTE VISIB/LIM", type: "VISIBILIDAD LIMITADA +12", priceCRC: 61300, color: "#6D6875" },
      { name: "BALCON ESTE VISIB/LIM", type: "VISIBILIDAD LIMITADA +12", priceCRC: 61300, color: "#8D99AE" },
      { name: "BALCON OESTE VISIB/LIM", type: "VISIBILIDAD LIMITADA +12", priceCRC: 61300, color: "#1D3557" },
      { name: "GRAMILLA DE PIE", type: "MAYOR 18AÑOS", priceCRC: 39500, color: "#E63946" }
    ]
  },
  "16966": {
    name: "Mejor Tarde que Nunca Tour 2026",
    date: "viernes, 02 de octubre de 2026 — 19:00 HRS",
    venue: "Vive Claro Distrito Cultural",
    location: "Bogotá, Colombia",
    mapImage: "",
    poster: "https://cdn.getcrowder.com/images/e9109c28-ef36-4718-9dcd-e6c7cb7f96f5-romeoprincetiquetera640x640.png",
    currency: "COP",
    currencySymbol: "$",
    exchangeRate: 0.00026,
    localities: [
      { name: "Preferencial - Etapa 1", type: "PREVENTA CLARO", priceLocal: 189000, color: "#3A86C8" },
      { name: "Preferencial - Etapa 2", type: "PREVENTA CLARO", priceLocal: 240000, color: "#3A86C8" },
      { name: "Preferencial - Etapa 3", type: "PREVENTA CLARO", priceLocal: 264000, color: "#3A86C8" },
      { name: "117 - 124 - Etapa 1", type: "REGULAR", priceLocal: 300000, color: "#FF9F1C" },
      { name: "117 - 124 - Etapa 2", type: "REGULAR", priceLocal: 360000, color: "#FF9F1C" },
      { name: "125 - 132 - Etapa 1", type: "REGULAR", priceLocal: 420000, color: "#2EC4B6" },
      { name: "125 - 132 - Etapa 2", type: "REGULAR", priceLocal: 480000, color: "#2EC4B6" },
      { name: "111, 113 & 115 (Menores +12) - Etapa 1", type: "REGULAR +12", priceLocal: 600000, color: "#E71D36" },
      { name: "111, 113 & 115 (Menores +12) - Etapa 2", type: "REGULAR +12", priceLocal: 661000, color: "#E71D36" },
      { name: "112, 114 & 116 - Etapa 1", type: "REGULAR", priceLocal: 600000, color: "#E71D36" },
      { name: "112, 114 & 116 - Etapa 2", type: "REGULAR", priceLocal: 661000, color: "#E71D36" },
      { name: "107 & 109 (Menores +12) - Etapa 1", type: "REGULAR +12", priceLocal: 661000, color: "#011627" },
      { name: "107 & 109 (Menores +12) - Etapa 2", type: "REGULAR +12", priceLocal: 781000, color: "#011627" },
      { name: "108 & 110 - Etapa 1", type: "REGULAR", priceLocal: 661000, color: "#011627" },
      { name: "108 & 110 - Etapa 2", type: "REGULAR", priceLocal: 781000, color: "#011627" },
      { name: "101, 103 & 105 (Menores +12) - Etapa 1", type: "REGULAR +12", priceLocal: 841000, color: "#FF007F" },
      { name: "101, 103 & 105 (Menores +12) - Etapa 2", type: "REGULAR +12", priceLocal: 961000, color: "#FF007F" },
      { name: "102, 104 & 106 - Etapa 1", type: "REGULAR", priceLocal: 841000, color: "#FF007F" },
      { name: "102, 104 & 106 - Etapa 2", type: "REGULAR", priceLocal: 961000, color: "#FF007F" },
      { name: "Platea E - Etapa 1", type: "PLATEA", priceLocal: 781000, color: "#8338EC" },
      { name: "Platea E - Etapa 2", type: "PLATEA", priceLocal: 901000, color: "#8338EC" },
      { name: "Platea D - Etapa 1", type: "PLATEA", priceLocal: 901000, color: "#3A86C8" },
      { name: "Platea D - Etapa 2", type: "PLATEA", priceLocal: 1021000, color: "#3A86C8" },
      { name: "Platea C - Etapa 1", type: "PLATEA", priceLocal: 961000, color: "#06D6A0" },
      { name: "Platea C - Etapa 2", type: "PLATEA", priceLocal: 1081000, color: "#06D6A0" },
      { name: "Platea B - Etapa 1", type: "PLATEA", priceLocal: 1081000, color: "#FFD166" },
      { name: "Platea B - Etapa 2", type: "PLATEA", priceLocal: 1202000, color: "#FFD166" },
      { name: "Platea A - Etapa 1", type: "PLATEA", priceLocal: 1202000, color: "#EF476F" },
      { name: "Platea A - Etapa 2", type: "PLATEA", priceLocal: 1322000, color: "#EF476F" },
      { name: "Palcos Oro - Etapa 1", type: "PALCOS", priceLocal: 10080000, color: "#D4AF37" },
      { name: "Palcos Diamante - Etapa 1", type: "PALCOS", priceLocal: 12310000, color: "#E5E4E2" }
    ]
  }
};

function formatCRC(n) {
  return n.toLocaleString('es-CR');
}
function crcToUSD(crc) {
  return (crc * CRC_TO_USD).toFixed(2);
}

function formatCurrency(n, currency) {
  if (currency === 'COP') {
    return n.toLocaleString('es-CO');
  } else {
    return n.toLocaleString('es-CR');
  }
}

function localToUSD(price, event) {
  var rate = event.exchangeRate || 0.0022;
  return (price * rate).toFixed(2);
}
