;; Events fragment components — served as HTML fragments for other apps.
;; container-cards entries, account page tickets, account page bookings.

;; ---------------------------------------------------------------------------
;; Container cards entries (fragments/container_cards_entries.html)
;; ---------------------------------------------------------------------------

(defcomp ~events-frag-entry-card (&key href name date-str time-str)
  (a :href href
     :class "flex flex-col gap-1 px-3 py-2 bg-stone-50 hover:bg-stone-100 rounded border border-stone-200 transition text-sm whitespace-nowrap flex-shrink-0 min-w-[180px]"
    (div :class "font-medium text-stone-900 truncate" name)
    (div :class "text-xs text-stone-600" date-str)
    (div :class "text-xs text-stone-500" time-str)))

(defcomp ~events-frag-entries-widget (&key cards)
  (div :class "mt-4 mb-2"
    (h3 :class "text-sm font-semibold text-stone-700 mb-2 px-2" "Events:")
    (div :class "overflow-x-auto scrollbar-hide" :style "scroll-behavior: smooth;"
      (div :class "flex gap-2 px-2" cards))))


;; ---------------------------------------------------------------------------
;; Account page tickets (fragments/account_page_tickets.html)
;; ---------------------------------------------------------------------------

(defcomp ~events-frag-ticket-item (&key href entry-name date-str calendar-name type-name badge)
  (div :class "py-4 first:pt-0 last:pb-0"
    (div :class "flex items-start justify-between gap-4"
      (div :class "min-w-0 flex-1"
        (a :href href :class "text-sm font-medium text-stone-800 hover:text-emerald-700 transition"
          entry-name)
        (div :class "mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-500"
          (span date-str)
          calendar-name
          type-name))
      (div :class "flex-shrink-0" badge))))

(defcomp ~events-frag-tickets-panel (&key items)
  (div :class "w-full max-w-3xl mx-auto px-4 py-6"
    (div :class "bg-white/70 backdrop-blur rounded-2xl shadow border border-stone-200 p-6 sm:p-8 space-y-6"
      (h1 :class "text-xl font-semibold tracking-tight" "Tickets")
      items)))

(defcomp ~events-frag-tickets-list (&key items)
  (div :class "divide-y divide-stone-100" items))


;; ---------------------------------------------------------------------------
;; Account page bookings (fragments/account_page_bookings.html)
;; ---------------------------------------------------------------------------

(defcomp ~events-frag-booking-item (&key name date-str calendar-name cost-str badge)
  (div :class "py-4 first:pt-0 last:pb-0"
    (div :class "flex items-start justify-between gap-4"
      (div :class "min-w-0 flex-1"
        (p :class "text-sm font-medium text-stone-800" name)
        (div :class "mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-stone-500"
          (span date-str)
          calendar-name
          cost-str))
      (div :class "flex-shrink-0" badge))))

(defcomp ~events-frag-bookings-panel (&key items)
  (div :class "w-full max-w-3xl mx-auto px-4 py-6"
    (div :class "bg-white/70 backdrop-blur rounded-2xl shadow border border-stone-200 p-6 sm:p-8 space-y-6"
      (h1 :class "text-xl font-semibold tracking-tight" "Bookings")
      items)))

(defcomp ~events-frag-bookings-list (&key items)
  (div :class "divide-y divide-stone-100" items))
