<?php
if (! defined('ABSPATH')) {
    exit;
} ?>
<footer class="puffergo-default-footer" style="background-color: var(--pg-neutral-50, rgb(250 250 250)); color: var(--pg-neutral-900, rgb(23 23 23));">
	<div style="max-width: 80rem; margin: 0 auto; padding: 1rem 1.5rem;">
		<div style="display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; justify-content: space-between;">
			<div style="display: inline-flex; align-items: center; gap: 0.75rem; min-width: 10rem;">
				<a href="<?php echo esc_url($data->home_url); ?>" aria-label="<?php echo esc_attr($data->brand_name); ?>" style="display: inline-flex; align-items: center; color: inherit;">
					<?php if (! puffergo_the_logo('h-8 w-auto object-contain', array('loading' => 'lazy'))) : ?>
						<span style="font-size: 0.95rem; font-weight: 700;"><?php echo esc_html($data->brand_name ? $data->brand_name : __('Logo', 'puffergo')); ?></span>
					<?php endif; ?>
				</a>
				
			</div>

			<?php if (! empty($data->sections)) : ?>
				<nav aria-label="<?php esc_attr_e('Footer', 'puffergo'); ?>" style="display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;">
					<?php
$pgo_footer_link_count = 0;

			    foreach ($data->sections as $pgo_section) : $pgo_links = isset($pgo_section['links']) && is_array($pgo_section['links']) ? $pgo_section['links'] : array();

			        if (empty($pgo_links)) {
			            continue;
			        }

foreach ($pgo_links as $pgo_link) : $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;
			            }

if ($pgo_footer_link_count >= 6) {
			                break 2;
			            } ?>
							<a href="<?php echo esc_url($pgo_link_url); ?>" style="font-size: 0.82rem; color: var(--pg-neutral-700, rgb(64 64 64)); text-decoration: none;"><?php echo esc_html($pgo_link_name); ?></a>
							<?php
			            ++$pgo_footer_link_count; endforeach; endforeach; ?>
				</nav>
			<?php endif; ?>

			<div style="display: inline-flex; align-items: center; gap: 0.75rem;">
				<?php if (! empty($data->contact_channels)) : ?>
					<div style="display: inline-flex; align-items: center; gap: 0.5rem;">
						<?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); ?>" aria-label="<?php echo esc_attr($pgo_ch_label); ?>" style="display: inline-flex; color: var(--pg-neutral-700, rgb(64 64 64));">
								<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; ?>

				<span style="font-size: 0.8rem; color: var(--pg-neutral-600, rgb(82 82 82));">
					<?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 endif; ?>
				</span>
			</div>

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