#!/usr/bin/env bash
# ZION TERMINAL - Gera o tema do tmux a partir do tema ativo do ZION
# Cyberdeck criado por Pablo Murad em 2026
# Escreve ~/.tmux-zion-tema.conf e recarrega se houver servidor tmux.
export LC_ALL=C
[ -r "$HOME/.zion-tema" ] && . "$HOME/.zion-tema" 2>/dev/null
tema="${ZION_TEMA:-ice}"
case "$tema" in
  amber) bg=94;  fg=231; abg=172; afg=16; pa=214; pb=94  ;;
  green) bg=22;  fg=231; abg=34;  afg=16; pa=46;  pb=22  ;;
  *)     bg=24;  fg=231; abg=39;  afg=16; pa=51;  pb=24  ;;
esac
OUT="$HOME/.tmux-zion-tema.conf"
cat > "$OUT" <<EOF
# ZION TERMINAL - tema tmux ($tema) - gerado automaticamente
set -g status-style "bg=colour$bg,fg=colour$fg"
set -g window-status-current-style "bg=colour$abg,fg=colour$afg,bold"
set -g pane-active-border-style "fg=colour$pa"
set -g pane-border-style "fg=colour$pb"
set -g message-style "bg=colour$abg,fg=colour$afg"
set -g status-left " #[bold]»Z»#[nobold] #S "
set -g status-left-length 24
set -g status-right "#(/opt/zion-terminal/bin/zion-tmux-status) "
set -g status-right-length 60
EOF
tmux source-file "$OUT" 2>/dev/null
[ "${1:-}" = "-q" ] || echo "tema tmux '$tema' aplicado ($OUT)"
