# ╭──────────────────────────────────────────────────────────────────────────────╮
# │  NNTmux Tmux Configuration                                                   │
# │  Modern styling with Nerd Font icons and Catppuccin-inspired colors          │
# │  Requires: Nerd Font (FiraCode, JetBrains Mono, etc.)                        │
# ╰──────────────────────────────────────────────────────────────────────────────╯

# GNU-Screen compatible prefix
set -g prefix2 C-a
bind C-a send-prefix -2

# Set copy mode to use VI keys - Activates PgUp/PgDn buttons
setw -g mode-keys vi

# Allows for faster key repetition
set -s escape-time 0

# Set 256 color display with true color support
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

# Always select window 0 when attaching
set-hook -g client-attached 'select-window -t 0; select-pane -t 0.0'

#==============================================================================
# 🎨 COLOR PALETTE - Catppuccin Mocha Inspired
#==============================================================================

# Base colors
# bg_dark   = colour234 (crust)
# bg        = colour235 (base)
# bg_light  = colour237 (surface0)
# fg        = colour255 (text)
# fg_dim    = colour250 (subtext0)
# accent    = colour75  (sapphire)
# green     = colour114 (green)
# yellow    = colour221 (yellow)
# red       = colour210 (red)
# purple    = colour141 (mauve)
# pink      = colour218 (pink)
# peach     = colour215 (peach)
# teal      = colour116 (teal)

#==============================================================================
# 📊 STATUS BAR - Modern Glassmorphism Style
#==============================================================================

# Status bar colors - darker base for contrast
set -g status-bg colour234
set -g status-fg colour255

# Status bar positioning and update interval
set -g status-position bottom
set -g status-interval 5
set -g status-justify left

# Left status - Session name with rounded powerline and icon
set -g status-left-length 50
set -g status-left "#[fg=colour234,bg=colour75,bold]   #S #[fg=colour75,bg=colour237]#[fg=colour255,bg=colour237]  #{session_windows} #[fg=colour237,bg=colour234]"

# Right status - System info with modern icons
# Shows: RAM | Current Load | Avg Load (5m) | Uptime | Time | Date
set -g status-right-length 200
set -g status-right "#[fg=colour237,bg=colour234]#[fg=colour116,bg=colour237]  #(free -h | grep 'Mem' | awk '{print $3\"/\"$2}') #[fg=colour238,bg=colour237]│#[fg=colour221,bg=colour237]  #(cat /proc/loadavg | awk '{print $1}') #[fg=colour238,bg=colour237]│#[fg=colour215,bg=colour237] 󰇙 #(cat /proc/loadavg | awk '{print $2}') #[fg=colour238,bg=colour237]│#[fg=colour114,bg=colour237] 󰥔 #(uptime -p | sed 's/up //' | sed 's/,.*//') #[fg=colour75,bg=colour237]#[fg=colour234,bg=colour75,bold]  %H:%M   %d %b "

# Window status format - inactive windows
setw -g window-status-format "#[fg=colour234,bg=colour236]#[fg=colour250,bg=colour236]  #I  #W  #[fg=colour236,bg=colour234]"

# Window status format - active window with accent color
setw -g window-status-current-format "#[fg=colour234,bg=colour75]#[fg=colour234,bg=colour75,bold]  #I  #W  #[fg=colour75,bg=colour234]"

# Window status separator
setw -g window-status-separator " "

#==============================================================================
# 🔲 PANE BORDERS - Modern Rounded Style with Icons
#==============================================================================

# Use rounded corners for pane borders (requires font with box-drawing chars)
set -g pane-border-lines heavy

# Pane border colors - subtle inactive, vibrant active
set -g pane-border-style fg=colour238
set -g pane-active-border-style fg=colour75

# Pane border format with status indicator and icons (requires tmux 3.2+)
set -g pane-border-format "#{?pane_active,#[fg=colour75]#[bg=colour235]  ,#[fg=colour245]#[bg=colour235]  }#[bold]#{pane_index}#[nobold] │ #{pane_title} #{?pane_active,#[fg=colour114]●,#[fg=colour238]○} "
set -g pane-border-status top

#==============================================================================
# 💬 MESSAGE STYLING
#==============================================================================

# Command message styling - accent color with bold
set -g message-style bg=colour75,fg=colour234,bold

# Command prompt styling
set -g message-command-style bg=colour237,fg=colour255

#==============================================================================
# 🪟 WINDOW OPTIONS
#==============================================================================

# Constrain window size to the maximum size of any client connected to that window
setw -g aggressive-resize on

# Activity monitoring with visual notification
setw -g monitor-activity on
set -g visual-activity off

# Window status activity styling - subtle notification
setw -g window-status-activity-style fg=colour221,bg=colour236,none

# Window status bell styling
setw -g window-status-bell-style fg=colour210,bg=colour236,bold

#==============================================================================
# 🔄 COPY MODE STYLING
#==============================================================================

# Copy mode colors
setw -g mode-style bg=colour75,fg=colour234,bold

#==============================================================================
# 🖱️ MOUSE & HISTORY
#==============================================================================

# Enable mouse support
set -g mouse on

# Scrollback line buffer per pane
set -g history-limit 6000

# Keep pane open after process ends - required for monitor.php re-spawns
set -g remain-on-exit on

#==============================================================================
# ⌨️ KEY BINDINGS
#==============================================================================

# Rename pane
bind t command-prompt -p " (rename-pane)" -I "#T" "select-pane -T '%%'"

# Reload config
bind r source-file ~/.tmux.conf \; display-message " Config reloaded!"

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Switch panes using Alt-arrow without 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

#==============================================================================
# 📦 POPUP STYLING (tmux 3.2+)
#==============================================================================

# Popup border style
set -g popup-border-style fg=colour75
set -g popup-border-lines rounded

