'use strict';

// Base de datos de puertos mundiales principales (World Port Index subset)
// Lat/Lon, nombre, país, zoom recomendado
const WORLD_PORTS = [
  // ── COLOMBIA ──────────────────────────────────────────────────────────────
  { name:'Barranquilla / Bocas de Ceniza', country:'Colombia', lat:10.9878, lon:-74.8040, zoom:13 },
  { name:'Cartagena de Indias',            country:'Colombia', lat:10.4236, lon:-75.5478, zoom:13 },
  { name:'Santa Marta',                    country:'Colombia', lat:11.2408, lon:-74.2041, zoom:13 },
  { name:'Buenaventura',                   country:'Colombia', lat:3.8800,  lon:-77.0300, zoom:13 },
  { name:'Tumaco',                         country:'Colombia', lat:1.8000,  lon:-78.7600, zoom:13 },
  { name:'Turbo',                          country:'Colombia', lat:8.0980,  lon:-76.7220, zoom:13 },
  { name:'Puerto Bolívar (Guajira)',       country:'Colombia', lat:12.2358, lon:-71.9578, zoom:13 },
  { name:'Coveñas',                        country:'Colombia', lat:9.4025,  lon:-75.6861, zoom:13 },
  { name:'Riohacha',                       country:'Colombia', lat:11.5444, lon:-72.9069, zoom:13 },
  // ── USA — NEW YORK AREA ───────────────────────────────────────────────────
  { name:'New York — Port Newark / Elizabeth', country:'USA', lat:40.6640, lon:-74.1435, zoom:13 },
  { name:'New York — Bayonne',             country:'USA',      lat:40.6654, lon:-74.1151, zoom:13 },
  { name:'New York — Staten Island',       country:'USA',      lat:40.6015, lon:-74.0707, zoom:12 },
  { name:'New York — Upper Bay',           country:'USA',      lat:40.6501, lon:-74.0399, zoom:11 },
  { name:'New York — Brooklyn / Red Hook', country:'USA',      lat:40.6762, lon:-74.0102, zoom:13 },
  { name:'New York — Manhattan',           country:'USA',      lat:40.7128, lon:-74.0059, zoom:12 },
  { name:'New York — Jamaica Bay',         country:'USA',      lat:40.6130, lon:-73.8276, zoom:12 },
  { name:'New York Anchorage',             country:'USA',      lat:40.5900, lon:-74.0500, zoom:11 },
  { name:'Long Island Sound',              country:'USA',      lat:41.0534, lon:-73.5387, zoom:10 },
  { name:'New Haven CT',                   country:'USA',      lat:41.3082, lon:-72.9282, zoom:13 },
  { name:'Bridgeport CT',                  country:'USA',      lat:41.1670, lon:-73.2048, zoom:13 },
  // ── USA — EAST COAST ──────────────────────────────────────────────────────
  { name:'Boston',                         country:'USA',      lat:42.3554, lon:-71.0526, zoom:12 },
  { name:'Providence RI',                  country:'USA',      lat:41.8240, lon:-71.4128, zoom:13 },
  { name:'Portland ME',                    country:'USA',      lat:43.6591, lon:-70.2568, zoom:13 },
  { name:'Baltimore',                      country:'USA',      lat:39.2724, lon:-76.5790, zoom:12 },
  { name:'Philadelphia',                   country:'USA',      lat:39.9526, lon:-75.1652, zoom:12 },
  { name:'Wilmington DE',                  country:'USA',      lat:39.7447, lon:-75.5484, zoom:13 },
  { name:'Norfolk / Hampton Roads',        country:'USA',      lat:36.8468, lon:-76.2951, zoom:12 },
  { name:'Newport News',                   country:'USA',      lat:36.9787, lon:-76.4300, zoom:13 },
  { name:'Savannah',                       country:'USA',      lat:32.0835, lon:-81.0998, zoom:12 },
  { name:'Charleston SC',                  country:'USA',      lat:32.7765, lon:-79.9311, zoom:12 },
  { name:'Wilmington NC',                  country:'USA',      lat:34.2257, lon:-77.9447, zoom:13 },
  { name:'Jacksonville',                   country:'USA',      lat:30.3322, lon:-81.6557, zoom:12 },
  { name:'Miami',                          country:'USA',      lat:25.7743, lon:-80.1937, zoom:12 },
  { name:'Port Everglades (Fort Lauderdale)', country:'USA',   lat:26.0931, lon:-80.1148, zoom:13 },
  { name:'Tampa',                          country:'USA',      lat:27.9506, lon:-82.4572, zoom:12 },
  { name:'Key West',                       country:'USA',      lat:24.5551, lon:-81.7800, zoom:13 },
  // ── USA — GULF COAST ─────────────────────────────────────────────────────
  { name:'New Orleans',                    country:'USA',      lat:29.9511, lon:-90.0715, zoom:12 },
  { name:'Houston',                        country:'USA',      lat:29.7604, lon:-95.3698, zoom:11 },
  { name:'Texas City',                     country:'USA',      lat:29.3838, lon:-94.9027, zoom:13 },
  { name:'Galveston',                      country:'USA',      lat:29.3013, lon:-94.7977, zoom:13 },
  { name:'Beaumont',                       country:'USA',      lat:30.0802, lon:-94.1266, zoom:12 },
  { name:'Lake Charles',                   country:'USA',      lat:30.2266, lon:-93.2174, zoom:12 },
  { name:'Baton Rouge',                    country:'USA',      lat:30.4515, lon:-91.1871, zoom:12 },
  { name:'Mobile',                         country:'USA',      lat:30.6954, lon:-88.0399, zoom:12 },
  { name:'Pascagoula',                     country:'USA',      lat:30.3460, lon:-88.5562, zoom:13 },
  { name:'Corpus Christi',                 country:'USA',      lat:27.8006, lon:-97.3964, zoom:12 },
  { name:'Brownsville',                    country:'USA',      lat:25.9017, lon:-97.4975, zoom:13 },
  { name:'Pensacola',                      country:'USA',      lat:30.4213, lon:-87.2169, zoom:13 },
  // ── USA — WEST COAST ─────────────────────────────────────────────────────
  { name:'Los Angeles / Long Beach',       country:'USA',      lat:33.7454, lon:-118.2260, zoom:12 },
  { name:'San Diego',                      country:'USA',      lat:32.7157, lon:-117.1611, zoom:12 },
  { name:'San Francisco',                  country:'USA',      lat:37.7749, lon:-122.4194, zoom:12 },
  { name:'Oakland',                        country:'USA',      lat:37.8044, lon:-122.2711, zoom:12 },
  { name:'Sacramento',                     country:'USA',      lat:38.5816, lon:-121.4944, zoom:12 },
  { name:'Stockton',                       country:'USA',      lat:37.9577, lon:-121.2908, zoom:13 },
  { name:'Portland OR',                    country:'USA',      lat:45.5231, lon:-122.6765, zoom:12 },
  { name:'Seattle / Puget Sound',          country:'USA',      lat:47.6062, lon:-122.3321, zoom:12 },
  { name:'Tacoma',                         country:'USA',      lat:47.2529, lon:-122.4443, zoom:12 },
  { name:'Everett WA',                     country:'USA',      lat:47.9790, lon:-122.2021, zoom:13 },
  { name:'Olympia WA',                     country:'USA',      lat:47.0379, lon:-122.9007, zoom:13 },
  { name:'Astoria OR',                     country:'USA',      lat:46.1879, lon:-123.8313, zoom:13 },
  { name:'Coos Bay OR',                    country:'USA',      lat:43.3665, lon:-124.2179, zoom:13 },
  { name:'Eureka CA',                      country:'USA',      lat:40.8021, lon:-124.1637, zoom:13 },
  { name:'Anchorage',                      country:'USA',      lat:61.2181, lon:-149.9003, zoom:11 },
  { name:'Kodiak AK',                      country:'USA',      lat:57.7900, lon:-152.4072, zoom:12 },
  { name:'Juneau AK',                      country:'USA',      lat:58.3005, lon:-134.4197, zoom:12 },
  { name:'Dutch Harbor AK',               country:'USA',      lat:53.8836, lon:-166.5422, zoom:12 },
  { name:'Honolulu HI',                   country:'USA',      lat:21.3069, lon:-157.8583, zoom:12 },
  { name:'Hilo HI',                        country:'USA',      lat:19.7297, lon:-155.0900, zoom:13 },
  // ── USA — INLAND / GREAT LAKES ───────────────────────────────────────────
  { name:'Chicago',                        country:'USA',      lat:41.8781, lon:-87.6298,  zoom:12 },
  { name:'Detroit',                        country:'USA',      lat:42.3314, lon:-83.0458,  zoom:12 },
  { name:'Toledo OH',                      country:'USA',      lat:41.6639, lon:-83.5552,  zoom:13 },
  { name:'Cleveland',                      country:'USA',      lat:41.4993, lon:-81.6944,  zoom:12 },
  { name:'Buffalo NY',                     country:'USA',      lat:42.8864, lon:-78.8784,  zoom:12 },
  { name:'Duluth',                         country:'USA',      lat:46.7867, lon:-92.1005,  zoom:12 },
  { name:'Milwaukee',                      country:'USA',      lat:43.0389, lon:-87.9065,  zoom:12 },
  { name:'Gary IN',                        country:'USA',      lat:41.5934, lon:-87.3465,  zoom:13 },
  { name:'Burns Harbor IN',               country:'USA',      lat:41.6364, lon:-87.1928,  zoom:13 },
  // ── CANADA ───────────────────────────────────────────────────────────────
  { name:'Vancouver',                      country:'Canada',   lat:49.2827, lon:-123.1207, zoom:12 },
  { name:'Prince Rupert',                  country:'Canada',   lat:54.3150, lon:-130.3208, zoom:12 },
  { name:'Victoria BC',                    country:'Canada',   lat:48.4284, lon:-123.3656, zoom:13 },
  { name:'Nanaimo BC',                     country:'Canada',   lat:49.1659, lon:-123.9401, zoom:13 },
  { name:'Kitimat BC',                     country:'Canada',   lat:54.0534, lon:-128.6534, zoom:13 },
  { name:'Montreal',                       country:'Canada',   lat:45.5088, lon:-73.5878,  zoom:12 },
  { name:'Quebec City',                    country:'Canada',   lat:46.8139, lon:-71.2080,  zoom:12 },
  { name:'Halifax',                        country:'Canada',   lat:44.6488, lon:-63.5752,  zoom:12 },
  { name:'Saint John NB',                  country:'Canada',   lat:45.2733, lon:-66.0633,  zoom:12 },
  { name:'St. John\'s NL',                country:'Canada',   lat:47.5615, lon:-52.7126,  zoom:12 },
  { name:'Thunder Bay ON',                country:'Canada',   lat:48.3809, lon:-89.2477,  zoom:12 },
  { name:'Hamilton ON',                   country:'Canada',   lat:43.2557, lon:-79.8711,  zoom:13 },
  { name:'Windsor ON',                    country:'Canada',   lat:42.3149, lon:-83.0364,  zoom:13 },
  // ── MÉXICO ────────────────────────────────────────────────────────────────
  { name:'Veracruz',                       country:'Mexico',   lat:19.2098, lon:-96.1322,  zoom:12 },
  { name:'Manzanillo MX',                 country:'Mexico',   lat:19.0529, lon:-104.3188, zoom:13 },
  { name:'Lázaro Cárdenas',               country:'Mexico',   lat:17.9510, lon:-102.2000, zoom:12 },
  { name:'Altamira',                       country:'Mexico',   lat:22.4086, lon:-97.9206,  zoom:13 },
  { name:'Tampico',                        country:'Mexico',   lat:22.2475, lon:-97.8619,  zoom:13 },
  { name:'Coatzacoalcos',                 country:'Mexico',   lat:18.1466, lon:-94.4363,  zoom:13 },
  { name:'Progreso (Yucatan)',            country:'Mexico',   lat:21.2800, lon:-89.6600,  zoom:13 },
  { name:'Ensenada',                       country:'Mexico',   lat:31.8500, lon:-116.6000, zoom:13 },
  { name:'Guaymas',                        country:'Mexico',   lat:27.9270, lon:-110.9040, zoom:13 },
  // ── CARIBE / CENTROAMÉRICA ────────────────────────────────────────────────
  { name:'Panama Canal — Colon (Atlantic)', country:'Panama',  lat:9.3606,  lon:-79.9006,  zoom:12 },
  { name:'Panama Canal — Balboa (Pacific)', country:'Panama',  lat:8.9533,  lon:-79.5660,  zoom:12 },
  { name:'Panama City (Rodman)',           country:'Panama',   lat:8.9333,  lon:-79.5500,  zoom:13 },
  { name:'Manzanillo Panama',             country:'Panama',   lat:9.3700,  lon:-79.8500,  zoom:13 },
  { name:'Kingston',                       country:'Jamaica',  lat:17.9957, lon:-76.7895,  zoom:12 },
  { name:'Puerto Limón',                   country:'Costa Rica',lat:9.9913, lon:-83.0281,  zoom:13 },
  { name:'Caldera',                        country:'Costa Rica',lat:9.9056, lon:-84.7153,  zoom:13 },
  { name:'Puerto Cortés',                  country:'Honduras', lat:15.8400, lon:-87.9500,  zoom:13 },
  { name:'Santo Tomás de Castilla',       country:'Guatemala',lat:15.6833, lon:-88.6167,  zoom:13 },
  { name:'Acajutla',                       country:'El Salvador',lat:13.5944,lon:-89.8331, zoom:13 },
  { name:'Managua (Corinto)',             country:'Nicaragua', lat:12.4892, lon:-87.1747,  zoom:13 },
  { name:'Santo Domingo',                  country:'Dominican R.',lat:18.4672,lon:-69.9505,zoom:13 },
  { name:'San Juan, PR',                   country:'USA',      lat:18.4663, lon:-66.1185,  zoom:13 },
  { name:'Havana',                         country:'Cuba',     lat:23.1423, lon:-82.3738,  zoom:13 },
  { name:'Santiago de Cuba',              country:'Cuba',     lat:20.0000, lon:-75.8333,  zoom:13 },
  { name:'Cienfuegos',                     country:'Cuba',     lat:22.1416, lon:-80.4536,  zoom:13 },
  { name:'Port-au-Prince',                country:'Haiti',    lat:18.5481, lon:-72.3382,  zoom:12 },
  { name:'Bridgetown (Barbados)',         country:'Barbados', lat:13.1132, lon:-59.6099,  zoom:13 },
  { name:'Willemstad (Curaçao)',          country:'Netherlands A.',lat:12.1224,lon:-68.9420,zoom:13},
  { name:'Oranjestad (Aruba)',            country:'Aruba',    lat:12.5092, lon:-70.0086,  zoom:13 },
  { name:'Paramaribo',                     country:'Suriname', lat:5.8520,  lon:-55.2038,  zoom:12 },
  { name:'Georgetown (Guyana)',           country:'Guyana',   lat:6.8013,  lon:-58.1553,  zoom:12 },
  // ── VENEZUELA ────────────────────────────────────────────────────────────
  { name:'Maracaibo',                      country:'Venezuela', lat:10.6333, lon:-71.6333,  zoom:12 },
  { name:'La Guaira',                      country:'Venezuela', lat:10.6025, lon:-66.9289,  zoom:13 },
  { name:'Puerto Cabello',                country:'Venezuela', lat:10.4767, lon:-68.0100,  zoom:13 },
  { name:'Barcelona (Venezuela)',         country:'Venezuela', lat:10.1278, lon:-64.6868,  zoom:13 },
  { name:'Port of Spain',                  country:'Trinidad',  lat:10.6518, lon:-61.5187,  zoom:13 },
  // ── SUDAMÉRICA ────────────────────────────────────────────────────────────
  { name:'Guayaquil',                      country:'Ecuador',  lat:-2.1667, lon:-79.9000,  zoom:12 },
  { name:'Esmeraldas',                     country:'Ecuador',  lat:0.9500,  lon:-79.6500,  zoom:13 },
  { name:'Callao (Lima)',                  country:'Peru',     lat:-12.0567,lon:-77.1547,  zoom:12 },
  { name:'Ilo',                            country:'Peru',     lat:-17.6500,lon:-71.3333,  zoom:13 },
  { name:'Salaverry',                      country:'Peru',     lat:-8.2167, lon:-78.9833,  zoom:13 },
  { name:'Paita',                          country:'Peru',     lat:-5.0833, lon:-81.1000,  zoom:13 },
  { name:'Arica',                          country:'Chile',    lat:-18.4746,lon:-70.3194,  zoom:13 },
  { name:'Iquique',                        country:'Chile',    lat:-20.2132,lon:-70.1534,  zoom:13 },
  { name:'Antofagasta',                    country:'Chile',    lat:-23.6519,lon:-70.3954,  zoom:13 },
  { name:'Coquimbo',                       country:'Chile',    lat:-29.9527,lon:-71.3386,  zoom:13 },
  { name:'Valparaíso',                     country:'Chile',    lat:-33.0472,lon:-71.6127,  zoom:12 },
  { name:'San Antonio (Chile)',            country:'Chile',    lat:-33.5938,lon:-71.6161,  zoom:13 },
  { name:'Talcahuano / Concepción',       country:'Chile',    lat:-36.7167,lon:-73.1167,  zoom:12 },
  { name:'Puerto Montt',                   country:'Chile',    lat:-41.4717,lon:-72.9333,  zoom:13 },
  { name:'Punta Arenas',                   country:'Chile',    lat:-53.1638,lon:-70.9171,  zoom:12 },
  { name:'Buenos Aires',                   country:'Argentina',lat:-34.6037,lon:-58.3816,  zoom:11 },
  { name:'La Plata (Dock Sud)',           country:'Argentina',lat:-34.6667,lon:-58.3333,  zoom:12 },
  { name:'Rosario',                        country:'Argentina',lat:-32.9442,lon:-60.6505,  zoom:12 },
  { name:'Bahía Blanca',                   country:'Argentina',lat:-38.7196,lon:-62.2724,  zoom:12 },
  { name:'Mar del Plata',                  country:'Argentina',lat:-38.0023,lon:-57.5575,  zoom:13 },
  { name:'Ushuaia',                        country:'Argentina',lat:-54.8019,lon:-68.3029,  zoom:13 },
  { name:'Montevideo',                     country:'Uruguay',  lat:-34.9011,lon:-56.1915,  zoom:12 },
  { name:'Santos',                         country:'Brazil',   lat:-23.9538,lon:-46.3328,  zoom:12 },
  { name:'São Sebastião',                 country:'Brazil',   lat:-23.8035,lon:-45.4058,  zoom:13 },
  { name:'Rio de Janeiro',                 country:'Brazil',   lat:-22.8938,lon:-43.1892,  zoom:11 },
  { name:'Itaguai (Sepetiba)',             country:'Brazil',   lat:-22.9300,lon:-43.7800,  zoom:12 },
  { name:'Vitória',                        country:'Brazil',   lat:-20.3222,lon:-40.3381,  zoom:13 },
  { name:'Salvador de Bahia',              country:'Brazil',   lat:-12.9711,lon:-38.5108,  zoom:12 },
  { name:'Aratu',                          country:'Brazil',   lat:-12.7833,lon:-38.5000,  zoom:13 },
  { name:'Ilhéus',                         country:'Brazil',   lat:-14.7853,lon:-39.0394,  zoom:13 },
  { name:'Fortaleza',                      country:'Brazil',   lat:-3.7172, lon:-38.5433,  zoom:12 },
  { name:'Natal',                          country:'Brazil',   lat:-5.7945, lon:-35.2110,  zoom:13 },
  { name:'Recife',                         country:'Brazil',   lat:-8.0476, lon:-34.8770,  zoom:12 },
  { name:'Maceió',                         country:'Brazil',   lat:-9.6658, lon:-35.7350,  zoom:13 },
  { name:'Manaus',                         country:'Brazil',   lat:-3.1190, lon:-60.0217,  zoom:12 },
  { name:'Belém',                          country:'Brazil',   lat:-1.4558, lon:-48.5044,  zoom:12 },
  { name:'São Luís (Ponta da Madeira)',   country:'Brazil',   lat:-2.6297, lon:-44.3028,  zoom:12 },
  { name:'Santarém',                       country:'Brazil',   lat:-2.4443, lon:-54.7082,  zoom:13 },
  // ── EUROPA — NORTE ────────────────────────────────────────────────────────
  { name:'Rotterdam',                      country:'Netherlands',lat:51.9225,lon:4.4792,   zoom:12 },
  { name:'Amsterdam',                      country:'Netherlands',lat:52.3676,lon:4.9041,   zoom:12 },
  { name:'Hamburg',                        country:'Germany',  lat:53.5753, lon:9.9935,    zoom:12 },
  { name:'Bremen / Bremerhaven',          country:'Germany',  lat:53.5386, lon:8.5833,    zoom:12 },
  { name:'Antwerp',                        country:'Belgium',  lat:51.2213, lon:4.3997,    zoom:12 },
  { name:'Zeebrugge',                      country:'Belgium',  lat:51.3478, lon:3.1972,    zoom:13 },
  { name:'Felixstowe',                     country:'UK',       lat:51.9606, lon:1.3160,    zoom:13 },
  { name:'London (Tilbury)',               country:'UK',       lat:51.4509, lon:0.3553,    zoom:12 },
  { name:'Southampton',                    country:'UK',       lat:50.8988, lon:-1.4044,   zoom:12 },
  { name:'Liverpool',                      country:'UK',       lat:53.4084, lon:-2.9916,   zoom:12 },
  { name:'Grimsby / Immingham',           country:'UK',       lat:53.6150, lon:-0.1850,   zoom:12 },
  { name:'Bristol / Avonmouth',           country:'UK',       lat:51.4996, lon:-2.6956,   zoom:12 },
  { name:'Glasgow / Greenock',            country:'UK',       lat:55.9516, lon:-4.7540,   zoom:12 },
  { name:'Belfast',                        country:'UK',       lat:54.5973, lon:-5.9301,   zoom:12 },
  { name:'Dublin',                         country:'Ireland',  lat:53.3498, lon:-6.2603,   zoom:12 },
  { name:'Cork',                           country:'Ireland',  lat:51.8979, lon:-8.4706,   zoom:12 },
  { name:'Le Havre',                       country:'France',   lat:49.4944, lon:0.1079,    zoom:12 },
  { name:'Dunkerque',                      country:'France',   lat:51.0343, lon:2.3767,    zoom:12 },
  { name:'Nantes / Saint-Nazaire',        country:'France',   lat:47.2184, lon:-2.2001,   zoom:12 },
  { name:'Bordeaux',                       country:'France',   lat:44.8378, lon:-0.5792,   zoom:12 },
  { name:'Marseille',                      country:'France',   lat:43.2965, lon:5.3818,    zoom:12 },
  { name:'Fos-sur-Mer',                   country:'France',   lat:43.4378, lon:4.9436,    zoom:13 },
  { name:'Oslo',                           country:'Norway',   lat:59.9139, lon:10.7522,   zoom:12 },
  { name:'Bergen',                         country:'Norway',   lat:60.3913, lon:5.3221,    zoom:12 },
  { name:'Stavanger',                      country:'Norway',   lat:58.9700, lon:5.7331,    zoom:12 },
  { name:'Tromsø',                         country:'Norway',   lat:69.6492, lon:18.9553,   zoom:12 },
  { name:'Gothenburg',                     country:'Sweden',   lat:57.7089, lon:11.9746,   zoom:12 },
  { name:'Stockholm',                      country:'Sweden',   lat:59.3293, lon:18.0686,   zoom:12 },
  { name:'Malmö',                          country:'Sweden',   lat:55.6050, lon:13.0038,   zoom:13 },
  { name:'Copenhagen',                     country:'Denmark',  lat:55.6761, lon:12.5683,   zoom:12 },
  { name:'Aarhus',                         country:'Denmark',  lat:56.1629, lon:10.2039,   zoom:13 },
  { name:'Esbjerg',                        country:'Denmark',  lat:55.4764, lon:8.4594,    zoom:13 },
  { name:'Helsinki',                       country:'Finland',  lat:60.1699, lon:24.9384,   zoom:12 },
  { name:'Turku',                          country:'Finland',  lat:60.4518, lon:22.2666,   zoom:13 },
  { name:'Gdansk',                         country:'Poland',   lat:54.3520, lon:18.6466,   zoom:12 },
  { name:'Gdynia',                         country:'Poland',   lat:54.5189, lon:18.5305,   zoom:13 },
  { name:'Szczecin',                       country:'Poland',   lat:53.4285, lon:14.5528,   zoom:13 },
  { name:'Rostock',                        country:'Germany',  lat:54.0887, lon:12.1403,   zoom:13 },
  { name:'Kiel',                           country:'Germany',  lat:54.3233, lon:10.1228,   zoom:12 },
  { name:'Tallinn',                        country:'Estonia',  lat:59.4370, lon:24.7536,   zoom:12 },
  { name:'Riga',                           country:'Latvia',   lat:56.9460, lon:24.1059,   zoom:12 },
  { name:'Klaipeda',                       country:'Lithuania',lat:55.7033, lon:21.1443,   zoom:13 },
  { name:'Kaliningrad',                    country:'Russia',   lat:54.7104, lon:20.4522,   zoom:12 },
  { name:'St. Petersburg',                country:'Russia',   lat:59.9343, lon:30.3351,   zoom:11 },
  // ── EUROPA — SUR ─────────────────────────────────────────────────────────
  { name:'Barcelona',                      country:'Spain',    lat:41.3851, lon:2.1734,    zoom:12 },
  { name:'Valencia',                       country:'Spain',    lat:39.4699, lon:-0.3763,   zoom:12 },
  { name:'Algeciras',                      country:'Spain',    lat:36.1388, lon:-5.4530,   zoom:12 },
  { name:'Bilbao',                         country:'Spain',    lat:43.3630, lon:-3.0013,   zoom:12 },
  { name:'Vigo',                           country:'Spain',    lat:42.2328, lon:-8.7226,   zoom:12 },
  { name:'Huelva',                         country:'Spain',    lat:37.2614, lon:-6.9447,   zoom:13 },
  { name:'Tarragona',                      country:'Spain',    lat:41.1189, lon:1.2445,    zoom:13 },
  { name:'Cartagena (Spain)',             country:'Spain',    lat:37.6012, lon:-0.9862,   zoom:13 },
  { name:'Las Palmas (Gran Canaria)',     country:'Spain',    lat:28.1472, lon:-15.4362,  zoom:12 },
  { name:'Santa Cruz de Tenerife',       country:'Spain',    lat:28.4636, lon:-16.2518,  zoom:13 },
  { name:'Lisbon',                         country:'Portugal', lat:38.7223, lon:-9.1393,   zoom:12 },
  { name:'Sines',                          country:'Portugal', lat:37.9513, lon:-8.8696,   zoom:13 },
  { name:'Leixões (Porto)',               country:'Portugal', lat:41.1860, lon:-8.7058,   zoom:13 },
  { name:'Genoa',                          country:'Italy',    lat:44.4056, lon:8.9463,    zoom:12 },
  { name:'La Spezia',                      country:'Italy',    lat:44.1024, lon:9.8240,    zoom:13 },
  { name:'Livorno',                        country:'Italy',    lat:43.5485, lon:10.3106,   zoom:13 },
  { name:'Civitavecchia (Rome)',          country:'Italy',    lat:42.0878, lon:11.7942,   zoom:13 },
  { name:'Naples',                         country:'Italy',    lat:40.8358, lon:14.2488,   zoom:12 },
  { name:'Gioia Tauro',                    country:'Italy',    lat:38.4265, lon:15.8992,   zoom:13 },
  { name:'Taranto',                        country:'Italy',    lat:40.4644, lon:17.2470,   zoom:13 },
  { name:'Venice',                         country:'Italy',    lat:45.4408, lon:12.3155,   zoom:12 },
  { name:'Trieste',                        country:'Italy',    lat:45.6495, lon:13.7768,   zoom:13 },
  { name:'Piraeus (Athens)',               country:'Greece',   lat:37.9477, lon:23.6458,   zoom:12 },
  { name:'Thessaloniki',                   country:'Greece',   lat:40.6401, lon:22.9444,   zoom:12 },
  { name:'Heraklion (Crete)',             country:'Greece',   lat:35.3387, lon:25.1442,   zoom:13 },
  { name:'Istanbul',                       country:'Turkey',   lat:41.0082, lon:28.9784,   zoom:12 },
  { name:'Izmir',                          country:'Turkey',   lat:38.4192, lon:27.1287,   zoom:12 },
  { name:'Mersin',                         country:'Turkey',   lat:36.8000, lon:34.6333,   zoom:13 },
  { name:'Iskenderun',                     country:'Turkey',   lat:36.5860, lon:36.1720,   zoom:13 },
  { name:'Izmit (Kocaeli)',                country:'Turkey',   lat:40.7654, lon:29.9408,   zoom:12 },
  { name:'Split',                          country:'Croatia',  lat:43.5081, lon:16.4402,   zoom:13 },
  { name:'Rijeka',                         country:'Croatia',  lat:45.3271, lon:14.4422,   zoom:13 },
  { name:'Koper',                          country:'Slovenia', lat:45.5517, lon:13.7301,   zoom:13 },
  { name:'Valletta (Malta)',              country:'Malta',    lat:35.8997, lon:14.5147,   zoom:13 },
  // ── MEDIO ORIENTE ────────────────────────────────────────────────────────
  { name:'Dubai (Jebel Ali)',              country:'UAE',      lat:24.9969, lon:55.0613,   zoom:12 },
  { name:'Dubai (Port Rashid)',           country:'UAE',      lat:25.2697, lon:55.2786,   zoom:13 },
  { name:'Abu Dhabi (Khalifa)',           country:'UAE',      lat:24.8000, lon:54.6500,   zoom:12 },
  { name:'Sharjah',                        country:'UAE',      lat:25.3463, lon:55.4209,   zoom:13 },
  { name:'Fujairah',                       country:'UAE',      lat:25.1288, lon:56.3261,   zoom:13 },
  { name:'Muscat (Sultan Qaboos)',        country:'Oman',     lat:23.6138, lon:58.5922,   zoom:12 },
  { name:'Salalah',                        country:'Oman',     lat:16.9450, lon:54.0050,   zoom:12 },
  { name:'Sohar',                          country:'Oman',     lat:24.3442, lon:56.6450,   zoom:13 },
  { name:'Jeddah',                         country:'Saudi Arabia',lat:21.4858,lon:39.1925, zoom:12 },
  { name:'Dammam / King Abdul Aziz',      country:'Saudi Arabia',lat:26.4337,lon:50.1033, zoom:12 },
  { name:'Yanbu',                          country:'Saudi Arabia',lat:24.0876,lon:38.0618, zoom:13 },
  { name:'Aqaba',                          country:'Jordan',   lat:29.5269, lon:35.0061,   zoom:13 },
  { name:'Kuwait City',                    country:'Kuwait',   lat:29.3759, lon:47.9774,   zoom:12 },
  { name:'Shuwaikh',                       country:'Kuwait',   lat:29.3500, lon:47.9333,   zoom:13 },
  { name:'Bandar Imam Khomeini',          country:'Iran',     lat:30.4350, lon:49.0758,   zoom:12 },
  { name:'Bandar Abbas',                   country:'Iran',     lat:27.1865, lon:56.2808,   zoom:12 },
  { name:'Ashdod',                         country:'Israel',   lat:31.8100, lon:34.6900,   zoom:13 },
  { name:'Haifa',                          country:'Israel',   lat:32.8191, lon:34.9983,   zoom:12 },
  { name:'Beirut',                         country:'Lebanon',  lat:33.8938, lon:35.5018,   zoom:12 },
  { name:'Latakia',                        country:'Syria',    lat:35.5317, lon:35.7911,   zoom:13 },
  { name:'Tartus',                         country:'Syria',    lat:34.8950, lon:35.8864,   zoom:13 },
  // ── AFRICA — NORTE ────────────────────────────────────────────────────────
  { name:'Suez Canal — Port Said',        country:'Egypt',    lat:31.2565, lon:32.2841,   zoom:12 },
  { name:'Suez Canal — Suez',             country:'Egypt',    lat:29.9668, lon:32.5498,   zoom:13 },
  { name:'Alexandria',                     country:'Egypt',    lat:31.2001, lon:29.9187,   zoom:12 },
  { name:'Damietta',                       country:'Egypt',    lat:31.4167, lon:31.8167,   zoom:13 },
  { name:'Tripoli (Libya)',               country:'Libya',    lat:32.9020, lon:13.1803,   zoom:12 },
  { name:'Benghazi',                       country:'Libya',    lat:32.1167, lon:20.0667,   zoom:13 },
  { name:'Tunis / La Goulette',          country:'Tunisia',  lat:36.8190, lon:10.2306,   zoom:12 },
  { name:'Sfax',                           country:'Tunisia',  lat:34.7406, lon:10.7603,   zoom:13 },
  { name:'Annaba',                         country:'Algeria',  lat:36.9167, lon:7.7667,    zoom:13 },
  { name:'Algiers',                        country:'Algeria',  lat:36.7372, lon:3.0870,    zoom:12 },
  { name:'Oran',                           country:'Algeria',  lat:35.6969, lon:-0.6331,   zoom:13 },
  { name:'Casablanca',                     country:'Morocco',  lat:33.5731, lon:-7.5898,   zoom:12 },
  { name:'Tanger Med',                     country:'Morocco',  lat:35.8833, lon:-5.5000,   zoom:13 },
  { name:'Agadir',                         country:'Morocco',  lat:30.4278, lon:-9.5981,   zoom:13 },
  // ── AFRICA — OESTE ────────────────────────────────────────────────────────
  { name:'Dakar',                          country:'Senegal',  lat:14.6928, lon:-17.4467,  zoom:12 },
  { name:'Abidjan',                        country:'Ivory Coast',lat:5.3160,lon:-4.0167,   zoom:12 },
  { name:'Tema (Accra)',                  country:'Ghana',    lat:5.6333, lon:-0.0167,    zoom:12 },
  { name:'Lagos (Apapa)',                  country:'Nigeria',  lat:6.4541,  lon:3.4110,    zoom:12 },
  { name:'Tin Can Island (Lagos)',        country:'Nigeria',  lat:6.4333,  lon:3.3500,    zoom:13 },
  { name:'Port Harcourt',                 country:'Nigeria',  lat:4.7742,  lon:7.0134,    zoom:12 },
  { name:'Warri',                          country:'Nigeria',  lat:5.5167,  lon:5.7500,    zoom:13 },
  { name:'Douala',                         country:'Cameroon', lat:4.0511,  lon:9.7679,    zoom:12 },
  { name:'Libreville',                     country:'Gabon',    lat:0.3924,  lon:9.4536,    zoom:12 },
  { name:'Pointe-Noire',                  country:'Congo',    lat:-4.7769, lon:11.8656,   zoom:12 },
  { name:'Luanda',                         country:'Angola',   lat:-8.8368, lon:13.2343,   zoom:12 },
  { name:'Lobito',                         country:'Angola',   lat:-12.3500,lon:13.5500,   zoom:13 },
  { name:'Walvis Bay',                     country:'Namibia',  lat:-22.9576,lon:14.5052,   zoom:12 },
  { name:'Freetown',                       country:'Sierra Leone',lat:8.4906,lon:-13.2317, zoom:12 },
  { name:'Conakry',                        country:'Guinea',   lat:9.5370,  lon:-13.6773,  zoom:12 },
  // ── AFRICA — ESTE / SUR ───────────────────────────────────────────────────
  { name:'Djibouti',                       country:'Djibouti', lat:11.5886, lon:43.1451,   zoom:12 },
  { name:'Berbera',                        country:'Somalia',  lat:10.4394, lon:45.0146,   zoom:13 },
  { name:'Mogadishu',                      country:'Somalia',  lat:2.0469,  lon:45.3182,   zoom:12 },
  { name:'Mombasa',                        country:'Kenya',    lat:-4.0435, lon:39.6682,   zoom:12 },
  { name:'Dar es Salaam',                 country:'Tanzania', lat:-6.7924, lon:39.2083,   zoom:12 },
  { name:'Zanzibar',                       country:'Tanzania', lat:-6.1659, lon:39.1989,   zoom:13 },
  { name:'Beira',                          country:'Mozambique',lat:-19.8436,lon:34.8389,  zoom:12 },
  { name:'Maputo',                         country:'Mozambique',lat:-25.9692,lon:32.5732,  zoom:12 },
  { name:'Toamasina (Tamatave)',          country:'Madagascar',lat:-18.1492,lon:49.4022,  zoom:12 },
  { name:'Antananarivo / Mahajanga',      country:'Madagascar',lat:-15.7167,lon:46.3167,  zoom:12 },
  { name:'Durban',                         country:'South Africa',lat:-29.8587,lon:31.0218,zoom:12 },
  { name:'Port Elizabeth',                country:'South Africa',lat:-33.9179,lon:25.5699, zoom:12 },
  { name:'Cape Town',                      country:'South Africa',lat:-33.9249,lon:18.4241, zoom:12 },
  { name:'Richards Bay',                  country:'South Africa',lat:-28.7816,lon:32.0804, zoom:13 },
  { name:'Port Louis (Mauritius)',        country:'Mauritius', lat:-20.1619,lon:57.4989,   zoom:12 },
  // ── ASIA — GOLFO PÉRSICO / SUBCONTINENTE ─────────────────────────────────
  { name:'Karachi',                        country:'Pakistan', lat:24.8607, lon:67.0011,   zoom:12 },
  { name:'Port Qasim',                    country:'Pakistan', lat:24.7753, lon:67.3100,   zoom:13 },
  { name:'Mumbai (JNPT)',                 country:'India',    lat:18.9388, lon:72.8355,   zoom:12 },
  { name:'Mundra',                         country:'India',    lat:22.8390, lon:69.7060,   zoom:13 },
  { name:'Kandla',                         country:'India',    lat:23.0333, lon:70.2167,   zoom:13 },
  { name:'Nhava Sheva (Mumbai)',          country:'India',    lat:18.9486, lon:72.9489,   zoom:13 },
  { name:'Cochin / Kochi',               country:'India',    lat:9.9312,  lon:76.2673,   zoom:12 },
  { name:'Chennai (Madras)',              country:'India',    lat:13.0827, lon:80.2707,   zoom:12 },
  { name:'Visakhapatnam',                 country:'India',    lat:17.6868, lon:83.2185,   zoom:12 },
  { name:'Kolkata (Calcutta)',            country:'India',    lat:22.5726, lon:88.3639,   zoom:12 },
  { name:'Haldia',                         country:'India',    lat:22.0667, lon:88.1000,   zoom:13 },
  { name:'Colombo',                        country:'Sri Lanka',lat:6.9271,  lon:79.8612,   zoom:12 },
  { name:'Chittagong',                     country:'Bangladesh',lat:22.3569,lon:91.8350,   zoom:12 },
  { name:'Yangon (Rangoon)',              country:'Myanmar',  lat:16.8661, lon:96.1951,   zoom:12 },
  { name:'Thilawa',                        country:'Myanmar',  lat:16.7000, lon:96.2500,   zoom:13 },
  // ── ASIA — SUDESTE ────────────────────────────────────────────────────────
  { name:'Singapore',                      country:'Singapore',lat:1.2644,  lon:103.8219,  zoom:12 },
  { name:'Port Klang',                     country:'Malaysia', lat:2.9983,  lon:101.3667,  zoom:12 },
  { name:'Penang',                         country:'Malaysia', lat:5.3678,  lon:100.4013,  zoom:12 },
  { name:'Tanjung Pelepas',              country:'Malaysia', lat:1.3600,  lon:103.5500,  zoom:13 },
  { name:'Laem Chabang',                   country:'Thailand', lat:13.0829, lon:100.8807,  zoom:12 },
  { name:'Bangkok',                        country:'Thailand', lat:13.7563, lon:100.5018,  zoom:12 },
  { name:'Ho Chi Minh City (Saigon)',     country:'Vietnam',  lat:10.7769, lon:106.7009,  zoom:12 },
  { name:'Haiphong',                       country:'Vietnam',  lat:20.8449, lon:106.6881,  zoom:12 },
  { name:'Da Nang',                        country:'Vietnam',  lat:16.0544, lon:108.2022,  zoom:13 },
  { name:'Manila',                         country:'Philippines',lat:14.5995,lon:120.9842, zoom:12 },
  { name:'Subic Bay',                      country:'Philippines',lat:14.8222,lon:120.2705, zoom:13 },
  { name:'Cebu',                           country:'Philippines',lat:10.3157,lon:123.8854, zoom:13 },
  { name:'Jakarta (Tanjung Priok)',       country:'Indonesia', lat:-6.1075, lon:106.8728,  zoom:12 },
  { name:'Surabaya',                       country:'Indonesia', lat:-7.2492, lon:112.7508,  zoom:12 },
  { name:'Batam / Batu Ampar',           country:'Indonesia', lat:1.1000,  lon:104.0333,  zoom:13 },
  { name:'Makassar',                       country:'Indonesia', lat:-5.1477, lon:119.4327,  zoom:12 },
  { name:'Balikpapan',                     country:'Indonesia', lat:-1.2379, lon:116.8529,  zoom:13 },
  { name:'Medan (Belawan)',               country:'Indonesia', lat:3.7850,  lon:98.6922,   zoom:12 },
  // ── ASIA — ESTE ──────────────────────────────────────────────────────────
  { name:'Shanghai',                       country:'China',    lat:31.2304, lon:121.4737,  zoom:11 },
  { name:'Ningbo-Zhoushan',               country:'China',    lat:29.8683, lon:121.5440,  zoom:11 },
  { name:'Shenzhen (Yantian)',             country:'China',    lat:22.5635, lon:114.2467,  zoom:12 },
  { name:'Guangzhou (Nansha)',             country:'China',    lat:22.7333, lon:113.6500,  zoom:12 },
  { name:'Guangzhou (Huangpu)',           country:'China',    lat:23.1116, lon:113.4603,  zoom:12 },
  { name:'Hong Kong',                      country:'China',    lat:22.3193, lon:114.1694,  zoom:12 },
  { name:'Tianjin (Xingang)',             country:'China',    lat:39.0211, lon:117.7108,  zoom:12 },
  { name:'Qingdao',                        country:'China',    lat:36.0671, lon:120.3826,  zoom:12 },
  { name:'Dalian',                         country:'China',    lat:38.9140, lon:121.6147,  zoom:12 },
  { name:'Xiamen',                         country:'China',    lat:24.4795, lon:118.0881,  zoom:12 },
  { name:'Fuzhou',                         country:'China',    lat:26.0745, lon:119.2965,  zoom:12 },
  { name:'Lianyungang',                    country:'China',    lat:34.6004, lon:119.2212,  zoom:12 },
  { name:'Wuhan',                          country:'China',    lat:30.5928, lon:114.3055,  zoom:12 },
  { name:'Busan',                          country:'South Korea',lat:35.1796,lon:129.0756, zoom:12 },
  { name:'Incheon',                        country:'South Korea',lat:37.4563,lon:126.7052, zoom:12 },
  { name:'Gwangyang',                      country:'South Korea',lat:34.9167,lon:127.7167, zoom:13 },
  { name:'Ulsan',                          country:'South Korea',lat:35.5383,lon:129.3114, zoom:12 },
  { name:'Tokyo / Yokohama',              country:'Japan',    lat:35.4437, lon:139.6380,  zoom:11 },
  { name:'Kobe / Osaka',                  country:'Japan',    lat:34.6901, lon:135.1956,  zoom:11 },
  { name:'Nagoya',                         country:'Japan',    lat:35.0702, lon:136.9344,  zoom:12 },
  { name:'Fukuoka / Hakata',             country:'Japan',    lat:33.5904, lon:130.4017,  zoom:12 },
  { name:'Hiroshima',                      country:'Japan',    lat:34.3853, lon:132.4553,  zoom:13 },
  { name:'Kitakyushu',                     country:'Japan',    lat:33.8834, lon:130.8751,  zoom:12 },
  { name:'Kaohsiung',                      country:'Taiwan',   lat:22.6273, lon:120.3014,  zoom:12 },
  { name:'Taipei / Keelung',             country:'Taiwan',   lat:25.1276, lon:121.7392,  zoom:12 },
  { name:'Taichung',                       country:'Taiwan',   lat:24.2793, lon:120.6628,  zoom:13 },
  { name:'Vladivostok',                    country:'Russia',   lat:43.1056, lon:131.8735,  zoom:12 },
  // ── OCEANÍA ───────────────────────────────────────────────────────────────
  { name:'Sydney',                         country:'Australia',lat:-33.8688,lon:151.2093,  zoom:12 },
  { name:'Melbourne',                      country:'Australia',lat:-37.8136,lon:144.9631,  zoom:12 },
  { name:'Brisbane',                       country:'Australia',lat:-27.4698,lon:153.0251,  zoom:12 },
  { name:'Fremantle (Perth)',             country:'Australia',lat:-32.0568,lon:115.7444,  zoom:12 },
  { name:'Adelaide',                       country:'Australia',lat:-34.9285,lon:138.6007,  zoom:12 },
  { name:'Port Hedland',                  country:'Australia',lat:-20.3117,lon:118.5883,  zoom:12 },
  { name:'Darwin',                         country:'Australia',lat:-12.4634,lon:130.8456,  zoom:12 },
  { name:'Townsville',                     country:'Australia',lat:-19.2590,lon:146.8169,  zoom:12 },
  { name:'Auckland',                       country:'New Zealand',lat:-36.8485,lon:174.7633,zoom:12 },
  { name:'Tauranga',                       country:'New Zealand',lat:-37.6878,lon:176.1651,zoom:13 },
  { name:'Wellington',                     country:'New Zealand',lat:-41.2865,lon:174.7762,zoom:12 },
  { name:'Christchurch / Lyttelton',     country:'New Zealand',lat:-43.6028,lon:172.7280, zoom:13 },
  { name:'Suva (Fiji)',                   country:'Fiji',     lat:-18.1416,lon:178.4419,   zoom:12 },
  { name:'Port Moresby',                  country:'Papua NG', lat:-9.4438, lon:147.1803,  zoom:12 },
  { name:'Nouméa',                         country:'New Caledonia',lat:-22.2558,lon:166.4505,zoom:12},
  // ── CARIBE ADICIONAL ─────────────────────────────────────────────────────
  { name:'Nassau (Bahamas)',              country:'Bahamas',  lat:25.0480, lon:-77.3587,  zoom:12 },
  { name:'Freeport (Bahamas)',            country:'Bahamas',  lat:26.5285, lon:-78.6960,  zoom:13 },
  { name:'Montego Bay',                   country:'Jamaica',  lat:18.4762, lon:-77.9216,  zoom:13 },
  { name:'Fort-de-France (Martinique)',  country:'Martinique',lat:14.6037,lon:-61.0766,   zoom:13 },
  { name:'Pointe-à-Pitre (Guadeloupe)', country:'Guadeloupe',lat:16.2401,lon:-61.5331,   zoom:13 },
  { name:'Charlotte Amalie (USVI)',      country:'USA',      lat:18.3419, lon:-64.9307,  zoom:13 },
  { name:'Road Town (BVI)',              country:'UK',       lat:18.4167, lon:-64.6167,  zoom:13 },
  { name:'Castries (St. Lucia)',         country:'St. Lucia',lat:14.0101, lon:-60.9875,  zoom:13 },
  { name:'St. George\'s (Grenada)',      country:'Grenada',  lat:12.0539, lon:-61.7488,  zoom:13 },
];

