<?php
/**
 * Email Template: Booking Confirmed
 *
 * Sent after Double-Opt-In confirmation.
 *
 * @package KursBooking
 * @since   1.0.0
 *
 * @var string $buchung_nummer  Booking number.
 * @var string $buchung_date    Booking date.
 * @var string $customer_name   Customer name.
 * @var string $customer_email  Customer email.
 * @var string $customer_phone  Customer phone.
 * @var string $kurs_title      Course title.
 * @var string $kurs_type       Course type (vor_ort, online, hybrid).
 * @var string $kurs_date       Formatted course date.
 * @var string $kurs_start      Start time.
 * @var string $kurs_end        End time.
 * @var string $kurs_location   Location name.
 * @var string $kurs_address     Location address.
 * @var string $kurs_instructor  Instructor name.
 * @var string                               $kurs_horse       Assigned horse (optional).
 * @var string                               $kurs_notes       Course-specific notes.
 * @var array<int, array<string, mixed>>     $tickets          Ticket details.
 * @var float  $total_price      Total price.
 * @var float  $net_price        Net price (without VAT).
 * @var float  $vat_amount       VAT amount.
 * @var float  $vat_rate         VAT rate percentage.
 * @var bool   $is_small_business Kleinunternehmer status.
 * @var bool   $deposit_enabled  Deposit enabled.
 * @var int    $deposit_percent  Deposit percentage.
 * @var float  $deposit_amount   Deposit amount.
 * @var float  $rest_amount      Remaining amount.
 * @var string $payment_due_date Payment due date.
 * @var string $default_notes    Default notes from settings.
 * @var string $zoom_link        Zoom link (if online/hybrid).
 * @var string                $zoom_password    Zoom password.
 * @var array<string, string> $company          Company data.
 * @var string                $cancellation     Cancellation policy HTML.
 * @var string $cancel_url       Cancellation URL.
 * @var string $agb_url          AGB URL.
 * @var string $privacy_url      Privacy policy URL.
 */

declare(strict_types=1);

// Prevent direct access.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Format function.
$format_price = function ( float $amount ): string {
	return number_format( $amount, 2, ',', '.' ) . ' €';
};

$is_online = in_array( $kurs_type ?? '', array( 'online', 'hybrid' ), true );
?>

