#!/usr/bin/env bash
set -euo pipefail

command -v zenity >/dev/null 2>&1 || { echo 'zenity is required.' >&2; exit 1; }
current="$(gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null || true)"
light=false dark=false fallback=false
case "$current" in
  *BRZ-HealthOS-Light*) light=true ;;
  *BRZ-HealthOS-Dark*) dark=true ;;
  *) fallback=true ;;
esac
choice="$(zenity --list --radiolist --title='BRZ HealthOS Appearance' --width=560 --height=360 \
  --text='<big><b>Choose your HealthOS appearance</b></big>\nChanges apply immediately. Ubuntu/Yaru remains available as the recovery fallback.' \
  --column='' --column='Profile' --column='Description' \
  "$light" light 'BRZ HealthOS Light — bright pink/lilac theme' \
  "$dark" dark 'BRZ HealthOS Dark — dark pink/lilac theme' \
  "$fallback" default 'Ubuntu/Yaru fallback — recovery appearance' 2>/dev/null)" || exit 0
brz-healthos-theme "$choice"
zenity --info --title='BRZ HealthOS Appearance' --text="Appearance changed to: $choice\n\nLog out and back in if the top panel does not update immediately." 2>/dev/null || true
