<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Employee Confirmed Meeting Email Template
 */
do_action( 'rtrb_get_email_header', $email, $booking );
do_action( 'rtrb_email_before_content', $email, $booking );
do_action( 'rtrb_email_content_start', $email, $booking );
?>

<!-- Email Content Text -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td class="main-content">
			<?php if ( ! empty( $settings['additional_content'] ) ) : ?>
				<?php echo wp_kses_post( wpautop( wptexturize( $settings['additional_content'] ) ) ); ?>
			<?php else : ?>
				<p style="margin: 0; font-size: 14px; color: #374151;"><?php esc_html_e( 'A new meeting has been confirmed and added to your schedule. Please review the details below.', 'radius-booking' ); ?></p>
			<?php endif; ?>
		</td>
	</tr>
</table>

<!-- Customer Info Box -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; margin: 16px 0;">
	<tr>
		<td style="padding: 16px 20px;">
			<p style="margin: 0 0 8px 0; font-weight: 600; font-size: 14px; color: #111827;"><?php esc_html_e( 'Customer Information:', 'radius-booking' ); ?></p>
			<p style="margin: 0 0 4px 0; font-size: 14px; color: #374151;"><strong><?php esc_html_e( 'Name:', 'radius-booking' ); ?></strong> <?php echo esc_html( $merge_tags['customer_name'] ?? '' ); ?></p>
			<p style="margin: 0 0 4px 0; font-size: 14px; color: #374151;"><strong><?php esc_html_e( 'Email:', 'radius-booking' ); ?></strong> <?php echo esc_html( $merge_tags['customer_email'] ?? '' ); ?></p>
			<?php if ( ! empty( $merge_tags['customer_phone'] ) ) : ?>
				<p style="margin: 0; font-size: 14px; color: #374151;"><strong><?php esc_html_e( 'Phone:', 'radius-booking' ); ?></strong> <?php echo esc_html( $merge_tags['customer_phone'] ); ?></p>
			<?php endif; ?>
		</td>
	</tr>
</table>

<?php do_action( 'rtrb_email_before_booking_details', $email, $booking ); ?>

