#
# Copyright 2019 FormDev Software GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# This file is loaded for all dark themes (that extend class FlatDarkLaf).
#
# Documentation:
#  - https://www.formdev.com/flatlaf/properties-files/
#  - https://www.formdev.com/flatlaf/how-to-customize/
#
# NOTE: Avoid copying the whole content of this file to own properties files.
#       This will make upgrading to newer FlatLaf versions complex and error-prone.
#       Instead, copy and modify only those properties that you need to alter.
#

# Colors and style mostly based on Darcula theme from IntelliJ IDEA Community Edition,
# which is licensed under the Apache 2.0 license. Copyright 2000-2019 JetBrains s.r.o.
# See: https://github.com/JetBrains/intellij-community/

#---- variables ----

# general background and foreground (text color)
@background = #3c3f41
@foreground = #bbb
@disabledBackground = @background
@disabledForeground = shade(@foreground,25%)

# component background
@buttonBackground = tint(@background,9%)
@componentBackground = tint(@background,5%)
@menuBackground = darken(@background,5%)

# selection
@selectionBackground = @accentSelectionBackground
@selectionForeground = contrast(@selectionBackground, @background, @foreground, 25%)
@selectionInactiveBackground = spin(saturate(shade(@selectionBackground,70%),20%),-15)
@selectionInactiveForeground = @foreground

# menu
@menuSelectionBackground = @selectionBackground
@menuHoverBackground = lighten(@menuBackground,10%,derived)
@menuCheckBackground = darken(@menuSelectionBackground,10%,derived noAutoInverse)
@menuAcceleratorForeground = darken(@foreground,15%)
@menuAcceleratorSelectionForeground = @selectionForeground

# misc
@cellFocusColor = lighten(@selectionBackground,10%)
@icon = shade(@foreground,7%)

# accent colors (blueish)
#   set @accentColor to use single accent color or
#   modify @accentBaseColor to use variations of accent base color
@accentColor = systemColor(accent,null)
@accentBaseColor = #4B6EAF
@accentBase2Color = lighten(saturate(spin(@accentBaseColor,-8),13%),5%)
#   accent color variations
@accentFocusColor               = if(@accentColor, @accentColor, shade(spin(@accentBaseColor,-8),20%))
@accentLinkColor                = if(@accentColor, @accentColor, lighten(saturate(spin(@accentBaseColor,-5),50%),16%))
@accentSelectionBackground      = if(@accentColor, @accentColor, @accentBaseColor)
@accentSliderColor              = if(@accentColor, @accentColor, @accentBase2Color)
@accentUnderlineColor           = if(@accentColor, @accentColor, @accentBase2Color)
@accentButtonDefaultBackground  = if(@accentColor, @accentColor, darken(spin(@accentBaseColor,-8),13%))

# for buttons within components (e.g. combobox or spinner)
@buttonArrowColor = shade(@foreground,17%)
@buttonDisabledArrowColor = darken(@buttonArrowColor,25%)
@buttonHoverArrowColor = lighten(@buttonArrowColor,10%,derived noAutoInverse)
@buttonPressedArrowColor = lighten(@buttonArrowColor,20%,derived noAutoInverse)

# Drop (use lazy colors for IntelliJ platform themes, which usually do not specify these colors)
@dropCellBackground = darken(List.selectionBackground,10%,lazy)
@dropCellForeground = lazy(List.selectionForeground)
@dropLineColor = lighten(List.selectionBackground,10%,lazy)
@dropLineShortColor = lighten(List.selectionBackground,30%,lazy)


#---- system colors ----

activeCaption = #434E60
inactiveCaption = #393C3D
controlHighlight = darken($controlShadow,20%)
controlLtHighlight = darken($controlShadow,25%)
controlDkShadow = lighten($controlShadow,10%)


#---- Button ----

Button.background = @buttonBackground
Button.hoverBackground = lighten($Button.background,3%,derived)
Button.pressedBackground = lighten($Button.background,6%,derived)
Button.selectedBackground = lighten($Button.background,10%,derived)
Button.selectedForeground = $Button.foreground
Button.disabledSelectedBackground = lighten($Button.background,3%,derived)

Button.borderColor = tint($Button.background,10%)
Button.disabledBorderColor = $Button.borderColor
Button.focusedBorderColor = $Component.focusedBorderColor
Button.hoverBorderColor = $Button.focusedBorderColor

Button.innerFocusWidth = 1

Button.default.background = @accentButtonDefaultBackground
Button.default.foreground = contrast($Button.default.background, @background, $Button.foreground, 25%)
Button.default.hoverBackground = lighten($Button.default.background,3%,derived)
Button.default.pressedBackground = lighten($Button.default.background,6%,derived)
Button.default.borderColor = tint($Button.default.background,15%)
Button.default.hoverBorderColor = tint($Button.default.background,18%)
Button.default.focusedBorderColor = $Button.default.hoverBorderColor
Button.default.focusColor = lighten($Component.focusColor,3%)
Button.default.boldText = true

