<?php
/**
 * PufferGo Product Info Component — 产品详情信息（标题/价格/描述/MOQ/交期/CTA/规格）。
 *
 * @param PufferGo_Product_Data $data 产品数据对象。
 *
 * @package PufferGo
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<div class="mt-10 px-4 sm:mt-16 sm:px-0 lg:mt-0">
	<h1 class="text-3xl font-bold tracking-tight text-neutral-900 sm:text-4xl"><?php echo esc_html( $data->title ); ?></h1>

	<?php if ( $data->price_display ) : ?>
		<div class="mt-3">
			<p class="text-3xl tracking-tight text-neutral-900"><?php echo esc_html( $data->price_display ); ?></p>
		</div>
	<?php endif; ?>

	<?php if ( $data->short_description ) : ?>
		<div class="mt-6">
			<h3 class="sr-only"><?php esc_html_e( 'Description', 'puffergo' ); ?></h3>
			<div class="space-y-6 text-base text-neutral-700">
				<?php echo wp_kses_post( $data->short_description ); ?>
			</div>
		</div>
	<?php endif; ?>

	<?php if ( $data->moq_display || $data->lead_time_display ) : ?>
		<div class="mt-6 grid grid-cols-2 gap-4">
			<?php if ( $data->moq_display ) : ?>
				<div>
					<h3 class="text-sm font-medium text-neutral-600"><?php esc_html_e( 'Minimum Order', 'puffergo' ); ?></h3>
					<p class="mt-1 text-lg font-medium text-neutral-900"><?php echo esc_html( $data->moq_display ); ?></p>
				</div>
			<?php endif; ?>
			<?php if ( $data->lead_time_display ) : ?>
				<div>
					<h3 class="text-sm font-medium text-neutral-600"><?php esc_html_e( 'Lead Time', 'puffergo' ); ?></h3>
					<p class="mt-1 text-lg font-medium text-neutral-900"><?php echo esc_html( $data->lead_time_display ); ?></p>
				</div>
			<?php endif; ?>
		</div>
	<?php endif; ?>

	<!-- CTA Button + Brochure Download -->
	<div class="mt-10 flex items-center gap-4">
		<?php if ( $data->cta_visible ) : ?>
		<a href="<?php echo esc_url( $data->cta_url ); ?>"<?php echo $data->cta_link_attrs; ?> class="flex flex-1 items-center justify-center rounded-md border border-transparent bg-brand-600 px-8 py-3 text-base font-medium text-white hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-2 focus:ring-offset-neutral-50 sm:w-full">
			<?php echo esc_html( $data->cta_text ); ?>
		</a>
		<?php endif; ?>

		<?php if ( $data->brochure_url ) : ?>
			<a href="<?php echo esc_url( $data->brochure_url ); ?>" target="_blank" rel="noopener noreferrer" class="flex items-center gap-2 rounded-md border border-neutral-300 bg-neutral-50 px-4 py-3 text-sm font-medium text-neutral-700 hover:bg-neutral-50">
				<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
					<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
				</svg>
				<?php esc_html_e( 'Download', 'puffergo' ); ?>
			</a>
		<?php endif; ?>
	</div>

	<!-- Specs Accordion -->
	<?php if ( ! empty( $data->specs ) ) : ?>
		<section aria-labelledby="details-heading" class="mt-12">
			<h2 id="details-heading" class="sr-only"><?php esc_html_e( 'Additional details', 'puffergo' ); ?></h2>
			<div class="divide-y divide-neutral-200 border-t border-neutral-200">
				<div class="spec-group">
					<button type="button" class="group relative flex w-full items-center justify-between py-6 text-left" data-toggle="spec-0" aria-expanded="false" aria-controls="spec-0">
						<span class="text-sm font-medium text-neutral-900 group-hover:text-brand-600"><?php esc_html_e( 'Specifications', 'puffergo' ); ?></span>
						<span class="ml-6 flex items-center">
							<svg class="h-6 w-6 transform text-brand-500 group-hover:text-brand-600 plus-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
								<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M12 4.5v15m7.5-7.5h-15"></path>
							</svg>
							<svg class="h-6 w-6 transform minus-icon text-brand-500 group-hover:text-brand-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
								<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M5 12h14"></path>
							</svg>
						</span>
					</button>
					<div id="spec-0" class="spec-content pb-6" role="region">
						<dl class="space-y-3">
							<?php foreach ( $data->specs as $spec ) : ?>
								<div class="flex flex-col sm:flex-row sm:items-center">
									<dt class="flex-1 text-sm font-medium text-neutral-900"><?php echo esc_html( $spec['key'] ); ?></dt>
									<dd class="mt-1 text-sm text-neutral-700 sm:mt-0 sm:ml-6"><?php echo esc_html( $spec['value'] ); ?></dd>
								</div>
							<?php endforeach; ?>
						</dl>
					</div>
				</div>
			</div>
		</section>
	<?php endif; ?>
</div>
