// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

// Package ui provides lipgloss styles for terminal output.
package ui

import (
	"time"

	"github.com/charmbracelet/lipgloss"
	"github.com/klauspost/lctime"
)

// Terminal output styles using ANSI colors for broad compatibility.
var (
	Success = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) // green
	Warning = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) // yellow
	Error   = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) // red
	Bold    = lipgloss.NewStyle().Bold(true)
)

// Heading styles with backgrounds for contrast on any theme.
var (
	// H1 is the primary heading style (top-level items).
	H1 = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("0")).
		Background(lipgloss.Color("4")).
		Padding(0, 1)
	// H2 is the secondary heading style (nested items).
	H2 = lipgloss.NewStyle().
		Bold(true).
		Foreground(lipgloss.Color("0")).
		Background(lipgloss.Color("6")).
		Padding(0, 1)
)

// FormatDate formats a time.Time as a date string using the user's locale.
// Locale is auto-detected from LC_TIME, LC_ALL, or LANG environment variables.
func FormatDate(t time.Time) string {
	return lctime.Strftime("%x", t)
}
