<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    header("Content-Type: application/json");

    include('config.php');

    date_default_timezone_set("Asia/Kolkata");

    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    require '../vendor/autoload.php';

    $requestData = json_decode(file_get_contents("php://input"), true);

    $teamId = $requestData['team_id'] ?? '';
    $ccList = $requestData['cc']      ?? [];
    $email  = $requestData['email']   ?? '';

    $filePath   = "https://www.procorporateleague.com/2026/pcl/assets/mail_image/";
    $imgVersion = time();

    /* ── PCL OVERALL STATS ── */
    $statscurl = curl_init();
    curl_setopt_array($statscurl, [
        CURLOPT_URL            => 'https://procorporateleague.com/pcl_rest/api/v1/pcl/stats',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 10,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'GET'
    ]);
    $statsResponse = curl_exec($statscurl);
    curl_close($statscurl);
    $statsJson = json_decode($statsResponse, true);
    $statsArrayData = [
        'total_matches_played'  => $statsJson['results'][0]['Total_Matches_Played']  ?? 0,
        'total_runs_Scored'     => $statsJson['results'][0]['Total_Runs_Scored']     ?? 0,
        'total_wickets_Claimed' => $statsJson['results'][0]['Total_Wickets_Claimed'] ?? 0,
        'total_hundreds'        => $statsJson['results'][0]['Total_Hundreds']        ?? 0,
        'total_fifties'         => $statsJson['results'][0]['Total_Fifties']         ?? 0,
    ];

    /* ── TEAM AI PROFILE ── */
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL            => "https://procorporateleague.com/pcl_rest/api/v12/teams/{$teamId}/ai-profile",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'GET',
    ));
    $response = curl_exec($curl);
    curl_close($curl);

    $teamData = json_decode($response, true);

    $profile = [];
    if (!empty($teamData) && !empty($teamData['data'])) {
        $profile = $teamData['data'][0] ?? [];
    }

    $LogoUrl = 'https://procorporateleague.com/wp-includes/images/team/' . rawurlencode((string)($profile['team_id'] ?? '')) . '.png';

    /* ── OLD TEAM MAP DATA ── */
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL            => 'https://www.procorporateleague.com/pcl_rest/api/v9/old-team-map-data/getAll',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'GET',
    ));
    $response = curl_exec($curl);
    curl_close($curl);

    $teamInfo     = json_decode($response, true);
    $teamInfoData = [];  // ← string ki jagah empty array
    if (!empty($teamInfo) && !empty($teamInfo['results']) && $teamInfo['code'] === 200) {
        foreach ($teamInfo['results'] as $key => $values) {
            if ($teamId == $values['team_id']) {
                $teamInfoData = $values;
                break;
            }
        }
    }

    // ── email: pehle requestData se, fallback teamInfoData se ──
   if (empty($email)) {
    $email = $teamInfoData['email'] ?? '';
}
    $name = $profile['team_name'] ?? '';

    /* ── ALL CITIES ── */
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL            => 'https://www.procorporateleague.com/pcl_rest/api/v9/corporate/getAllCities',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'GET',
    ));
    $response = curl_exec($curl);
    curl_close($curl);

    $getData  = json_decode($response, true);
    $cityData = [];
    if (!empty($getData) && !empty($getData['results']) && $getData['code'] === 200) {
        $cityData = $getData['results'] ?? [];
    }

    /* ── ALL SECTORS ── */
    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL            => 'https://www.procorporateleague.com/pcl_rest/api/v9/corporate/getAllSectors',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING       => '',
        CURLOPT_MAXREDIRS      => 10,
        CURLOPT_TIMEOUT        => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST  => 'GET',
    ));
    $response = curl_exec($curl);
    curl_close($curl);

    $getData    = json_decode($response, true);
    $sectorData = [];
    if (!empty($getData) && !empty($getData['results']) && $getData['code'] === 200) {
        $sectorData = $getData['results'] ?? [];
    }

    /* ── MATCH CITY & SECTOR ── */
    $singleCity   = [];
    $singleSector = [];

    // ── FIX: teamInfoData array hai tabhi foreach chalo ──
    if (!empty($teamInfoData) && is_array($teamInfoData)) {
        foreach ($cityData as $cityVal) {
            if (($teamInfoData['city'] ?? '') == $cityVal['id']) {
                $singleCity = $cityVal;
                break;
            }
        }

        foreach ($sectorData as $sectorVal) {
            if (($teamInfoData['sector'] ?? '') == $sectorVal['id']) {
                $singleSector = $sectorVal;
                break;
            }
        }
    }

    /* ── SMTP CREDENTIALS ── */
    $smtpSql = "SELECT * FROM `smtp_auth_data` WHERE id = 1";
    $smtpExe = mysqli_query($conn, $smtpSql);
    $smtpRow = mysqli_fetch_assoc($smtpExe);
    if (empty($smtpRow)) {
        echo json_encode(["status_code" => 400, "status" => "ERROR", "message" => "SMTP AUTH MISSING"]);
        die;
    }

    ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Corporate World Cup™ – Invitation | <?= $profile['team_name']??'' ?> | <?= $singleCity['city_name']??'' ?></title>
</head>
<body style="margin:0;padding:0;background-color:#e8edf5;font-family:Georgia,'Times New Roman',serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;">

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#e8edf5;">
<tr>
<td align="center" style="padding:24px 12px;">

