<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$title = isset( $title ) ? (string) $title : 'AVI Intelligence OS';
$subtitle = isset( $subtitle ) ? (string) $subtitle : '';
$badge = isset( $badge ) ? (string) $badge : '📍 POWERED BY AVI INTELLIGENCE';
$size = isset( $size ) ? (string) $size : 'default';
$align = isset( $align ) ? (string) $align : 'left';
$glow = ! empty( $glow );
$cta_primary = ( isset( $cta_primary ) && is_array( $cta_primary ) ) ? $cta_primary : array();
$cta_secondary = ( isset( $cta_secondary ) && is_array( $cta_secondary ) ) ? $cta_secondary : array();
$hero_extra_after_subtitle = isset( $hero_extra_after_subtitle ) ? (string) $hero_extra_after_subtitle : '';
$title_size = $size === 'small' ? '32px' : ( $size === 'large' ? '58px' : '42px' );
$align_css = $align === 'center' ? 'text-align:center;' : '';
$max_width = $align === 'center' ? '900px' : '740px';
$title_html = wp_kses(
	$title,
	array(
		'br'   => array(),
		'span' => array( 'class' => true ),
	)
);
$badge_html = wp_kses(
	$badge,
	array(
		'span' => array( 'class' => true ),
	)
);
?>
<section class="avi-hero" style="position:relative;background:var(--avi-gradient-hero);padding:120px 20px 80px;color:#fff;overflow:hidden;">
	<?php if ( $glow ) : ?>
		<div style="position:absolute;inset:0;background:var(--avi-gradient-glow);pointer-events:none;"></div>
	<?php endif; ?>
	<div style="max-width:1200px;margin:0 auto;position:relative;<?php echo esc_attr( $align_css ); ?>">
		<div class="avi-hero-badge"><?php echo $badge_html; ?></div>
		<h1 style="margin:16px 0 10px;font-size:<?php echo esc_attr( $title_size ); ?>;line-height:1.1;"><?php echo $title_html; ?></h1>
		<?php if ( $subtitle !== '' ) : ?>
			<p style="margin:0;color:var(--avi-text-muted);max-width:<?php echo esc_attr( $max_width ); ?>;<?php echo $align === 'center' ? 'margin-left:auto;margin-right:auto;' : ''; ?>"><?php echo esc_html( $subtitle ); ?></p>
		<?php endif; ?>
		<?php if ( $hero_extra_after_subtitle !== '' ) : ?>
			<?php
			echo wp_kses(
				$hero_extra_after_subtitle,
				array(
					'div'  => array(
						'class' => true,
						'style' => true,
						'id'    => true,
					),
					'span' => array(
						'class' => true,
						'style' => true,
						'id'    => true,
					),
				)
			);
			?>
		<?php endif; ?>
		<?php if ( ! empty( $cta_primary['label'] ) && ! empty( $cta_primary['url'] ) ) : ?>
			<div style="margin-top:18px;display:flex;gap:10px;flex-wrap:wrap;<?php echo $align === 'center' ? 'justify-content:center;' : ''; ?>">
				<a class="avi-btn avi-btn--primary" href="<?php echo esc_url( (string) $cta_primary['url'] ); ?>"><?php echo esc_html( (string) $cta_primary['label'] ); ?></a>
				<?php if ( ! empty( $cta_secondary['label'] ) && ! empty( $cta_secondary['url'] ) ) : ?>
					<a class="avi-nav-link" style="color:#fff;align-self:center;" href="<?php echo esc_url( (string) $cta_secondary['url'] ); ?>"><?php echo esc_html( (string) $cta_secondary['label'] ); ?></a>
				<?php endif; ?>
			</div>
		<?php endif; ?>
	</div>
</section>
