unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Lista de plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/catppuccin'
set -g @plugin 'sainnhe/tmux-fzf'
# Opcional: salvar automaticamente a cada 15 minutos

set -g @continuum-restore 'on'
set -g @continuum-save-interval '15'
run '~/.tmux/plugins/tpm/tpm'

set -g @catppuccin_flavor "mocha"
set -g @catppuccin_window_status_style "rounded"

run '~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux'

# Make the status line pretty and add some modules
set -g status-right-length 100
set -g status-left-length 100
set -g status-left ""
set -g status-right "#{E:@catppuccin_status_directory} "
set -ag status-right "#{E:@catppuccin_status_application} "
set -agF status-right "#{E:@catppuccin_status_cpu}"
set -ag status-right "#{E:@catppuccin_status_uptime} "

run "~/.config/tmux/plugins/tmux-continuum/continuum.tmux"
run '~/.config/tmux/plugins/tmux-cpu/cpu.tmux'
run '~/.config/tmux/plugins/tmux-fzf/main.tmux'
run '~/.config/tmux/plugins/tmux-fzf-url/fzf-url.tmux'
run '~/.config/tmux/plugins/tmux-pomodoro/pomodoro.tmux'
run '~/.config/tmux/plugins/tmux-sensible/sensible.tmux'

# Suporte a 256 cores
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# Remove delay ao pressionar ESC (importante para Vim/Neovim)
set -s escape-time 0
set -g history-limit 50000
set -g renumber-windows on
set -g mouse on
set -g status-interval 1

# ────────────────────────────────────────────────────────────────
# KEYBINDINGS
# ────────────────────────────────────────────────────────────────

bind c new-window -c "#{pane_current_path}" -n "#{b:pane_current_path}" -S
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %

bind R source-file ~/.config/tmux/tmux.conf \; display "config reloaded!"
#bind r detach

# Navegação entre panes com Alt + setas (sem prefix!)
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Navegação entre janelas com Shift + setas
bind -n S-Left previous-window
bind -n S-Right next-window

# Resize de panes com Ctrl + setas
bind -n C-Left resize-pane -L 2
bind -n C-Right resize-pane -R 2
bind -n C-Up resize-pane -U 2
bind -n C-Down resize-pane -D 2

# ────────────────────────────────────────────────────────────────
# CATPPUCCIN MOCHA COLORS
# ────────────────────────────────────────────────────────────────

thm_bg="#1e1e2e"
thm_fg="#cdd6f4"
thm_cyan="#89dceb"
thm_black="#181825"
thm_gray="#313244"
thm_magenta="#c29df1"
thm_pink="#f5c2e7"
thm_red="#f38ba8"
thm_green="#a6e3a1"
thm_yellow="#f9e2af"
thm_blue="#89b4fa"
thm_orange="#fab387"
thm_black4="#585b70"
thm_black0="#11111b"
thm_white="#cdd6f4"

set -g @ctp_bg "#24273a"
set -g @ctp_surface_1 "#494d64"
set -g @ctp_fg "#cad3f5"
set -g @ctp_mauve "#c6a0f6"
set -g @ctp_crust "#181926" 
# ────────────────────────────────────────────────────────────────
# DESIGN DA STATUS BAR
# ────────────────────────────────────────────────────────────────

# status line
set -gF status-style "bg=#{@ctp_bg},fg=#{@ctp_fg}"
#set -g status-position bottom
#set -g status-style "bg=$thm_bg,fg=$thm_fg" 

# windows
set -gF window-status-format "#[bg=#{@ctp_surface_1},fg=#{@ctp_fg}] ##I ##W "
set -gF window-status-current-format "#[bg=$thm_black0,fg=$thm_white,bold] ##I ##W "
#set -g status-justify left
set -g window-status-separator "" 

# Status bar esquerda
#set -g status-left-length 100
set -g status-left "#[bg=$thm_magenta,fg=$thm_bg,bold] 🐑::#S #[bg=$thm_bg,fg=$thm_magenta]"


# Status bar direita
set -g status-right-length 200


# ────────────────────────────────────────────────────────────────
# DESIGN DOS PANES
# ────────────────────────────────────────────────────────────────

# Borda dos panes
set -g pane-border-style "fg=$thm_gray"
set -g pane-active-border-style "fg=$thm_magenta"

# Estilo das mensagens
set -g message-style "bg=$thm_orange,fg=$thm_bg,bold"
set -g message-command-style "bg=$thm_magenta,fg=$thm_bg,bold"
setw -g mode-style "bg=$thm_magenta,fg=$thm_bg"

# ────────────────────────────────────────────────────────────────
# EXTRAS
# ────────────────────────────────────────────────────────────────

# Destaca janela com atividade
#setw -g monitor-activity on
#set -g visual-activity on
setw -g window-status-activity-style "fg=$thm_yellow,bg=$thm_bg"

# Título da janela do terminal
set -g set-titles on
set -g set-titles-string "#S::#W"

# Display de números ao trocar de pane
set -g display-panes-time 4000
set -g display-panes-colour "$thm_gray"
set -g display-panes-active-colour "$thm_magenta"

bind t display-popup -E "zsh"
bind d display-popup -E "spf"

# ────────────────────────────────────────────────────────────────
# PLUGINS
# ────────────────────────────────────────────────────────────────

set -g @fzf-url-open "chromium"