// ── Buscador ─────────────────────────────────────────────────────────────────
window.PortSearch = {
  init() {
    const input = document.getElementById('port-search');
    const list  = document.getElementById('port-suggestions');
    if (!input) return;

    input.addEventListener('input', () => {
      const q = input.value.trim().toLowerCase();
      if (q.length < 2) { list.classList.add('hidden'); return; }

      const matches = WORLD_PORTS.filter(p =>
        p.name.toLowerCase().includes(q) || p.country.toLowerCase().includes(q)
      ).slice(0, 10);

      if (!matches.length) { list.classList.add('hidden'); return; }

      list.innerHTML = matches.map((p, i) => `
        <div class="port-item" data-idx="${i}"
             data-lat="${p.lat}" data-lon="${p.lon}" data-zoom="${p.zoom}">
          <span class="port-name">${p.name}</span>
          <span class="port-country">${p.country}</span>
        </div>
      `).join('');
      list.classList.remove('hidden');

      list.querySelectorAll('.port-item').forEach(el => {
        el.addEventListener('click', () => {
          const lat  = parseFloat(el.dataset.lat);
          const lon  = parseFloat(el.dataset.lon);
          const zoom = parseInt(el.dataset.zoom);
          window.flyToCoords(lon, lat, zoom);
          input.value = el.querySelector('.port-name').textContent;
          list.classList.add('hidden');
        });
      });
    });

    // Cerrar al hacer clic fuera
    document.addEventListener('click', (e) => {
      if (!input.contains(e.target) && !list.contains(e.target))
        list.classList.add('hidden');
    });

    input.addEventListener('keydown', (e) => {
      if (e.key === 'Escape') { list.classList.add('hidden'); input.value = ''; }
    });
  },
};
