<?php
/**
 * Email Template: Two-Factor Authentication Code
 * 
 * This template can be overridden by copying it to:
 * your-theme/guard-dog/emails/two-factor-code.php
 *
 * Available variables:
 * @var string $code The 6-digit verification code
 * @var WP_User $user The user object
 * @var string $site_name The site name
 * @var int $expiry_minutes Code expiration time in minutes (default: 10)
 *
 * @package GuardDog
 * @since 1.8.5
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
// $expiry_minutes is a local variable in a template file, not a global variable
// The Plugin Checker incorrectly flags local template variables as globals
// This variable is scoped to this template file and does not pollute the global namespace

// Set default expiry if not provided
if ( ! isset( $expiry_minutes ) ) {
	$expiry_minutes = 10;
}
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<?php // Translators: %s is the site name. ?>
	<title><?php echo esc_html( sprintf( __( '[%s] Two-Factor Authentication Code', 'guard-dog' ), $site_name ) ); ?></title>
	<style type="text/css">
		body {
			font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
			line-height: 1.6;
			color: #333333;
			background-color: #f4f4f4;
			margin: 0;
			padding: 0;
		}
		.email-wrapper {
			max-width: 600px;
			margin: 0 auto;
			background-color: #ffffff;
		}
		.email-header {
			background-color: #0073aa;
			color: #ffffff;
			padding: 20px;
			text-align: center;
		}
		.email-header h1 {
			margin: 0;
			font-size: 24px;
			font-weight: 600;
		}
		.email-content {
			padding: 40px 30px;
		}
		.email-content p {
			margin: 0 0 15px 0;
			font-size: 16px;
		}
		.verification-code {
			background-color: #f8f9fa;
			border: 2px solid #0073aa;
			border-radius: 4px;
			padding: 20px;
			text-align: center;
			margin: 30px 0;
		}
		.verification-code-label {
			font-size: 14px;
			color: #666666;
			margin-bottom: 10px;
			text-transform: uppercase;
			letter-spacing: 1px;
		}
		.verification-code-value {
			font-size: 36px;
			font-weight: bold;
			color: #0073aa;
			letter-spacing: 8px;
			font-family: "Courier New", Courier, monospace;
		}
		.email-footer {
			background-color: #f8f9fa;
			padding: 20px 30px;
			text-align: center;
			font-size: 14px;
			color: #666666;
			border-top: 1px solid #e1e1e1;
		}
		.warning-text {
			color: #d63638;
			font-size: 14px;
			margin-top: 20px;
		}
	</style>
</head>
<body>
	<div class="email-wrapper">
		<div class="email-header">
			<h1><?php echo esc_html( $site_name ); ?></h1>
		</div>
		<div class="email-content">
			<p><?php 
				// Translators: %s is the user's display name.
				echo esc_html( sprintf( __( 'Hello %s,', 'guard-dog' ), $user->display_name ) ); 
			?></p>
			
			<p><?php esc_html_e( 'You have requested a two-factor authentication code to log in to your account.', 'guard-dog' ); ?></p>
			
			<div class="verification-code">
				<div class="verification-code-label">
					<?php esc_html_e( 'Your Verification Code', 'guard-dog' ); ?>
				</div>
				<div class="verification-code-value">
					<?php echo esc_html( $code ); ?>
				</div>
			</div>
			
			<p><?php
				echo esc_html( sprintf(
					// Translators: %d is the expiration time in minutes.
					_n( 
						'This code will expire in %d minute.', 
						'This code will expire in %d minutes.', 
						$expiry_minutes, 
						'guard-dog' 
					), 
					$expiry_minutes 
				) ); 
			?></p>
			
			<p class="warning-text">
				<strong><?php esc_html_e( 'Security Notice:', 'guard-dog' ); ?></strong>
				<?php esc_html_e( 'If you did not request this code, please ignore this email and consider changing your password.', 'guard-dog' ); ?>
			</p>
		</div>
		<div class="email-footer">
			<p><?php 
				// Translators: %s is the site name.
				echo esc_html( sprintf( __( 'This email was sent from %s', 'guard-dog' ), $site_name ) ); 
			?></p>
			<p><?php esc_html_e( 'Please do not reply to this email.', 'guard-dog' ); ?></p>
		</div>
	</div>
</body>
</html>

