<?php
if ( ! defined( 'ABSPATH' ) ) exit;
$bingocr_pickup_time = substr( (string) ( $reservation['pickup_time'] ?? '' ), 0, 5 );
$bingocr_return_time = substr( (string) ( $reservation['return_time'] ?? '' ), 0, 5 );
?>
<!DOCTYPE html>
<html lang="<?php echo esc_attr( $reservation['language'] ?? 'en' ); ?>">
<head>
<meta charset="UTF-8">
<style>
  body{font-family:Arial,sans-serif;color:#333;margin:0;padding:0}
  .wrap{max-width:600px;margin:0 auto;padding:24px}
  .header{background:#e63946;color:#fff;padding:20px 24px;border-radius:6px 6px 0 0}
  .header h1{margin:0;font-size:22px}
  .content{background:#fff;border:1px solid #e0e0e0;padding:24px;border-radius:0 0 6px 6px}
  .ref-box{background:#f5f5f5;border-left:4px solid #e63946;padding:12px 16px;margin:16px 0;font-size:18px;font-weight:bold}
  .section-title{font-size:12px;text-transform:uppercase;letter-spacing:1px;color:#888;margin:22px 0 4px;font-weight:bold}
  table{width:100%;border-collapse:collapse;margin:8px 0 16px}
  td{padding:8px 0;border-bottom:1px solid #f0f0f0}
  td:first-child{color:#666;width:55%}
  td:last-child{text-align:right}
  .total-row td{font-weight:bold;font-size:16px;border-bottom:none;color:#e63946}
  .deposit-row td{color:#888;font-style:italic;border-bottom:none}
  .footer{text-align:center;color:#999;font-size:12px;margin-top:24px}
</style>
</head>
<body>
<div class="wrap">
  <div class="header">
    <h1><?php echo esc_html( $settings['company_name'] ); ?></h1>
  </div>
  <div class="content">
    <p><?php echo esc_html( $l['dear'] . ' ' . $reservation['customer_name'] ) . ','; ?></p>
    <p><?php echo esc_html( $l['intro_received'] ); ?></p>

    <div class="ref-box"><?php echo esc_html( $l['reference'] ); ?> <?php echo esc_html( $reservation['reservation_number'] ); ?></div>

    <div class="section-title"><?php echo esc_html( $l['booking_details'] ); ?></div>
    <table>
      <tr><td><?php echo esc_html( $l['vehicle'] ); ?></td><td><?php echo esc_html( $reservation['brand'] . ' ' . $reservation['model'] ); ?></td></tr>
      <tr><td><?php echo esc_html( $l['pickup'] ); ?></td><td><?php echo esc_html( $reservation['pickup_date'] . ' — ' . $bingocr_pickup_time ); ?></td></tr>
      <tr><td><?php echo esc_html( $l['return'] ); ?></td><td><?php echo esc_html( $reservation['return_date'] . ' — ' . $bingocr_return_time ); ?></td></tr>
      <?php if ( ! empty( $reservation['pickup_location_name'] ) ) : ?>
      <tr><td><?php echo esc_html( $l['pickup_location'] ); ?></td><td><?php echo esc_html( $reservation['pickup_location_name'] ); ?></td></tr>
      <?php endif; ?>
      <?php if ( ! empty( $reservation['dropoff_location_name'] ) ) : ?>
      <tr><td><?php echo esc_html( $l['dropoff_location'] ); ?></td><td><?php echo esc_html( $reservation['dropoff_location_name'] ); ?></td></tr>
      <?php endif; ?>
      <tr><td><?php echo esc_html( $l['status'] ); ?></td><td><?php echo esc_html( BingoCR_Email::status_label( $reservation['status'], $l ) ); ?></td></tr>
      <?php if ( ! empty( $reservation['payment_method'] ) ) : ?>
      <tr><td><?php echo esc_html( $l['payment'] ); ?></td><td><?php echo esc_html( BingoCR_Email::payment_label( $reservation['payment_method'], $l ) ); ?></td></tr>
      <?php endif; ?>
    </table>

    <?php include __DIR__ . '/partial-summary.php'; ?>

    <?php if ( ! empty( $settings['payment_instructions'] ) ) : ?>
    <p><strong><?php echo esc_html( $l['payment'] ); ?>:</strong><br><?php echo wp_kses_post( $settings['payment_instructions'] ); ?></p>
    <?php endif; ?>

    <?php if ( ! empty( $reservation['notes'] ) ) : ?>
    <p><strong><?php echo esc_html( $l['notes'] ); ?></strong> <?php echo esc_html( $reservation['notes'] ); ?></p>
    <?php endif; ?>

    <p><?php echo esc_html( $l['outro'] ); ?></p>
  </div>
  <div class="footer"><?php echo esc_html( $settings['company_name'] ); ?></div>
</div>
</body>
</html>
