;; Cart ticket components

(defcomp ~cart-ticket-type-name (&key name)
  (p :class "mt-0.5 text-[0.7rem] sm:text-xs text-stone-500" name))

(defcomp ~cart-ticket-type-hidden (&key value)
  (input :type "hidden" :name "ticket_type_id" :value value))

(defcomp ~cart-ticket-article (&key name type-name date-str price qty-url csrf entry-id type-hidden minus qty plus line-total)
  (article :class "flex flex-col sm:flex-row gap-3 sm:gap-4 rounded-2xl bg-white shadow-sm border border-stone-200 p-3 sm:p-4"
    (div :class "flex-1 min-w-0"
      (div :class "flex flex-col sm:flex-row sm:items-start justify-between gap-2 sm:gap-3"
        (div :class "min-w-0"
          (h3 :class "text-sm sm:text-base font-semibold text-stone-900" name)
          type-name
          (p :class "mt-0.5 text-[0.7rem] sm:text-xs text-stone-500" date-str))
        (div :class "text-left sm:text-right"
          (p :class "text-sm sm:text-base font-semibold text-stone-900" price)))
      (div :class "mt-3 flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4"
        (div :class "flex items-center gap-2 text-xs sm:text-sm text-stone-700"
          (span :class "text-[0.65rem] sm:text-xs uppercase tracking-wide text-stone-500" "Quantity")
          (form :action qty-url :method "post" :sx-post qty-url :sx-swap "none"
            (input :type "hidden" :name "csrf_token" :value csrf)
            (input :type "hidden" :name "entry_id" :value entry-id)
            type-hidden
            (input :type "hidden" :name "count" :value minus)
            (button :type "submit" :class "inline-flex items-center justify-center w-8 h-8 text-sm font-medium rounded-full border border-emerald-600 text-emerald-700 hover:bg-emerald-50 text-xl" "-"))
          (span :class "inline-flex items-center justify-center px-2 py-1 rounded-full bg-stone-100 text-[0.7rem] sm:text-xs font-medium" qty)
          (form :action qty-url :method "post" :sx-post qty-url :sx-swap "none"
            (input :type "hidden" :name "csrf_token" :value csrf)
            (input :type "hidden" :name "entry_id" :value entry-id)
            type-hidden
            (input :type "hidden" :name "count" :value plus)
            (button :type "submit" :class "inline-flex items-center justify-center w-8 h-8 text-sm font-medium rounded-full border border-emerald-600 text-emerald-700 hover:bg-emerald-50 text-xl" "+")))
        (div :class "flex items-center justify-between sm:justify-end gap-3"
          (p :class "text-sm sm:text-base font-semibold text-stone-900" line-total))))))

(defcomp ~cart-tickets-section (&key items)
  (div :class "mt-6 border-t border-stone-200 pt-4"
    (h2 :class "text-base font-semibold mb-2"
      (i :class "fa fa-ticket mr-1" :aria-hidden "true") " Event tickets")
    (div :class "space-y-3" items)))
