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

/**
 * HTML Template: Service Order Review Email
 *
 * Sent to the user when they receive a review for a service order.
 *
 * @var string   $email_heading
 * @var string   $profile_name
 * @var string   $participant_name
 * @var string   $service_title
 * @var int      $service_id
 * @var int      $order_id
 * @var string   $order_link
 * @var string   $review_comment
 * @var float    $rating
 * @var int      $review_communication
 * @var int      $review_clarity
 * @var int      $review_professionalism
 * @var int      $review_quality_work
 * @var int      $review_understanding
 * @var string   $reviewer_label
 * @var string   $reviewer_type
 * @var bool     $sent_to_admin
 * @var bool     $plain_text
 * @var WC_Email $email
 */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_header', $email_heading, $email );
?>

<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;">
	<tr>
		<td style="padding: 40px 20px;">

			<!-- Greeting -->
			<p style="margin: 0 0 20px 0;">
				<?php
				printf(
					// translators: %s is the user's participant name.
					esc_html__( 'Hello %s,', 'gigneo' ),
					esc_html( $participant_name )
				);
				?>
			</p>

			<!-- Introduction -->
			<p style="margin: 0 0 30px 0;">
				<?php
				printf(
					// translators: %1$s: Reviewer name, %2$s: Reviewer label.
					esc_html__( 'You have received a new review from %1$s (%2$s). Feedback from your clients helps build trust and improve your professional profile.', 'gigneo' ),
					'<strong>' . esc_html( $profile_name ) . '</strong>',
					esc_html( $reviewer_label )
				);
				?>
			</p>

			<!-- Section heading -->
			<h3 style="margin: 0 0 15px 0;">
				<?php echo esc_html__( 'Order details', 'gigneo' ); ?>
			</h3>

			<!-- Details table -->
			<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; background: #F7F7F7; border: 1px solid #f0f0f0; border-radius: 12px; margin: 0 0 30px 0;">
				<!-- Order ID -->
				<tr>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; width: 50%;">
						<?php echo esc_html__( 'Order ID', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-align: right;">
						<?php echo esc_html( gigneo_format_id( $order_id, 'order', false ) ); ?>
					</td>
				</tr>

				<!-- Service ID -->
				<tr>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0;">
						<?php echo esc_html__( 'Service ID', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-align: right;">
						<?php echo esc_html( gigneo_format_id( $service_id, 'service', false ) ); ?>
					</td>
				</tr>

				<!-- Service title -->
				<tr>
					<td style="padding: 14px 16px;">
						<?php echo esc_html__( 'Service title', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; text-align: right;">
						<?php echo esc_html( $service_title ); ?>
					</td>
				</tr>
			</table>

			<!-- Review Comment Section -->
			<h3 style="margin: 0 0 15px 0;">
				<?php echo esc_html__( 'Review comment', 'gigneo' ); ?>
			</h3>

			<!-- Review Comment Card -->
			<div style="background-color: #ffffff; border: 1px solid #f0f0f0; border-radius: 12px; padding: 24px; margin-bottom: 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.02);">
				<div style="display: flex; align-items: center; margin-bottom: 25px; border-bottom: 1px solid #f0f0f0; padding-bottom: 20px;">
					<div style="margin-right: 20px;">
						<div style=" margin-bottom: 5px;">
							<?php
							for ( $i = 1; $i <= 5; $i++ ) {
								if ( $rating >= $i ) {
									echo '★';
								} elseif ( $rating >= ( $i - 0.5 ) ) {
									echo '½';
								} else {
									echo '☆';
								}
							}
							?>
						</div>
						<div style=" text-transform: uppercase; letter-spacing: 0.5px;">
							<?php echo esc_html__( 'Overall Rating', 'gigneo' ); ?>
						</div>
					</div>
					<div style="background: #FFF9E6; padding: 10px 15px; border-radius: 8px; border: 1px solid #FFEBA8;">
						<span>
							<?php echo esc_html( number_format( $rating, 1 ) ); ?>
						</span>
						<span style=" margin-left: 2px;">/ 5.0</span>
					</div>
				</div>

				<!-- Rating Breakdown -->
				<div style="margin-bottom: 25px;">
					<h4 style=" margin: 0 0 15px 0; text-transform: uppercase; letter-spacing: 0.5px;">
						<?php echo esc_html__( 'Rating Details', 'gigneo' ); ?>
					</h4>
					<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%;">
						<tr>
							<td style="padding: 8px 0;   border-bottom: 1px dashed #f0f0f0;">
								<?php echo esc_html__( 'Communication Level', 'gigneo' ); ?>
							</td>
							<td style="padding: 8px 0;  text-align: right; border-bottom: 1px dashed #f0f0f0;">
								<span style=" margin-right: 5px;">★</span><?php echo esc_html( number_format( $review_communication, 1 ) ); ?>
							</td>
						</tr>
						<?php if ( 'freelancer' === $reviewer_type ) { ?>
						<tr>
							<td style="padding: 8px 0;   border-bottom: 1px dashed #f0f0f0;">
								<?php echo esc_html__( 'Clarity of Requirements', 'gigneo' ); ?>
							</td>
							<td style="padding: 8px 0;  text-align: right; border-bottom: 1px dashed #f0f0f0;">
								<span style=" margin-right: 5px;">★</span><?php echo esc_html( number_format( $review_clarity, 1 ) ); ?>
							</td>
						</tr>
						<tr>
							<td style="padding: 8px 0;  ">
								<?php echo esc_html__( 'Professionalism', 'gigneo' ); ?>
							</td>
							<td style="padding: 8px 0;  text-align: right;">
								<span style=" margin-right: 5px;">★</span><?php echo esc_html( number_format( $review_professionalism, 1 ) ); ?>
							</td>
						</tr>
						<?php } else { ?>
						<tr>
							<td style="padding: 8px 0;   border-bottom: 1px dashed #f0f0f0;">
								<?php echo esc_html__( 'Quality of work', 'gigneo' ); ?>
							</td>
							<td style="padding: 8px 0;  text-align: right; border-bottom: 1px dashed #f0f0f0;">
								<span style=" margin-right: 5px;">★</span><?php echo esc_html( number_format( $review_quality_work, 1 ) ); ?>
							</td>
						</tr>
						<tr>
							<td style="padding: 8px 0;  ">
								<?php echo esc_html__( 'Understanding', 'gigneo' ); ?>
							</td>
							<td style="padding: 8px 0;  text-align: right;">
								<span style=" margin-right: 5px;">★</span><?php echo esc_html( number_format( $review_understanding, 1 ) ); ?>
							</td>
						</tr>
						<?php } ?>
					</table>
				</div>

				<div style=" font-style: italic; background: #F7F7F7; padding: 20px; border-radius: 12px; position: relative;">
					<span style=" position: absolute; top: 10px; left:  font-family: Georgia, serif;">&ldquo;</span>
					<div style="padding-left: 20px;">
						<?php echo wp_kses( $review_comment, gigneo_allowed_html_tags() ); ?>
					</div>
				</div>
			</div>

			<!-- CTA Button -->
			<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; margin: 0 0 30px 0;">
				<tr>
					<td style="text-align: center; padding: 10px 0;">
						<a href="<?php echo esc_url( $order_link ); ?>" target="_blank" rel="noopener">
							<?php echo esc_html__( 'View review details', 'gigneo' ); ?> &rarr;
						</a>
					</td>
				</tr>
			</table>

			<p style="  margin: 20px 0 0 0;  ">
				<?php
				printf(
						// translators: %s is reviewer label
					esc_html__( 'Feedback from %s helps build trust and improve your professional profile.', 'gigneo' ),
					esc_html( $reviewer_label )
				);
				?>
			</p>

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

<?php
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_footer', $email );