<?php
/**
 * Template Name: Simple
 *
 * PufferGo default footer template part (TailwindUI-based).
 * Displays only Footer information from step2 data (globalElements.footer).
 * Renders sections with titles (e.g. Services, Company, Legal) and links under each.
 * Fallback: dynamic year and site name when no step2 footer is saved.
 *
 * @var PufferGo_Footer_Data $data Footer data (injected by render_variants).
 *
 * @package PufferGo
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<footer class="puffergo-default-footer bg-neutral-50">
	<div class="mx-auto max-w-7xl overflow-hidden px-6 py-20 sm:py-20 lg:px-8">
		<div class="puffergo-footer-brand mb-10">
			<a href="<?php echo esc_url( $data->home_url ); ?>" class="inline-flex items-center text-neutral-900 no-underline" aria-label="<?php echo esc_attr( $data->brand_name ); ?>">
			<?php if ( ! puffergo_the_logo( 'h-8 w-auto max-w-[12rem] object-contain object-left', array( 'loading' => 'lazy' ) ) ) : ?>
				<span class="text-lg font-semibold"><?php echo esc_html( $data->brand_name ? $data->brand_name : __( 'Logo', 'puffergo' ) ); ?></span>
			<?php endif; ?>
			</a>
		</div>
		<?php if ( ! empty( $data->sections ) ) : ?>
			<div class="puffergo-footer-sections grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-3 xl:flex xl:justify-center xl:gap-x-16">
				<?php foreach ( $data->sections as $section ) : ?>
					<?php
					$title = isset( $section['title'] ) ? $section['title'] : '';
					$links = isset( $section['links'] ) && is_array( $section['links'] ) ? $section['links'] : array();
					if ( empty( $links ) ) {
						continue;
					}
					?>
					<div class="puffergo-footer-section">
						<?php if ( $title !== '' ) : ?>
							<h3 class="puffergo-footer-section-title text-sm font-semibold uppercase tracking-wider text-neutral-900"><?php echo esc_html( $title ); ?></h3>
						<?php endif; ?>
						<ul class="puffergo-footer-links mt-4 list-none p-0 m-0 space-y-3 text-sm/6">
							<?php foreach ( $links as $link ) : ?>
								<?php
								$name = isset( $link['name'] ) ? $link['name'] : '';
								$url  = isset( $link['url'] ) ? $link['url'] : '';
								if ( $url === '' ) {
									continue;
								}
								if ( $name === '' ) {
									continue;
								}
								?>
								<li><a href="<?php echo esc_url( $url ); ?>" class="text-neutral-600 hover:text-neutral-900"><?php echo esc_html( $name ); ?></a></li>
							<?php endforeach; ?>
						</ul>
					</div>
				<?php endforeach; ?>
			</div>
		<?php endif; ?>
		<?php require PUFFERGO_PLUGIN_DIR . '/templates/components/footer-empty-menu-notice.php'; ?>
		<p class="mt-10 text-center text-sm/6 text-neutral-600">
			<?php if ( $data->copyright_text !== '' ) : ?>
				<?php echo esc_html( $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>
</footer>
