<?php

$tribalCouncils = [
  [
    'name' => 'Independent Bands',
    'logo' => '',
    'website' => '',
    'contact' => [],
    'tribal-councils' => [
      ['1', 'Hornepayne'],
      ['2', 'Mishkeegogamang'],
      ['3', 'Mocreebec Council of the Cree Nation'],
      ['4', 'Sandy Lake'],
      ['5', 'Wahgoshig'],
      ['6', 'Weenusk (Peawanuck)']
    ]
  ],
  [
    'name' => 'Independent First Nations Alliance',
    'logo' => 'ifna_logo',
    'website' => 'https://ifna.ca/',
    'contact' => [
      'po_box' => '98 King Street Box 5010',
      'address' => 'Sioux Lookout, Ontario P8T 1K6',
      'phone' => '1-807-737-1902',
      'fax' => '1-807-737-3501'
    ],
    'tribal-councils' => [
      ['7', 'Lac Seul'],
      ['8', 'Muskrat Dam'],
      ['9', 'Pikangikum']
    ]
  ],
  [
    'name' => 'Keewaytinook Okimakanak',
    'logo' => 'keewaytinook_okimakanak_logo',
    'website' => 'https://www.kochiefs.ca/',
    'contact' => [
      'po_box' => 'PO Box 340',
      'address' => '8 Mine Lake Road Balmertown, ON P0V 1C0',
      'phone' => '1-807-735-1381',
      'fax' => '1-807-735-1383'
    ],
    'tribal-councils' => [
      ['10', 'Deer Lake'],
      ['11', 'Fort Severn'],
      ['12', 'Keewaywin'],
      ['13', 'McDowell Lake'],
      ['14', 'North Spirit Lake'],
      ['15', 'Poplar Hill']
    ]
  ],
  [
    'name' => 'Matawa First Nations',
    'logo' => 'matawa_first_nations_logo',
    'website' => 'https://www.matawa.on.ca/',
    'contact' => [
      'po_box' => '',
      'address' => '233 Court St South Thunder Bay, ON P7B 2X9',
      'phone' => '1-807-344-4575',
      'fax' => '1-807-344-2977'
    ],
    'tribal-councils' => [
      ['16', 'Aroland'],
      ['17', 'Constance Lake'],
      ['18', 'Eabametoong'],
      ['19', 'Ginoogaming'],
      ['20', 'Long Lake #58'],
      ['21', 'Marten Falls'],
      ['22', 'Neskantaga'],
      ['23', 'Nibinamik'],
      ['24', 'Webequie']
    ]
  ],
  [
    'name' => 'Mushkegowuk Council',
    'logo' => 'mushkegowuk_council_logo',
    'website' => 'https://www.mushkegowuk.ca/',
    'contact' => [
      'po_box' => 'PO Box 370',
      'address' => 'Moose Factory, ON P0L 1W0',
      'phone' => '1-705-658-4222',
      'fax' => '1-705-658-4250'
    ],
    'tribal-councils' => [
      ['25', 'Attawapiskat'],
      ['26', 'Chapleau Cree'],
      ['27', 'Fort Albany'],
      ['28', 'Kashechewan'],
      ['29', 'Missanabie Cree'],
      ['30', 'Moose Cree'],
      ['31', 'aykwa Tagamou']
    ]
  ],
  [
    'name' => 'Shibogama First Nations Council',
    'logo' => 'shibogama_first_nations_logo',
    'website' => 'https://www.shibogama.on.ca/',
    'contact' => [
      'po_box' => 'PO Box 449',
      'address' => 'Sioux Lookout, ON P8T 1A5',
      'phone' => '1-807-737-2662',
      'fax' => '1-807-737-1583'
    ],
    'tribal-councils' => [
      ['32', 'Kasabonika Lake'],
      ['33', 'Kingfisher Lake'],
      ['34', 'Wapekeka'],
      ['35', 'Wawakapewin'],
      ['36', 'Wunnumin Lake']
    ]
  ],
  [
    'name' => 'Wabun Tribal Council',
    'logo' => 'wabum_tribal_council_logo',
    'website' => 'https://www.wabuntribalcouncil.ca/',
    'contact' => [
      'po_box' => '',
      'address' => '313 Railway St Timmins, ON P4N 2P4',
      'phone' => '1-705-268-9066',
      'fax' => '1-705-268-8554'
    ],
    'tribal-councils' => [
      ['37', 'Beaverhouse'],
      ['38', 'Brunswick House'],
      ['39', 'Chapleau Ojibway'],
      ['40', 'Flying Post'],
      ['41', 'Matachewan'],
      ['42', 'Mattagami']
    ]
  ],
  [
    'name' => 'Windigo First Nations Council',
    'logo' => 'windigo_first_nations_council_logo',
    'website' => 'https://www.windigo.on.ca/',
    'contact' => [
      'po_box' => 'PO Box 229',
      'address' => 'Sioux Lookout, ON P8T 1A3',
      'phone' => '1-807-737-1585',
      'fax' => '1-807-737-3133'
    ],
    'tribal-councils' => [
      ['43', 'Bearskin Lake'],
      ['44', 'Cat Lake'],
      ['45', 'Koocheching'],
      ['46', 'North Caribou Lake'],
      ['47', 'Sachigo Lake'],
      ['48', 'Slate Falls'],
      ['49', 'Whitewater Lake']
    ]
  ],
]