Button.toolbar.hoverBackground = lighten($Button.background,1%,derived)
Button.toolbar.pressedBackground = lighten($Button.background,4%,derived)
Button.toolbar.selectedBackground = lighten($Button.background,7%,derived)


#---- CheckBox ----

CheckBox.icon.focusWidth = 1

# enabled
CheckBox.icon.borderColor = tint($Component.borderColor,5%)
CheckBox.icon.background = tint(@background,5%)
CheckBox.icon.selectedBorderColor = tint($CheckBox.icon.borderColor,20%)
CheckBox.icon.selectedBackground = $CheckBox.icon.background
CheckBox.icon.checkmarkColor = shade(@foreground,10%)

# disabled
CheckBox.icon.disabledBorderColor = shade($CheckBox.icon.borderColor,20%)
CheckBox.icon.disabledBackground = @disabledBackground
CheckBox.icon.disabledCheckmarkColor = darken($CheckBox.icon.checkmarkColor,25%)

# focused
CheckBox.icon.focusedBorderColor = $Component.focusedBorderColor
CheckBox.icon.focusedBackground = fade($CheckBox.icon.focusedBorderColor,30%)

# hover
CheckBox.icon.hoverBorderColor = $CheckBox.icon.focusedBorderColor
CheckBox.icon.hoverBackground = lighten($CheckBox.icon.background,3%,derived)

# pressed
CheckBox.icon.pressedBorderColor = $CheckBox.icon.focusedBorderColor
CheckBox.icon.pressedBackground = lighten($CheckBox.icon.background,6%,derived)


# used if CheckBox.icon.style or RadioButton.icon.style = filled
# enabled
CheckBox.icon[filled].selectedBorderColor = $CheckBox.icon.checkmarkColor
CheckBox.icon[filled].selectedBackground = $CheckBox.icon.checkmarkColor
CheckBox.icon[filled].checkmarkColor = $CheckBox.icon.background
# hover
CheckBox.icon[filled].hoverSelectedBackground = darken($CheckBox.icon[filled].selectedBackground,3%,derived)
# pressed
CheckBox.icon[filled].pressedSelectedBackground = darken($CheckBox.icon[filled].selectedBackground,6%,derived)


#---- CheckBoxMenuItem ----

CheckBoxMenuItem.icon.checkmarkColor = @buttonArrowColor
CheckBoxMenuItem.icon.disabledCheckmarkColor = @buttonDisabledArrowColor


#---- Component ----

Component.borderColor = tint(@background,19%)
Component.disabledBorderColor = $Component.borderColor
Component.focusedBorderColor = lighten($Component.focusColor,5%)
Component.focusColor = @accentFocusColor
Component.linkColor = @accentLinkColor
Component.accentColor = if(@accentColor, @accentColor, @accentBaseColor)
Component.grayFilter = -20,-70,100

