<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>{{ $title }}</title>
  <style>
    body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 40px auto;
      max-width: 900px;
      line-height: 1.6;
      color: #2c3e50;
      background-color: #fafafa;
    }

    /* HEADER */
    .header {
      text-align: center;
      border-bottom: 3px solid #3498db;
      padding-bottom: 20px;
      margin-bottom: 30px;
    }
    .header img {
      max-height: 60px;
      margin-bottom: 10px;
    }
    .header h1 {
      margin: 0;
      font-size: 26px;
      font-weight: 700;
      color: #2c3e50;
    }
    .header h2 {
      margin: 5px 0 8px;
      font-size: 16px;
      color: #7f8c8d;
      font-weight: 500;
    }
    .header p {
      font-size: 12px;
      color: #95a5a6;
    }

    /* INFO SECTIONS */
    .info-section {
      background: #fff;
      border: 1px solid #ecf0f1;
      border-radius: 8px;
      padding: 20px;
      margin-bottom: 20px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .info-section h3 {
      margin-top: 0;
      font-size: 15px;
      font-weight: 600;
      color: #34495e;
      border-bottom: 1px solid #ecf0f1;
      padding-bottom: 6px;
      margin-bottom: 15px;
    }

    /* GRID LAYOUT */
    .grid-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }

    .info-row {
      display: flex;
      margin-bottom: 8px;
    }
    .info-label {
      width: 140px;
      font-weight: 600;
      color: #7f8c8d;
      font-size: 13px;
    }
    .info-value {
      flex: 1;
      color: #2c3e50;
      font-size: 13px;
    }

    /* STATUS */
    .status {
      padding: 4px 10px;
      border-radius: 20px;
      font-weight: 600;
      text-transform: uppercase;
      font-size: 11px;
      display: inline-block;
    }
    .status-progress { background-color: #f39c12; color: white; }
    .status-review { background-color: #3498db; color: white; }
    .status-success { background-color: #27ae60; color: white; }
    .status-rejected { background-color: #e74c3c; color: white; }

    /* LINK BUTTON */
    .proof-link a {
      display: inline-block;
      padding: 6px 12px;
      background-color: #3498db;
      color: #fff;
      border-radius: 4px;
      text-decoration: none;
      font-size: 12px;
      transition: background 0.2s ease;
    }
    .proof-link a:hover {
      background-color: #2980b9;
    }

    /* FOOTER */
    .footer {
      margin-top: 30px;
      text-align: center;
      font-size: 12px;
      color: #95a5a6;
      border-top: 1px solid #ecf0f1;
      padding-top: 15px;
    }
  </style>
</head>
<body>
  <!-- HEADER -->
  <div class="header">
    <img src="https://midhouse.id/assets/midhouse-lg-BTn6Gm79.png" alt="Company Logo">
    <h1>MidHouse</h1>
    <h2>Payment Receipt</h2>
    <p>Generated on: {{ now()->format('d/m/Y H:i:s') }}</p>
  </div>

  <!-- PAYMENT INFO (2 cols) -->
  <div class="info-section">
    <h3>Payment Information</h3>
    <div class="grid-2">
      <div>
        <div class="info-row">
          <div class="info-label">Invoice ID:</div>
          <div class="info-value">{{ $payment->invoice_id }}</div>
        </div>
        <div class="info-row">
          <div class="info-label">Status:</div>
          <div class="info-value">
            <span class="status status-{{ $payment->status }}">{{ $payment->status }}</span>
          </div>
        </div>
        <div class="info-row">
          <div class="info-label">Bank Name:</div>
          <div class="info-value">{{ $payment->nama_bank }}</div>
        </div>
        <div class="info-row">
          <div class="info-label">Account Number:</div>
          <div class="info-value">{{ $payment->norek }}</div>
        </div>
      </div>
      <div>
        <div class="info-row">
          <div class="info-label">Account Holder:</div>
          <div class="info-value">{{ $payment->atas_nama }}</div>
        </div>
        <div class="info-row">
          <div class="info-label">Verified At:</div>
          <div class="info-value">
            {{ $payment->verified_at ? $payment->verified_at->format('d/m/Y H:i:s') : 'Not verified' }}
          </div>
        </div>
        <div class="info-row">
          <div class="info-label">Created At:</div>
          <div class="info-value">{{ $payment->created_at->format('d/m/Y H:i:s') }}</div>
        </div>
      </div>
    </div>
  </div>

  <!-- CUSTOMER & BOOKING INFO (side by side) -->
  <div class="grid-2">
    <div class="info-section">
      <h3>Customer Information</h3>
      <div class="info-row">
        <div class="info-label">Name:</div>
        <div class="info-value">{{ $payment->user ? $payment->user->name : 'Unknown' }}</div>
      </div>
      <div class="info-row">
        <div class="info-label">Email:</div>
        <div class="info-value">{{ $payment->user ? $payment->user->email : 'Unknown' }}</div>
      </div>
    </div>

    <div class="info-section">
      <h3>Booking Information</h3>
      @if($payment->booking)
        <div class="info-row">
          <div class="info-label">Check-in Date:</div>
          <div class="info-value">
            {{ $payment->booking->checkin ? date('d/m/Y', strtotime($payment->booking->checkin)) : 'Not set' }}
          </div>
        </div>
        <div class="info-row">
          <div class="info-label">Total Amount:</div>
          <div class="info-value">Rp {{ number_format($payment->booking->total_price, 0, ',', '.') }}</div>
        </div>
        <div class="info-row">
          <div class="info-label">Room:</div>
          <div class="info-value">
            {{ $payment->booking->room ? $payment->booking->room->kode_kamar : 'Unknown' }}
          </div>
        </div>
      @else
        <div class="info-row">
          <div class="info-label">Booking:</div>
          <div class="info-value">Booking information not available</div>
        </div>
      @endif
    </div>
  </div>

  <!-- PAYMENT PROOF -->
  <div class="info-section">
    <h3>Payment Proof</h3>
    <div class="info-row">
      <div class="info-label">Proof File:</div>
      <div class="info-value proof-link">
        @if($payment->bukti)
          <a href="http://127.0.0.1:8000{{ $payment->bukti }}" target="_blank">View Payment Proof</a>
        @else
          No proof uploaded
        @endif
      </div>
    </div>
  </div>

  <!-- FOOTER -->
  <div class="footer">
    <p>This document was generated automatically by MidHouse Universe System.</p>
    <p>For any inquiries, please contact our support team.</p>
  </div>
</body>
</html>