<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="900" style="max-width:900px;background-color:#ffffff;overflow:hidden;">

  <!-- ══════════════════════ HEADER ══════════════════════ -->
  <!-- <tr>
    <td style="background-color:#0b2c6b;padding:0;"> -->

      <!-- TOP NAV BAR -->
      <!-- <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td style="padding:16px 28px;border-bottom:1px solid rgba(255,255,255,0.08);">
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td valign="middle">
                  <table role="presentation" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                      <td valign="middle" style="padding-right:12px;">
                        <table cellpadding="0" cellspacing="0" border="0">
                          <tr>
                            <td align="center" valign="middle" style="width:46px;height:46px;background:#0d2a5e;border-radius:10px;border:1px solid rgba(215,175,89,0.3);">
                              <img src="https://www.procorporateleague.com/2026/pcl/Imp_PCL_Logo_Black.png" width="48" style="display:block;border:0;height:auto;" alt="PCL">
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td valign="middle">
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:15px;font-weight:700;color:#d7af59;letter-spacing:0.5px;line-height:1.2;">Pro Corporate League</div>
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#ffffff;letter-spacing:1px;text-transform:uppercase;margin-top:2px;">Corporate World Cup™ Qualification</div>
                      </td>
                    </tr>
                  </table>
                </td>
                <td align="right" valign="middle">
                  <div style="display:inline-block;border:1px solid rgba(215,175,89,0.4);color:#d7af59;font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;padding:7px 16px;border-radius:2px;letter-spacing:0.5px;">#CorporateKaWorldCup</div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table> -->

      <!-- GOLD DIVIDER -->
      <!-- <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td style="height:3px;background:linear-gradient(90deg,#d7af59 0%,#f5e4a0 50%,#d7af59 100%);font-size:0;line-height:0;">&nbsp;</td></tr>
      </table> -->

      <!-- HERO -->
      <!-- <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          
          <td valign="middle" width="52%" style="padding:32px 0 32px 28px;">
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:14px;">&#9654; Official Invitation · <?= $singleCity['city_name']??'' ?> Edition 2026</div>
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:34px;color:#ffffff;margin-bottom:8px;font-style:italic;">We are pleased<br>to invite,</div>
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:30px;font-weight:700;color:#d7af59;line-height:1.15;margin-bottom:6px;"><?= $profile['team_name']??'' ?></div>
            <div style="height:3px;width:50px;background-color:#d7af59;margin:12px 0 16px;"></div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#ffffff;line-height:1.8;">
              To secure a team for the <strong style="color:#d7af59;"><?= $singleCity['city_name']??'' ?> Edition</strong><br>of the Corporate World Cup™ Qualification Round.
            </div>
          </td>

          
          <td valign="middle" width="48%" style="padding:24px 24px 24px 16px;">
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#071a3e;border:1px solid rgba(215,175,89,0.25);">
              <tr>
                <td style="padding:20px 20px 0;">
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:14px;">Slot Details</div>
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                      <td style="padding-bottom:12px;">
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;color:#7a9cc4;text-transform:uppercase;letter-spacing:1px;margin-bottom:3px;">Company</div>
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:16px;font-weight:700;color:#ffffff;"><?= $profile['team_name']??'' ?></div>
                      </td>
                    </tr>
                    <tr>
                      <td style="padding-bottom:12px;border-top:1px solid rgba(255,255,255,0.07);padding-top:12px;">
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;color:#7a9cc4;text-transform:uppercase;letter-spacing:1px;margin-bottom:3px;">City</div>
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:16px;font-weight:700;color:#ffffff;"><?= $singleCity['city_name']??'' ?></div>
                      </td>
                    </tr>
                    <tr>
                      <td style="border-top:1px solid rgba(255,255,255,0.07);padding-top:12px;">
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;color:#7a9cc4;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px;">Status</div>
                        <div style="display:inline-block;background:#1e3a1a;border:1px solid #2e5a2a;color:#4caf50;font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;padding:5px 14px;letter-spacing:1px;">&#9679; Category Reservation Open</div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
              
              <tr>
                <td style="padding:0;">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-top:1px solid rgba(255,255,255,0.07);margin-top:16px;">
                    <tr>
                      <td align="center" style="padding:12px 4px;border-right:1px solid rgba(255,255,255,0.07);">
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#d7af59;line-height:1;">8</div>
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:8px;color:#ffffff;text-transform:uppercase;letter-spacing:0.8px;margin-top:4px;">Teams/City</div>
                      </td>
                      <td align="center" style="padding:12px 4px;border-right:1px solid rgba(255,255,255,0.07);">
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#d7af59;line-height:1;">1</div>
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:8px;color:#ffffff;text-transform:uppercase;letter-spacing:0.8px;margin-top:4px;">Per Sector</div>
                      </td>
                      <td align="center" style="padding:12px 4px;border-right:1px solid rgba(255,255,255,0.07);">
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#d7af59;line-height:1;">18</div>
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:8px;color:#ffffff;text-transform:uppercase;letter-spacing:0.8px;margin-top:4px;">Matches</div>
                      </td>
                      <td align="center" style="padding:12px 4px;">
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#d7af59;line-height:1;">Top 2</div>
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:8px;color:#ffffff;text-transform:uppercase;letter-spacing:0.8px;margin-top:4px;">Qualify</div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table> -->

      
      <!-- <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr><td style="height:3px;background:linear-gradient(90deg,#d7af59 0%,#f5e4a0 50%,#d7af59 100%);font-size:0;line-height:0;">&nbsp;</td></tr>
      </table> -->

    <!-- </td>
  </tr> -->







    <!-- ══════════════════════ IPL / WORLD CUP DARK BLOCK ══════════════════════ -->
  <tr>
    <td style="padding:20px 28px;">

      <table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#021224;border-collapse:collapse;">
        <tr>
          <td style="padding:40px 30px 30px 30px;vertical-align:top;">

            <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr>
                <!-- LEFT COLUMN -->
                <td width="55%" style="vertical-align:top;padding-right:20px;">

                  <!-- Badge -->
                  <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td bgcolor="#DDA126" style="background-color:#DDA126;padding:4px 12px;border-radius:20px;font-family:'Montserrat',Arial,sans-serif;font-size:9px;font-weight:bold;color:#021224;text-transform:uppercase;letter-spacing:0.5px;">
                        #CORPORATEWORLDCUP 2026-27 * INVITATION ONLY
                      </td>
                    </tr>
                  </table>

                  <!-- Heading -->
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-top:25px;">
                    <tr>
                      <td style="font-family:'Montserrat',Arial,sans-serif;font-size:28px;font-weight:700;line-height:36px;color:#FFFFFF;letter-spacing:-0.5px;">
                        India has IPL Now<br>
                        Corporate India gets<br>
                        its own <span style="color:#E2A727;">World Cup.</span>
                      </td>
                    </tr>
                  </table>

                  <!-- 4 Badge Cards -->
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-top:28px;margin-bottom:24px;">
                    <tr>
                      <td width="22%" bgcolor="#FFFFFF" style="background-color:#FFFFFF;border-radius:6px;padding:14px 6px;text-align:center;vertical-align:middle;">
                        <span style="font-size:11px;font-weight:bold;color:#333333;display:block;margin-bottom:4px;">Out of</span>
                        <span style="font-size:24px;font-weight:800;color:#DDA126;display:block;margin-bottom:6px;line-height:1;">500+</span>
                        <span style="font-size:10px;font-weight:bold;color:#000000;display:block;line-height:13px;text-transform:uppercase;">Corporate<br>Teams</span>
                      </td>
                      <td width="2%" style="width:8px;"></td>
                      <td width="22%" bgcolor="#FFFFFF" style="background-color:#FFFFFF;border-radius:6px;padding:8px 6px;text-align:center;vertical-align:middle;">
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:64px;">
                          <tr>
                            <td align="center" valign="middle" style="height:64px;padding-bottom:4px;">
                              <img src="<?= $LogoUrl??''?>" style="height:auto;width:100%;max-width:108px;max-height:64px;object-fit:contain;display:block;margin:0 auto;" alt="<?= $profile['team_name']??'' ?>">
                            </td>
                          </tr>
                        </table>
                        <span style="font-size:9px;font-weight:bold;color:#000000;display:block;letter-spacing:-0.1px;text-transform:uppercase;margin-bottom:6px;line-height:11px;word-break:break-word;"><?= $profile['team_name']??'' ?></span>
                        <span style="font-size:10px;font-weight:bold;color:#000000;display:block;line-height:13px;text-transform:uppercase;">Selected<br>Team</span>
                      </td>
                      <td width="2%" style="width:8px;"></td>
                      <td width="22%" bgcolor="#FFFFFF" style="background-color:#FFFFFF;border-radius:6px;padding:14px 6px;text-align:center;vertical-align:middle;">
                        <span style="font-size:11px;font-weight:bold;color:#DDA126;display:block;line-height:14px;margin-bottom:10px;"><?= $singleSector['sector_name']??'' ?></span>
                        <span style="font-size:10px;font-weight:bold;color:#000000;display:block;line-height:13px;text-transform:uppercase;">Category<br>Opportunity</span>
                      </td>
                      <td width="2%" style="width:8px;"></td>
                      <td width="22%" bgcolor="#FFFFFF" style="background-color:#FFFFFF;border-radius:6px;padding:14px 6px;text-align:center;vertical-align:middle;">
                        <span style="font-size:11px;font-weight:bold;color:#333333;display:block;margin-bottom:4px;"><?= $singleCity['city_name']??'' ?></span>
                        <span style="font-size:21px;font-weight:800;color:#DDA126;display:block;margin-bottom:6px;letter-spacing:-0.5px;line-height:1;">INVITE</span>
                        <span style="font-size:10px;font-weight:bold;color:#000000;display:block;line-height:13px;text-transform:uppercase;">Before Public<br>Opening</span>
                      </td>
                    </tr>
                  </table>

                  <!-- Website -->
                  <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                      <td style="font-family:Arial,sans-serif;font-size:14px;color:#FFFFFF;">
                        <a href="https://corporateworldcup.com" target="_blank" style="color:#FFFFFF;text-decoration:none;">corporateworldcup.com</a>
                      </td>
                    </tr>
                  </table>

                </td>

                <!-- RIGHT COLUMN -->
                <td width="45%" style="vertical-align:top;">

                  <!-- Label -->
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-bottom:12px;">
                    <tr>
                      <td align="right" style="font-family:'Montserrat',Arial,sans-serif;font-size:12px;font-weight:bold;color:#FFFFFF;">
                        City Qualification Stage
                      </td>
                    </tr>
                  </table>

                  <!-- White Card -->
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF" style="background-color:#FFFFFF;border-radius:8px;overflow:hidden;">
                    <tr>
                      <td style="padding:20px 15px 15px 15px;">

                        <!-- Logo -->
                        <table border="0" cellpadding="0" cellspacing="0" width="100%" style="margin-bottom:10px;">
                          <tr>
                            <td align="left">
                               <img src="<?= $LogoUrl??''?>" style="height:auto;width:auto;max-width:140px;max-height:48px;object-fit:contain;display:block;" alt="<?= $profile['team_name']??'' ?>">
                            </td>
                          </tr>
                        </table>

                        <!-- Trophy SVG -->
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                          <tr>
                            <td align="center" style="padding-top:5px;padding-bottom:5px;">
                                <img src="https://wplspeedqueen.com/email_api/cwctrophy.png" style="height:240px;object-fit:cover;display:block;max-width:100%;" alt="Corporate World Cup Trophy">
                            </td>
                          </tr>
                        </table>

                      </td>
                    </tr>
                  </table>

                </td>
              </tr>
            </table>

          </td>
        </tr>
      </table>

    </td>
  </tr>
  <!-- ══ END IPL/WORLD CUP BLOCK ══ -->
  <!-- ══ END HEADER ══ -->


  <!-- ══════════════════════ INTRO TEXT ══════════════════════ -->

  <tr>
    <td style="padding:32px 28px 0;">
      <p style="margin:0 0 14px;font-family:Georgia,'Times New Roman',serif;font-size:20px;font-weight:700;color:#04122b;line-height:1.3;">
        Dear Team <?= $profile['team_name']??'' ?>,
      </p>
      <p style="margin:0 0 16px;font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.9;color:#2c3e5a;">
        <!-- This isn't just an invitation — this is your official entry into  -->
        This is more than an invitation—it is your official opportunity to be part of India's most exclusive corporate sporting platform <strong>#CorporateKaWorldCup</strong>.
      </p>
      <p style="margin:0 0 20px;font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.9;color:#2c3e5a;">
        <!-- As part of the Corporate World Cup™ structure, <strong>only one corporate team per sector is permitted in each city</strong>, ensuring exclusive category representation throughout the qualification journey and beyond. -->
         As part of the Corporate World Cup™ 2026–27, <?= $profile['team_name']??'' ?> has been identified as a leading organization within its category and is being invited to participate in the City Qualification Stage. 
      </p>
      <p style="margin:0 0 20px;font-family:Arial,Helvetica,sans-serif;font-size:14px;line-height:1.9;color:#2c3e5a;">
        <!-- The Corporate World Cup™ is not an open-entry tournament. Only selected corporate organisations with the vision for team sport, brand visibility, and employee engagement are extended this exclusive invitation. -->
         The participation in the Corporate World Cup™ is reserved for carefully selected organizations that recognize the power of sport in building culture, strengthening teams, and enhancing their employer brand. 
      </p>
    </td>
  </tr>
  <!-- ══ END INTRO ══ -->



  <!-- ══════════════════════ CWC TROPHY IMAGE ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td align="center">
            <img src="https://wplspeedqueen.com/email_api/firechat.png" style="height:auto;object-fit:cover;display:block;max-width:100%;" alt="Corporate World Cup Trophy">
          </td>
        </tr>
        <tr>
          <td align="center" style="padding-top:16px;">
            <p style="margin:0;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.9;color:#2c3e5a;text-align:center;max-width:560px;">
              Only one corporate team per sector is permitted in each city, ensuring exclusive category representation throughout the journey to the Corporate World Cup National Finals.
            </p>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END TROPHY ══ -->


  


   <!-- ══════════════════════ FOUNDING TEAM BENEFITS ══════════════════════ -->
  <tr>
    <td style="padding:32px 28px 0;">

      <div style="font-family:Georgia,'Times New Roman',serif;font-size:30px;font-weight:700;color:#04122b;text-align:center;margin-bottom:10px;">
        Your Founding Team Benefits
      </div>
      <p style="margin:0 0 24px;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.7;color:#64748b;text-align:center;">
        Eleven premium advantages reserved for selected existing PCL teams entering the Corporate World Cup&trade; qualification journey.
      </p>

      <!-- Row 1: 6 cards -->
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:10px;">
        <tr>
          <?php
          $foundingBenefitsRow1 = [
            ['icon'=>'&#127942;','title'=>'Founding<br>Team','sub'=>'Legacy<br>recognition'],
            ['icon'=>'&#128274;','title'=>'Category<br>Exclusivity','sub'=>'No<br>competitor'],
            ['icon'=>'&#127760;','title'=>'CWC<br>Qualification','sub'=>'Top 2<br>pathway'],
            ['icon'=>'&#127970;','title'=>'Trophy At<br>Office','sub'=>'Premium<br>activation'],
            ['icon'=>'&#127909;','title'=>'PR<br>Episode','sub'=>'Media<br>story'],
            ['icon'=>'&#127908;','title'=>'Firechat','sub'=>'25 July<br>2026'],
          ];
          foreach ($foundingBenefitsRow1 as $b):
          ?>
          <td width="16.66%" valign="top" style="padding:0 4px;">
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#f8fafd;border:1px solid #e2e8f0;border-radius:8px;">
              <tr>
                <td align="center" style="padding:16px 6px;">
                  <div style="font-size:22px;margin-bottom:8px;line-height:1;"><?= $b['icon'] ?></div>
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;color:#04122b;line-height:1.3;margin-bottom:6px;"><?= $b['title'] ?></div>
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#7a9cc4;line-height:1.3;"><?= $b['sub'] ?></div>
                </td>
              </tr>
            </table>
          </td>
          <?php endforeach; ?>
        </tr>
      </table>

      <!-- Row 2: 5 cards -->
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:20px;">
        <tr>
          <?php
          $foundingBenefitsRow2 = [
            ['icon'=>'&#127952;','title'=>'Test<br>Twenty&trade;','sub'=>'Legacy<br>format'],
            ['icon'=>'&#128100;','title'=>'30<br>Ambassadors','sub'=>'Employees<br>carry brand'],
            ['icon'=>'&#128640;','title'=>'LinkedIn<br>Visibility','sub'=>'12<br>months'],
            ['icon'=>'&#11088;','title'=>'VIP<br>Access','sub'=>'Events &amp;<br>passes'],
            ['icon'=>'&#127916;','title'=>'Closing<br>Stage','sub'=>'Legends<br>ceremony'],
          ];
          foreach ($foundingBenefitsRow2 as $b):
          ?>
          <td width="20%" valign="top" style="padding:0 4px;">
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#f8fafd;border:1px solid #e2e8f0;border-radius:8px;">
              <tr>
                <td align="center" style="padding:16px 6px;">
                  <div style="font-size:22px;margin-bottom:8px;line-height:1;"><?= $b['icon'] ?></div>
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;color:#04122b;line-height:1.3;margin-bottom:6px;"><?= $b['title'] ?></div>
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#7a9cc4;line-height:1.3;"><?= $b['sub'] ?></div>
                </td>
              </tr>
            </table>
          </td>
          <?php endforeach; ?>
        </tr>
      </table>

      <!-- Recognition strip -->
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td style="background-color:#0b2c6b;border-radius:40px;padding:18px 28px;">
            <p style="margin:0;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.6;color:#ffffff;text-align:center;">
              This is not a public registration. <strong style="color:#d7af59;">This is recognition.</strong> Your team has been invited because it has already earned credibility inside the PCL ecosystem.
            </p>
          </td>
        </tr>
      </table>

    </td>
  </tr>
  <!-- ══ END FOUNDING TEAM BENEFITS ══ -->

  <!-- ══════════════════════ CORPORATE VISIBILITY BENEFITS ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
            style="border:2px solid #dde3ee;border-radius:0;overflow:hidden;background-color:#f8fafd;">
        <tr><td height="6" style="background:linear-gradient(90deg,#0b2c6b 0%,#1d56d9 100%);line-height:6px;font-size:6px;">&nbsp;</td></tr>
        <tr>
          <td style="padding:28px 28px 28px;">

            <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;color:#1d56d9;letter-spacing:2px;text-transform:uppercase;margin-bottom:12px;">Corporate Visibility Benefits</div>
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:26px;font-weight:700;color:#04122b;line-height:1.2;margin-bottom:20px;">
              <?= $profile['team_name']??'' ?>'s Brand — In Front Of A Global Audience For 12 Months.
            </div>

            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:12px;">
              <tr>
                <td width="25%" valign="top" style="padding-right:8px;">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ffffff;border:1.5px solid #dde3ee;">
                    <tr><td style="padding:18px 16px;">
                      <div style="font-size:22px;margin-bottom:10px;">&#128250;</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;color:#04122b;margin-bottom:6px;">Live Match Visibility</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;line-height:1.6;">Stadium, scoreboard &amp; jersey branding across all 18 matches.</div>
                    </td></tr>
                  </table>
                </td>
                <td width="25%" valign="top" style="padding-right:8px;">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ffffff;border:1.5px solid #dde3ee;">
                    <tr><td style="padding:18px 16px;">
                      <div style="font-size:22px;margin-bottom:10px;">&#128247;</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;color:#04122b;margin-bottom:6px;">Social &amp; Highlights</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;line-height:1.6;">Social media exposure, highlight packages &amp; team features.</div>
                    </td></tr>
                  </table>
                </td>
                <td width="25%" valign="top" style="padding-right:8px;">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ffffff;border:1.5px solid #dde3ee;">
                    <tr><td style="padding:18px 16px;">
                      <div style="font-size:22px;margin-bottom:10px;">&#128240;</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;color:#04122b;margin-bottom:6px;">Media Release &amp; PR</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;line-height:1.6;">Digital &amp; print publicity. Interviews &amp; team presentations.</div>
                    </td></tr>
                  </table>
                </td>
                <td width="25%" valign="top">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ffffff;border:1.5px solid #dde3ee;">
                    <tr><td style="padding:18px 16px;">
                      <div style="font-size:22px;margin-bottom:10px;">&#128313;</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;color:#04122b;margin-bottom:6px;">AI-Powered Rankings</div>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;line-height:1.6;">AI team &amp; player rankings across the entire CWC™ ecosystem.</div>
                    </td></tr>
                  </table>
                </td>
              </tr>
            </table>

            <!-- Sony LIV highlight -->
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td style="background:#04122b;padding:18px 22px;">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                      <td valign="middle">
                        <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:4px;">Top 2 City Teams Qualify For</div>
                        <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#ffffff;">Corporate World Cup National Finals</div>
                      </td>
                      <td align="right" valign="middle">
                        <div style="display:inline-block;background:#d7af59;color:#04122b;font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;padding:8px 18px;letter-spacing:1px;">&#128250; LIVE ON SONY LIV OTT</div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>

          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END VISIBILITY ══ -->


  <!-- ══════════════════════ MERCHANDISE DETAILS ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
             style="border:1px solid #dde3ee;background-color:#f8fafd;border-radius:0;overflow:hidden;">

        <tr><td height="6" style="background:#0d2a5e;line-height:6px;font-size:6px;">&nbsp;</td></tr>

        <tr>
          <td style="padding:32px 28px 32px;">

            <div style="font-family:Georgia,'Times New Roman',serif;font-size:26px;font-weight:700;color:#04122b;margin-bottom:24px;">
              Premium Team Merchandise <span style="font-size:15px;font-weight:400;color:#64748b;font-family:Arial,Helvetica,sans-serif;">(30 Players)</span>
            </div>

            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td width="33%" valign="top" style="padding-right:16px;">
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:14px;">&#9670; Kit Items</div>
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128247; 30 White Match Jerseys</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128247; 30 Colored Match Jerseys</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128084; 30 White Track Pants</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128084; 30 Colored Track Pants</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;">&#129691; 30 Practice Shorts</td></tr>
                  </table>
                </td>
                <td width="33%" valign="top" style="padding-right:16px;">
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:14px;">&#9670; Accessories</div>
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#129399; 30 Premium Team Jackets</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#129510; 60 Customized Team Caps</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#127869; 30 Premium Kit Bags</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;">&#127869; 30 Shoulder / Pithu Bags</td></tr>
                  </table>
                </td>
                <td width="34%" valign="top">
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:14px;">&#9670; Customization</div>
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#127970; Company Logo Branding</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#127942; Team Name Branding</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128100; Player Name Printing</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;border-bottom:1px solid #eef0f4;">&#128290; Player Number Printing</td></tr>
                    <tr><td style="padding:5px 0;font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#2c3e5a;line-height:1.5;">&#128204; Optional Sponsor Branding</td></tr>
                  </table>
                </td>
              </tr>
            </table>

          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END MERCHANDISE ══ -->



  <!-- ══════════════════════ MERCHANDISE IMAGE ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td align="center">
            <img src="https://wplspeedqueen.com/email_api/cwcmerchandise.jpeg" style="width:100%;max-width:100%;height:auto;display:block;" alt="CWC Merchandise">
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END MERCHANDISE IMAGE ══ -->




   <!-- ══════════════════════ REGISTRATION & PAYMENT ══════════════════════ -->
  <tr>
    <td style="padding:28px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
             style="border:1px solid #dde3ee;background-color:#f8fafd;">
        <tr><td height="6" style="background:#0d2a5e;line-height:6px;font-size:6px;">&nbsp;</td></tr>
        <tr>
          <td style="padding:28px 28px 24px;">
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:22px;font-weight:700;color:#04122b;margin-bottom:12px;">
              Registration &amp; Payment Terms
            </div>
            <p style="margin:0 0 14px;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.8;color:#2c3e5a;">
              Please share your <strong>GST details</strong> and <strong>company logo</strong> for the Proforma Invoice generation.
            </p>
            <p style="margin:0 0 24px;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.8;color:#2c3e5a;">
              Upon receipt of the advance payment, <strong><?= $profile['team_name']??'' ?></strong> will secure one of only eight available Corporate World Cup™ team slots in <?= $singleCity['city_name']??'' ?>. The slot will be reserved exclusively for <?= $profile['team_name']??'' ?>, subject to completion of registration formalities.
            </p>

            <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">
              <tr>
                <td align="center" style="padding:4px;">
                  <a href="mailto:info@corporateworldcup.com?subject=CWC Slot Confirmation - <?= $profile['team_name']??'' ?> <?= $singleCity['city_name']??'' ?>"
                    style="display:inline-block;background-color:white;color:#d7af59;text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;padding:11px 20px;border:1px solid #d7af59;letter-spacing:0.5px;white-space:nowrap;">
                    Confirm My Slot
                  </a>
                </td>
                <td align="center" style="padding:4px;">
                  <a href="https://wa.me/919999999999"
                    style="display:inline-block;background-color:white;color:#d7af59;text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;padding:11px 20px;border:1px solid #d7af59;letter-spacing:0.5px;white-space:nowrap;">
                    Talk To CWC Team
                  </a>
                </td>
                <td align="center" style="padding:4px;">
                  <a href="mailto:info@corporateworldcup.com?subject=Need More Time - <?= $profile['team_name']??'' ?>"
                    style="display:inline-block;background-color:white;color:#d7af59;text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:700;padding:11px 20px;border:1px solid #cbd5e1;letter-spacing:0.5px;white-space:nowrap;">
                    Need More Time
                  </a>
                </td>
              </tr>
            </table>

            <p style="margin:16px 0 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#7a5500;font-weight:700;text-align:center;">
              With only 8 corporate teams per city &amp; 1 team per sector — your slot is time-sensitive.
            </p>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END REGISTRATION ══ -->


  


  <!-- ══════════════════════ MEGA LAUNCH CEREMONY ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"
             style="border:1px solid #d7af59;background-color:#fdfaf0;">
        <tr><td style="height:4px;background-color:#d7af59;font-size:0;line-height:0;">&nbsp;</td></tr>
        <tr>
          <td style="padding:28px 28px;">

            <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#7a5500;text-transform:uppercase;letter-spacing:1.5px;margin-bottom:10px;">&#9670; Mark Your Calendar</div>
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:28px;font-weight:700;color:#04122b;margin-bottom:8px;line-height:1.2;">Mega Launch Ceremony</div>
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:32px;font-weight:700;color:#d7af59;letter-spacing:1px;margin-bottom:18px;">25 JULY 2026</div>

            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td width="60%" valign="top" style="padding-right:20px;">
                  <p style="margin:0 0 12px;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.8;color:#2c3e5a;">
                    As part of the Corporate World Cup™ Mega Launch Ceremony, the organizers will provide a <strong>complimentary stay for the Team Captain</strong>.
                  </p>
                  <p style="margin:0;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.8;color:#2c3e5a;">
                    Join us for this exclusive launch event, where we'll bring together corporate teams, business leaders, media partners, and special guests as the Corporate World Cup™ journey officially begins.
                  </p>
                </td>
                <td width="40%" valign="top">
                  <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#04122b;padding:16px 20px;">
                    <tr><td>
                      <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;font-weight:700;color:#d7af59;letter-spacing:2px;text-transform:uppercase;margin-bottom:10px;">What to Expect</div>
                      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr><td style="padding:3px 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;line-height:1.5;">&#9656; Corporate Team Introductions</td></tr>
                        <tr><td style="padding:3px 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;line-height:1.5;">&#9656; Business Leader Networking</td></tr>
                        <tr><td style="padding:3px 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;line-height:1.5;">&#9656; Media Partner Presentations</td></tr>
                        <tr><td style="padding:3px 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;line-height:1.5;">&#9656; Complimentary Captain Stay</td></tr>
                        <tr><td style="padding:3px 0;font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;line-height:1.5;">&#9656; Official CWC™ Kickoff</td></tr>
                      </table>
                    </td></tr>
                  </table>
                </td>
              </tr>
            </table>

          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END LAUNCH CEREMONY ══ -->





 

  <!-- ══════════════════════════════════════════PCL STATS BANNER══════════════════════════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#113B93;">
        <tr>
          <td style="padding:20px 10px;">
            <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <?php
                $pclGlobalStats = [
                  ['val'=>number_format((int)$statsArrayData['total_matches_played']),'lbl'=>'Matches'],
                  ['val'=>number_format((int)$statsArrayData['total_runs_Scored']),'lbl'=>'Runs'],
                  ['val'=>number_format((int)$statsArrayData['total_wickets_Claimed']),'lbl'=>'Wickets'],
                  ['val'=>number_format((int)$statsArrayData['total_hundreds']),'lbl'=>'Hundreds'],
                  ['val'=>number_format((int)$statsArrayData['total_fifties']),'lbl'=>'Fifties'],
                ];
                $lastIdx = count($pclGlobalStats) - 1;
                foreach ($pclGlobalStats as $idx => $gs):
                ?>
                <td align="center" width="20%" style="padding:6px 4px;<?= $idx < $lastIdx ? 'border-right:1px solid rgba(255,255,255,0.1);' : '' ?>">
                  <div style="font-family:Georgia,'Times New Roman',serif;font-size:20px;font-weight:700;color:#d7af59;line-height:1.1;"><?= $gs['val'] ?></div>
                  <div style="font-family:Arial,Helvetica,sans-serif;font-size:9px;color:#fff;text-transform:uppercase;letter-spacing:1px;margin-top:5px;"><?= $gs['lbl'] ?></div>
                </td>
                <?php endforeach; ?>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END STATS BANNER ══ -->

  <!-- ══════════════════════════════════════════CHAMPIONS SECTION══════════════════════════════════════════ -->
  <tr>
    <td style="padding:28px 28px 0;">
      <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#04122b;margin-bottom:4px;border-bottom:2px solid #d7af59;padding-bottom:10px;">Chris Gayle #TheUniverseBoss &times; PCL</div>
      <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#64748b;text-transform:uppercase;letter-spacing:1px;margin-bottom:16px;margin-top:4px;">Year 2026 Corporate Champions</div>
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <?php
          $champions = [
            ['img'=>'jr_image_1.jpeg','name'=>'HCL Tech','cat'=>'IT &amp; Services (Platinum)'],
            ['img'=>'jr_image_2.jpeg','name'=>'Siemens','cat'=>'IT &amp; Services (Diamond)'],
            ['img'=>'jr_image_3.jpeg','name'=>'Sopra Banking','cat'=>'IT &amp; Services (Platinum)'],
            ['img'=>'jr_image_4.jpeg','name'=>'KEI Wires &amp; Cables','cat'=>'Corporate'],
          ];
          foreach ($champions as $c):
          ?>
          <td width="25%" align="center" style="padding:0 5px;">
            <div style="border:1px solid #e2e8f0;overflow:hidden;margin-bottom:8px;">
              <img src="<?= $filePath . $c['img'] . '?v=' . $imgVersion ?>" width="138" height="104" style="display:block;width:100%;object-fit:cover;border:0;" alt="<?= $c['name'] ?>">
            </div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;color:#04122b;line-height:1.4;"><?= $c['name'] ?></div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;margin-top:2px;"><?= $c['cat'] ?></div>
          </td>
          <?php endforeach; ?>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td style="padding:24px 28px 0;">
      <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#04122b;margin-bottom:4px;border-bottom:2px solid #0d2a5e;padding-bottom:10px;">Year 2026 Corporate Challengers</div>
      <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#64748b;text-transform:uppercase;letter-spacing:1px;margin-bottom:16px;margin-top:4px;">Competing for the Crown</div>
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <?php
          $challengers = [
            ['img'=>'jr_image_5.jpeg','name'=>'COFORGE Gurugram','cat'=>'IT &amp; Services (Platinum)'],
            ['img'=>'jr_image_6.jpeg','name'=>'COFORGE Noida','cat'=>'IT &amp; Services (Diamond)'],
            ['img'=>'jr_image_7.jpeg','name'=>'IFFCO','cat'=>'IT &amp; Services (Platinum)'],
            ['img'=>'jr_image_8.jpeg','name'=>'SPARK MINDA','cat'=>'Corporate'],
          ];
          foreach ($challengers as $c):
          ?>
          <td width="25%" align="center" style="padding:0 5px;">
            <div style="border:1px solid #e2e8f0;overflow:hidden;margin-bottom:8px;">
              <img src="<?= $filePath . $c['img'] . '?v=' . $imgVersion ?>" width="138" height="104" style="display:block;width:100%;object-fit:cover;border:0;" alt="<?= $c['name'] ?>">
            </div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;color:#04122b;line-height:1.4;"><?= $c['name'] ?></div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;margin-top:2px;"><?= $c['cat'] ?></div>
          </td>
          <?php endforeach; ?>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td style="padding:24px 28px 0;">
      <div style="font-family:Georgia,'Times New Roman',serif;font-size:17px;font-weight:700;color:#04122b;margin-bottom:4px;border-bottom:2px solid #d7af59;padding-bottom:10px;">Jonty Rhodes &times; PCL 2025</div>
      <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#64748b;text-transform:uppercase;letter-spacing:1px;margin-bottom:16px;margin-top:4px;">Champions &amp; Awards Ceremony</div>
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <?php
          $jonty = [
            ['img'=>'jr_image_9.jpeg','name'=>'TCS','cat'=>'Tata Consultancy Services'],
            ['img'=>'jr_image_10.jpeg','name'=>'Teleperformance','cat'=>'Corporate Champion'],
            ['img'=>'jr_image_11.jpeg','name'=>'Optum Noida','cat'=>'Healthcare Leader'],
            ['img'=>'jr_image_12.jpeg','name'=>'Team Avengers','cat'=>'Corporate Champion'],
          ];
          foreach ($jonty as $c):
          ?>
          <td width="25%" align="center" style="padding:0 5px;">
            <div style="border:1px solid #e2e8f0;overflow:hidden;margin-bottom:8px;">
              <img src="<?= $filePath . $c['img'] . '?v=' . $imgVersion ?>" width="138" height="104" style="display:block;width:100%;object-fit:cover;border:0;" alt="<?= $c['name'] ?>">
            </div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;font-weight:700;color:#04122b;line-height:1.4;"><?= $c['name'] ?></div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#64748b;margin-top:2px;"><?= $c['cat'] ?></div>
          </td>
          <?php endforeach; ?>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END CHAMPIONS ══ -->


  


  <!-- ══════════════════════ MAIN CTA ══════════════════════ -->
  <tr>
    <td style="padding:24px 28px 0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-bottom:16px;">
        <tr>
          <td align="center" style="padding:4px 0;">
            <a href="https://corporateworldcup.com"
              style="display:inline-block;background-color:#d7af59;color:#04122b;text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:14px;font-weight:700;padding:15px 40px;letter-spacing:0.5px;">
              Secure  Slot &rarr;
            </a>
          </td>
        </tr>
        <tr>
          <td align="center" style="font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#7a5500;font-weight:700;padding-top:8px;letter-spacing:0.3px;">
            Only 8 slots per city &bull; 1 per sector &bull; First-come, first-serve
          </td>
        </tr>
      </table>

      <!-- WhatsApp -->
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#f0fdf4;border:1px solid #bbf7d0;margin-bottom:0;">
        <tr>
          <td align="center" style="padding:20px;">
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:15px;color:#14532d;font-weight:700;margin-bottom:12px;">Need help with next steps?</div>
            <a href="https://wa.me/919999999999"
              style="display:inline-block;background-color:#16a34a;color:#ffffff;text-decoration:none;font-family:Arial,Helvetica,sans-serif;font-size:13px;font-weight:700;padding:12px 28px;letter-spacing:0.3px;">
              Talk to CWC Support on WhatsApp
            </a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END MAIN CTA ══ -->




  <!-- ══════════════════════ FOOTER ══════════════════════ -->
  <tr>
    <td style="padding:0;">
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:28px;">
        <tr><td style="height:3px;background-color:#d7af59;font-size:0;line-height:0;">&nbsp;</td></tr>
      </table>
      <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#0b2c6b;">
        <tr>
          <td align="center" style="padding:28px 24px;">
            <img src="https://www.procorporateleague.com/2026/pcl/Imp_PCL_Logo_Black.png" alt="PCL" style="width:60px;height:auto;max-width:60px;display:block;margin:0 auto 14px;border:0;">
            <div style="font-family:Georgia,'Times New Roman',serif;font-size:16px;font-weight:700;color:#d7af59;margin-bottom:6px;">Pro Corporate League</div>
            <div style="font-family:Arial,Helvetica,sans-serif;font-size:11px;color:#ffffff;text-transform:uppercase;letter-spacing:1.5px;margin-bottom:16px;">Corporate World Cup™ · <?= $singleCity['city_name']??'' ?> Edition 2026</div>
            <img src="https://wplspeedqueen.com/email_api/qrPCL.jpeg" alt="Scan QR Code" width="72" height="72" style="display:block;margin:0 auto 16px;border:2px solid #d7af59;">
            <a href="https://corporateworldcup.com" style="font-family:Arial,Helvetica,sans-serif;font-size:12px;color:#d7af59;text-decoration:none;font-weight:700;letter-spacing:0.5px;">corporateworldcup.com</a>
            <div style="margin-top:20px;padding-top:16px;border-top:1px solid rgba(255,255,255,0.07);font-family:Arial,Helvetica,sans-serif;font-size:10px;color:#ffffff;line-height:1.6;">
              &copy; 2026 Pro Corporate League. All rights reserved.<br>
              This communication is an official Corporate World Cup™ invitation for <?= $profile['team_name']??'' ?>.<br>
              Pro Corporate League &bull; India's Largest Corporate Cricket Ecosystem
            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <!-- ══ END FOOTER ══ -->

