{{define "profile.tmpl"}}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile - Decor By Hannahs</title>
<link rel="stylesheet" href="/static/css/styles.css">
<script>
(function() {
  const savedTheme = localStorage.getItem('theme') || 'light';
  document.documentElement.setAttribute('data-theme', savedTheme);
})();
</script>
<script src="/static/js/alpine.js" defer></script>
<script src="/static/htmx/htmx.min.js" defer></script>
<script src="/static/js/drawer.js" defer></script>
<style>
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}
.status-pending {
  background: hsl(var(--warning) / 0.1);
  color: hsl(var(--warning));
}
.status-confirmed {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
}
.status-completed {
  background: hsl(var(--muted) / 0.5);
  color: hsl(var(--muted-foreground));
}
.status-cancelled {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
}
.booking-card {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s;
}
.booking-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
</style>
</head>

<body>
{{template "header" .}}

<main>
<div style="max-width: 1000px; margin: 0 auto;">
<div style="margin-bottom: 2rem;">
<h1 style="font-size: 2.5rem; font-weight: 700; margin-bottom: 0.5rem;">Welcome, {{.DisplayName}}</h1>
<p style="color: hsl(var(--muted-foreground)); font-size: 1.125rem;">Manage your account and bookings</p>
</div>

<div class="grid grid-cols-1" style="gap: 1.5rem;">
<div class="card">
<div class="card-header">
<h3 class="card-title">Account Information</h3>
<p class="card-description">Your personal details</p>
</div>
<div class="card-content">
<div style="display: flex; flex-direction: column; gap: 1rem;">
<div>
<strong>Email:</strong> {{.Email}}
</div>
<div style="display: flex; gap: 1rem; flex-wrap: wrap;">
<a href="{{.OrySettingsURL}}" class="btn btn-outline">Account Settings</a>
<a href="/logout" class="btn btn-outline" style="color: hsl(var(--destructive)); border-color: hsl(var(--destructive));">Logout</a>
</div>
</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h3 class="card-title">Your Bookings</h3>
<p class="card-description">View and manage your service bookings</p>
</div>
<div class="card-content">
{{if .Bookings}}
{{range .Bookings}}
<div class="booking-card">
<div style="display: flex; justify-content: space-between; align-items: start; margin-bottom: 0.75rem;">
<div>
<h4 style="font-size: 1.25rem; font-weight: 600; margin-bottom: 0.25rem;">{{.ServiceName}}</h4>
<p style="color: hsl(var(--muted-foreground)); font-size: 0.875rem;">Booked on {{.CreatedAt}}</p>
</div>
<span class="status-badge status-{{.Status}}">{{.Status}}</span>
</div>
<div style="display: grid; gap: 0.5rem; margin-bottom: 0.75rem;">
<div style="display: flex; gap: 0.5rem;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
<span style="font-size: 0.875rem;">Event Date: <strong>{{.EventDate}}</strong></span>
</div>
{{if .Address}}
<div style="display: flex; gap: 0.5rem;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
<circle cx="12" cy="10" r="3"></circle>
</svg>
<span style="font-size: 0.875rem;">{{.Address}}</span>
</div>
{{end}}
<div style="display: flex; gap: 0.5rem;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="1" x2="12" y2="23"></line>
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"></path>
</svg>
<span style="font-size: 0.875rem;">Price: <strong>${{printf "%.2f" (divf .ServicePriceCents 100)}}</strong></span>
</div>
</div>
{{if .Notes}}
<div style="padding: 0.75rem; background: hsl(var(--muted) / 0.3); border-radius: 6px; font-size: 0.875rem;">
<strong>Notes:</strong> {{.Notes}}
</div>
{{end}}
</div>
{{end}}
{{else}}
<p style="color: hsl(var(--muted-foreground));">No bookings yet. <a href="/booking" style="color: hsl(var(--primary)); text-decoration: underline;">Book your first service</a></p>
{{end}}
</div>
</div>
</div>
</div>
</main>

{{template "footer"}}
{{template "theme-script"}}
</body>
</html>
{{end}}
