<?php
/**
 * Shared event details block for all event email templates.
 * Clean design inspired by Zoom meeting emails.
 *
 * Available variables: $merge_tags, $email, $booking
 *
 * @package RadiusTheme\RadiusBooking
 * @since   1.3.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<!-- Event Details -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom: 24px;">
	<tr>
		<td style="padding: 0;">

			<!-- Event Info Table -->
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 16px;">
				<?php if ( ! empty( $merge_tags['event_name'] ) ) : ?>
				<tr>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #6b7280; font-size: 13px; font-weight: 500; width: 35%;">Event</td>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #111827; font-size: 13px; font-weight: 600;"><?php echo esc_html( $merge_tags['event_name'] ); ?></td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $merge_tags['event_date'] ) ) : ?>
				<tr>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #6b7280; font-size: 13px; font-weight: 500;">Date</td>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #111827; font-size: 13px;"><?php echo esc_html( $merge_tags['event_date'] ); ?></td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $merge_tags['event_time'] ) ) : ?>
				<tr>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #6b7280; font-size: 13px; font-weight: 500;">Time</td>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #111827; font-size: 13px;"><?php echo esc_html( $merge_tags['event_time'] ); ?></td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $merge_tags['event_location'] ) ) : ?>
				<tr>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #6b7280; font-size: 13px; font-weight: 500;">Location</td>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6; color: #111827; font-size: 13px;"><?php echo esc_html( $merge_tags['event_location'] ); ?></td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $merge_tags['staff_name'] ) ) : ?>
				<tr>
					<td style="padding: 12px 16px; color: #6b7280; font-size: 13px; font-weight: 500;">Organizer</td>
					<td style="padding: 12px 16px; color: #111827; font-size: 13px;"><?php echo esc_html( $merge_tags['staff_name'] ); ?></td>
				</tr>
				<?php endif; ?>
			</table>

			<!-- Tickets -->
			<?php if ( ! empty( $merge_tags['all_tickets'] ) && is_array( $merge_tags['all_tickets'] ) ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 16px;">
				<tr>
					<td style="padding: 12px 16px; background-color: #f9fafb; border-bottom: 1px solid #e5e7eb;">
						<p style="margin: 0; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em;">Your Tickets</p>
					</td>
				</tr>
				<?php foreach ( $merge_tags['all_tickets'] as $ticket ) : ?>
				<tr>
					<td style="padding: 12px 16px; border-bottom: 1px solid #f3f4f6;">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td style="font-size: 13px; font-weight: 600; color: #111827;">
									<?php echo esc_html( $ticket['quantity'] ); ?>&times; <?php echo esc_html( $ticket['name'] ); ?>
									<?php if ( $ticket['price'] > 0 ) : ?>
										<span style="color: #6b7280; font-weight: 400;">(<?php echo esc_html( get_rtrb_currency_symbol() . number_format( $ticket['price'] * $ticket['quantity'], 2 ) ); ?>)</span>
									<?php else : ?>
										<span style="color: #059669; font-weight: 400;">Free</span>
									<?php endif; ?>
								</td>
							</tr>
							<?php if ( ! empty( $ticket['registration_number'] ) ) : ?>
							<tr>
								<td style="font-size: 12px; color: #9ca3af; font-family: monospace; letter-spacing: 0.05em; padding-top: 2px;">
									<?php echo esc_html( $ticket['registration_number'] ); ?>
								</td>
							</tr>
							<?php endif; ?>
						</table>
					</td>
				</tr>
				<?php endforeach; ?>
			</table>
			<?php elseif ( ! empty( $merge_tags['ticket_name'] ) ) : ?>
			<!-- Fallback: single ticket -->
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 16px;">
				<tr>
					<td style="padding: 12px 16px;">
						<p style="margin: 0 0 2px 0; font-size: 13px; font-weight: 600; color: #111827;">
							<?php if ( ! empty( $merge_tags['ticket_quantity'] ) ) : ?><?php echo esc_html( $merge_tags['ticket_quantity'] ); ?>&times; <?php endif; ?><?php echo esc_html( $merge_tags['ticket_name'] ); ?>
						</p>
						<?php if ( ! empty( $merge_tags['registration_number'] ) ) : ?>
						<p style="margin: 0; font-size: 12px; color: #9ca3af; font-family: monospace; letter-spacing: 0.05em;">
							<?php echo esc_html( $merge_tags['registration_number'] ); ?>
						</p>
						<?php endif; ?>
					</td>
				</tr>
			</table>
			<?php endif; ?>

			<!-- Selected Sessions -->
			<?php if ( ! empty( $merge_tags['selected_sessions'] ) ) : ?>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 16px;">
				<tr>
					<td style="padding: 12px 16px; background-color: #f9fafb; border-bottom: 1px solid #e5e7eb;">
						<p style="margin: 0; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em;">Selected Sessions</p>
					</td>
				</tr>
				<tr>
					<td style="padding: 12px 16px; font-size: 13px; color: #374151; line-height: 1.6;">
						<?php echo esc_html( $merge_tags['selected_sessions'] ); ?>
					</td>
				</tr>
			</table>
			<?php endif; ?>

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