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

use PixelioCartAbandonRecoveryMore\Includes\Utils\Pixelio_Cart_Abandon_Recovery_More_Util;

$pixelio_site_name = get_bloginfo( 'name' );
$pixelio_site_description = get_bloginfo( 'description' );
$pixelio_default_subject = __( 'Your cart is waiting for you!', 'rivio-ai-cart-recovery-marketing-email-automation' );
?>

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
	<meta charset="<?php bloginfo( 'charset' ); ?>" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body style="margin:0; padding:0; background:#f3f4f6; font-family:Arial, Helvetica, sans-serif;">

<table width="100%" cellpadding="0" cellspacing="0" border="0" style="width:100%; background:#f3f4f6; padding:32px 12px;" >
	<tr>
		<td align="center" class="pixelio-cart-abandon-recovery-more-email-body">

			<table width="640" cellpadding="0" cellspacing="0" border="0" style="width:100%; max-width:640px; background:#ffffff; border-radius:16px; overflow:hidden; box-shadow:0 8px 24px rgba(15,23,42,0.08);" >

				<!-- Header -->
				<tr>
					<td align="center" style="padding:32px 28px 22px 28px; background:#ffffff; border-bottom:1px solid #eef0f3;">

						<?php if ( function_exists( 'get_custom_logo' ) && has_custom_logo() ) : ?>
							<div style="margin-bottom:18px;">
								<?php
								echo wp_kses_post(
									wp_get_attachment_image(
										get_theme_mod( 'custom_logo' ),
										'full',
										false,
										array(
											'style' => 'max-height:64px; width:auto; display:block; margin:0 auto;',
										)
									)
								);
								?>
							</div>
						<?php else : ?>
							<p style="margin:0 0 14px 0; font-size:18px; font-weight:700; color:#111827;">
								<?php echo esc_html( $pixelio_site_name ); ?>
							</p>
						<?php endif; ?>

						<h1 class="pixelio-cart-abandon-recovery-more-email-subject-placeholder" style="margin:0; font-size:24px; line-height:1.3; font-weight:700; color:#111827;">
							<?php echo esc_html( ! empty( $subject ) ? $subject : $pixelio_default_subject ); ?>
						</h1>

					</td>
				</tr>

				<!-- Content -->
				<tr>
					<td class="pixelio-cart-abandon-recovery-more-email-content" style="padding:30px 32px 10px 32px; font-size:16px; line-height:1.7; color:#374151;">

						<?php
						echo wp_kses(
							$pixelio_cart_abandon_recovery_more_email,
							Pixelio_Cart_Abandon_Recovery_More_Util::$pixelio_cart_abandon_recovery_more_allowed_html
						);
						?>

						<?php if ( ! empty( $pixelio_cart_abandon_recovery_more_coupon_code ) ) : ?>
							<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin:28px 0; background:#fff7ed; border:1px solid #fed7aa; border-radius:14px;">
								<tr>
									<td align="center" style="padding:22px 20px;">

										<p style="margin:0 0 10px 0; font-size:14px; line-height:1.4; color:#9a3412; font-weight:700; text-transform:uppercase; letter-spacing:0.04em;">
											<?php esc_html_e( 'Your exclusive coupon code', 'rivio-ai-cart-recovery-marketing-email-automation' ); ?>
										</p>

										<p style="margin:0; display:inline-block; padding:12px 22px; background:#ffffff; border:2px dashed #fb923c; border-radius:10px; font-size:22px; line-height:1.2; font-weight:800; color:#c2410c; letter-spacing:0.06em;">
											<?php echo esc_html( $pixelio_cart_abandon_recovery_more_coupon_code ); ?>
										</p>

									</td>
								</tr>
							</table>
						<?php endif; ?>

					</td>
				</tr>

				<!-- CTA -->
				<?php if ( ! empty( $link ) ) : ?>
					<tr>
						<td align="center" style="padding:12px 32px 36px 32px;">
							<a href="<?php echo esc_url( $link ); ?>" style="display:inline-block; background:#111827; color:#ffffff; text-decoration:none; font-size:16px; font-weight:700; padding:15px 26px; border-radius:10px;">
								<?php esc_html_e( 'Return to my cart', 'rivio-ai-cart-recovery-marketing-email-automation' ); ?>
							</a>
						</td>
					</tr>
				<?php endif; ?>

				<!-- Footer -->
				<tr>
					<td align="center" style="padding:26px 28px; background:#f9fafb; border-top:1px solid #eef0f3; font-size:13px; line-height:1.6; color:#6b7280;">

						<p style="margin:0 0 6px 0; font-size:14px; color:#374151; font-weight:700;">
							<?php echo esc_html( $pixelio_site_name ); ?>
						</p>

						<?php if ( ! empty( $pixelio_site_description ) ) : ?>
							<p style="margin:0 0 14px 0;">
								<?php echo esc_html( $pixelio_site_description ); ?>
							</p>
						<?php endif; ?>

						<p style="margin:0;">
							© <?php echo esc_html( gmdate( 'Y' ) ); ?>
							·
							<a href="<?php echo esc_url( home_url() ); ?>" style="color:#2563eb; text-decoration:none;">
								<?php echo esc_html( wp_parse_url( home_url(), PHP_URL_HOST ) ); ?>
							</a>

							<?php if ( ! empty( $pixelio_cart_abandon_recovery_unsubscribed_link ) ) : ?>
								·
								<a href="<?php echo esc_url( $pixelio_cart_abandon_recovery_unsubscribed_link ); ?>" style="color:#ef4444; text-decoration:none;">
									<?php esc_html_e( 'Unsubscribe', 'rivio-ai-cart-recovery-marketing-email-automation' ); ?>
								</a>
							<?php endif; ?>
						</p>

					</td>
				</tr>

			</table>

		</td>
	</tr>
</table>

<?php if ( ! empty( $pixelio_cart_abandon_recovery_tracking_url ) ) : ?>
	<img src="<?php echo esc_url( $pixelio_cart_abandon_recovery_tracking_url ); ?>" width="1" height="1" style="display:none;" alt="" />
<?php endif; ?>

</body>
</html>
