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

$faqs = $args['faqs'] ?? array();

if ( empty( $faqs ) ) {
	return;
}

?>
<div class="gn-section gn-faqs-section" id="gn-faqs">
	<div class="gn-head">
		<h3 class="gn-title"><?php esc_html_e( 'FAQs', 'gigneo' ); ?></h3>
	</div>
	<div class="gn-body">
		<div class="gn-faqs gn-accordion-wrapper">
			<?php
			foreach ( $faqs as $key => $faq_item ) {
				$faq_question = ! empty( $faq_item['question'] ) ? $faq_item['question'] : '';
				$faq_answer   = ! empty( $faq_item['answer'] ) ? $faq_item['answer'] : '';

				if ( empty( $faq_question ) || empty( $faq_answer ) ) {
					continue;
				}
				?>
				<div class="gn-accordion-item">
					<div class="gn-head">
						<h4 class="gn-title"><?php echo esc_html( $faq_question ); ?></h4>
						<button type="button" class="gn-toggle">
							<i class="hi hi-chevron-down" aria-hidden="true"></i>
						</button>
					</div>
					<div class="gn-body">
						<pre class="gn-pre"><?php echo wp_kses( $faq_answer, gigneo_allowed_html_tags() ); ?></pre>
					</div>
				</div>
			<?php } ?>
		</div>
	</div>
</div>
