;; Newsletter management components

(defcomp ~account-newsletter-desc (&key description)
  (when description
    (p :class "text-xs text-stone-500 mt-0.5 truncate" description)))

(defcomp ~account-newsletter-toggle (&key id url hdrs target cls checked knob-cls)
  (div :id id :class "flex items-center"
    (button :sx-post url :sx-headers hdrs :sx-target target :sx-swap "outerHTML"
      :class cls :role "switch" :aria-checked checked
      (span :class knob-cls))))


(defcomp ~account-newsletter-item (&key name desc toggle)
  (div :class "flex items-center justify-between py-4 first:pt-0 last:pb-0"
    (div :class "min-w-0 flex-1"
      (p :class "text-sm font-medium text-stone-800" name)
      desc)
    (div :class "ml-4 flex-shrink-0" toggle)))

(defcomp ~account-newsletter-list (&key items)
  (div :class "divide-y divide-stone-100" items))

(defcomp ~account-newsletter-empty ()
  (p :class "text-sm text-stone-500" "No newsletters available."))

(defcomp ~account-newsletters-panel (&key list)
  (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" "Newsletters")
      list)))