<div style="font-family: Arial, Helvetica, sans-serif; max-width: 600px; margin: 0 auto; background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden;">

	<!-- Header -->
	<div style="background-color: #28a745; color: #ffffff; padding: 24px; text-align: center;">
		<div style="font-size: 48px; margin-bottom: 8px;">✓</div>
		<h1 style="margin: 0; font-size: 24px; font-weight: normal;">
			<?php esc_html_e( 'Buchung bestätigt!', 'kurs-booking' ); ?>
		</h1>
	</div>

	<!-- Content -->
	<div style="padding: 32px;">

		<p style="font-size: 16px; color: #333333; margin-bottom: 24px;">
			<?php
			printf(
				/* translators: %s: Customer name */
				esc_html__( 'Guten Tag %s,', 'kurs-booking' ),
				esc_html( $customer_name )
			);
			?>
		</p>

		<p style="font-size: 16px; color: #333333; margin-bottom: 24px;">
			<?php esc_html_e( 'Ihre Buchung wurde erfolgreich bestätigt! Hier sind alle Details:', 'kurs-booking' ); ?>
		</p>

		<!-- Booking Confirmation Box -->
		<div style="background-color: #e8f5e9; border: 1px solid #4caf50; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h2 style="font-size: 14px; text-transform: uppercase; color: #2e7d32; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Buchungsbestätigung', 'kurs-booking' ); ?>
			</h2>

			<table style="width: 100%; border-collapse: collapse;">
				<tr>
					<td style="padding: 8px 0; color: #666666; width: 160px;"><?php esc_html_e( 'Buchungsnummer:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333; font-weight: bold; font-size: 18px;"><?php echo esc_html( $buchung_nummer ); ?></td>
				</tr>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Buchungsdatum:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $buchung_date ); ?></td>
				</tr>
			</table>
		</div>

		<!-- Course Details -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Gebuchte Leistung', 'kurs-booking' ); ?>
			</h3>

			<table style="width: 100%; border-collapse: collapse;">
				<tr>
					<td style="padding: 8px 0; color: #666666; width: 160px;"><?php esc_html_e( 'Kurs:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333; font-weight: bold;"><?php echo esc_html( $kurs_title ); ?></td>
				</tr>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Datum:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $kurs_date ); ?></td>
				</tr>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Uhrzeit:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;">
						<?php echo esc_html( $kurs_start ); ?>
						<?php if ( ! empty( $kurs_end ) ) : ?>
							– <?php echo esc_html( $kurs_end ); ?>
						<?php endif; ?>
						<?php esc_html_e( 'Uhr', 'kurs-booking' ); ?>
					</td>
				</tr>
				<?php if ( ! empty( $kurs_location ) && 'online' !== $kurs_type ) : ?>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Ort:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;">
						<?php echo esc_html( $kurs_location ); ?>
						<?php if ( ! empty( $kurs_address ) ) : ?>
							<br><span style="color: #666666;"><?php echo esc_html( $kurs_address ); ?></span>
						<?php endif; ?>
					</td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $kurs_instructor ) ) : ?>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Reitlehrer/in:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $kurs_instructor ); ?></td>
				</tr>
				<?php endif; ?>
				<?php if ( ! empty( $kurs_horse ) ) : ?>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Zugeteiltes Pferd:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $kurs_horse ); ?></td>
				</tr>
				<?php endif; ?>
			</table>
		</div>

		<!-- Zoom Access (Online/Hybrid only) -->
		<?php if ( $is_online && ! empty( $zoom_link ) ) : ?>
		<div style="background-color: #e3f2fd; border: 1px solid #2196f3; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #1565c0; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Zoom-Zugangsdaten', 'kurs-booking' ); ?>
			</h3>

			<table style="width: 100%; border-collapse: collapse;">
				<tr>
					<td style="padding: 8px 0; color: #666666; width: 160px;"><?php esc_html_e( 'Meeting-Link:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0;">
						<a href="<?php echo esc_url( $zoom_link ); ?>" style="color: #1565c0; word-break: break-all;">
							<?php echo esc_html( $zoom_link ); ?>
						</a>
					</td>
				</tr>
				<?php if ( ! empty( $zoom_password ) ) : ?>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Passwort:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333; font-family: monospace; font-weight: bold;">
						<?php echo esc_html( $zoom_password ); ?>
					</td>
				</tr>
				<?php endif; ?>
			</table>

			<p style="margin: 16px 0 0 0; color: #1565c0; font-size: 14px;">
				<?php esc_html_e( 'Bitte treten Sie dem Meeting 5 Minuten vor Beginn bei.', 'kurs-booking' ); ?>
			</p>
		</div>
		<?php endif; ?>

		<!-- Customer Details -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Teilnehmer', 'kurs-booking' ); ?>
			</h3>

			<table style="width: 100%; border-collapse: collapse;">
				<tr>
					<td style="padding: 8px 0; color: #666666; width: 160px;"><?php esc_html_e( 'Name:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $customer_name ); ?></td>
				</tr>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'E-Mail:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $customer_email ); ?></td>
				</tr>
				<?php if ( ! empty( $customer_phone ) ) : ?>
				<tr>
					<td style="padding: 8px 0; color: #666666;"><?php esc_html_e( 'Telefon:', 'kurs-booking' ); ?></td>
					<td style="padding: 8px 0; color: #333333;"><?php echo esc_html( $customer_phone ); ?></td>
				</tr>
				<?php endif; ?>
			</table>
		</div>

		<!-- Price Details -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Preis', 'kurs-booking' ); ?>
			</h3>

			<?php
			// Sprint 4.10: Track manual items for hint display.
			$manual_items_hints = array();
			?>

			<?php foreach ( $tickets as $ticket ) : ?>
			<div style="display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #dee2e6;">
				<span style="color: #333333;">
					<?php echo esc_html( $ticket['quantity'] ); ?>× <?php echo esc_html( $ticket['name'] ); ?>
					<?php // Sprint 4.10: Show per_day calculation if applicable. ?>
					<?php if ( ! empty( $ticket['per_day'] ) && ! empty( $ticket['price_label'] ) ) : ?>
						<br><span style="color: #666666; font-size: 12px;"><?php echo esc_html( $ticket['price_label'] ); ?></span>
					<?php else : ?>
						<span style="color: #666666;">@ <?php echo esc_html( $format_price( $ticket['unit_price'] ) ); ?></span>
					<?php endif; ?>
					<?php // Sprint 4.10: Add asterisk for manual payment items. ?>
					<?php if ( empty( $ticket['auto_invoice'] ) ) : ?>
						<span style="color: #ff9800;">*</span>
						<?php
						// Collect hints for display below.
						if ( ! empty( $ticket['hinweis'] ) && ! in_array( $ticket['hinweis'], $manual_items_hints, true ) ) {
							$manual_items_hints[] = $ticket['hinweis'];
						}
						?>
					<?php endif; ?>
				</span>
				<span style="color: #333333;">
					<?php echo esc_html( $format_price( $ticket['subtotal'] ) ); ?>
				</span>
			</div>
			<?php endforeach; ?>

			<?php // Sprint 4.10: Display hints for manual payment items. ?>
			<?php if ( ! empty( $manual_items_hints ) ) : ?>
			<div style="padding: 8px 0; color: #ff9800; font-size: 12px; border-bottom: 1px solid #dee2e6;">
				<?php foreach ( $manual_items_hints as $hint ) : ?>
					<span>* <?php echo esc_html( $hint ); ?></span><br>
				<?php endforeach; ?>
			</div>
			<?php endif; ?>

			<?php if ( $is_small_business ) : ?>
				<!-- Kleinunternehmer - keine MwSt-Ausweisung -->
				<div style="display: flex; justify-content: space-between; padding: 16px 0 8px 0; border-top: 2px solid #333333; margin-top: 8px;">
					<span style="font-size: 18px; font-weight: bold; color: #333333;">
						<?php esc_html_e( 'Gesamtbetrag:', 'kurs-booking' ); ?>
					</span>
					<span style="font-size: 18px; font-weight: bold; color: #333333;">
						<?php echo esc_html( $format_price( $total_price ) ); ?>
					</span>
				</div>
				<div style="padding: 8px 0; color: #666666; font-size: 12px; font-style: italic;">
					<?php esc_html_e( 'Gemäß § 19 UStG wird keine Umsatzsteuer berechnet.', 'kurs-booking' ); ?>
				</div>
			<?php else : ?>
				<!-- MwSt-Ausweis -->
				<div style="display: flex; justify-content: space-between; padding: 8px 0; margin-top: 8px; border-top: 1px solid #dee2e6;">
					<span style="color: #666666;">
						<?php esc_html_e( 'Nettobetrag:', 'kurs-booking' ); ?>
					</span>
					<span style="color: #666666;">
						<?php echo esc_html( $format_price( $net_price ) ); ?>
					</span>
				</div>
				<div style="display: flex; justify-content: space-between; padding: 8px 0;">
					<span style="color: #666666;">
						<?php
						printf(
							/* translators: %s: VAT rate */
							esc_html__( 'zzgl. %s%% USt:', 'kurs-booking' ),
							esc_html( number_format( $vat_rate, 0 ) )
						);
						?>
					</span>
					<span style="color: #666666;">
						<?php echo esc_html( $format_price( $vat_amount ) ); ?>
					</span>
				</div>
				<div style="display: flex; justify-content: space-between; padding: 16px 0 8px 0; border-top: 2px solid #333333;">
					<span style="font-size: 18px; font-weight: bold; color: #333333;">
						<?php esc_html_e( 'Gesamtbetrag (brutto):', 'kurs-booking' ); ?>
					</span>
					<span style="font-size: 18px; font-weight: bold; color: #333333;">
						<?php echo esc_html( $format_price( $total_price ) ); ?>
					</span>
				</div>
			<?php endif; ?>

			<?php if ( $deposit_enabled ) : ?>
			<div style="display: flex; justify-content: space-between; padding: 8px 0; color: #666666;">
				<span>
					<?php
					printf(
						/* translators: %d: Deposit percentage */
						esc_html__( 'Anzahlung (%d%%):', 'kurs-booking' ),
						(int) $deposit_percent
					);
					?>
				</span>
				<span><?php echo esc_html( $format_price( $deposit_amount ) ); ?></span>
			</div>
			<div style="display: flex; justify-content: space-between; padding: 8px 0; color: #666666;">
				<span><?php esc_html_e( 'Restbetrag:', 'kurs-booking' ); ?></span>
				<span><?php echo esc_html( $format_price( $rest_amount ) ); ?></span>
			</div>
			<?php endif; ?>
		</div>

		<!-- Payment Info -->
		<div style="background-color: #fff3cd; border: 1px solid #ffc107; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #856404; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Zahlung', 'kurs-booking' ); ?>
			</h3>

			<p style="margin: 0 0 16px 0; color: #856404;">
				<?php esc_html_e( 'Die Rechnung erhalten Sie in Kürze per separater E-Mail.', 'kurs-booking' ); ?>
			</p>

			<?php // Sprint 4.10: Show invoice amount info if there are manual items. ?>
			<?php if ( ! empty( $has_manual_items ) && ! empty( $invoice_total ) ) : ?>
			<p style="margin: 0 0 16px 0; color: #856404; font-weight: bold;">
				<?php
				printf(
					/* translators: %s: Invoice amount */
					esc_html__( 'Rechnungsbetrag: %s', 'kurs-booking' ),
					esc_html( $format_price( $invoice_total ) )
				);
				?>
			</p>
			<p style="margin: 0 0 16px 0; color: #666666; font-size: 12px;">
				<?php esc_html_e( 'Die mit * gekennzeichneten Positionen werden separat verrechnet und erscheinen nicht auf der Rechnung.', 'kurs-booking' ); ?>
			</p>
			<?php endif; ?>

			<?php if ( ! empty( $company['iban'] ) ) : ?>
			<table style="width: 100%; border-collapse: collapse;">
				<tr>
					<td style="padding: 4px 0; color: #856404;"><?php esc_html_e( 'Kontoinhaber:', 'kurs-booking' ); ?></td>
					<td style="padding: 4px 0; color: #333333;"><?php echo esc_html( $company['name'] ?? '' ); ?></td>
				</tr>
				<tr>
					<td style="padding: 4px 0; color: #856404;"><?php esc_html_e( 'IBAN:', 'kurs-booking' ); ?></td>
					<td style="padding: 4px 0; color: #333333; font-family: monospace;"><?php echo esc_html( $company['iban'] ); ?></td>
				</tr>
				<?php if ( ! empty( $company['bic'] ) ) : ?>
				<tr>
					<td style="padding: 4px 0; color: #856404;"><?php esc_html_e( 'BIC:', 'kurs-booking' ); ?></td>
					<td style="padding: 4px 0; color: #333333; font-family: monospace;"><?php echo esc_html( $company['bic'] ); ?></td>
				</tr>
				<?php endif; ?>
				<tr>
					<td style="padding: 4px 0; color: #856404;"><?php esc_html_e( 'Verwendungszweck:', 'kurs-booking' ); ?></td>
					<td style="padding: 4px 0; color: #333333; font-weight: bold;"><?php echo esc_html( $buchung_nummer ); ?></td>
				</tr>
				<tr>
					<td style="padding: 4px 0; color: #856404;"><?php esc_html_e( 'Zahlungsziel:', 'kurs-booking' ); ?></td>
					<td style="padding: 4px 0; color: #333333; font-weight: bold;"><?php echo esc_html( $payment_due_date ); ?></td>
				</tr>
			</table>
			<?php endif; ?>
		</div>

		<!-- Important Notes -->
		<?php if ( ! empty( $default_notes ) || ! empty( $kurs_notes ) ) : ?>
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Wichtige Hinweise', 'kurs-booking' ); ?>
			</h3>
			<?php if ( ! empty( $default_notes ) ) : ?>
			<div style="color: #333333; margin-bottom: 12px; white-space: pre-line;">
				<?php echo esc_html( $default_notes ); ?>
			</div>
			<?php endif; ?>
			<?php if ( ! empty( $kurs_notes ) ) : ?>
			<div style="color: #333333; background-color: #e8f4fc; border-left: 3px solid #007bff; padding: 12px; margin-top: 12px; white-space: pre-line;">
				<strong style="display: block; margin-bottom: 6px;"><?php esc_html_e( 'Hinweise zu diesem Kurs:', 'kurs-booking' ); ?></strong>
				<?php echo esc_html( $kurs_notes ); ?>
			</div>
			<?php endif; ?>
		</div>
		<?php endif; ?>

		<?php if ( ! empty( $is_digital_product ) ) : ?>
		<!-- Sprint 4.6: Digital Product - Withdrawal Consent Confirmation (§312f BGB) -->
		<div style="background-color: #fff3e0; border: 1px solid #ff9800; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #e65100; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Wichtig: Widerrufsverzicht fuer digitales Produkt', 'kurs-booking' ); ?>
			</h3>
			<p style="margin: 0 0 12px 0; color: #333333; font-size: 14px;">
				<?php esc_html_e( 'Gemaess § 312f BGB bestaetigen wir hiermit die von Ihnen erteilte Zustimmung:', 'kurs-booking' ); ?>
			</p>
			<div style="background-color: #ffffff; border-left: 4px solid #ff9800; padding: 12px; margin: 12px 0; font-style: italic; color: #333333;">
				<?php
				if ( ! empty( $withdrawal_consent_text ) ) {
					echo esc_html( $withdrawal_consent_text );
				} else {
					esc_html_e( 'Ich stimme der Vertragsausfuehrung vor Ablauf der Widerrufsfrist zu und weiss, dass dadurch mein Widerrufsrecht erlischt.', 'kurs-booking' );
				}
				?>
			</div>
			<p style="margin: 12px 0 0 0; color: #e65100; font-size: 14px; font-weight: bold;">
				<?php esc_html_e( 'Mit Beginn der Bereitstellung der digitalen Inhalte ist Ihr Widerrufsrecht erloschen (§ 356 Abs. 5 BGB).', 'kurs-booking' ); ?>
			</p>
		</div>

		<!-- Digital Product - No Cancellation -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Stornierung', 'kurs-booking' ); ?>
			</h3>
			<p style="margin: 0; color: #333333; font-size: 14px;">
				<?php esc_html_e( 'Bei digitalen Produkten ist eine Stornierung nicht moeglich, da der Zugang sofort nach Zahlungseingang bereitgestellt wird.', 'kurs-booking' ); ?>
			</p>
			<?php if ( ! empty( $video_access_days ) && $video_access_days > 0 ) : ?>
			<p style="margin: 12px 0 0 0; color: #666666; font-size: 14px;">
				<?php
				printf(
					/* translators: %d: Number of days for video access */
					esc_html__( 'Ihr Zugang ist %d Tage ab Freischaltung gueltig.', 'kurs-booking' ),
					(int) $video_access_days
				);
				?>
			</p>
			<?php else : ?>
			<p style="margin: 12px 0 0 0; color: #666666; font-size: 14px;">
				<?php esc_html_e( 'Ihr Zugang ist unbegrenzt gueltig.', 'kurs-booking' ); ?>
			</p>
			<?php endif; ?>
		</div>

		<?php else : ?>
		<!-- Cancellation Policy (for non-digital products) -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Stornobedingungen', 'kurs-booking' ); ?>
			</h3>
			<div style="color: #333333;">
				<?php echo wp_kses_post( $cancellation ); ?>
			</div>
			<?php if ( ! empty( $cancel_url ) ) : ?>
			<p style="margin: 16px 0 0 0; font-size: 14px;">
				<a href="<?php echo esc_url( $cancel_url ); ?>" style="color: #dc3545;">
					<?php esc_html_e( 'Buchung stornieren', 'kurs-booking' ); ?>
				</a>
			</p>
			<?php else : ?>
			<p style="margin: 16px 0 0 0; color: #666666; font-size: 14px;">
				<?php esc_html_e( 'Eine Stornierung ist nur schriftlich per E-Mail möglich.', 'kurs-booking' ); ?>
			</p>
			<?php endif; ?>
		</div>

		<!-- Withdrawal Notice (§312g BGB) for non-digital products -->
		<div style="background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin-bottom: 24px;">
			<h3 style="font-size: 14px; text-transform: uppercase; color: #6c757d; margin: 0 0 16px 0; letter-spacing: 1px;">
				<?php esc_html_e( 'Widerrufsrecht', 'kurs-booking' ); ?>
			</h3>
			<p style="margin: 0; color: #333333; font-size: 14px;">
				<?php esc_html_e( 'Gemäß § 312g Abs. 2 Nr. 9 BGB besteht bei Dienstleistungen im Bereich Freizeitbetätigungen zu einem spezifischen Termin kein gesetzliches Widerrufsrecht.', 'kurs-booking' ); ?>
			</p>
			<?php if ( ! empty( $agb_url ) ) : ?>
			<p style="margin: 12px 0 0 0; font-size: 14px;">
				<?php esc_html_e( 'Es gelten unsere', 'kurs-booking' ); ?>
				<a href="<?php echo esc_url( $agb_url ); ?>" style="color: #007bff;">
					<?php esc_html_e( 'AGB', 'kurs-booking' ); ?>
				</a>.
			</p>
			<?php endif; ?>
		</div>
		<?php endif; ?>

		<!-- Contact -->
		<p style="font-size: 14px; color: #666666; margin-bottom: 24px;">
			<?php esc_html_e( 'Bei Fragen erreichen Sie uns unter:', 'kurs-booking' ); ?><br>
			<?php if ( ! empty( $company['phone'] ) ) : ?>
				<?php esc_html_e( 'Tel:', 'kurs-booking' ); ?> <?php echo esc_html( $company['phone'] ); ?><br>
			<?php endif; ?>
			<?php if ( ! empty( $company['email'] ) ) : ?>
				<?php esc_html_e( 'E-Mail:', 'kurs-booking' ); ?>
				<a href="mailto:<?php echo esc_attr( $company['email'] ); ?>" style="color: #007bff;">
					<?php echo esc_html( $company['email'] ); ?>
				</a>
			<?php endif; ?>
		</p>

		<p style="font-size: 16px; color: #333333;">
			<?php esc_html_e( 'Mit freundlichen Grüßen', 'kurs-booking' ); ?><br><br>
			<?php if ( ! empty( $company['ceo'] ) ) : ?>
				<?php echo esc_html( $company['ceo'] ); ?><br>
			<?php endif; ?>
			<strong><?php echo esc_html( $company['name'] ?? '' ); ?></strong>
		</p>

	</div>

	<!-- Footer -->
	<div style="background-color: #f8f9fa; padding: 24px; border-top: 1px solid #e0e0e0;">
		<?php if ( ! empty( $company ) ) : ?>
		<div style="font-size: 12px; color: #6c757d; line-height: 1.6;">
			<strong><?php echo esc_html( $company['name'] ?? '' ); ?></strong><br>
			<?php echo esc_html( $company['address'] ?? '' ); ?><br>
			<?php echo esc_html( $company['zip'] ?? '' ); ?> <?php echo esc_html( $company['city'] ?? '' ); ?><br>

			<?php if ( ! empty( $company['phone'] ) ) : ?>
				<?php esc_html_e( 'Tel:', 'kurs-booking' ); ?> <?php echo esc_html( $company['phone'] ); ?> |
			<?php endif; ?>

			<?php if ( ! empty( $company['email'] ) ) : ?>
				<?php esc_html_e( 'E-Mail:', 'kurs-booking' ); ?>
				<a href="mailto:<?php echo esc_attr( $company['email'] ); ?>" style="color: #007bff;">
					<?php echo esc_html( $company['email'] ); ?>
				</a>
			<?php endif; ?>

			<br><br>

			<?php if ( ! empty( $company['ceo'] ) ) : ?>
				<?php esc_html_e( 'Geschäftsführer:', 'kurs-booking' ); ?> <?php echo esc_html( $company['ceo'] ); ?><br>
			<?php endif; ?>

			<?php if ( ! empty( $company['tax_number'] ) ) : ?>
				<?php esc_html_e( 'Steuernummer:', 'kurs-booking' ); ?> <?php echo esc_html( $company['tax_number'] ); ?>
			<?php endif; ?>

			<?php if ( ! empty( $company['vat_id'] ) ) : ?>
				| <?php esc_html_e( 'USt-IdNr.:', 'kurs-booking' ); ?> <?php echo esc_html( $company['vat_id'] ); ?>
			<?php endif; ?>
		</div>
		<?php endif; ?>

		<?php if ( ! empty( $privacy_url ) ) : ?>
		<div style="margin-top: 16px; font-size: 12px;">
			<a href="<?php echo esc_url( $privacy_url ); ?>" style="color: #007bff;">
				<?php esc_html_e( 'Datenschutzerklärung', 'kurs-booking' ); ?>
			</a>
		</div>
		<?php endif; ?>
	</div>

</div>
