<!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;
    }
    .status-badge {
      display: inline-block;
      padding: 4px 12px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: 500;
    }
    .status-open { background: #fef3c7; color: #92400e; }
    .status-in_progress { background: #dbeafe; color: #1e40af; }
    .status-waiting_on_customer { background: #e9d5ff; color: #6b21a8; }
    .status-resolved { background: #d1fae5; color: #065f46; }
    .status-closed { background: #e5e7eb; color: #374151; }
    .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: #eff6ff;
      border-left: 4px solid #3b82f6;
      padding: 15px;
      margin: 15px 0;
      border-radius: 0 8px 8px 0;
    }
    .author {
      font-weight: 500;
      color: #1e40af;
      margin-bottom: 8px;
    }
  </style>
</head>
<body>
  <div class="header">
    <h2 style="margin: 0 0 10px 0;">New Reply on Your Support Ticket</h2>
    <span class="status-badge status-<%= @ticket.status %>"><%= @ticket.status.humanize %></span>
  </div>

  <div class="content">
    <div class="ticket-info">
      <strong><%= @ticket.ticket_number %></strong> - <%= @ticket.subject %>
    </div>

    <p>The support team has replied to your ticket:</p>

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

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

  <div class="footer">
    <p>You received this email because you have an open support ticket.</p>
    <p>Ticket: <%= @ticket.ticket_number %> | Website: <%= @website.subdomain %></p>
  </div>
</body>
</html>
