# === EDIT FILE LOCATIONS BELOW ===

# Your todo.txt directory (this should be an absolute path)
#export TODO_DIR="/Users/gina/Documents/todo"
export TODO_DIR="${HOME:-$USERPROFILE}/Library/Mobile Documents/com~apple~CloudDocs/Documents/todo/"

# Your todo/done/report.txt locations
export TODO_FILE="$TODO_DIR/todo.txt"
export DONE_FILE="$TODO_DIR/done.txt"
export REPORT_FILE="$TODO_DIR/report.txt"

# You can customize your actions directory location
#export TODO_ACTIONS_DIR="$HOME/.config/todo"

# == EDIT FILE LOCATIONS ABOVE ===

# === COLOR MAP ===

## Text coloring and formatting is done by inserting ANSI escape codes.
## If you have re-mapped your color codes, or use the todo.txt
## output in another output system (like Conky), you may need to
## over-ride by uncommenting and editing these defaults.
## If you change any of these here, you also need to uncomment
## the defaults in the COLORS section below. Otherwise, todo.txt
## will still use the defaults!

# export BLACK='\033[0;30m'
# export RED='\033[0;31m'
# export GREEN='\033[0;32m'
# export BROWN='\033[0;33m'
# export BLUE='\033[0;34m'
# export PURPLE='\033[0;35m'
# export CYAN='\033[0;36m'
# export LIGHT_GREY='\033[0;37m'
# export DARK_GREY='\033[1;30m'
# export LIGHT_RED='\033[1;31m'
# export LIGHT_GREEN='\033[1;32m'
# export YELLOW='\033[1;33m'
# export LIGHT_BLUE='\033[1;34m'
# export LIGHT_PURPLE='\033[1;35m'
# export LIGHT_CYAN='\033[1;36m'
# export WHITE='\033[1;37m'
# export DEFAULT='\033[0m'

# === COLORS ===

## Uncomment and edit to override these defaults.
## Reference the constants from the color map above,
## or use $NONE to disable highlighting.
#
# Priorities can be any upper-case letter.
# A,B,C are highlighted; you can add coloring for more.
#
# export PRI_A=$YELLOW        # color for A priority
# export PRI_B=$GREEN         # color for B priority
# export PRI_C=$LIGHT_BLUE    # color for C priority
# export PRI_D=...            # define your own
# export PRI_X=$WHITE         # color unless explicitly defined

# There is highlighting for tasks that have been done,
# but haven't been archived yet.
#
# export COLOR_DONE=$LIGHT_GREY

# There is highlighting for projects, contexts, dates, and item numbers.
#
# export COLOR_PROJECT=$RED
# export COLOR_CONTEXT=$RED
# export COLOR_DATE=$BLUE
# export COLOR_NUMBER=$LIGHT_GREY

# There is highlighting for metadata key:value pairs e.g.
# DUE:2006-08-01 or note:MYNOTE
#
# export COLOR_META=$CYAN

# === BEHAVIOR ===

## verbosity
#
# By default, additional information and confirmation of actions (like
# "TODO: 1 added") are printed. You can suppress this via 0 or add extra
# verbosity via 2.
# export TODOTXT_VERBOSE=1

## automatic date on add
#
# Automatically prepend the current date when adding new tasks
# Equivalent to always using the -t flag
export TODOTXT_DATE_ON_ADD=1

## customize list output
#
# TODOTXT_SORT_COMMAND will filter after line numbers are
# inserted, but before colorization, and before hiding of
# priority, context, and project.
#
# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2'
export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -k 2,2 -k 1,1n'

# Use the enhanced 'today' action as default for focused daily view
export TODOTXT_DEFAULT_ACTION=today

# TODOTXT_FINAL_FILTER will filter list output after colorization,
# priority hiding, context hiding, and project hiding. That is,
# just before the list output is displayed.
#
# export TODOTXT_FINAL_FILTER='cat'
export TODOTXT_FINAL_FILTER="$HOME/.config/todo/futureTasks"

# === ULTRA-OPTIMIZED TODO.TXT COLOR CONFIGURATION ===
#
# DESIGN PHILOSOPHY:
# 1. Color Psychology: Red=urgent, Orange=important, Blue=systematic, Green=contextual
# 2. Cognitive Load: Minimize competing bright colors, use muted tones for metadata
# 3. Hierarchy: Visual intensity should match task urgency
# 4. Accessibility: Support for colorblind users and high contrast needs
# 5. Semantic Meaning: Colors should have logical associations
#
# PRIORITY SYSTEM:
# (A) = Red: "Stop what you're doing, handle this now"
# (B) = Orange: "Important but not urgent, schedule appropriately"
# (C) = Blue: "Systematic work, handle in order"
# (D) = Cyan: "Nice to have, fill-in work"
# (X) = Grey: "Unpriorized, needs triage"
#
# ---
# Ensure the actions directory is explicitly set (helps custom actions discovery).
export TODO_ACTIONS_DIR="$HOME/.config/todo"

# Enable colors (0 = colors enabled; 1 = disabled in many builds).
export TODOTXT_DISABLE_COLOR=0