</table>

</td>
</tr>
</table>

</body>
</html>
<?php
$emailBody = ob_get_clean();

/* ===============================
   SEND EMAIL
================================ */
$mail = new PHPMailer(true);

$ccList = $requestData['cc'] ?? [];

//$email = $_GET['email'] ?? $_POST['to_email'] ?? $requestData['email'] ?? '';
//$toName = $_GET['to_name'] ?? $_POST['to_name'] ?? $requestData['to_name'] ?? '';

//$email = $_GET['email'] ?? $_POST['to_email'] ?? $requestData['email'] ?? '';  // ← DELETE

$toName = $profile['team_name']??'';


try {
    $mail->isSMTP();
    $mail->Host       = $smtpRow['smtp_host'];
    $mail->SMTPAuth   = true;
    $mail->Username   = $smtpRow['smtp_username'];
    $mail->Password   = $smtpRow['smtp_password'];
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port       = 587;

    $mail->CharSet  = 'UTF-8';
    $mail->Encoding = 'base64';

    $mail->setFrom('sachin.gupta@procorporateleague.com', 'Pro Corporate League');

    $mail->addAddress($email, htmlspecialchars($toName));
    //$mail->addAddress('mohammad.mozammil@procorporateleague.com', 'Mozammil');
    
    if (!empty($ccList) && is_array($ccList))
    {
        foreach ($ccList as $cc)
        {
            $ccEmail = trim($cc['email'] ?? '');
            $ccName  = trim($cc['name']  ?? '');

            if (!empty($ccEmail))
            {
                $mail->addCC($ccEmail, $ccName);
            }
        }
    }
    else{
      $mail->addCC('sachin.gupta@procorporateleague.com', 'Sachin Gupta');
      $mail->addCC('rifat.saleem@procorporateleague.com', 'Rifat Saleem');
    }

    $mail->isHTML(true);
    $mail->Subject = !empty($requestData['subject']) ? $requestData['subject'] : 'Existing Team ';
    $mail->Body    = $emailBody;

    $mail->send();

    echo json_encode([
        "status_code" => 200,
        "status"      => "success",
        "message"     => "Email sent successfully"
    ]);

} 
// catch (Exception $e) {
//     echo json_encode([
//         "status_code" => 500,
//         "status"      => "error",
//         "message"     => $mail->ErrorInfo
//     ]);
// }

catch (Exception $e) {
    echo json_encode([
        "status_code" => 500,
        "status"      => "error",
        "message"     => $mail->ErrorInfo,
        "debug"       => [
            "email"   => $email,
            "toName"  => $toName,
            "teamId"  => $teamId,
            "smtp_host" => $smtpRow['smtp_host'],
            "smtp_user" => $smtpRow['smtp_username'],
        ]
    ]);
}
?>