unbind r
bind r source-file ~/.tmux.conf

set -g prefix C-a

# Basic options
set -g mouse on
set -g default-terminal "tmux-256color"
set -g status on
set -g status-position top

# Load catppuccin colors first
set -g @catppuccin_flavor "mocha"
run ~/.config/tmux/plugins/catppuccin/catppuccin.tmux

# Override status bar with transparent styling (AFTER the theme is loaded)
set -g status-style "bg=default"
set -g status-left ""
set -g status-right-length 100
set -g status-left-length 100

# Window styling
set -g window-status-format "#[fg=#{@thm_fg},bg=default] #I #W "
set -g window-status-current-format "#[fg=#{@thm_blue},bg=default,bold] #I #W "

# Status line right elements
set -g status-right "#[fg=#{@thm_blue},bg=default] #{pane_current_path} "
set -ag status-right "#[fg=#{@thm_pink},bg=default] #S "
set -ag status-right "#[fg=#{@thm_green},bg=default] #h "

# List of other plugins
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'jimeh/tmuxifier'

# Pane borders
set -g pane-border-style "fg=#{@thm_gray}"
set -g pane-active-border-style "fg=#{@thm_blue}"

# Navigation
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

# Smart pane switching with awareness of Vim splits
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'