<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
      line-height: 1.6;
      color: #333;
      max-width: 600px;
      margin: 0 auto;
      padding: 20px;
    }
    .header { padding: 20px 0; border-bottom: 1px solid #eee; }
    .priority-badge {
      display: inline-block;
      padding: 4px 12px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: bold;
      text-transform: uppercase;
    }
    .priority-low { background: #e5e7eb; color: #374151; }
    .priority-normal { background: #dbeafe; color: #1e40af; }
    .priority-high { background: #ffedd5; color: #9a3412; }
    .priority-urgent { background: #fee2e2; color: #991b1b; }
    .content { padding: 20px 0; }
    .ticket-info { background: #f9fafb; padding: 15px; border-radius: 8px; margin: 15px 0; }
    .button {
      display: inline-block;
      background-color: #3b82f6;
      color: white;
      text-decoration: none;
      padding: 12px 24px;
      border-radius: 6px;
      font-weight: 500;
    }
    .footer {
      font-size: 12px;
      color: #9ca3af;
      border-top: 1px solid #eee;
      padding-top: 20px;
      margin-top: 30px;
    }
    .message-content {
      background: #fef3c7;
      border-left: 4px solid #f59e0b;
      padding: 15px;
      margin: 15px 0;
      border-radius: 0 8px 8px 0;
    }
    .author {
      font-weight: 500;
      color: #92400e;
      margin-bottom: 8px;
    }
  </style>
</head>
<body>
  <div class="header">
    <h2 style="margin: 0 0 10px 0;">Customer Reply</h2>
    <span class="priority-badge priority-<%= @ticket.priority %>"><%= @ticket.priority %></span>
  </div>

  <div class="content">
    <div class="ticket-info">
      <strong><%= @ticket.ticket_number %></strong> - <%= @ticket.subject %><br>
      <span style="color: #6b7280; font-size: 14px;">Website: <%= @website.subdomain %></span>
    </div>

    <p>The customer has replied to this ticket:</p>

    <div class="message-content">
      <div class="author"><%= @message.author_name %></div>
      <%= simple_format(@message.content) %>
    </div>

    <p style="text-align: center; margin-top: 25px;">
      <a href="<%= tenant_admin_support_ticket_url(@ticket, host: ENV.fetch('BASE_DOMAIN', 'localhost:3000')) %>" class="button">
        View & Reply
      </a>
    </p>
  </div>

  <div class="footer">
    <p>This ticket requires a response.</p>
  </div>
</body>
</html>