?>

<article>

  <div class="bg-white">
    <h2 class="text-xl p-4 text-red-500 font-bold">First Nations & Tribal Council Information</h2>
    <p class="px-4 mb-4 font-medium underline">Where are you from?</p>
  </div>

  <div class="px-4">

    <div class="h-1 my-4 bg-blue-500"></div>

    <!-- Tribal Council Info Components Loop -->
    <?php foreach ($tribalCouncils as $tribalCouncil) { ?>
      <div>

        <div class="relative flex items-center space-x-2">

          <?php if ($tribalCouncil['logo']) : ?>
            <img class="tribal-council-logo object-cover" src="<?php echo get_template_directory_uri() . '/assets/images/logos/tribal-councils/' . $tribalCouncil['logo'] . '.png' ?>" alt="Tribal Council Logo">
          <?php endif; ?>

          <h3 class="font-bold"><?= $tribalCouncil['name'] ?></h3>
          <a class="absolute inset-0 w-full h-full font-medium underline" href="<?= $tribalCouncil['website'] ?>"></a>

        </div>

        <!-- Contact Information -->
        <?php if ($tribalCouncil['contact']) : ?>
          <div class="accordion bg-red-500 text-white my-2">
            <div class="flex px-2 rounded-md justify-between">
              <p class="gap-x-3 rounded-md p-2 text-sm leading-6 flex items-center align-middle font-bold">Contact Information</p>

              <button class="accordion-toggle">
                <i class="fas fa-chevron-down items-center ml-auto rounded-m px-2.5 py-2 " aria-hidden="true"></i>
                <i class="fas fa-times items-center ml-auto rounded-md px-3 py-2" aria-hidden="true"></i>
              </button>

            </div>
            <div class="accordion-content space-y-4">
              <ul class="space-y-2">

                <?php if ($tribalCouncil['contact']['po_box']) : ?>
                  <li>
                    <p><strong>PO Box: </strong><?= $tribalCouncil['contact']['po_box'] ?></p>
                  </li>
                <?php endif; ?>

                <li>
                  <p><strong>Address: </strong><?= $tribalCouncil['contact']['address'] ?></p>
                </li>

                <li>
                  <p><strong>Phone: </strong><a class="font-medium underline" href="tel:+<?= str_replace("-", "", $tribalCouncil['contact']['phone']);  ?>"><?= $tribalCouncil['contact']['phone'] ?></a></p>
                </li>

                <li>
                  <p><strong>Fax: </strong><a class="font-medium underline" href="fax:+<?= str_replace("-", "", $tribalCouncil['contact']['fax']);  ?>"><?= $tribalCouncil['contact']['fax'] ?></a></p>
                </li>

              </ul>
            </div>
          </div>
        <?php endif; ?>

        <!-- Tribal Councils -->
        <div class="accordion bg-green-900 text-white my-2">
          <div class="flex px-2 rounded-md justify-between">
            <p class="gap-x-3 rounded-md p-2 text-sm leading-6 flex items-center align-middle font-bold">Tribal Councils</p>

            <button class="accordion-toggle">
              <i class="fas fa-chevron-down items-center ml-auto rounded-m px-2.5 py-2 " aria-hidden="true"></i>
              <i class="fas fa-times items-center ml-auto rounded-md px-3 py-2" aria-hidden="true"></i>
            </button>

          </div>
          <div class="accordion-content space-y-4">
            <ul class="space-y-2">

              <?php foreach ($tribalCouncil['tribal-councils'] as $tribalCouncil) : ?>
                <li class="flex space-x-2">
                  <p><strong><?= $tribalCouncil[0] ?></strong></p>
                  <p><?= $tribalCouncil[1] ?></p>
                </li>
              <?php endforeach; ?>

            </ul>
          </div>
        </div>

      </div>


      <div class="h-1 my-4 bg-blue-500"></div>
    <?php } ?>

  </div>


</article>