<?php
if ( ! defined( 'ABSPATH' ) ) exit;
$bingocr_admin_url   = admin_url( 'admin.php?page=bingocr-reservations' );
$bingocr_pickup_time = substr( (string) ( $reservation['pickup_time'] ?? '' ), 0, 5 );
$bingocr_return_time = substr( (string) ( $reservation['return_time'] ?? '' ), 0, 5 );
?>
<!DOCTYPE html>
<html lang="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:#1d2327;color:#fff;padding:16px 24px;border-radius:6px 6px 0 0}
  .content{background:#fff;border:1px solid #e0e0e0;padding:24px;border-radius:0 0 6px 6px}
  .section-title{font-size:12px;text-transform:uppercase;letter-spacing:1px;color:#888;margin:18px 0 4px;font-weight:bold}
  table{width:100%;border-collapse:collapse;margin:8px 0 12px}
  td{padding:7px 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:15px;border-bottom:none}
  .deposit-row td{color:#888;font-style:italic;border-bottom:none}
  .btn{display:inline-block;background:#e63946;color:#fff;padding:10px 20px;text-decoration:none;border-radius:4px;margin-top:16px}
</style>
</head>
<body>
<div class="wrap">
  <div class="header"><h2 style="margin:0"><?php echo esc_html( $l['new_booking'] ); ?></h2></div>
  <div class="content">
    <div class="section-title"><?php echo esc_html( $l['booking_details'] ); ?></div>
    <table>
      <tr><td><?php echo esc_html( rtrim( $l['reference'], ':' ) ); ?></td><td><strong><?php echo esc_html( $reservation['reservation_number'] ); ?></strong></td></tr>
      <tr><td><?php echo esc_html( $l['customer'] ); ?></td><td><?php echo esc_html( $reservation['customer_name'] ); ?></td></tr>
      <tr><td><?php echo esc_html( $l['email'] ); ?></td><td><?php echo esc_html( $reservation['customer_email'] ); ?></td></tr>
      <tr><td><?php echo esc_html( $l['phone'] ); ?></td><td><?php echo esc_html( $reservation['customer_phone'] ?: '—' ); ?></td></tr>
      <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; ?>
      <?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( $reservation['notes'] ) ) : ?>
    <p><strong><?php echo esc_html( $l['notes'] ); ?></strong> <?php echo esc_html( $reservation['notes'] ); ?></p>
    <?php endif; ?>

    <a href="<?php echo esc_url( $bingocr_admin_url ); ?>" class="btn"><?php echo esc_html( $l['view_admin'] ); ?></a>
  </div>
</div>
</body>
</html>
