<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- False positive: locally-scoped variables (template view-vars via TemplateLoader::render() extract+include within a method, or closure locals), not plugin globals.
defined( 'ABSPATH' ) || exit;
/**
 * Action outcome summary for booking lifecycle emails.
 *
 * Expected variables:
 * - Optional: $bookaro_action_summary
 * - Optional: $bookaro_action_details (array)
 * - Optional: $bookaro_action_payment_summary
 */
$bookaro_action_summary = isset( $bookaro_action_summary ) ? trim( (string) $bookaro_action_summary ) : '';
$bookaro_action_payment_summary = isset( $bookaro_action_payment_summary ) ? trim( (string) $bookaro_action_payment_summary ) : '';
$bookaro_action_details = isset( $bookaro_action_details ) && is_array( $bookaro_action_details )
    ? array_values( array_filter( array_map( 'trim', $bookaro_action_details ) ) )
    : [];

if ( $bookaro_action_summary === '' && empty( $bookaro_action_details ) && $bookaro_action_payment_summary === '' ) {
    return;
}
?>
<div class="bookaro-policy-snippet">
    <h3 class="bookaro-email-subheading"><?php esc_html_e( 'What changed', 'mybookaro' ); ?></h3>
    <?php if ( $bookaro_action_summary !== '' ) : ?>
        <p><?php echo esc_html( $bookaro_action_summary ); ?></p>
    <?php endif; ?>
    <ul class="bookaro-policy-list">
        <?php foreach ( $bookaro_action_details as $line ) : ?>
            <li><?php echo esc_html( $line ); ?></li>
        <?php endforeach; ?>
        <?php if ( $bookaro_action_payment_summary !== '' ) : ?>
            <li><?php echo esc_html( $bookaro_action_payment_summary ); ?></li>
        <?php endif; ?>
    </ul>
</div>
