-- Catppuccin Mocha Theme for Lumacs
-- Enhanced version with rich styling using all available face attributes
-- Based on the popular Catppuccin color scheme (Mocha variant)

local theme = editor:create_and_register_theme("catppuccin-mocha")

-- Catppuccin Mocha color palette
local base     = lumacs.Color(30, 30, 46)      -- #1e1e2e
local mantle   = lumacs.Color(24, 24, 37)      -- #181825
local crust    = lumacs.Color(17, 17, 27)      -- #11111b
local surface0 = lumacs.Color(49, 50, 68)      -- #313244
local surface1 = lumacs.Color(69, 71, 90)      -- #45475a
local surface2 = lumacs.Color(88, 91, 112)     -- #585b70
local overlay0 = lumacs.Color(108, 112, 134)   -- #6c7086
local overlay1 = lumacs.Color(127, 132, 156)   -- #7f849c
local overlay2 = lumacs.Color(147, 153, 178)   -- #9399b2
local subtext0 = lumacs.Color(166, 173, 200)   -- #a6adc8
local subtext1 = lumacs.Color(186, 194, 222)   -- #bac2de
local text     = lumacs.Color(205, 214, 244)   -- #cdd6f4

-- Catppuccin colors
local rosewater = lumacs.Color(245, 224, 220)  -- #f5e0dc
local flamingo  = lumacs.Color(242, 205, 205)  -- #f2cdcd
local pink      = lumacs.Color(245, 194, 231)  -- #f5c2e7
local mauve     = lumacs.Color(203, 166, 247)  -- #cba6f7
local red       = lumacs.Color(243, 139, 168)  -- #f38ba8
local maroon    = lumacs.Color(235, 160, 172)  -- #eba0ac
local peach     = lumacs.Color(250, 179, 135)  -- #fab387
local yellow    = lumacs.Color(249, 226, 175)  -- #f9e2af
local green     = lumacs.Color(166, 227, 161)  -- #a6e3a1
local teal      = lumacs.Color(148, 226, 213)  -- #94e2d5
local sky       = lumacs.Color(137, 220, 235)  -- #89dceb
local sapphire  = lumacs.Color(116, 199, 236)  -- #74c7ec
local blue      = lumacs.Color(137, 180, 250)  -- #89b4fa
local lavender  = lumacs.Color(180, 190, 254)  -- #b4befe

-- === SET ALL THEME ELEMENTS (Complete theming) ===

-- Special elements (base)
theme:set_color(lumacs.ThemeElement.Background, text, base)
theme:set_color(lumacs.ThemeElement.Foreground, text, base)
theme:set_color(lumacs.ThemeElement.Normal, text, base)

-- Text syntax elements
theme:set_color(lumacs.ThemeElement.Keyword, mauve, base)
theme:set_color(lumacs.ThemeElement.String, green, base)
theme:set_color(lumacs.ThemeElement.Comment, overlay0, base)
theme:set_color(lumacs.ThemeElement.Function, blue, base)
theme:set_color(lumacs.ThemeElement.Type, yellow, base)
theme:set_color(lumacs.ThemeElement.Number, peach, base)
theme:set_color(lumacs.ThemeElement.Constant, peach, base)
theme:set_color(lumacs.ThemeElement.Variable, text, base)
theme:set_color(lumacs.ThemeElement.Builtin, red, base)
theme:set_color(lumacs.ThemeElement.Preprocessor, pink, base)
theme:set_color(lumacs.ThemeElement.Operator, sky, base)
theme:set_color(lumacs.ThemeElement.Error, text, red)
theme:set_color(lumacs.ThemeElement.Warning, base, yellow)

-- UI elements
theme:set_color(lumacs.ThemeElement.StatusLine, text, surface0)
theme:set_color(lumacs.ThemeElement.StatusLineInactive, overlay1, surface1)
theme:set_color(lumacs.ThemeElement.MessageLine, text, base)
theme:set_color(lumacs.ThemeElement.LineNumber, overlay0, base)
theme:set_color(lumacs.ThemeElement.LineNumberCurrent, lavender, base)
theme:set_color(lumacs.ThemeElement.Cursor, base, text)
theme:set_color(lumacs.ThemeElement.Selection, text, surface1)
theme:set_color(lumacs.ThemeElement.SearchMatch, base, yellow)
theme:set_color(lumacs.ThemeElement.SearchFail, text, red)
theme:set_color(lumacs.ThemeElement.MatchParen, base, pink)

-- Minibuffer elements
theme:set_color(lumacs.ThemeElement.MinibufferPrompt, lavender, base)
theme:set_color(lumacs.ThemeElement.MinibufferInput, text, surface0)
theme:set_color(lumacs.ThemeElement.MinibufferCompletion, subtext1, surface0)
theme:set_color(lumacs.ThemeElement.MinibufferMatch, base, mauve)

-- Window elements
theme:set_color(lumacs.ThemeElement.WindowBorder, surface1, base)
theme:set_color(lumacs.ThemeElement.WindowBorderActive, lavender, base)
theme:set_color(lumacs.ThemeElement.WindowSeparator, surface1, base)
theme:set_color(lumacs.ThemeElement.TabLine, overlay1, surface0)
theme:set_color(lumacs.ThemeElement.TabLineSel, text, mauve)

-- === SYNTAX HIGHLIGHTING FACES (Rich Styling) ===

-- Base default face
local default_face = lumacs.FaceAttributes()
default_face.foreground = text
default_face.background = base
default_face.family = "Iosevka"
default_face.height = 110  -- 11pt
default_face.weight = lumacs.FontWeight.Normal
default_face.slant = lumacs.FontSlant.Normal
theme:set_face("default", default_face)