<!-- Meeting Details Card -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin: 16px 0; background-color: #F5FAFF; border: 1px solid #BDCFFF; border-radius: 8px;">
	<tr>
		<td style="padding: 25px 30px;">
			<h3 style="margin: 0 0 16px 0; font-size: 16px; font-weight: 600; color: #111827;"><?php esc_html_e( 'Meeting Details', 'radius-booking' ); ?></h3>

			<?php if ( ! empty( $merge_tags['meeting_type_name'] ) ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid #CEDEEF;">
				<tr>
					<td style="padding: 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; width: 40%;"><?php esc_html_e( 'Meeting Type:', 'radius-booking' ); ?></td>
					<td style="padding: 12px 0; font-size: 14px; color: #111827; font-weight: 600; text-align: right;"><?php echo esc_html( $merge_tags['meeting_type_name'] ); ?></td>
				</tr>
			</table>
			<?php endif; ?>

			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid #CEDEEF;">
				<tr>
					<td style="padding: 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; width: 40%;"><?php esc_html_e( 'Date:', 'radius-booking' ); ?></td>
					<td style="padding: 12px 0; font-size: 14px; color: #111827; text-align: right;"><?php echo esc_html( $merge_tags['booking_date'] ?? '' ); ?></td>
				</tr>
			</table>

			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid #CEDEEF;">
				<tr>
					<td style="padding: 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; width: 40%;"><?php esc_html_e( 'Time:', 'radius-booking' ); ?></td>
					<td style="padding: 12px 0; font-size: 14px; color: #111827; text-align: right;">
						<?php echo esc_html( $merge_tags['time'] ?? '' ); ?>
						<?php if ( ! empty( $merge_tags['end_time'] ) ) : ?> - <?php echo esc_html( $merge_tags['end_time'] ); ?><?php endif; ?>
					</td>
				</tr>
			</table>

			<?php if ( ! empty( $merge_tags['duration'] ) ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid #CEDEEF;">
				<tr>
					<td style="padding: 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; width: 40%;"><?php esc_html_e( 'Duration:', 'radius-booking' ); ?></td>
					<td style="padding: 12px 0; font-size: 14px; color: #111827; text-align: right;"><?php echo esc_html( $merge_tags['duration'] ); ?></td>
				</tr>
			</table>
			<?php endif; ?>

			<?php if ( ! empty( $merge_tags['location'] ) ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom: 1px solid #CEDEEF;">
				<tr>
					<td style="padding: 12px 0; font-size: 14px; color: #6B7280; font-weight: 500; width: 40%;"><?php esc_html_e( 'Location:', 'radius-booking' ); ?></td>
					<td style="padding: 12px 0; font-size: 14px; color: #111827; text-align: right;"><?php echo esc_html( $merge_tags['location'] ); ?></td>
				</tr>
			</table>
			<?php endif; ?>

			<?php if ( ! empty( $merge_tags['meeting_price'] ) && floatval( $merge_tags['meeting_price'] ) > 0 ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td style="padding: 14px 0 0 0; font-size: 16px; color: #111827; font-weight: 700; width: 40%;"><?php esc_html_e( 'Price:', 'radius-booking' ); ?></td>
					<td style="padding: 14px 0 0 0; font-size: 18px; color: #0040ff; font-weight: 700; text-align: right;">
						<?php echo esc_html( ( $merge_tags['currency_symbol'] ?? '$' ) . number_format( floatval( $merge_tags['meeting_price'] ), 2 ) ); ?>
						<?php if ( ! empty( $merge_tags['payment_status'] ) ) : ?>
							<span style="font-size: 12px; color: #16a34a; font-weight: 600;">(<?php echo esc_html( ucfirst( $merge_tags['payment_status'] ) ); ?>)</span>
						<?php endif; ?>
					</td>
				</tr>
			</table>
			<?php endif; ?>

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

<?php if ( ! empty( $merge_tags['meeting_link'] ) ) : ?>
<!-- Meeting Link Box -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin: 16px 0;">
	<tr>
		<td align="center" style="padding: 20px; background-color: #EFF6FF; border: 1px solid #BFDBFE; border-radius: 8px;">
			<p style="margin: 0 0 14px 0; font-size: 14px; font-weight: 600; color: #1E40AF;"><?php esc_html_e( 'Meeting Link', 'radius-booking' ); ?></p>
			<a href="<?php echo esc_url( $merge_tags['meeting_link'] ); ?>" target="_blank" rel="noopener noreferrer" style="display: inline-block; padding: 12px 28px; background-color: #2563EB; color: #ffffff; text-decoration: none; font-size: 14px; font-weight: 600; border-radius: 8px;">
				<?php
				$provider = $merge_tags['meeting_provider'] ?? '';
				if ( 'google_calendar' === $provider ) {
					esc_html_e( 'Open Google Meet', 'radius-booking' );
				} elseif ( 'zoom' === $provider ) {
					esc_html_e( 'Start Zoom Meeting', 'radius-booking' );
				} else {
					esc_html_e( 'Open Meeting', 'radius-booking' );
				}
				?>
			</a>
		</td>
	</tr>
</table>
<?php endif; ?>

<?php do_action( 'rtrb_email_after_booking_details', $email, $booking ); ?>

<?php if ( ! empty( $settings['footer_text'] ) ) : ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td class="footer-text" style="padding: 16px 0; font-size: 14px; color: #374151;">
			<?php echo wp_kses_post( wpautop( wptexturize( $settings['footer_text'] ) ) ); ?>
		</td>
	</tr>
</table>
<?php endif; ?>

<?php do_action( 'rtrb_email_before_button', $email, $booking ); ?>

<?php if ( ! empty( $settings['button_text'] ) ) : ?>
	<?php do_action( 'rtrb_email_button', $email, $booking, $settings ); ?>
<?php endif; ?>

<?php
do_action( 'rtrb_email_content_end', $email, $booking );
do_action( 'rtrb_email_after_content', $email, $booking );
do_action( 'rtrb_get_email_footer', $email, $booking );
?>
