# =============================================================================
# OS-SPECIFIC ALIASES
# =============================================================================
if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v apt-get >/dev/null 2>&1; then
    # Linux Only System update & cleanup
    alias uu='sudo apt-get update && \
    sudo apt-get upgrade -y && \
    sudo apt-get full-upgrade -y && \
    sudo apt-get autoremove -y && \
    sudo apt-get autoclean -y && \
    sudo apt-get clean'
elif [[ "$OSTYPE" == "darwin"* ]]; then
    # macOS Only
    alias flushdns='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder'
fi

# =============================================================================
# UNIVERSAL GIT ALIASES (Fixed: Removed broken "$@" from aliases)
# =============================================================================
alias gph='git push'
alias gco='git checkout'
alias gbh='git branch'
alias gmt='git commit'
alias gpl='git pull'
alias grb='git rebase'
alias grt='git reset'
alias gst='git status'
alias gsts='git stash push --staged'
# Keep staged changes in the index; the stash also records their snapshot.
alias gstu='git stash push --keep-index --include-untracked'
alias gsta='git stash push --include-untracked'
alias grmrf='git checkout -- . && git clean -fd'

# Create a feature worktree from origin/integration: gwa pill
gwa() {
    if [ "$#" -ne 1 ] || [ -z "$1" ]; then
        printf 'Usage: gwa <feature-name>\n' >&2
        return 1
    fi
    git worktree add "../worktree/$1" -b "feature/$1" origin/integration
}

# List loaded aliases, optionally filtered by a case-insensitive keyword.
ah() {
    if [ "$#" -eq 0 ]; then
        alias
    else
        alias | command grep -iF -- "$*"
    fi
}
