<?php
if (! defined('ABSPATH')) {
    exit;
} ?>
<footer class="puffergo-default-footer bg-neutral-950 text-neutral-100" style="background-color: var(--pg-neutral-950, rgb(10 10 10)); color: var(--pg-neutral-100, rgb(245 245 245));">
	<div class="mx-auto max-w-canvas px-6 pb-8 pt-16 sm:pt-20 lg:px-8 lg:pt-24">
		<div class="lg:grid lg:grid-cols-12 lg:items-start lg:gap-10">
			<div class="space-y-8 lg:col-span-4">
				<a href="<?php echo esc_url($data->home_url); ?>" class="inline-block" aria-label="<?php echo esc_attr($data->brand_name); ?>" style="color: inherit;">
					<?php if (! puffergo_the_logo('h-9 w-auto object-contain', array('loading' => 'lazy'))) : ?>
						<span class="text-lg font-semibold text-neutral-50"><?php echo esc_html($data->brand_name ? $data->brand_name : __('Logo', 'puffergo')); ?></span>
					<?php endif; ?>
				</a>

				<?php if ($data->site_description) : ?>
					<p class="text-sm/6 text-balance text-neutral-300"><?php echo esc_html($data->site_description); ?></p>
				<?php endif; ?>

				<?php if ($data->contact_email !== '' || $data->contact_phone !== '' || $data->contact_address !== '' || $data->wechat_value !== '') : ?>
					<div class="space-y-1 text-sm/6 text-neutral-300">
						<?php if ($data->contact_email !== '') : ?>
							<p>
								<span class="font-medium text-neutral-100"><?php esc_html_e('Email', 'puffergo'); ?>:</span>
								<a href="<?php echo esc_url('mailto:' . $data->contact_email); ?>" class="ml-1 text-neutral-200 hover:text-neutral-50" style="color: inherit;"><?php echo esc_html($data->contact_email); ?></a>
							</p>
						<?php endif; ?>
						<?php if ($data->contact_phone !== '') : ?>
							<p>
								<span class="font-medium text-neutral-100"><?php esc_html_e('Phone', 'puffergo'); ?>:</span>
								<a href="<?php echo esc_url('tel:' . $data->contact_phone); ?>" class="ml-1 text-neutral-200 hover:text-neutral-50" style="color: inherit;"><?php echo esc_html($data->contact_phone); ?></a>
							</p>
						<?php endif; ?>
						<?php if ($data->wechat_value !== '') : ?>
							<p>
								<span class="font-medium text-neutral-100"><?php esc_html_e('WeChat', 'puffergo'); ?>:</span>
								<span class="ml-1 text-neutral-200"><?php echo esc_html($data->wechat_value); ?></span>
							</p>
						<?php endif; ?>
						<?php if ($data->contact_address !== '') : ?>
							<p class="text-balance">
								<span class="font-medium text-neutral-100"><?php esc_html_e('Address', 'puffergo'); ?>:</span>
								<span class="ml-1 text-neutral-200"><?php echo esc_html($data->contact_address); ?></span>
							</p>
						<?php endif; ?>
					</div>
				<?php endif; ?>

				<?php if (! empty($data->contact_channels)) : ?>
					<div class="flex gap-x-6">
						<?php foreach ($data->contact_channels as $pgo_ch) : ?>
							<?php
$pgo_ch_href = isset($pgo_ch['href']) ? $pgo_ch['href'] : $data->home_url;
						    $pgo_ch_type = isset($pgo_ch['type']) ? $pgo_ch['type'] : '';
						    $pgo_ch_icon = isset($pgo_ch['icon']) ? $pgo_ch['icon'] : 'link';
						    $pgo_ch_label = $pgo_ch_type !== '' ? $pgo_ch_type : __('Link', 'puffergo');
						    $channel_icon_slug = $pgo_ch_icon; ?>
							<a href="<?php echo esc_url($pgo_ch_href); ?>" class="text-neutral-300 hover:text-neutral-50" aria-label="<?php echo esc_attr($pgo_ch_label); ?>" style="color: inherit;">
								<span class="sr-only"><?php echo esc_html($pgo_ch_label); ?></span>
								<?php require PUFFERGO_PLUGIN_DIR . '/templates/components/channel-icon.php'; ?>
							</a>
						<?php endforeach; ?>
					</div>
				<?php endif; ?>
			</div>

			<?php if (! empty($data->sections)) : ?>
				<div class="mt-14 flex flex-row flex-wrap gap-8 lg:col-span-8 lg:mt-0">
					<?php foreach ($data->sections as $pgo_section) : ?>
						<?php
						    $pgo_section_title = isset($pgo_section['title']) ? $pgo_section['title'] : '';
					    $pgo_links = isset($pgo_section['links']) && is_array($pgo_section['links']) ? $pgo_section['links'] : array();

					    if (empty($pgo_links)) {
					        continue;
					    } ?>
						<div class="min-w-[12rem] flex-1">
							<?php if ($pgo_section_title !== '') : ?>
								<h3 class="text-sm/6 font-semibold text-neutral-100"><?php echo esc_html($pgo_section_title); ?></h3>
							<?php endif; ?>
							<ul role="list" class="m-0 mt-5 list-none space-y-3 pl-0">
								<?php foreach ($pgo_links as $pgo_link) : ?>
									<?php
					    $pgo_link_name = isset($pgo_link['name']) ? $pgo_link['name'] : '';
								    $pgo_link_url = isset($pgo_link['url']) ? $pgo_link['url'] : '';

								    if ($pgo_link_url === '' || $pgo_link_name === '') {
								        continue;
								    } ?>
									<li>
										<a href="<?php echo esc_url($pgo_link_url); ?>" class="text-sm/6 text-neutral-300 hover:text-neutral-50" style="color: inherit;"><?php echo esc_html($pgo_link_name); ?></a>
									</li>
								<?php endforeach; ?>
							</ul>
						</div>
					<?php endforeach; ?>
				</div>
			<?php endif; ?>

			<?php require PUFFERGO_PLUGIN_DIR . '/templates/components/footer-empty-menu-notice.php'; ?>
		</div>

		<div class="mt-14 border-t border-neutral-700/70 pt-7 sm:mt-16">
			<p class="text-sm/6 text-neutral-300">
				<?php if ($data->copyright_text !== '') : ?>
					<?php echo wp_kses_post($data->copyright_text); ?>
				<?php else : ?>
					&copy; <?php echo esc_html($data->year); ?> <?php echo esc_html($data->brand_name); ?>. <?php esc_html_e('All rights reserved.', 'puffergo'); ?>
				<?php endif; ?>
			</p>
		</div>
	</div>
</footer>
