package dev.fyloz.plannervio.ui.style

import javafx.geometry.Pos
import javafx.scene.Cursor
import javafx.scene.paint.Color
import javafx.scene.paint.Paint
import javafx.scene.text.TextAlignment
import kfoenix.JFXStylesheet.Companion.jfxButton
import kfoenix.JFXStylesheet.Companion.jfxListView
import kfoenix.JFXStylesheet.Companion.jfxRippler
import kfoenix.JFXStylesheet.Companion.jfxRipplerFill
import kfoenix.JFXStylesheet.Companion.jfxVerticalGap
import tornadofx.*

val primaryTheme = mapOf(
        50 to c("#fcf2e7"),
        100 to c("#f8dec3"),
        200 to c("#f3c89c"),
        300 to c("#eeb274"),
        400 to c("#eaa256"),
        500 to c("#e69138"),
        600 to c("#e38932"),
        700 to c("#df7e2b"),
        800 to c("#db7424"),
        900 to c("#d56217")
)

val accentTheme = mapOf(
        50 to c("#e8f0f8"),
        100 to c("#c5daee"),
        200 to c("#9ec2e3"),
        300 to c("#77aad7"),
        400 to c("#5a97cf"),
        500 to c("#3d85c6"),
        600 to c("#377dc0"),
        700 to c("#2f72b9"),
        800 to c("#2768b1"),
        900 to c("#1a55a4")
)

val background = Color.WHITE

class Style : Stylesheet() {

    companion object {
        // Css properties
        val jfxFocusColor by cssproperty<MultiValue<Paint>>("-jfx-focus-color")
        val jfxUnFocusColor by cssproperty<MultiValue<Paint>>("-jfx-unfocus-color")

        // Jfx classes
        val jfxTextField by cssclass()

        // Classes
        val active by cssclass()
        val appNameLabel by cssclass()
        val centered by cssclass()
        val jfxSvgGlyphWrapper by cssclass()
        val navBar by cssclass()
        val test by cssclass()
    }

    init {
        label {
            fontFamily = "Biryani Regular"
        }

        navBar {
            backgroundColor += primaryTheme.getValue(700)
            prefWidth = 250.px

            label {
                fontFamily = "Biryani DemiBold"
                fontSize = 2.em
                textFill = Color.WHITE

                and(appNameLabel) {
                    prefWidth = 250.px
                }
            }

            jfxTextField {
                jfxFocusColor.value += primaryTheme.getValue(100)
                jfxUnFocusColor.value += primaryTheme.getValue(100)
                textFill = Color.WHITE
                fontSize = 1.2.em
                borderInsets += box(10.px)
            }

            jfxButton {
                cursor = Cursor.HAND
                prefWidth = 250.px
                backgroundRadius += box(0.px)

                jfxRippler {
                    jfxRipplerFill.value = primaryTheme.getValue(100)
                }

                and(active) {
                    backgroundColor += primaryTheme.getValue(300)
                }

                jfxSvgGlyphWrapper {
                    padding = box(10.px, 15.px, 0.px, 0.px)
                }

                label {
                    fontSize = 1.2.em
                }
            }
        }

        tableView {
            backgroundColor += background
            borderColor += box(c(0.0, 0.0, 0.0, 0.12))

            columnHeader {
                backgroundColor += background
                prefHeight = 56.px

                label {
                    alignment = Pos.CENTER_LEFT
                }
            }

            filler {
                backgroundColor += background
            }

            tableRowCell {
                prefHeight = 52.px
                borderColor += box(c(0.0, 0.0, 0.0, 0.12), background, background, background)
                borderWidth += box(1.px, 0.px, 0.px, 0.px)
                backgroundColor += background

                and(hover) {
                    backgroundColor += c(0.0, 0.0, 0.0, 0.04)
                }
            }

            tableColumn {
                alignment = Pos.CENTER_LEFT
                borderColor += box(Color.TRANSPARENT)
                padding = box(0.px, 16.px)

                and(centered) {
                    alignment = Pos.CENTER
                }
            }
        }
    }
}
