"""
NOMAZRA — Comprehensive Country Database.
140+ countries with emergency contacts, legal system info, rights frameworks.
Production-grade data for the world's legal systems.
"""

# fmt: off
COUNTRIES = [
    # ── AFRICA ──
    {"code":"DZ","name":"Algeria","flag":"🇩🇿","legal_system":"civil","languages":["ar","fr"],"currency":"DZD","emergency":"17","capital":"Algiers","continent":"Africa"},
    {"code":"AO","name":"Angola","flag":"🇦🇴","legal_system":"civil","languages":["pt"],"currency":"AOA","emergency":"113","capital":"Luanda","continent":"Africa"},
    {"code":"BJ","name":"Benin","flag":"🇧🇯","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"117","capital":"Porto-Novo","continent":"Africa"},
    {"code":"BW","name":"Botswana","flag":"🇧🇼","legal_system":"mixed","languages":["en","tn"],"currency":"BWP","emergency":"999","capital":"Gaborone","continent":"Africa"},
    {"code":"BF","name":"Burkina Faso","flag":"🇧🇫","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"17","capital":"Ouagadougou","continent":"Africa"},
    {"code":"BI","name":"Burundi","flag":"🇧🇮","legal_system":"civil","languages":["fr","rn"],"currency":"BIF","emergency":"117","capital":"Gitega","continent":"Africa"},
    {"code":"CV","name":"Cabo Verde","flag":"🇨🇻","legal_system":"civil","languages":["pt"],"currency":"CVE","emergency":"132","capital":"Praia","continent":"Africa"},
    {"code":"CM","name":"Cameroon","flag":"🇨🇲","legal_system":"mixed","languages":["fr","en"],"currency":"XAF","emergency":"117","capital":"Yaoundé","continent":"Africa"},
    {"code":"CF","name":"Central African Republic","flag":"🇨🇫","legal_system":"civil","languages":["fr","sg"],"currency":"XAF","emergency":"117","capital":"Bangui","continent":"Africa"},
    {"code":"TD","name":"Chad","flag":"🇹🇩","legal_system":"civil","languages":["fr","ar"],"currency":"XAF","emergency":"17","capital":"N'Djamena","continent":"Africa"},
    {"code":"KM","name":"Comoros","flag":"🇰🇲","legal_system":"mixed","languages":["ar","fr"],"currency":"KMF","emergency":"17","capital":"Moroni","continent":"Africa"},
    {"code":"CG","name":"Congo (Brazzaville)","flag":"🇨🇬","legal_system":"civil","languages":["fr"],"currency":"XAF","emergency":"117","capital":"Brazzaville","continent":"Africa"},
    {"code":"CD","name":"Congo (DRC)","flag":"🇨🇩","legal_system":"civil","languages":["fr"],"currency":"CDF","emergency":"112","capital":"Kinshasa","continent":"Africa"},
    {"code":"CI","name":"Côte d'Ivoire","flag":"🇨🇮","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"110","capital":"Yamoussoukro","continent":"Africa"},
    {"code":"DJ","name":"Djibouti","flag":"🇩🇯","legal_system":"mixed","languages":["fr","ar"],"currency":"DJF","emergency":"17","capital":"Djibouti","continent":"Africa"},
    {"code":"EG","name":"Egypt","flag":"🇪🇬","legal_system":"mixed","languages":["ar"],"currency":"EGP","emergency":"122","capital":"Cairo","continent":"Africa"},
    {"code":"GQ","name":"Equatorial Guinea","flag":"🇬🇶","legal_system":"civil","languages":["es","fr","pt"],"currency":"XAF","emergency":"114","capital":"Malabo","continent":"Africa"},
    {"code":"ER","name":"Eritrea","flag":"🇪🇷","legal_system":"mixed","languages":["ti","ar","en"],"currency":"ERN","emergency":"114","capital":"Asmara","continent":"Africa"},
    {"code":"SZ","name":"Eswatini","flag":"🇸🇿","legal_system":"mixed","languages":["en","ss"],"currency":"SZL","emergency":"999","capital":"Mbabane","continent":"Africa"},
    {"code":"ET","name":"Ethiopia","flag":"🇪🇹","legal_system":"civil","languages":["am"],"currency":"ETB","emergency":"991","capital":"Addis Ababa","continent":"Africa"},
    {"code":"GA","name":"Gabon","flag":"🇬🇦","legal_system":"civil","languages":["fr"],"currency":"XAF","emergency":"1730","capital":"Libreville","continent":"Africa"},
    {"code":"GM","name":"Gambia","flag":"🇬🇲","legal_system":"mixed","languages":["en"],"currency":"GMD","emergency":"117","capital":"Banjul","continent":"Africa"},
    {"code":"GH","name":"Ghana","flag":"🇬🇭","legal_system":"common","languages":["en"],"currency":"GHS","emergency":"191","capital":"Accra","continent":"Africa"},
    {"code":"GN","name":"Guinea","flag":"🇬🇳","legal_system":"civil","languages":["fr"],"currency":"GNF","emergency":"117","capital":"Conakry","continent":"Africa"},
    {"code":"GW","name":"Guinea-Bissau","flag":"🇬🇼","legal_system":"civil","languages":["pt"],"currency":"XOF","emergency":"117","capital":"Bissau","continent":"Africa"},
    {"code":"KE","name":"Kenya","flag":"🇰🇪","legal_system":"mixed","languages":["en","sw"],"currency":"KES","emergency":"999","capital":"Nairobi","continent":"Africa"},
    {"code":"LS","name":"Lesotho","flag":"🇱🇸","legal_system":"mixed","languages":["en","st"],"currency":"LSL","emergency":"123","capital":"Maseru","continent":"Africa"},
    {"code":"LR","name":"Liberia","flag":"🇱🇷","legal_system":"common","languages":["en"],"currency":"LRD","emergency":"911","capital":"Monrovia","continent":"Africa"},
    {"code":"LY","name":"Libya","flag":"🇱🇾","legal_system":"mixed","languages":["ar"],"currency":"LYD","emergency":"1515","capital":"Tripoli","continent":"Africa"},
    {"code":"MG","name":"Madagascar","flag":"🇲🇬","legal_system":"civil","languages":["mg","fr"],"currency":"MGA","emergency":"117","capital":"Antananarivo","continent":"Africa"},
    {"code":"MW","name":"Malawi","flag":"🇲🇼","legal_system":"mixed","languages":["en","ny"],"currency":"MWK","emergency":"997","capital":"Lilongwe","continent":"Africa"},
    {"code":"ML","name":"Mali","flag":"🇲🇱","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"17","capital":"Bamako","continent":"Africa"},
    {"code":"MR","name":"Mauritania","flag":"🇲🇷","legal_system":"mixed","languages":["ar"],"currency":"MRU","emergency":"17","capital":"Nouakchott","continent":"Africa"},
    {"code":"MU","name":"Mauritius","flag":"🇲🇺","legal_system":"mixed","languages":["en","fr"],"currency":"MUR","emergency":"999","capital":"Port Louis","continent":"Africa"},
    {"code":"MA","name":"Morocco","flag":"🇲🇦","legal_system":"civil","languages":["ar","fr"],"currency":"MAD","emergency":"19","capital":"Rabat","continent":"Africa"},
    {"code":"MZ","name":"Mozambique","flag":"🇲🇿","legal_system":"civil","languages":["pt"],"currency":"MZN","emergency":"119","capital":"Maputo","continent":"Africa"},
    {"code":"NA","name":"Namibia","flag":"🇳🇦","legal_system":"mixed","languages":["en"],"currency":"NAD","emergency":"10111","capital":"Windhoek","continent":"Africa"},
    {"code":"NE","name":"Niger","flag":"🇳🇪","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"17","capital":"Niamey","continent":"Africa"},
    {"code":"NG","name":"Nigeria","flag":"🇳🇬","legal_system":"mixed","languages":["en"],"currency":"NGN","emergency":"112","capital":"Abuja","continent":"Africa"},
    {"code":"RW","name":"Rwanda","flag":"🇷🇼","legal_system":"civil","languages":["rw","en","fr"],"currency":"RWF","emergency":"112","capital":"Kigali","continent":"Africa"},
    {"code":"ST","name":"São Tomé and Príncipe","flag":"🇸🇹","legal_system":"civil","languages":["pt"],"currency":"STN","emergency":"112","capital":"São Tomé","continent":"Africa"},
    {"code":"SN","name":"Senegal","flag":"🇸🇳","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"17","capital":"Dakar","continent":"Africa"},
    {"code":"SC","name":"Seychelles","flag":"🇸🇨","legal_system":"mixed","languages":["en","fr"],"currency":"SCR","emergency":"999","capital":"Victoria","continent":"Africa"},
    {"code":"SL","name":"Sierra Leone","flag":"🇸🇱","legal_system":"mixed","languages":["en"],"currency":"SLE","emergency":"999","capital":"Freetown","continent":"Africa"},
    {"code":"SO","name":"Somalia","flag":"🇸🇴","legal_system":"mixed","languages":["so","ar"],"currency":"SOS","emergency":"888","capital":"Mogadishu","continent":"Africa"},
    {"code":"ZA","name":"South Africa","flag":"🇿🇦","legal_system":"mixed","languages":["en","af","zu"],"currency":"ZAR","emergency":"10111","capital":"Pretoria","continent":"Africa"},
    {"code":"SS","name":"South Sudan","flag":"🇸🇸","legal_system":"mixed","languages":["en"],"currency":"SSP","emergency":"999","capital":"Juba","continent":"Africa"},
    {"code":"SD","name":"Sudan","flag":"🇸🇩","legal_system":"mixed","languages":["ar","en"],"currency":"SDG","emergency":"999","capital":"Khartoum","continent":"Africa"},
    {"code":"TZ","name":"Tanzania","flag":"🇹🇿","legal_system":"common","languages":["sw","en"],"currency":"TZS","emergency":"112","capital":"Dodoma","continent":"Africa"},
    {"code":"TG","name":"Togo","flag":"🇹🇬","legal_system":"civil","languages":["fr"],"currency":"XOF","emergency":"117","capital":"Lomé","continent":"Africa"},
    {"code":"TN","name":"Tunisia","flag":"🇹🇳","legal_system":"civil","languages":["ar","fr"],"currency":"TND","emergency":"197","capital":"Tunis","continent":"Africa"},
    {"code":"UG","name":"Uganda","flag":"🇺🇬","legal_system":"mixed","languages":["en","sw"],"currency":"UGX","emergency":"999","capital":"Kampala","continent":"Africa"},
    {"code":"ZM","name":"Zambia","flag":"🇿🇲","legal_system":"mixed","languages":["en"],"currency":"ZMW","emergency":"999","capital":"Lusaka","continent":"Africa"},
    {"code":"ZW","name":"Zimbabwe","flag":"🇿🇼","legal_system":"mixed","languages":["en","sn","nd"],"currency":"ZWL","emergency":"999","capital":"Harare","continent":"Africa"},

    # ── AMERICAS ──
    {"code":"AR","name":"Argentina","flag":"🇦🇷","legal_system":"civil","languages":["es"],"currency":"ARS","emergency":"911","capital":"Buenos Aires","continent":"Americas"},
    {"code":"BS","name":"Bahamas","flag":"🇧🇸","legal_system":"common","languages":["en"],"currency":"BSD","emergency":"919","capital":"Nassau","continent":"Americas"},
    {"code":"BB","name":"Barbados","flag":"🇧🇧","legal_system":"common","languages":["en"],"currency":"BBD","emergency":"211","capital":"Bridgetown","continent":"Americas"},
    {"code":"BZ","name":"Belize","flag":"🇧🇿","legal_system":"common","languages":["en"],"currency":"BZD","emergency":"911","capital":"Belmopan","continent":"Americas"},
    {"code":"BO","name":"Bolivia","flag":"🇧🇴","legal_system":"civil","languages":["es"],"currency":"BOB","emergency":"110","capital":"Sucre","continent":"Americas"},
    {"code":"BR","name":"Brazil","flag":"🇧🇷","legal_system":"civil","languages":["pt"],"currency":"BRL","emergency":"190","capital":"Brasília","continent":"Americas"},
    {"code":"CA","name":"Canada","flag":"🇨🇦","legal_system":"mixed","languages":["en","fr"],"currency":"CAD","emergency":"911","capital":"Ottawa","continent":"Americas"},
    {"code":"CL","name":"Chile","flag":"🇨🇱","legal_system":"civil","languages":["es"],"currency":"CLP","emergency":"133","capital":"Santiago","continent":"Americas"},
    {"code":"CO","name":"Colombia","flag":"🇨🇴","legal_system":"civil","languages":["es"],"currency":"COP","emergency":"123","capital":"Bogotá","continent":"Americas"},
    {"code":"CR","name":"Costa Rica","flag":"🇨🇷","legal_system":"civil","languages":["es"],"currency":"CRC","emergency":"911","capital":"San José","continent":"Americas"},
    {"code":"CU","name":"Cuba","flag":"🇨🇺","legal_system":"civil","languages":["es"],"currency":"CUP","emergency":"106","capital":"Havana","continent":"Americas"},
    {"code":"DO","name":"Dominican Republic","flag":"🇩🇴","legal_system":"civil","languages":["es"],"currency":"DOP","emergency":"911","capital":"Santo Domingo","continent":"Americas"},
    {"code":"EC","name":"Ecuador","flag":"🇪🇨","legal_system":"civil","languages":["es"],"currency":"USD","emergency":"911","capital":"Quito","continent":"Americas"},
    {"code":"SV","name":"El Salvador","flag":"🇸🇻","legal_system":"civil","languages":["es"],"currency":"USD","emergency":"911","capital":"San Salvador","continent":"Americas"},
    {"code":"GT","name":"Guatemala","flag":"🇬🇹","legal_system":"civil","languages":["es"],"currency":"GTQ","emergency":"110","capital":"Guatemala City","continent":"Americas"},
    {"code":"GY","name":"Guyana","flag":"🇬🇾","legal_system":"common","languages":["en"],"currency":"GYD","emergency":"911","capital":"Georgetown","continent":"Americas"},
    {"code":"HT","name":"Haiti","flag":"🇭🇹","legal_system":"civil","languages":["fr","ht"],"currency":"HTG","emergency":"114","capital":"Port-au-Prince","continent":"Americas"},
    {"code":"HN","name":"Honduras","flag":"🇭🇳","legal_system":"civil","languages":["es"],"currency":"HNL","emergency":"199","capital":"Tegucigalpa","continent":"Americas"},
    {"code":"JM","name":"Jamaica","flag":"🇯🇲","legal_system":"common","languages":["en"],"currency":"JMD","emergency":"119","capital":"Kingston","continent":"Americas"},
    {"code":"MX","name":"Mexico","flag":"🇲🇽","legal_system":"civil","languages":["es"],"currency":"MXN","emergency":"911","capital":"Mexico City","continent":"Americas"},
    {"code":"NI","name":"Nicaragua","flag":"🇳🇮","legal_system":"civil","languages":["es"],"currency":"NIO","emergency":"118","capital":"Managua","continent":"Americas"},
    {"code":"PA","name":"Panama","flag":"🇵🇦","legal_system":"civil","languages":["es"],"currency":"PAB","emergency":"911","capital":"Panama City","continent":"Americas"},
    {"code":"PY","name":"Paraguay","flag":"🇵🇾","legal_system":"civil","languages":["es","gn"],"currency":"PYG","emergency":"911","capital":"Asunción","continent":"Americas"},
    {"code":"PE","name":"Peru","flag":"🇵🇪","legal_system":"civil","languages":["es"],"currency":"PEN","emergency":"105","capital":"Lima","continent":"Americas"},
    {"code":"SR","name":"Suriname","flag":"🇸🇷","legal_system":"civil","languages":["nl"],"currency":"SRD","emergency":"115","capital":"Paramaribo","continent":"Americas"},
    {"code":"TT","name":"Trinidad and Tobago","flag":"🇹🇹","legal_system":"common","languages":["en"],"currency":"TTD","emergency":"999","capital":"Port of Spain","continent":"Americas"},
    {"code":"US","name":"United States","flag":"🇺🇸","legal_system":"common","languages":["en"],"currency":"USD","emergency":"911","capital":"Washington, D.C.","continent":"Americas"},
    {"code":"UY","name":"Uruguay","flag":"🇺🇾","legal_system":"civil","languages":["es"],"currency":"UYU","emergency":"911","capital":"Montevideo","continent":"Americas"},
    {"code":"VE","name":"Venezuela","flag":"🇻🇪","legal_system":"civil","languages":["es"],"currency":"VES","emergency":"171","capital":"Caracas","continent":"Americas"},

    # ── ASIA ──
    {"code":"AF","name":"Afghanistan","flag":"🇦🇫","legal_system":"mixed","languages":["ps","fa"],"currency":"AFN","emergency":"119","capital":"Kabul","continent":"Asia"},
    {"code":"AM","name":"Armenia","flag":"🇦🇲","legal_system":"civil","languages":["hy"],"currency":"AMD","emergency":"911","capital":"Yerevan","continent":"Asia"},
    {"code":"AZ","name":"Azerbaijan","flag":"🇦🇿","legal_system":"civil","languages":["az"],"currency":"AZN","emergency":"102","capital":"Baku","continent":"Asia"},
    {"code":"BH","name":"Bahrain","flag":"🇧🇭","legal_system":"mixed","languages":["ar"],"currency":"BHD","emergency":"999","capital":"Manama","continent":"Asia"},
    {"code":"BD","name":"Bangladesh","flag":"🇧🇩","legal_system":"common","languages":["bn"],"currency":"BDT","emergency":"999","capital":"Dhaka","continent":"Asia"},
    {"code":"BT","name":"Bhutan","flag":"🇧🇹","legal_system":"civil","languages":["dz"],"currency":"BTN","emergency":"113","capital":"Thimphu","continent":"Asia"},
    {"code":"BN","name":"Brunei","flag":"🇧🇳","legal_system":"mixed","languages":["ms"],"currency":"BND","emergency":"993","capital":"Bandar Seri Begawan","continent":"Asia"},
    {"code":"KH","name":"Cambodia","flag":"🇰🇭","legal_system":"civil","languages":["km"],"currency":"KHR","emergency":"117","capital":"Phnom Penh","continent":"Asia"},
    {"code":"CN","name":"China","flag":"🇨🇳","legal_system":"civil","languages":["zh"],"currency":"CNY","emergency":"110","capital":"Beijing","continent":"Asia"},
    {"code":"GE","name":"Georgia","flag":"🇬🇪","legal_system":"civil","languages":["ka"],"currency":"GEL","emergency":"112","capital":"Tbilisi","continent":"Asia"},
    {"code":"IN","name":"India","flag":"🇮🇳","legal_system":"common","languages":["hi","en"],"currency":"INR","emergency":"112","capital":"New Delhi","continent":"Asia"},
    {"code":"ID","name":"Indonesia","flag":"🇮🇩","legal_system":"civil","languages":["id"],"currency":"IDR","emergency":"110","capital":"Jakarta","continent":"Asia"},
    {"code":"IR","name":"Iran","flag":"🇮🇷","legal_system":"religious","languages":["fa"],"currency":"IRR","emergency":"110","capital":"Tehran","continent":"Asia"},
    {"code":"IQ","name":"Iraq","flag":"🇮🇶","legal_system":"mixed","languages":["ar","ku"],"currency":"IQD","emergency":"104","capital":"Baghdad","continent":"Asia"},
    {"code":"IL","name":"Israel","flag":"🇮🇱","legal_system":"mixed","languages":["he","ar"],"currency":"ILS","emergency":"100","capital":"Jerusalem","continent":"Asia"},
    {"code":"JP","name":"Japan","flag":"🇯🇵","legal_system":"civil","languages":["ja"],"currency":"JPY","emergency":"110","capital":"Tokyo","continent":"Asia"},
    {"code":"JO","name":"Jordan","flag":"🇯🇴","legal_system":"mixed","languages":["ar"],"currency":"JOD","emergency":"911","capital":"Amman","continent":"Asia"},
    {"code":"KZ","name":"Kazakhstan","flag":"🇰🇿","legal_system":"civil","languages":["kk","ru"],"currency":"KZT","emergency":"102","capital":"Astana","continent":"Asia"},
    {"code":"KW","name":"Kuwait","flag":"🇰🇼","legal_system":"mixed","languages":["ar"],"currency":"KWD","emergency":"112","capital":"Kuwait City","continent":"Asia"},
    {"code":"KG","name":"Kyrgyzstan","flag":"🇰🇬","legal_system":"civil","languages":["ky","ru"],"currency":"KGS","emergency":"102","capital":"Bishkek","continent":"Asia"},
    {"code":"LA","name":"Laos","flag":"🇱🇦","legal_system":"civil","languages":["lo"],"currency":"LAK","emergency":"191","capital":"Vientiane","continent":"Asia"},
    {"code":"LB","name":"Lebanon","flag":"🇱🇧","legal_system":"mixed","languages":["ar"],"currency":"LBP","emergency":"112","capital":"Beirut","continent":"Asia"},
    {"code":"MY","name":"Malaysia","flag":"🇲🇾","legal_system":"mixed","languages":["ms"],"currency":"MYR","emergency":"999","capital":"Kuala Lumpur","continent":"Asia"},
    {"code":"MV","name":"Maldives","flag":"🇲🇻","legal_system":"mixed","languages":["dv"],"currency":"MVR","emergency":"119","capital":"Malé","continent":"Asia"},
    {"code":"MN","name":"Mongolia","flag":"🇲🇳","legal_system":"civil","languages":["mn"],"currency":"MNT","emergency":"102","capital":"Ulaanbaatar","continent":"Asia"},
    {"code":"MM","name":"Myanmar","flag":"🇲🇲","legal_system":"common","languages":["my"],"currency":"MMK","emergency":"199","capital":"Naypyidaw","continent":"Asia"},
    {"code":"NP","name":"Nepal","flag":"🇳🇵","legal_system":"common","languages":["ne"],"currency":"NPR","emergency":"100","capital":"Kathmandu","continent":"Asia"},
    {"code":"KP","name":"North Korea","flag":"🇰🇵","legal_system":"civil","languages":["ko"],"currency":"KPW","emergency":"119","capital":"Pyongyang","continent":"Asia"},
    {"code":"OM","name":"Oman","flag":"🇴🇲","legal_system":"mixed","languages":["ar"],"currency":"OMR","emergency":"9999","capital":"Muscat","continent":"Asia"},
    {"code":"PK","name":"Pakistan","flag":"🇵🇰","legal_system":"mixed","languages":["ur","en"],"currency":"PKR","emergency":"15","capital":"Islamabad","continent":"Asia"},
    {"code":"PS","name":"Palestine","flag":"🇵🇸","legal_system":"mixed","languages":["ar"],"currency":"ILS","emergency":"100","capital":"Ramallah","continent":"Asia"},
    {"code":"PH","name":"Philippines","flag":"🇵🇭","legal_system":"mixed","languages":["fil","en"],"currency":"PHP","emergency":"911","capital":"Manila","continent":"Asia"},
    {"code":"QA","name":"Qatar","flag":"🇶🇦","legal_system":"mixed","languages":["ar"],"currency":"QAR","emergency":"999","capital":"Doha","continent":"Asia"},
    {"code":"SA","name":"Saudi Arabia","flag":"🇸🇦","legal_system":"religious","languages":["ar"],"currency":"SAR","emergency":"911","capital":"Riyadh","continent":"Asia"},
    {"code":"SG","name":"Singapore","flag":"🇸🇬","legal_system":"common","languages":["en","ms","zh","ta"],"currency":"SGD","emergency":"999","capital":"Singapore","continent":"Asia"},
    {"code":"KR","name":"South Korea","flag":"🇰🇷","legal_system":"civil","languages":["ko"],"currency":"KRW","emergency":"112","capital":"Seoul","continent":"Asia"},
    {"code":"LK","name":"Sri Lanka","flag":"🇱🇰","legal_system":"mixed","languages":["si","ta"],"currency":"LKR","emergency":"119","capital":"Sri Jayawardenepura Kotte","continent":"Asia"},
    {"code":"SY","name":"Syria","flag":"🇸🇾","legal_system":"mixed","languages":["ar"],"currency":"SYP","emergency":"112","capital":"Damascus","continent":"Asia"},
    {"code":"TW","name":"Taiwan","flag":"🇹🇼","legal_system":"civil","languages":["zh"],"currency":"TWD","emergency":"110","capital":"Taipei","continent":"Asia"},
    {"code":"TJ","name":"Tajikistan","flag":"🇹🇯","legal_system":"civil","languages":["tg"],"currency":"TJS","emergency":"02","capital":"Dushanbe","continent":"Asia"},
    {"code":"TH","name":"Thailand","flag":"🇹🇭","legal_system":"civil","languages":["th"],"currency":"THB","emergency":"191","capital":"Bangkok","continent":"Asia"},
    {"code":"TL","name":"Timor-Leste","flag":"🇹🇱","legal_system":"civil","languages":["pt","tet"],"currency":"USD","emergency":"112","capital":"Dili","continent":"Asia"},
    {"code":"TR","name":"Turkey","flag":"🇹🇷","legal_system":"civil","languages":["tr"],"currency":"TRY","emergency":"155","capital":"Ankara","continent":"Asia"},
    {"code":"TM","name":"Turkmenistan","flag":"🇹🇲","legal_system":"civil","languages":["tk"],"currency":"TMT","emergency":"02","capital":"Ashgabat","continent":"Asia"},
    {"code":"AE","name":"United Arab Emirates","flag":"🇦🇪","legal_system":"mixed","languages":["ar"],"currency":"AED","emergency":"999","capital":"Abu Dhabi","continent":"Asia"},
    {"code":"UZ","name":"Uzbekistan","flag":"🇺🇿","legal_system":"civil","languages":["uz"],"currency":"UZS","emergency":"102","capital":"Tashkent","continent":"Asia"},
    {"code":"VN","name":"Vietnam","flag":"🇻🇳","legal_system":"civil","languages":["vi"],"currency":"VND","emergency":"113","capital":"Hanoi","continent":"Asia"},
    {"code":"YE","name":"Yemen","flag":"🇾🇪","legal_system":"mixed","languages":["ar"],"currency":"YER","emergency":"199","capital":"Sana'a","continent":"Asia"},

    # ── EUROPE ──
    {"code":"AL","name":"Albania","flag":"🇦🇱","legal_system":"civil","languages":["sq"],"currency":"ALL","emergency":"112","capital":"Tirana","continent":"Europe"},
    {"code":"AD","name":"Andorra","flag":"🇦🇩","legal_system":"civil","languages":["ca"],"currency":"EUR","emergency":"112","capital":"Andorra la Vella","continent":"Europe"},
    {"code":"AT","name":"Austria","flag":"🇦🇹","legal_system":"civil","languages":["de"],"currency":"EUR","emergency":"112","capital":"Vienna","continent":"Europe"},
    {"code":"BY","name":"Belarus","flag":"🇧🇾","legal_system":"civil","languages":["be","ru"],"currency":"BYN","emergency":"102","capital":"Minsk","continent":"Europe"},
    {"code":"BE","name":"Belgium","flag":"🇧🇪","legal_system":"civil","languages":["nl","fr","de"],"currency":"EUR","emergency":"112","capital":"Brussels","continent":"Europe"},
    {"code":"BA","name":"Bosnia and Herzegovina","flag":"🇧🇦","legal_system":"civil","languages":["bs","hr","sr"],"currency":"BAM","emergency":"122","capital":"Sarajevo","continent":"Europe"},
    {"code":"BG","name":"Bulgaria","flag":"🇧🇬","legal_system":"civil","languages":["bg"],"currency":"BGN","emergency":"112","capital":"Sofia","continent":"Europe"},
    {"code":"HR","name":"Croatia","flag":"🇭🇷","legal_system":"civil","languages":["hr"],"currency":"EUR","emergency":"112","capital":"Zagreb","continent":"Europe"},
    {"code":"CY","name":"Cyprus","flag":"🇨🇾","legal_system":"mixed","languages":["el","tr"],"currency":"EUR","emergency":"112","capital":"Nicosia","continent":"Europe"},
    {"code":"CZ","name":"Czech Republic","flag":"🇨🇿","legal_system":"civil","languages":["cs"],"currency":"CZK","emergency":"112","capital":"Prague","continent":"Europe"},
    {"code":"DK","name":"Denmark","flag":"🇩🇰","legal_system":"civil","languages":["da"],"currency":"DKK","emergency":"112","capital":"Copenhagen","continent":"Europe"},
    {"code":"EE","name":"Estonia","flag":"🇪🇪","legal_system":"civil","languages":["et"],"currency":"EUR","emergency":"112","capital":"Tallinn","continent":"Europe"},
    {"code":"FI","name":"Finland","flag":"🇫🇮","legal_system":"civil","languages":["fi","sv"],"currency":"EUR","emergency":"112","capital":"Helsinki","continent":"Europe"},
    {"code":"FR","name":"France","flag":"🇫🇷","legal_system":"civil","languages":["fr"],"currency":"EUR","emergency":"112","capital":"Paris","continent":"Europe"},
    {"code":"DE","name":"Germany","flag":"🇩🇪","legal_system":"civil","languages":["de"],"currency":"EUR","emergency":"112","capital":"Berlin","continent":"Europe"},
    {"code":"GR","name":"Greece","flag":"🇬🇷","legal_system":"civil","languages":["el"],"currency":"EUR","emergency":"112","capital":"Athens","continent":"Europe"},
    {"code":"HU","name":"Hungary","flag":"🇭🇺","legal_system":"civil","languages":["hu"],"currency":"HUF","emergency":"112","capital":"Budapest","continent":"Europe"},
    {"code":"IS","name":"Iceland","flag":"🇮🇸","legal_system":"civil","languages":["is"],"currency":"ISK","emergency":"112","capital":"Reykjavik","continent":"Europe"},
    {"code":"IE","name":"Ireland","flag":"🇮🇪","legal_system":"common","languages":["en","ga"],"currency":"EUR","emergency":"112","capital":"Dublin","continent":"Europe"},
    {"code":"IT","name":"Italy","flag":"🇮🇹","legal_system":"civil","languages":["it"],"currency":"EUR","emergency":"112","capital":"Rome","continent":"Europe"},
    {"code":"XK","name":"Kosovo","flag":"🇽🇰","legal_system":"civil","languages":["sq","sr"],"currency":"EUR","emergency":"112","capital":"Pristina","continent":"Europe"},
    {"code":"LV","name":"Latvia","flag":"🇱🇻","legal_system":"civil","languages":["lv"],"currency":"EUR","emergency":"112","capital":"Riga","continent":"Europe"},
    {"code":"LI","name":"Liechtenstein","flag":"🇱🇮","legal_system":"civil","languages":["de"],"currency":"CHF","emergency":"112","capital":"Vaduz","continent":"Europe"},
    {"code":"LT","name":"Lithuania","flag":"🇱🇹","legal_system":"civil","languages":["lt"],"currency":"EUR","emergency":"112","capital":"Vilnius","continent":"Europe"},
    {"code":"LU","name":"Luxembourg","flag":"🇱🇺","legal_system":"civil","languages":["lb","fr","de"],"currency":"EUR","emergency":"112","capital":"Luxembourg","continent":"Europe"},
    {"code":"MT","name":"Malta","flag":"🇲🇹","legal_system":"mixed","languages":["mt","en"],"currency":"EUR","emergency":"112","capital":"Valletta","continent":"Europe"},
    {"code":"MD","name":"Moldova","flag":"🇲🇩","legal_system":"civil","languages":["ro"],"currency":"MDL","emergency":"112","capital":"Chișinău","continent":"Europe"},
    {"code":"MC","name":"Monaco","flag":"🇲🇨","legal_system":"civil","languages":["fr"],"currency":"EUR","emergency":"112","capital":"Monaco","continent":"Europe"},
    {"code":"ME","name":"Montenegro","flag":"🇲🇪","legal_system":"civil","languages":["sr"],"currency":"EUR","emergency":"112","capital":"Podgorica","continent":"Europe"},
    {"code":"NL","name":"Netherlands","flag":"🇳🇱","legal_system":"civil","languages":["nl"],"currency":"EUR","emergency":"112","capital":"Amsterdam","continent":"Europe"},
    {"code":"MK","name":"North Macedonia","flag":"🇲🇰","legal_system":"civil","languages":["mk"],"currency":"MKD","emergency":"112","capital":"Skopje","continent":"Europe"},
    {"code":"NO","name":"Norway","flag":"🇳🇴","legal_system":"civil","languages":["no"],"currency":"NOK","emergency":"112","capital":"Oslo","continent":"Europe"},
    {"code":"PL","name":"Poland","flag":"🇵🇱","legal_system":"civil","languages":["pl"],"currency":"PLN","emergency":"112","capital":"Warsaw","continent":"Europe"},
    {"code":"PT","name":"Portugal","flag":"🇵🇹","legal_system":"civil","languages":["pt"],"currency":"EUR","emergency":"112","capital":"Lisbon","continent":"Europe"},
    {"code":"RO","name":"Romania","flag":"🇷🇴","legal_system":"civil","languages":["ro"],"currency":"RON","emergency":"112","capital":"Bucharest","continent":"Europe"},
    {"code":"RU","name":"Russia","flag":"🇷🇺","legal_system":"civil","languages":["ru"],"currency":"RUB","emergency":"112","capital":"Moscow","continent":"Europe"},
    {"code":"SM","name":"San Marino","flag":"🇸🇲","legal_system":"civil","languages":["it"],"currency":"EUR","emergency":"112","capital":"San Marino","continent":"Europe"},
    {"code":"RS","name":"Serbia","flag":"🇷🇸","legal_system":"civil","languages":["sr"],"currency":"RSD","emergency":"192","capital":"Belgrade","continent":"Europe"},
    {"code":"SK","name":"Slovakia","flag":"🇸🇰","legal_system":"civil","languages":["sk"],"currency":"EUR","emergency":"112","capital":"Bratislava","continent":"Europe"},
    {"code":"SI","name":"Slovenia","flag":"🇸🇮","legal_system":"civil","languages":["sl"],"currency":"EUR","emergency":"112","capital":"Ljubljana","continent":"Europe"},
    {"code":"ES","name":"Spain","flag":"🇪🇸","legal_system":"civil","languages":["es"],"currency":"EUR","emergency":"112","capital":"Madrid","continent":"Europe"},
    {"code":"SE","name":"Sweden","flag":"🇸🇪","legal_system":"civil","languages":["sv"],"currency":"SEK","emergency":"112","capital":"Stockholm","continent":"Europe"},
    {"code":"CH","name":"Switzerland","flag":"🇨🇭","legal_system":"civil","languages":["de","fr","it"],"currency":"CHF","emergency":"112","capital":"Bern","continent":"Europe"},
    {"code":"UA","name":"Ukraine","flag":"🇺🇦","legal_system":"civil","languages":["uk"],"currency":"UAH","emergency":"102","capital":"Kyiv","continent":"Europe"},
    {"code":"GB","name":"United Kingdom","flag":"🇬🇧","legal_system":"common","languages":["en"],"currency":"GBP","emergency":"999","capital":"London","continent":"Europe"},

    # ── OCEANIA ──
    {"code":"AU","name":"Australia","flag":"🇦🇺","legal_system":"common","languages":["en"],"currency":"AUD","emergency":"000","capital":"Canberra","continent":"Oceania"},
    {"code":"FJ","name":"Fiji","flag":"🇫🇯","legal_system":"common","languages":["en","fj"],"currency":"FJD","emergency":"911","capital":"Suva","continent":"Oceania"},
    {"code":"NZ","name":"New Zealand","flag":"🇳🇿","legal_system":"common","languages":["en","mi"],"currency":"NZD","emergency":"111","capital":"Wellington","continent":"Oceania"},
    {"code":"PG","name":"Papua New Guinea","flag":"🇵🇬","legal_system":"common","languages":["en","tpi"],"currency":"PGK","emergency":"000","capital":"Port Moresby","continent":"Oceania"},
    {"code":"WS","name":"Samoa","flag":"🇼🇸","legal_system":"mixed","languages":["sm","en"],"currency":"WST","emergency":"999","capital":"Apia","continent":"Oceania"},
    {"code":"TO","name":"Tonga","flag":"🇹🇴","legal_system":"common","languages":["to","en"],"currency":"TOP","emergency":"911","capital":"Nuku'alofa","continent":"Oceania"},
    {"code":"VU","name":"Vanuatu","flag":"🇻🇺","legal_system":"mixed","languages":["bi","en","fr"],"currency":"VUV","emergency":"112","capital":"Port Vila","continent":"Oceania"},
]
# fmt: on

# Lookup by code
COUNTRY_MAP = {c['code']: c for c in COUNTRIES}

# Legal topics available per legal system type
LEGAL_TOPICS = {
    'common': ['civil', 'criminal', 'family', 'labor', 'property', 'business',
               'immigration', 'tax', 'constitutional', 'tort', 'contract',
               'consumer', 'environmental', 'human_rights'],
    'civil': ['civil', 'criminal', 'family', 'labor', 'property', 'business',
              'immigration', 'tax', 'constitutional', 'administrative',
              'commercial', 'consumer', 'environmental', 'human_rights'],
    'mixed': ['civil', 'criminal', 'family', 'labor', 'property', 'business',
              'immigration', 'tax', 'constitutional', 'customary',
              'religious', 'commercial', 'consumer', 'human_rights'],
    'religious': ['civil', 'criminal', 'family', 'labor', 'property', 'business',
                  'immigration', 'tax', 'constitutional', 'sharia',
                  'commercial', 'consumer', 'human_rights'],
}


def get_country(code):
    """Get full country data by ISO code."""
    c = COUNTRY_MAP.get(code.upper())
    if not c:
        return None
    c_copy = dict(c)
    c_copy['topics'] = LEGAL_TOPICS.get(c['legal_system'], LEGAL_TOPICS['mixed'])
    return c_copy


def get_all_countries():
    """Return all countries with topics."""
    result = []
    for c in COUNTRIES:
        c_copy = dict(c)
        c_copy['topics'] = LEGAL_TOPICS.get(c['legal_system'], LEGAL_TOPICS['mixed'])
        result.append(c_copy)
    return result


def search_countries(query):
    """Search countries by name or code."""
    q = query.lower()
    return [
        dict(c, topics=LEGAL_TOPICS.get(c['legal_system'], LEGAL_TOPICS['mixed']))
        for c in COUNTRIES
        if q in c['name'].lower() or q == c['code'].lower()
    ]


# ── Emergency contacts per country (detailed) ──
EMERGENCY_CONTACTS = {
    "US": {
        "country": "United States",
        "hotlines": [
            {"name": "Emergency (Police/Fire/Ambulance)", "phone": "911", "description": "Universal emergency number", "hours": "24/7"},
            {"name": "National Domestic Violence Hotline", "phone": "1-800-799-7233", "description": "Help for domestic violence victims", "hours": "24/7"},
            {"name": "Legal Aid Society", "phone": "1-212-577-3300", "description": "Free legal assistance for low-income individuals", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "ACLU Legal Helpline", "phone": "1-212-549-2500", "description": "Civil liberties and rights violations", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "National Suicide Prevention Lifeline", "phone": "988", "description": "Crisis support and suicide prevention", "hours": "24/7"},
            {"name": "Immigration Legal Services", "phone": "1-800-354-0365", "description": "Immigration law assistance", "hours": "Mon-Fri 9AM-5PM"},
        ],
        "online_resources": [
            {"name": "LawHelp.org", "url": "https://www.lawhelp.org"},
            {"name": "Legal Services Corporation", "url": "https://www.lsc.gov"},
            {"name": "FindLaw", "url": "https://www.findlaw.com"},
        ],
    },
    "GB": {
        "country": "United Kingdom",
        "hotlines": [
            {"name": "Emergency Services", "phone": "999", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "Citizens Advice Bureau", "phone": "0800 144 8848", "description": "Free legal and general advice", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "Law Society", "phone": "020 7242 1222", "description": "Find a solicitor", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "National Domestic Abuse Helpline", "phone": "0808 2000 247", "description": "Support for domestic abuse victims", "hours": "24/7"},
            {"name": "Shelter Housing Helpline", "phone": "0808 800 4444", "description": "Housing and homelessness advice", "hours": "Mon-Fri 8AM-8PM"},
        ],
        "online_resources": [
            {"name": "GOV.UK Legal Aid", "url": "https://www.gov.uk/legal-aid"},
            {"name": "Citizens Advice", "url": "https://www.citizensadvice.org.uk"},
        ],
    },
    "CA": {
        "country": "Canada",
        "hotlines": [
            {"name": "Emergency Services", "phone": "911", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "Legal Aid Ontario", "phone": "1-800-668-8258", "description": "Free legal services", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Canadian Bar Association", "phone": "1-800-267-8860", "description": "Lawyer referral service", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "Assaulted Women's Helpline", "phone": "1-866-863-0511", "description": "Support for women experiencing violence", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Justice Canada", "url": "https://www.justice.gc.ca"},
            {"name": "Legal Aid Canada", "url": "https://www.legalaid.on.ca"},
        ],
    },
    "AU": {
        "country": "Australia",
        "hotlines": [
            {"name": "Emergency Services", "phone": "000", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "Legal Aid NSW", "phone": "1300 888 529", "description": "Free legal assistance", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "1800RESPECT", "phone": "1800 737 732", "description": "Domestic violence and sexual assault", "hours": "24/7"},
            {"name": "Law Access NSW", "phone": "1300 888 529", "description": "Legal information and referral", "hours": "Mon-Fri 9AM-5PM"},
        ],
        "online_resources": [
            {"name": "Legal Aid Australia", "url": "https://www.legalaid.nsw.gov.au"},
        ],
    },
    "IN": {
        "country": "India",
        "hotlines": [
            {"name": "Police Emergency", "phone": "100", "description": "Police emergency", "hours": "24/7"},
            {"name": "Women Helpline", "phone": "1091", "description": "Women in distress", "hours": "24/7"},
            {"name": "National Human Rights Commission", "phone": "011-24663333", "description": "Human rights violations", "hours": "Mon-Fri 9:30AM-6PM"},
            {"name": "Child Helpline", "phone": "1098", "description": "Children in need", "hours": "24/7"},
            {"name": "Ambulance", "phone": "108", "description": "Emergency medical", "hours": "24/7"},
            {"name": "National Legal Services Authority", "phone": "011-23382778", "description": "Free legal aid", "hours": "Mon-Fri 10AM-5PM"},
        ],
        "online_resources": [
            {"name": "National Legal Services Authority", "url": "https://nalsa.gov.in"},
            {"name": "India Code", "url": "https://www.indiacode.nic.in"},
        ],
    },
    "NG": {
        "country": "Nigeria",
        "hotlines": [
            {"name": "Police Emergency", "phone": "112", "description": "National emergency number", "hours": "24/7"},
            {"name": "Nigeria Police Force", "phone": "199", "description": "Police direct", "hours": "24/7"},
            {"name": "Legal Aid Council of Nigeria", "phone": "+234-9-6702283", "description": "Free legal representation", "hours": "Mon-Fri 8AM-4PM"},
            {"name": "National Human Rights Commission", "phone": "+234-9-5238541", "description": "Human rights violations", "hours": "Mon-Fri 8AM-4PM"},
            {"name": "NAPTIP Anti-Trafficking", "phone": "0800-0000-0001", "description": "Anti-human trafficking", "hours": "24/7"},
            {"name": "Domestic Violence Hotline", "phone": "+234-9-2900535", "description": "Support for domestic violence victims", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Nigerian Law (LawNigeria)", "url": "https://www.lawnigeria.com"},
            {"name": "Legal Aid Council", "url": "https://www.legalaidcouncil.gov.ng"},
        ],
    },
    "KE": {
        "country": "Kenya",
        "hotlines": [
            {"name": "Emergency Services", "phone": "999", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "National Legal Aid Service", "phone": "+254-20-2717234", "description": "Free legal aid", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Kenya National Commission on Human Rights", "phone": "+254-20-2717908", "description": "Human rights", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Gender Violence Hotline", "phone": "1195", "description": "Report gender-based violence", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Kenya Law", "url": "http://kenyalaw.org"},
        ],
    },
    "ZA": {
        "country": "South Africa",
        "hotlines": [
            {"name": "Police Emergency", "phone": "10111", "description": "South African Police Service", "hours": "24/7"},
            {"name": "Legal Aid South Africa", "phone": "0800 110 110", "description": "Free legal assistance", "hours": "Mon-Fri 7:30AM-4PM"},
            {"name": "Stop Gender Violence Helpline", "phone": "0800 150 150", "description": "Gender-based violence support", "hours": "24/7"},
            {"name": "Childline South Africa", "phone": "0800 055 555", "description": "Child abuse and neglect", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Legal Aid South Africa", "url": "https://legal-aid.co.za"},
            {"name": "South African Government", "url": "https://www.gov.za"},
        ],
    },
    "AE": {
        "country": "United Arab Emirates",
        "hotlines": [
            {"name": "Emergency", "phone": "999", "description": "Police emergency", "hours": "24/7"},
            {"name": "Ambulance", "phone": "998", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Ministry of Justice", "phone": "600-544-444", "description": "Legal inquiries", "hours": "Sun-Thu 7:30AM-3:30PM"},
            {"name": "Dubai Foundation for Women & Children", "phone": "800-111", "description": "Women and children in distress", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "UAE Government Legal Portal", "url": "https://www.government.ae"},
        ],
    },
    "KH": {
        "country": "Cambodia",
        "hotlines": [
            {"name": "Police Emergency", "phone": "117", "description": "National police emergency", "hours": "24/7"},
            {"name": "Ambulance / Fire", "phone": "119", "description": "Emergency medical and fire", "hours": "24/7"},
            {"name": "Legal Aid of Cambodia (LAC)", "phone": "+855-23-220-504", "description": "Free legal representation for vulnerable groups", "hours": "Mon-Fri 8:00-17:00"},
            {"name": "Cambodia Human Rights Committee (CHRC)", "phone": "1285", "description": "Human rights violations hotline", "hours": "24/7"},
            {"name": "Cambodian Center for Human Rights (CCHR)", "phone": "+855-23-726-901", "description": "Human rights advocacy and legal assistance", "hours": "Mon-Fri 8:00-17:00"},
            {"name": "Anti-Human Trafficking Hotline", "phone": "1288", "description": "Report trafficking and exploitation", "hours": "24/7"},
            {"name": "Women's Crisis Center (LICADHO)", "phone": "+855-23-727-102", "description": "Support for women experiencing violence", "hours": "Mon-Fri 8:00-17:00"},
        ],
        "online_resources": [
            {"name": "Bar Association of the Kingdom of Cambodia", "url": "https://www.bakc.org.kh"},
            {"name": "Cambodian Legal Resources", "url": "https://www.cambodia-law.org"},
        ],
    },
    "DE": {
        "country": "Germany",
        "hotlines": [
            {"name": "Emergency (Police/Fire/Ambulance)", "phone": "112", "description": "European emergency number", "hours": "24/7"},
            {"name": "Police Non-Emergency", "phone": "110", "description": "Police reports and inquiries", "hours": "24/7"},
            {"name": "Rechtsanwaltskammer (BAR)", "phone": "+49-30-284939-0", "description": "German Bar Association - lawyer referral", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "Violence Against Women Helpline", "phone": "0800 0116 016", "description": "Support for women", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "German Federal Ministry of Justice", "url": "https://www.bmj.de"},
            {"name": "Gesetze im Internet", "url": "https://www.gesetze-im-internet.de"},
        ],
    },
    "FR": {
        "country": "France",
        "hotlines": [
            {"name": "SAMU (Medical)", "phone": "15", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Police", "phone": "17", "description": "Police emergency", "hours": "24/7"},
            {"name": "Fire (Pompiers)", "phone": "18", "description": "Fire emergency", "hours": "24/7"},
            {"name": "European Emergency", "phone": "112", "description": "Universal EU emergency", "hours": "24/7"},
            {"name": "Violences Femmes Info", "phone": "3919", "description": "Support for women", "hours": "24/7"},
            {"name": "Accès au Droit", "phone": "3039", "description": "Free legal information", "hours": "Mon-Fri 9AM-6PM"},
        ],
        "online_resources": [
            {"name": "Legifrance", "url": "https://www.legifrance.gouv.fr"},
            {"name": "Service Public", "url": "https://www.service-public.fr"},
        ],
    },
    "BR": {
        "country": "Brazil",
        "hotlines": [
            {"name": "Polícia Militar", "phone": "190", "description": "Military police emergency", "hours": "24/7"},
            {"name": "SAMU (Ambulance)", "phone": "192", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Fire Department", "phone": "193", "description": "Fire emergency", "hours": "24/7"},
            {"name": "Defensoria Pública", "phone": "129", "description": "Free legal assistance", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Disque Direitos Humanos", "phone": "100", "description": "Human rights violations", "hours": "24/7"},
            {"name": "Central de Atendimento à Mulher", "phone": "180", "description": "Women's helpline", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Planalto.gov.br (Legislation)", "url": "http://www.planalto.gov.br"},
        ],
    },
    "MX": {
        "country": "Mexico",
        "hotlines": [
            {"name": "Emergency", "phone": "911", "description": "Universal emergency", "hours": "24/7"},
            {"name": "National Human Rights Commission", "phone": "800-715-2000", "description": "Human rights", "hours": "24/7"},
            {"name": "Women's Justice Line", "phone": "800-911-2000", "description": "Women in danger", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Diario Oficial de la Federación", "url": "https://www.dof.gob.mx"},
        ],
    },
    "JP": {
        "country": "Japan",
        "hotlines": [
            {"name": "Police", "phone": "110", "description": "Police emergency", "hours": "24/7"},
            {"name": "Fire/Ambulance", "phone": "119", "description": "Fire and ambulance", "hours": "24/7"},
            {"name": "Japan Legal Support Center (Houterasu)", "phone": "0570-078374", "description": "Free legal consultation", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "Immigration Information Center", "phone": "0570-013904", "description": "Immigration assistance", "hours": "Mon-Fri 8:30AM-5:15PM"},
        ],
        "online_resources": [
            {"name": "Japan Legal Support Center", "url": "https://www.houterasu.or.jp"},
            {"name": "e-Gov Laws (Japan)", "url": "https://www.e-gov.go.jp"},
        ],
    },
    "PH": {
        "country": "Philippines",
        "hotlines": [
            {"name": "Emergency", "phone": "911", "description": "National emergency", "hours": "24/7"},
            {"name": "Public Attorney's Office", "phone": "8929-9436", "description": "Free legal assistance", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Commission on Human Rights", "phone": "8294-8704", "description": "Human rights violations", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "VAWC Hotline", "phone": "8527-8836", "description": "Violence against women and children", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Official Gazette Philippines", "url": "https://www.officialgazette.gov.ph"},
        ],
    },
    "PK": {
        "country": "Pakistan",
        "hotlines": [
            {"name": "Police Emergency", "phone": "15", "description": "Police emergency", "hours": "24/7"},
            {"name": "Rescue/Ambulance", "phone": "1122", "description": "Emergency rescue", "hours": "24/7"},
            {"name": "National Commission for Human Rights", "phone": "051-9217856", "description": "Human rights", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "Women's Helpline", "phone": "0800-22444", "description": "Women in distress", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Pakistan Code", "url": "http://www.pakistancode.gov.pk"},
        ],
    },
    "BD": {
        "country": "Bangladesh",
        "hotlines": [
            {"name": "National Emergency", "phone": "999", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "National Legal Aid Services", "phone": "16430", "description": "Free legal aid", "hours": "Mon-Thu 9AM-5PM"},
            {"name": "National Human Rights Commission", "phone": "+880-2-9116001", "description": "Human rights", "hours": "Sun-Thu 9AM-5PM"},
            {"name": "Women & Children Helpline", "phone": "10921", "description": "Women and children in distress", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Bangladesh Laws", "url": "http://bdlaws.minlaw.gov.bd"},
        ],
    },
    "EG": {
        "country": "Egypt",
        "hotlines": [
            {"name": "Police Emergency", "phone": "122", "description": "Police", "hours": "24/7"},
            {"name": "Ambulance", "phone": "123", "description": "Emergency medical", "hours": "24/7"},
            {"name": "National Council for Women", "phone": "15115", "description": "Women's rights and support", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Egyptian Government Portal", "url": "https://www.egypt.gov.eg"},
        ],
    },
    "GH": {
        "country": "Ghana",
        "hotlines": [
            {"name": "Police Emergency", "phone": "191", "description": "Ghana Police Service", "hours": "24/7"},
            {"name": "Fire Service", "phone": "192", "description": "Fire emergency", "hours": "24/7"},
            {"name": "Ambulance", "phone": "193", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Legal Aid Commission", "phone": "+233-302-664761", "description": "Free legal assistance", "hours": "Mon-Fri 8AM-5PM"},
            {"name": "Domestic Violence & Victim Support (DOVVSU)", "phone": "+233-302-773906", "description": "Domestic violence support", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Ghana Legal Information Institute", "url": "https://ghalii.org"},
        ],
    },
    "SG": {
        "country": "Singapore",
        "hotlines": [
            {"name": "Police / Ambulance / Fire", "phone": "999", "description": "Emergency services", "hours": "24/7"},
            {"name": "Legal Aid Bureau", "phone": "1800-325-1424", "description": "Free legal aid for qualifying persons", "hours": "Mon-Fri 8:30AM-5PM"},
            {"name": "Law Society Pro Bono", "phone": "6536-0650", "description": "Pro bono legal assistance", "hours": "Mon-Fri 9AM-5:30PM"},
        ],
        "online_resources": [
            {"name": "Singapore Statutes Online", "url": "https://sso.agc.gov.sg"},
        ],
    },
    "MY": {
        "country": "Malaysia",
        "hotlines": [
            {"name": "Emergency", "phone": "999", "description": "Police, Fire, Ambulance", "hours": "24/7"},
            {"name": "Malaysian Bar Council", "phone": "+603-2050-2050", "description": "Lawyer referral service", "hours": "Mon-Fri 8:30AM-5:30PM"},
            {"name": "Legal Aid Department", "phone": "+603-8885-1000", "description": "Free legal assistance for low-income", "hours": "Mon-Fri 8:30AM-5PM"},
            {"name": "Talian Nur (Women/Children)", "phone": "15999", "description": "Domestic violence, child abuse", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Malaysian Legal Portal", "url": "http://www.commonlii.org/my"},
        ],
    },
    "TH": {
        "country": "Thailand",
        "hotlines": [
            {"name": "Police Emergency", "phone": "191", "description": "Royal Thai Police", "hours": "24/7"},
            {"name": "Tourist Police", "phone": "1155", "description": "Tourist assistance", "hours": "24/7"},
            {"name": "Ambulance", "phone": "1669", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Legal Aid Center", "phone": "+66-2-141-5100", "description": "Free legal aid", "hours": "Mon-Fri 8:30AM-4:30PM"},
        ],
        "online_resources": [
            {"name": "Thai Law Online", "url": "https://www.thailawonline.com"},
        ],
    },
    "ID": {
        "country": "Indonesia",
        "hotlines": [
            {"name": "Police", "phone": "110", "description": "Police emergency", "hours": "24/7"},
            {"name": "Ambulance", "phone": "118", "description": "Emergency medical", "hours": "24/7"},
            {"name": "National Legal Aid Foundation (YLBHI)", "phone": "+62-21-3929840", "description": "Free legal assistance", "hours": "Mon-Fri 9AM-5PM"},
            {"name": "National Commission on Human Rights", "phone": "+62-21-3925230", "description": "Human rights violations", "hours": "Mon-Fri 8AM-4PM"},
        ],
        "online_resources": [
            {"name": "Indonesian National Law Database", "url": "https://peraturan.bpk.go.id"},
        ],
    },
    "SA": {
        "country": "Saudi Arabia",
        "hotlines": [
            {"name": "Police Emergency", "phone": "911", "description": "Emergency services", "hours": "24/7"},
            {"name": "Human Rights Commission", "phone": "8001-241-1919", "description": "Human rights complaints", "hours": "Sun-Thu 8AM-3PM"},
            {"name": "Domestic Violence Helpline", "phone": "1919", "description": "Domestic violence support", "hours": "24/7"},
        ],
        "online_resources": [
            {"name": "Saudi Legal Portal (Najiz)", "url": "https://www.najiz.sa"},
        ],
    },
    "TR": {
        "country": "Turkey",
        "hotlines": [
            {"name": "Police", "phone": "155", "description": "Police emergency", "hours": "24/7"},
            {"name": "Fire", "phone": "110", "description": "Fire emergency", "hours": "24/7"},
            {"name": "Ambulance", "phone": "112", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Violence Against Women Helpline", "phone": "183", "description": "Women in danger", "hours": "24/7"},
            {"name": "Legal Aid (Adli Yardım)", "phone": "+90-312-416-7272", "description": "Free legal assistance", "hours": "Mon-Fri 9AM-5PM"},
        ],
        "online_resources": [
            {"name": "Turkish Legislation Database", "url": "https://www.mevzuat.gov.tr"},
        ],
    },
    "RU": {
        "country": "Russia",
        "hotlines": [
            {"name": "Unified Emergency", "phone": "112", "description": "All emergencies", "hours": "24/7"},
            {"name": "Police", "phone": "102", "description": "Police", "hours": "24/7"},
            {"name": "Ambulance", "phone": "103", "description": "Medical emergency", "hours": "24/7"},
            {"name": "Free Legal Aid Hotline", "phone": "8-800-555-5550", "description": "Free legal consultation", "hours": "Mon-Fri 9AM-6PM"},
        ],
        "online_resources": [
            {"name": "Consultant.ru (Legislation)", "url": "https://www.consultant.ru"},
        ],
    },
    "CN": {
        "country": "China",
        "hotlines": [
            {"name": "Police", "phone": "110", "description": "Public security", "hours": "24/7"},
            {"name": "Ambulance", "phone": "120", "description": "Emergency medical", "hours": "24/7"},
            {"name": "Fire", "phone": "119", "description": "Fire emergency", "hours": "24/7"},
            {"name": "Legal Aid Hotline", "phone": "12348", "description": "Free legal consultation", "hours": "Mon-Fri 9AM-5PM"},
        ],
        "online_resources": [
            {"name": "China Law Info", "url": "https://www.pkulaw.com"},
        ],
    },
    "KR": {
        "country": "South Korea",
        "hotlines": [
            {"name": "Police/Emergency", "phone": "112", "description": "Police and emergency", "hours": "24/7"},
            {"name": "Fire/Ambulance", "phone": "119", "description": "Fire and medical emergency", "hours": "24/7"},
            {"name": "Korea Legal Aid Corporation", "phone": "132", "description": "Free legal consultation", "hours": "Mon-Fri 9AM-6PM"},
            {"name": "National Human Rights Commission", "phone": "1331", "description": "Human rights", "hours": "Mon-Fri 9AM-6PM"},
        ],
        "online_resources": [
            {"name": "Korean Law Information Center", "url": "https://www.law.go.kr"},
        ],
    },
}

# Default emergency template for countries without specific data
def get_emergency_info(country_code):
    """Get emergency info for a country. Falls back to generic if not specifically listed."""
    code = country_code.upper()
    if code in EMERGENCY_CONTACTS:
        return EMERGENCY_CONTACTS[code]

    country = COUNTRY_MAP.get(code)
    if not country:
        return None

    return {
        "country": country['name'],
        "hotlines": [
            {
                "name": "Emergency Services",
                "phone": country['emergency'],
                "description": f"National emergency number for {country['name']}",
                "hours": "24/7",
            },
        ],
        "online_resources": [],
        "note": f"For detailed legal aid contacts in {country['name']}, consult your local bar association or legal aid office.",
    }
