<?php
/**
 * Base Email.
 *
 * @package Noesia_Commerce_Suite
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View templates receive local variables from their renderer.
$title              = isset( $title ) ? (string) $title : '';
$body               = isset( $body ) ? (string) $body : '';
$button_label       = isset( $button_label ) ? (string) $button_label : '';
$button_url         = isset( $button_url ) ? (string) $button_url : home_url( '/' );
$settings           = isset( $settings ) && is_array( $settings ) ? $settings : Noesia_CS_Settings::get_all();
$is_preview         = ! empty( $is_preview );
$extra_footer_html  = isset( $extra_footer_html ) ? (string) $extra_footer_html : '';
$primary            = ! empty( $settings['email_button_color'] ) ? sanitize_hex_color( $settings['email_button_color'] ) : '';
$primary            = $primary ? $primary : '#6f45ff';
$logo_url           = ! empty( $settings['email_logo'] ) ? esc_url( $settings['email_logo'] ) : '';
$footer_text        = ! empty( $settings['email_footer_text'] ) ? (string) $settings['email_footer_text'] : '';
?>
<div style="font-family:Arial,sans-serif;background:#f7f7fb;padding:24px;">
	<div style="max-width:620px;margin:0 auto;background:#ffffff;border:1px solid #ececf4;border-radius:20px;padding:28px;">
		<?php if ( $logo_url ) : ?>
			<img src="<?php echo esc_url( $logo_url ); ?>" alt="" style="max-width:140px;height:auto;margin-bottom:16px;" />
		<?php endif; ?>
		<h2 style="margin:0 0 12px;color:#111827;font-size:22px;line-height:1.25;"><?php echo esc_html( $title ); ?></h2>
		<?php if ( $is_preview ) : ?>
			<p style="margin:0 0 14px;color:#6b7280;font-size:13px;"><?php esc_html_e( 'Layout preview. No customer data is included.', 'noesia-commerce-suite' ); ?></p>
		<?php endif; ?>
		<p style="margin:0 0 22px;color:#374151;font-size:15px;line-height:1.6;"><?php echo nl2br( esc_html( $body ) ); ?></p>
		<a href="<?php echo esc_url( $button_url ); ?>" target="_blank" rel="noopener noreferrer" style="display:inline-block;background:<?php echo esc_attr( $primary ); ?>;color:#ffffff;text-decoration:none;border-radius:999px;padding:12px 18px;font-weight:700;"><?php echo esc_html( $button_label ); ?></a>
		<?php if ( $footer_text ) : ?>
			<p style="margin:18px 0 0;color:#6b7280;font-size:12px;"><?php echo esc_html( $footer_text ); ?></p>
		<?php endif; ?>
		<?php echo wp_kses_post( $extra_footer_html ); ?>
	</div>
</div>
