<?php
/**
 * Template Name: Variant 3
 *
 * PufferGo footer template variant 3 (Tailwind UI: logo + description + sections grid + copyright).
 * Uses same footer context as footer.php / footer-2.php.
 *
 * @var PufferGo_Footer_Data $data Footer data (injected by render_variants).
 *
 * @package PufferGo
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<footer class="puffergo-footer-3 puffergo-default-footer bg-neutral-50">
	<div class="mx-auto max-w-7xl px-6 pt-16 pb-8 sm:pt-24 lg:px-8 lg:pt-32">
		<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 ); ?>">
				<?php if ( ! puffergo_the_logo( 'h-9 w-auto object-contain ', array( 'loading' => 'lazy' ) ) ) : ?>
					<span class="text-lg font-semibold text-neutral-900"><?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-600"><?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="text-sm/6 text-neutral-600 space-y-1">
						<?php if ( $data->contact_email !== '' ) : ?>
							<p>
								<span class="font-medium text-neutral-800"><?php esc_html_e( 'Email', 'puffergo' ); ?>：</span>
								<a href="<?php echo esc_url( 'mailto:' . $data->contact_email ); ?>" class="hover:text-neutral-900"><?php echo esc_html( $data->contact_email ); ?></a>
							</p>
						<?php endif; ?>
						<?php if ( $data->contact_phone !== '' ) : ?>
							<p>
								<span class="font-medium text-neutral-800"><?php esc_html_e( 'Phone', 'puffergo' ); ?>：</span>
								<a href="<?php echo esc_url( 'tel:' . $data->contact_phone ); ?>" class="hover:text-neutral-900"><?php echo esc_html( $data->contact_phone ); ?></a>
							</p>
						<?php endif; ?>
						<?php if ( $data->wechat_value !== '' ) : ?>
							<p>
								<span class="font-medium text-neutral-800"><?php esc_html_e( 'WeChat', 'puffergo' ); ?>：</span>
								<span><?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-800"><?php esc_html_e( 'Address', 'puffergo' ); ?>：</span>
								<span><?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-600 hover:text-neutral-800" aria-label="<?php echo esc_attr( $pgo_ch_label ); ?>">
								<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-16 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-900"><?php echo esc_html( $pgo_section_title ); ?></h3>
						<?php endif; ?>
						<ul role="list" class="mt-6 space-y-4 list-none pl-0 m-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 === '' ) {
									continue;
								}
								if ( $pgo_link_name === '' ) {
									continue;
								}
								?>
								<li>
									<a href="<?php echo esc_url( $pgo_link_url ); ?>" class="text-sm/6 text-neutral-600 hover:text-neutral-900"><?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-16 border-t border-neutral-900/10 pt-8 sm:mt-20 lg:mt-24">
			<p class="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>
	</div>
</footer>
