<div class="main-panel">
	<div class="content-wrapper">
		<div class="row">
			<div class="col-md-3 grid-margin stretch-card">
				<div class="card">
					<div class="card-body">
					<h4 class="card-title">Company Name</h4>
						<div class="media">
							<i class="typcn typcn-globe icon-md text-info d-flex align-self-start me-3"></i>
							<div class="media-body">
							<p class="card-text"><?php echo $company_list[0]['company_name'];?></p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-3 grid-margin stretch-card">
				<div class="card">
					<div class="card-body">
						<h4 class="card-title">Contact Person</h4>
						<div class="media">
							<i class="typcn typcn-user icon-md text-info d-flex align-self-center me-3"></i>
							<div class="media-body">
								<p class="card-text"><?php echo $company_list[0]['contact_person'];?></p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-3 grid-margin stretch-card">
				<div class="card">
					<div class="card-body">
						<h4 class="card-title">Contact Email</h4>
						<div class="media">
							<i class="typcn typcn-mail icon-md text-info d-flex align-self-end me-3"></i>
							<div class="media-body">
								<p class="card-text"> <?php echo $company_list[0]['contact_email'];?></p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-md-3 grid-margin stretch-card">
				<div class="card">
					<div class="card-body">
						<h4 class="card-title">Contact Details</h4>
						<div class="media">
							<i class="typcn typcn-phone icon-md text-info d-flex align-self-end me-3"></i>
							<div class="media-body">
								<p class="card-text"><?php echo $company_list[0]['country_code'];?> - <?php echo $company_list[0]['phone'];?></p>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php
		$file_map = [];
			foreach ($data['company_files'] as $file) {
				$file_map[$file['type_id']][] = $file;
			}
		?>
		<div class="row">
			<div class="container mt-4">
			  <div class="row">
				<?php foreach ($data['type_list'] as $index => $type): ?>
				<?php
					$hasFiles = !empty($file_map[$type['id']]);
					$cardClass = $hasFiles ? 'bg-success text-white' : 'bg-info text-white';
				  ?>
				  <div class="col-md-3 mb-4">
					<div class="card h-100">
					  <div class="card-header <?= $cardClass ?>">
						<strong><?= $type['type_name']; ?></strong>
					  </div>
					  <div class="card-body p-2" style="max-height: 200px; overflow-y: auto;">
						<?php if (!empty($file_map[$type['id']])): ?>
						  <ul class="list-group list-group-flush">
							<?php foreach ($file_map[$type['id']] as $file): ?>
							  <li class="list-group-item small py-1 px-2"><?= $file['file_name']; ?></li>
							<?php endforeach; ?>
						  </ul>
						<?php else: ?>
						  <p class="text-muted small mb-0 text-align-self-center"> No Files Attached </p>
						<?php endif; ?>
					  </div>
					</div>
				  </div>

				  <!-- Open new row after every 4 cards if needed -->
				  <?php if (($index + 1) % 4 == 0): ?>
					</div><div class="row">
				  <?php endif; ?>
				<?php endforeach; ?>
			  </div>
			</div>
		</div>
	</div>
</div>

  <!-- ./wrapper -->