Component.error.borderColor = desaturate($Component.error.focusedBorderColor,25%)
Component.error.focusedBorderColor = #8b3c3c
Component.warning.borderColor = darken(desaturate($Component.warning.focusedBorderColor,20%),10%)
Component.warning.focusedBorderColor = #ac7920
Component.custom.borderColor = desaturate(#f00,50%,relative derived noAutoInverse)


#---- Desktop ----

Desktop.background = #3E434C


#---- DesktopIcon ----

DesktopIcon.background = lighten($Desktop.background,10%,derived)


#---- HelpButton ----

HelpButton.questionMarkColor = shade(@foreground,10%)
HelpButton.disabledQuestionMarkColor = tint(@background,30%)


#---- InternalFrame ----

InternalFrame.activeTitleBackground = darken(@background,10%)
InternalFrame.activeTitleForeground = @foreground
InternalFrame.inactiveTitleBackground = lighten($InternalFrame.activeTitleBackground,5%)
InternalFrame.inactiveTitleForeground = @disabledForeground

InternalFrame.activeBorderColor = darken(@background,7%)
InternalFrame.inactiveBorderColor = darken(@background,3%)

InternalFrame.buttonHoverBackground = lighten($InternalFrame.activeTitleBackground,10%,derived)
InternalFrame.buttonPressedBackground = lighten($InternalFrame.activeTitleBackground,20%,derived)
InternalFrame.closeHoverBackground = lazy(Actions.Red)
InternalFrame.closePressedBackground = darken(Actions.Red,10%,lazy)
InternalFrame.closeHoverForeground = #fff
InternalFrame.closePressedForeground = #fff

InternalFrame.activeDropShadowOpacity = 0.5
InternalFrame.inactiveDropShadowOpacity = 0.75


#---- Menu ----

Menu.icon.arrowColor = @buttonArrowColor
Menu.icon.disabledArrowColor = @buttonDisabledArrowColor


#---- MenuBar ----

MenuBar.borderColor = $Separator.foreground


#---- PasswordField ----

PasswordField.capsLockIconColor = #ffffff64
PasswordField.revealIconColor = @foreground


#---- Popup ----

[mac]Popup.roundedBorderWidth = 1
Popup.dropShadowColor = #000
Popup.dropShadowOpacity = 0.25


#---- PopupMenu ----

PopupMenu.borderColor = tint(@background,17%)
PopupMenu.hoverScrollArrowBackground = lighten(@background,5%)


#---- ProgressBar ----

ProgressBar.background = lighten(@background,8%)
ProgressBar.foreground = @accentSliderColor
ProgressBar.selectionBackground = @foreground
ProgressBar.selectionForeground = contrast($ProgressBar.foreground, @background, @foreground, 25%)


#---- RootPane ----

RootPane.activeBorderColor = lighten(@background,7%,derived)
RootPane.inactiveBorderColor = lighten(@background,5%,derived)


#---- ScrollBar ----

ScrollBar.track = lighten(@background,1%,derived noAutoInverse)
ScrollBar.thumb = lighten($ScrollBar.track,10%,derived noAutoInverse)
ScrollBar.hoverTrackColor = lighten($ScrollBar.track,4%,derived noAutoInverse)
ScrollBar.hoverThumbColor = lighten($ScrollBar.thumb,10%,derived noAutoInverse)
ScrollBar.pressedThumbColor = lighten($ScrollBar.thumb,15%,derived noAutoInverse)
ScrollBar.hoverButtonBackground = lighten(@background,5%,derived noAutoInverse)
ScrollBar.pressedButtonBackground = lighten(@background,10%,derived noAutoInverse)


#---- Separator ----

Separator.foreground = tint(@background,10%)


#---- Slider ----

Slider.trackValueColor = @accentSliderColor
Slider.trackColor = lighten(@background,15%)
Slider.thumbColor = $Slider.trackValueColor
Slider.tickColor = @disabledForeground
Slider.focusedColor = fade(changeLightness($Component.focusColor,60%,derived),30%,derived)
Slider.hoverThumbColor = lighten($Slider.thumbColor,5%,derived)
Slider.pressedThumbColor = lighten($Slider.thumbColor,8%,derived)
Slider.disabledTrackColor = lighten(@background,10%)
Slider.disabledThumbColor = $Slider.disabledTrackColor


#---- SplitPane ----

SplitPaneDivider.draggingColor = $Component.borderColor


#---- TabbedPane ----

TabbedPane.underlineColor = @accentUnderlineColor
TabbedPane.inactiveUnderlineColor = mix(@accentUnderlineColor,$TabbedPane.background,60%)
TabbedPane.disabledUnderlineColor = lighten(@background,23%)
TabbedPane.hoverColor = darken($TabbedPane.background,5%,derived noAutoInverse)
TabbedPane.focusColor = mix(@selectionBackground,$TabbedPane.background,25%)
TabbedPane.contentAreaColor = $Component.borderColor

TabbedPane.buttonHoverBackground = darken($TabbedPane.background,5%,derived noAutoInverse)
TabbedPane.buttonPressedBackground = darken($TabbedPane.background,8%,derived noAutoInverse)

TabbedPane.closeBackground = null
TabbedPane.closeForeground = @disabledForeground
TabbedPane.closeHoverBackground = lighten($TabbedPane.background,5%,derived)
TabbedPane.closeHoverForeground = @foreground
TabbedPane.closePressedBackground = lighten($TabbedPane.background,10%,derived)
TabbedPane.closePressedForeground = $TabbedPane.closeHoverForeground


#---- Table ----

Table.gridColor = lighten($Table.background,8%)


#---- TableHeader ----

TableHeader.hoverBackground = lighten($TableHeader.background,5%,derived)
TableHeader.pressedBackground = lighten($TableHeader.background,10%,derived)
TableHeader.separatorColor = lighten($TableHeader.background,10%)
TableHeader.bottomSeparatorColor = $TableHeader.separatorColor


#---- TitlePane ----

TitlePane.embeddedForeground = darken($TitlePane.foreground,15%)
TitlePane.buttonHoverBackground = lighten($TitlePane.background,15%,derived)
TitlePane.buttonPressedBackground = lighten($TitlePane.background,10%,derived)


#---- ToggleButton ----

ToggleButton.selectedBackground = lighten($ToggleButton.background,10%,derived)
ToggleButton.disabledSelectedBackground = lighten($ToggleButton.background,3%,derived)

ToggleButton.toolbar.selectedBackground = lighten($ToggleButton.background,7%,derived)


#---- ToolBar ----

ToolBar.hoverButtonGroupBackground = lighten($ToolBar.background,3%,derived)


#---- ToolTip ----

ToolTip.border = 4,6,4,6
ToolTip.background = shade(@background,50%)


#---- Tree ----

Tree.hash = lighten($Tree.background,5%)



#---- Styles ------------------------------------------------------------------

#---- inTextField ----
# for leading/trailing components in text fields

[style]Button.inTextField = \
	focusable: false; \
	toolbar.margin: 1,1,1,1; \
	toolbar.spacingInsets: 1,1,1,1; \
	toolbar.hoverBackground: lighten($TextField.background,5%); \
	toolbar.pressedBackground: lighten($TextField.background,10%); \
	toolbar.selectedBackground: lighten($TextField.background,15%)