# Base ANSI color codes (only set if not already defined by the CLI).
DEFAULT=${DEFAULT:-'\033[0m'}
BLACK=${BLACK:-'\033[0;30m'}
RED=${RED:-'\033[0;31m'}
GREEN=${GREEN:-'\033[0;32m'}
BROWN=${BROWN:-'\033[0;33m'}
BLUE=${BLUE:-'\033[0;34m'}
PURPLE=${PURPLE:-'\033[0;35m'}
CYAN=${CYAN:-'\033[0;36m'}
LIGHT_GREY=${LIGHT_GREY:-'\033[0;37m'}
DARK_GREY=${DARK_GREY:-'\033[1;30m'}
LIGHT_RED=${LIGHT_RED:-'\033[1;31m'}
LIGHT_GREEN=${LIGHT_GREEN:-'\033[1;32m'}
YELLOW=${YELLOW:-'\033[1;33m'}
LIGHT_BLUE=${LIGHT_BLUE:-'\033[1;34m'}
LIGHT_PURPLE=${LIGHT_PURPLE:-'\033[1;35m'}
LIGHT_CYAN=${LIGHT_CYAN:-'\033[1;36m'}
WHITE=${WHITE:-'\033[1;37m'}

# ULTRA-OPTIMIZED PRIORITY COLORS
# Based on urgency hierarchy: Red (urgent) > Orange (important) > Blue (normal)
# Uses color psychology: Red = stop/urgent, Orange = caution, Blue = calm/systematic
export PRI_A="$LIGHT_RED"     # 🔥 URGENT: Bright red for immediate attention
export PRI_B="$YELLOW"        # ⚡ IMPORTANT: Yellow/orange for high priority
export PRI_C="$LIGHT_BLUE"    # 📋 NORMAL: Cool blue for systematic work
export PRI_D="$CYAN"          # 💭 LOW: Cyan for nice-to-have items
export PRI_X="$LIGHT_GREY"    # ⚪ UNSET: Muted for unpriorized items

# ADAPTIVE THEME DETECTION
# Detect terminal theme and set appropriate colors
detect_terminal_theme() {
  # Check manual override first
  if [[ -n "$TODO_THEME" ]]; then
    echo "$TODO_THEME"
    return
  fi

  # Check terminal-specific environment variables
  case "$TERM_PROGRAM" in
    "Ghostty")
      # Ghostty sets theme info
      if [[ "$GHOSTTY_RESOURCES_DIR" == *"dark"* ]] || [[ "$COLORSCHEME" == *"dark"* ]]; then
        echo "dark"
      else
        echo "light"
      fi
      ;;
    "iTerm.app")
      # iTerm2 theme detection
      if [[ "$ITERM_PROFILE" == *"Dark"* ]] || [[ "$COLORFGBG" =~ ^[0-9]+\;0$ ]]; then
        echo "dark"
      else
        echo "light"
      fi
      ;;
    *)
      # Fallback: check COLORFGBG (foreground;background)
      if [[ "$COLORFGBG" =~ \;0$ ]]; then
        echo "dark"
      elif [[ "$COLORFGBG" =~ \;15$ ]]; then
        echo "light"
      else
        # Default to dark (most common)
        echo "dark"
      fi
      ;;
  esac
}

TERMINAL_THEME=$(detect_terminal_theme)

# ADAPTIVE SEMANTIC TOKEN COLORS
# Adjust colors based on terminal theme
if [[ "$TERMINAL_THEME" == "light" ]]; then
  # Light theme: use darker colors for visibility
  export COLOR_PROJECT="$PURPLE"
  export COLOR_CONTEXT="$GREEN"
  export COLOR_DATE="$DARK_GREY"
  export COLOR_DONE="$DARK_GREY"
  export COLOR_META="$BLUE"
  export COLOR_NUMBER="$DARK_GREY"
else
  # Dark theme: use lighter colors for visibility
  export COLOR_PROJECT="$LIGHT_PURPLE"
  export COLOR_CONTEXT="$GREEN"
  export COLOR_DATE="$LIGHT_GREY"
  export COLOR_DONE="$LIGHT_GREY"
  export COLOR_META="$CYAN"
  export COLOR_NUMBER="$LIGHT_GREY"
fi

# Reset color
export COLOR_END="$DEFAULT"

# ADVANCED COLOR FEATURES
# Enable 256-color support if terminal supports it
if [[ $COLORTERM == *"256"* ]] || [[ $TERM == *"256"* ]]; then
  # Enhanced colors for 256-color terminals
  # Overrides for better readability
  export PRI_A="\033[38;5;196m"    # Bright red (more vibrant)
  export PRI_B="\033[38;5;214m"    # Orange (true orange, not yellow)
  export COLOR_PROJECT="\033[38;5;141m"  # Light purple
  export COLOR_CONTEXT="\033[38;5;34m"   # Forest green
fi

# ACCESSIBILITY OPTIONS
# Uncomment for high contrast mode (good for bright terminals)
# export PRI_A="$WHITE\033[41m"     # White text on red background
# export PRI_B="$BLACK\033[43m"     # Black text on yellow background
# export PRI_C="$WHITE\033[44m"     # White text on blue background

# Uncomment for colorblind-friendly mode (uses shape + color)
# export PRI_A="$LIGHT_RED▲"        # Triangle for urgent
# export PRI_B="$YELLOW●"           # Circle for important
# export PRI_C="$LIGHT_BLUE■"       # Square for normal

# --- end color configuration ---