-- Keywords (mauve, bold)
local keyword_face = lumacs.FaceAttributes()
keyword_face.foreground = mauve
keyword_face.weight = lumacs.FontWeight.Bold
keyword_face.inherit = "default"
theme:set_face("font-lock-keyword-face", keyword_face)

-- Strings (green, italic)
local string_face = lumacs.FaceAttributes()
string_face.foreground = green
string_face.slant = lumacs.FontSlant.Italic
string_face.inherit = "default"
theme:set_face("font-lock-string-face", string_face)

-- Comments (overlay0, italic, light)
local comment_face = lumacs.FaceAttributes()
comment_face.foreground = overlay0
comment_face.slant = lumacs.FontSlant.Italic
comment_face.weight = lumacs.FontWeight.Light
comment_face.inherit = "default"
theme:set_face("font-lock-comment-face", comment_face)

-- Function names (blue, bold)
local function_face = lumacs.FaceAttributes()
function_face.foreground = blue
function_face.weight = lumacs.FontWeight.Bold
function_face.inherit = "default"
theme:set_face("font-lock-function-name-face", function_face)

-- Type names (yellow, bold)
local type_face = lumacs.FaceAttributes()
type_face.foreground = yellow
type_face.weight = lumacs.FontWeight.Bold
type_face.inherit = "default"
theme:set_face("font-lock-type-face", type_face)

-- Variables (text, normal)
local variable_face = lumacs.FaceAttributes()
variable_face.foreground = text
variable_face.inherit = "default"
theme:set_face("font-lock-variable-name-face", variable_face)

-- Constants (peach, bold)
local constant_face = lumacs.FaceAttributes()
constant_face.foreground = peach
constant_face.weight = lumacs.FontWeight.Bold
constant_face.inherit = "default"
theme:set_face("font-lock-constant-face", constant_face)

-- Builtin functions (red, bold, underline)
local builtin_face = lumacs.FaceAttributes()
builtin_face.foreground = red
builtin_face.weight = lumacs.FontWeight.Bold
builtin_face.underline = true
builtin_face.inherit = "default"
theme:set_face("font-lock-builtin-face", builtin_face)

-- === UI FACES (Rich Styling) ===

-- Mode line (status bar) - surface0 background, text foreground
local modeline_face = lumacs.FaceAttributes()
modeline_face.foreground = text
modeline_face.background = surface0
modeline_face.weight = lumacs.FontWeight.Bold
modeline_face.family = "Inter"
modeline_face.height = 100
theme:set_face("mode-line", modeline_face)

-- Inactive mode line
local modeline_inactive_face = lumacs.FaceAttributes()
modeline_inactive_face.foreground = overlay1
modeline_inactive_face.background = surface1
modeline_inactive_face.inherit = "mode-line"
theme:set_face("mode-line-inactive", modeline_inactive_face)

-- Minibuffer prompt (lavender, bold)
local minibuffer_prompt_face = lumacs.FaceAttributes()
minibuffer_prompt_face.foreground = lavender
minibuffer_prompt_face.weight = lumacs.FontWeight.Bold
minibuffer_prompt_face.inherit = "default"
theme:set_face("minibuffer-prompt", minibuffer_prompt_face)

-- Line numbers (overlay0, small)
local line_number_face = lumacs.FaceAttributes()
line_number_face.foreground = overlay0
line_number_face.background = base
line_number_face.family = "Iosevka"
line_number_face.height = 90
line_number_face.weight = lumacs.FontWeight.Light
theme:set_face("line-number", line_number_face)

-- Current line number (highlighted)
local line_number_current_face = lumacs.FaceAttributes()
line_number_current_face.foreground = lavender
line_number_current_face.weight = lumacs.FontWeight.Bold
line_number_current_face.inherit = "line-number"
theme:set_face("line-number-current", line_number_current_face)

-- Cursor (inverse, bold)
local cursor_face = lumacs.FaceAttributes()
cursor_face.foreground = base
cursor_face.background = text
cursor_face.inverse = true
cursor_face.weight = lumacs.FontWeight.Bold
cursor_face.inherit = "default"
theme:set_face("cursor", cursor_face)

-- Selection/region (surface1 background)
local region_face = lumacs.FaceAttributes()
region_face.foreground = text
region_face.background = surface1
region_face.weight = lumacs.FontWeight.Bold
theme:set_face("region", region_face)

-- Search matches (yellow background, bold)
local isearch_face = lumacs.FaceAttributes()
isearch_face.foreground = base
isearch_face.background = yellow
isearch_face.weight = lumacs.FontWeight.Bold
theme:set_face("isearch", isearch_face)

-- Error (red background, bold, underline)
local error_face = lumacs.FaceAttributes()
error_face.foreground = text
error_face.background = red
error_face.weight = lumacs.FontWeight.Bold
error_face.underline = true
theme:set_face("error", error_face)

-- Warning (yellow, bold)
local warning_face = lumacs.FaceAttributes()
warning_face.foreground = yellow
warning_face.weight = lumacs.FontWeight.Bold
warning_face.inherit = "default"
theme:set_face("warning", warning_face)

-- Success (green, bold)
local success_face = lumacs.FaceAttributes()
success_face.foreground = green
success_face.weight = lumacs.FontWeight.Bold
success_face.inherit = "default"
theme:set_face("success", success_face)

print(string.format("Enhanced theme '%s' loaded with complete Catppuccin Mocha styling.", theme:name()))