/**********************************************************
  SASS is used for variables. Use 'qt-style.css' for
  Qt-specific CSS that would be invalid for SCSS.

  [data] is a placeholder for the data directory.

**********************************************************/
/* Background */
$bg-primary: #323232;
$bg-secondary: #000;
$bg-control: #808080;
$bg-disabled: $bg-secondary;

/* Accent Colours */
$primary: #00FF00;
$secondary: #008000;

/* Colours */
$text-colour: #D6D6D6;
$text-disabled: darken($text-colour, 33%);
$button-text-colour: #DED9CB;
$border-colour: #2D2D2D;
$border-group-colour: #4D4D4D;
$text-colour-sidebar-heading: #969696;


/**********************************************************
  Base
**********************************************************/
QScrollArea *,
QMainWindow *,
QDialog *,
QMessageBox {
    color: $text-colour;
    selection-background-color: $secondary;
    selection-color: #fff;
}

QLabel:disabled {
    color: $text-disabled;
}

/* Horizontal Line */
QFrame[frameShape="4"],
QFrame[frameShape="5"] {
    border: none;
    background: $border-colour;
    max-height: 1px;
}


/**********************************************************
  Tooltips
**********************************************************/
QToolTip {
    color: #fff;
    background-color: $bg-secondary;
    border: 1px solid $border-colour;
}


/**********************************************************
  Scroll Bars
**********************************************************/
$scrollbar-width: 16px;

QScrollBar {
    background-color: transparent;
}

QScrollBar:vertical {
    background-color: transparent;
    border: 0;
    width: $scrollbar-width;
    margin: 0;
}

QScrollBar:horizontal {
    background-color: transparent;
    border: 0;
    border-radius: 10px;
    height: $scrollbar-width;
    margin: 0;
}

QScrollBar::handle:vertical {
    background-color: rgba(255, 255, 255, 0.5);
    min-height: 25px;
    margin: 3px;
}

QScrollBar::handle:horizontal {
    background-color: rgba(255, 255, 255, 0.5);
    min-width: 25px;
    margin: 3px;
}

QScrollBar::add-line {
    height: 0px;
    width: 0px;
    subcontrol-position: bottom;
    subcontrol-origin: margin;
}

QScrollBar::sub-line {
    height: 0px;
    width: 0px;
    subcontrol-position: top;
    subcontrol-origin: margin;
}


/**********************************************************
  Buttons
**********************************************************/
QPushButton,
QToolButton {
    background-color: $bg-primary;
    color: $button-text-colour;
    border: 2px solid $border-colour;
    margin: 0;
    padding: 4px 16px;
    selection-background-color: transparent;
}

QPushButton:focus,
QToolButton:focus {
    background-color: darken($bg-primary, 5%);
    color: #fff;
}

QPushButton:hover,
QToolButton:hover {
    background-color: lighten($bg-primary, 5%);
    color: #fff;
}

QPushButton:pressed,
QToolButton:pressed {
    background-color: darken($bg-primary, 5%);
    border-color: darken($border-colour, 5%);
    color: $primary;
}

/* Checked */
QPushButton:checked,
QToolButton:checked {
    background: $secondary;
    color: #fff;
}

QPushButton:checked:focus,
QPushButton:checked:hover,
QToolButton:checked:focus,
QToolButton:checked:hover {
    background-color: lighten($secondary, 5%);
    color: #fff;
}

QPushButton:checked:pressed,
QToolButton:checked:pressed {
    background-color: darken($secondary, 5%);
}

/* Disabled */
QPushButton:disabled,
QToolButton:disabled {
    background: $bg-disabled;
    color: $text-disabled;
}


/**********************************************************
  Ordinary Tabs
**********************************************************/
QTabWidget::pane,
QTabWidget::tab-bar {
    &:top {
        border-bottom: 1px solid $border-colour;
    }

    &:bottom {
        border-top: 1px solid $border-colour;
        border-bottom: none;
    }
}

QTabBar::tab {
    background: lighten($bg-secondary, 5%);
    border: 1px solid $border-colour;
    color: #fff;
    padding: 4px 8px;
    margin: 0;
}

QTabBar::tab:hover {
    border-color: lighten($border-colour, 10%);
    color: darken($text-colour, 10%);

    &:top {
        border-bottom-color: transparent;
    }

    &:bottom {
        border-top-color: transparent;
    }
}

QTabBar::tab:selected {
    background: $bg-secondary;
    color: $primary;
    border-color: $primary;

    &:top {
        border-bottom-color: transparent;
    }

    &:bottom {
        border-top-color: transparent;
    }
}

QTabBar::tab:disabled {
    color: $text-disabled;
}

QTabBar QToolButton {
    padding: 0;

    &::left-arrow {
        image: url([data]/qt/assets/arrow_left.svg);

        &:hover {
            image: url([data]/qt/assets/arrow_left_hover.svg);
        }

        &:pressed {
            image: url([data]/qt/assets/arrow_left_pressed.svg);
        }

        &:disabled {
            image: url([data]/qt/assets/arrow_left_disabled.svg);
        }
    }

    &::right-arrow {
        image: url([data]/qt/assets/arrow_right.svg);

        &:hover {
            image: url([data]/qt/assets/arrow_right_hover.svg);
        }

        &:pressed {
            image: url([data]/qt/assets/arrow_right_pressed.svg);
        }

        &:disabled {
            image: url([data]/qt/assets/arrow_right_disabled.svg);
        }
    }
}


/**********************************************************
  Header/Tabs
**********************************************************/
#Header {
    background-color: $bg-secondary;
    background-image: url([data]/img/header/header.png);
    background-position: right bottom;
    background-repeat: no-repeat;
}

#MainTabCustom {
    background-color: $bg-secondary;
    background-image: url([data]/img/header/tabs.png);
    background-position: right top;
    background-repeat: no-repeat;
    border-bottom: 1px solid $border-colour;

    > QToolButton,
    > QSpacerItem {
        background: transparent;
        border: 1px solid $border-colour;
        border-bottom: 2px solid $border-colour;
    }

    QToolButton {
        color: $text-colour;
        padding: 4px;
        padding-left: 8px;
        padding-right: 2px;
        height: 16px;
    }

    QToolButton:hover {
        border-color: lighten($border-colour, 10%);
        color: darken($text-colour, 10%);
        border-bottom: 2px solid transparent;
    }

    QToolButton::checked {
        background: $bg-secondary;
        color: $primary;
        border-color: $primary;
        border-bottom: 2px solid transparent;
    }

    QToolButton:disabled {
        color: $text-disabled;
    }
}


/**********************************************************
  Menu Bar
**********************************************************/
QMenuBar {
    background-color: $bg-secondary;
    spacing: 0;
    color: $text-colour;
}

QMenuBar#MainMenubar {
    background-image: url([data]/img/header/menubar.png);
    background-position: right bottom;
    background-repeat: no-repeat;
}

QMenuBar::item {
    background-color: transparent;
    color: lighten($text-colour, 10%);
    padding: 5px 10px;
    margin: 0;
}

QMenuBar::item:selected {
    background-color: lighten($bg-primary, 5%);
    color: #fff;
}

QMenuBar::item:pressed {
    background-color: $secondary;
    color: #fff;
}

QMenuBar::item:disabled {
    color: $text-disabled;
}

QMenu {
    background: $bg-secondary;
    border: 1px solid $border-colour;
}

QMenu::item {
    background-color: $bg-secondary;
    color: $text-colour;
}

QMenu::item:selected {
    background-color: lighten($bg-secondary, 20%);
    color: #fff;
}

QMenuBar {
    /* Only show checked 'background' color on menu bar */
    QMenu::item:checked {
        background-color: darken($secondary, 10%);
    }
}

QMenu::separator {
    height: 1px;
    margin: 3px 0;
    background: $bg-primary;
}

QMenu::item:disabled {
    color: darken($text-colour, 50%);
}


/**********************************************************
  Toolbar
**********************************************************/
QToolBar {
    background-color: $bg-secondary;
    border: 0;
    margin: 4px 0;
    spacing: 0;
    color: $text-colour;

    QPushButton,
    QToolButton {
        background-color: transparent;
        color: $button-text-colour;
        border: 1px solid transparent;
        margin: 0;
        padding: 4px;
        selection-background-color: transparent;
    }

    &::separator {
        background: $border-colour;
        width: 2;
        margin: 4px;
    }
}


/**********************************************************
  Dock
**********************************************************/
QDockWidget {
    titlebar-close-icon: url([data]/img/general/close.svg);
    titlebar-normal-icon: url([data]/qt/assets/undock.svg);

    &::title {
        background-color: lighten($bg-secondary, 10%);
        padding: 4px;
    }
}


/**********************************************************
  HeaderView (shared with TreeView and TableView)
**********************************************************/
QHeaderView::section {
    background: $bg-primary;
    color: white;
    padding: 2px 4px;
}


/**********************************************************
  TreeView
**********************************************************/
QTreeView {
    background: $bg-secondary;
    alternate-background-color: lighten($bg-secondary, 10%);
    show-decoration-selected: 1;
    selection-background-color: $secondary;
}

QTreeView::item {
    border: 0px solid transparent;
    padding: 4px 3px;
}

QTreeView::item:hover {
    background: lighten($bg-secondary, 15%);
}

QTreeView::item:selected {
    background: $secondary;
    color: #fff;
}

QTreeView::item:selected:active {
    background: $secondary;
}

QTreeView::item:disabled {
    color: $text-disabled;
}


/**********************************************************
  Sidebar
**********************************************************/
#MainTabWidget {
    QTreeView {
        background: $bg-secondary;
        show-decoration-selected: 0;
    }

    QTreeView::branch {
        background: transparent;
    }

    /* Sidebar Item */
    QTreeView::item {
        background: transparent;
        border: none;
        color: $text-colour;
        padding: 2px 4px;
        height: 28px;
    }

    QTreeView::item:hover {
        background: lighten($bg-secondary, 20%);
        color: #fff;
    }

    QTreeView::item:selected,
    QTreeView::item:selected:active {
        background: $secondary;
        color: #fff;
    }

    QTreeView::item:disabled {
        color: #202020;
    }

    /* Sidebar Heading */
    QTreeView::item:has-children {
        background: transparent;
        border-bottom: 1px solid darken($text-colour-sidebar-heading, 40%);
        color: $text-colour-sidebar-heading;
        padding: 10px 5px;
        margin-top: 10px;
        height: 32px;
    }
}


/**********************************************************
  Checkbox
**********************************************************/
QCheckBox {
    spacing: 5px;
}

QCheckBox::indicator {
    background-color: $bg-control;
    width: 16px;
    height: 16px;
}

QCheckBox::indicator:unchecked {
    image: none;
}

QCheckBox::indicator:unchecked:hover {
    background-color: lighten($bg-control, 10%);
    image: none;
}

QCheckBox:unchecked:hover {
    color: lighten($text-colour, 10%);
}

QCheckBox::indicator:unchecked:pressed {
    background-color: darken($bg-control, 10%);
    image: none;
}

QCheckBox:unchecked:pressed {
    color: darken($text-colour, 10%);
}

QCheckBox::indicator:checked {
    background-color: $primary;
    image: url([data]/qt/assets/checkbox.svg);
}

QCheckBox:checked {
    color: $primary;
}

QCheckBox::indicator:checked:hover {
    background-color: darken($primary, 5%);
    image: url([data]/qt/assets/checkbox.svg);
}

QCheckBox:checked:hover {
    color: darken($primary, 5%);
}

QCheckBox::indicator:checked:pressed {
    background-color: darken($primary, 15%);
    image: url([data]/qt/assets/checkbox.svg);
}

QCheckBox:checked:pressed {
    color: darken($primary, 15%);
}

QCheckBox:disabled {
    color: $text-disabled;
}

QCheckBox::indicator:disabled {
    background: darken($text-disabled, 30%);
}

/* No style for indeterminate states as currently unused */


/**********************************************************
  Radio Buttons
**********************************************************/
QRadioButton {
    spacing: 5px;
}

QRadioButton::indicator {
    width: 16px;
    height: 16px;
}

QRadioButton::indicator:unchecked {
    image: url([data]/qt/assets/radio-unchecked.svg);
}

QRadioButton::indicator:unchecked:hover {
    image: url([data]/qt/assets/radio-unchecked-hover.svg);
}

QRadioButton:unchecked:hover {
    color: lighten($text-colour, 10%);
}

QRadioButton::indicator:unchecked:pressed {
    image: url([data]/qt/assets/radio-unchecked-pressed.svg);
}

QRadioButton:unchecked:pressed {
    color: darken($text-colour, 10%);
}

QRadioButton::indicator:checked {
    image: url([data]/qt/assets/radio-checked.svg);
}

QRadioButton:checked {
    color: $primary;
}

QRadioButton::indicator:checked:hover {
    image: url([data]/qt/assets/radio-checked-hover.svg);
}

QRadioButton:checked:hover {
    color: darken($primary, 5%);
}

QRadioButton::indicator:checked:pressed {
    image: url([data]/qt/assets/radio-checked-pressed.svg);
}

QRadioButton:checked:pressed {
    color: darken($primary, 15%);
}

QRadioButton:disabled {
    color: $text-disabled;
}

QRadioButton::indicator:disabled {
    image: url([data]/qt/assets/radio-unchecked-disabled.svg);
}

QRadioButton::indicator:checked:disabled {
    image: url([data]/qt/assets/radio-checked-disabled.svg);
}


/**********************************************************
  Combo Box
**********************************************************/
QComboBox {
    background: $bg-primary;
    border: 1px solid $border-colour;
    padding: 5px;
    padding-right: 20px;
    min-width: 6em;

    &:focus,
    &:hover {
        background: lighten($bg-primary, 5%);
        color: #fff;
    }

    &:on {
        background: $secondary;
        color: #fff;
    }

    &:off {
        background: lighten($bg-secondary, 20%);
        color: #fff;
    }

    &::drop-down::button {
        border: 0;
    }

    &::down-button {
        subcontrol-origin: padding;
        border: 0px solid $border-colour;
        width: 12px;
        image: url([data]/qt/assets/arrow_down.svg);
    }

    &::down-arrow {
        subcontrol-origin: padding;
        image: url([data]/qt/assets/arrow_down.svg);
        border: 0px solid $border-colour;
        width: 12px;

        &:hover {
            image: url([data]/qt/assets/arrow_down_hover.svg);
        }

        &:pressed,
        &:disabled,
        &:off {
            image: url([data]/qt/assets/arrow_down_pressed.svg);
        }
    }

    &:disabled {
        background: $bg-disabled;
        color: $text-disabled;
    }
}

QComboBox QAbstractItemView {
    background: $bg-secondary;
    border: 1px solid $bg-primary;
    padding: 0px;
    margin: 0px;
    selection-background-color: $secondary;
    selection-color: #fff;
}


/**********************************************************
  Sliders
**********************************************************/
QSlider::groove:horizontal {
    border: 1px solid $bg-secondary;
    background: $bg-primary;
    height: 8px;
    margin: 2px 0;
}

QSlider::handle:horizontal {
    border: 1px solid $bg-secondary;
    background: $bg-control;
    width: 10px;
    margin: -6px 0;
    border-radius: 2px;
}

QSlider::sub-page:horizontal {
    background: $primary;
    height: 8px;
    margin: 3px 0;
}

QSlider::groove:vertical {
    border: 1px solid $bg-secondary;
    background: $bg-primary;
    width: 8px;
    margin: 0 2px;
}

QSlider::handle:vertical {
    border: 1px solid $bg-secondary;
    background: $bg-control;
    height: 10px;
    margin: 0 -6px;
    border-radius: 2px;
}

QSlider::add-page:vertical {
    background: $primary;
    width: 8px;
    margin: 0 3px;
}

QSlider::groove:horizontal:disabled,
QSlider::groove:vertical:disabled {
    background: $bg-secondary;
    border: 1px solid $bg-primary;
}

QSlider::sub-page:horizontal:disabled,
QSlider::add-page:vertical:disabled {
    background: $bg-disabled;
}


/**********************************************************
  Spinners
**********************************************************/
QSpinBox,
QDoubleSpinBox,
QDateTimeEdit {
    background: $bg-primary;
    border: 2px solid $border-colour;
    color: $button-text-colour;
    margin: 0;
    padding: 4px;

    &:focus {
        background-color: darken($bg-primary, 5%);
        border-color: darken($border-colour, 5%);
        color: #fff;
    }

    &:hover {
        background-color: lighten($bg-primary, 5%);
        color: #fff;
    }

    &:disabled {
        background: $bg-disabled;
        color: $text-disabled;
    }

    &::up-button,
    &::down-button {
        border: 0px solid $border-colour;
        width: 16px;
    }

    &::up-button {
        subcontrol-origin: padding;
        subcontrol-position: top right;
    }

    &::down-button {
        subcontrol-origin: padding;
        subcontrol-position: bottom right;
    }

    &::up-arrow,
    &::down-arrow {
        width: 12px;
        height: 12px;
    }

    &::up-arrow {
    image: url([data]/qt/assets/arrow_up.svg);

        &:hover {
            image: url([data]/qt/assets/arrow_up_hover.svg);
        }

        &:pressed {
            image: url([data]/qt/assets/arrow_up_pressed.svg);
        }

        &:disabled,
        &:off {
            image: url([data]/qt/assets/arrow_up_disabled.svg);
        }
    }

    &::down-arrow {
        image: url([data]/qt/assets/arrow_down.svg);

        &:hover {
            image: url([data]/qt/assets/arrow_down_hover.svg);
        }

        &:pressed {
            image: url([data]/qt/assets/arrow_down_pressed.svg);
        }

        &:disabled,
        &:off {
            image: url([data]/qt/assets/arrow_down_disabled.svg);
        }
    }
}


/**********************************************************
  Group Box
**********************************************************/
QGroupBox {
    background: transparent;
    border: 0;
    border-top: 1px solid $border-group-colour;
    border-radius: 0px;
    margin-top: 8px;
    padding: 10px;
}

QGroupBox::title {
    color: $text-colour;
    subcontrol-origin: margin;
    subcontrol-position: top left;
    left: 10px;
    padding: 0 4px;
    text-align: left;
}


/**********************************************************
  Status Bar
**********************************************************/
/*
QStatusBar {
    background: brown;
}

QStatusBar::item {
    border: 1px solid red;
    border-radius: 3px;
}*/


/**********************************************************
  Line Edit Box
**********************************************************/
QTextEdit,
QLineEdit {
    background-color: $bg-primary;
    color: $button-text-colour;
    border: 1px solid $border-colour;
    padding: 4px;
    selection-background-color: $secondary;
}

QTextEdit:hover,
QLineEdit:hover {
    background-color: lighten($bg-primary, 5%);
    color: #fff;
}


/**********************************************************
  Text Edit
**********************************************************/
QTextEdit#LicenseText,
QTextEdit#LicenseText:hover,
QListView {
    background-color: $bg-secondary;
    color: $text-colour;
}


/**********************************************************
  Message Box
**********************************************************/
QMessageBox {
    QLabel {
        color: $text-colour;
    }

    QTextEdit {
        font-family: monospace;
    }
}


/**********************************************************
  Table
**********************************************************/
QTableView {
    background: $bg-secondary;
    color: white;
    padding: 2px 4px;
    selection-background-color: $secondary;
    gridline-color: $bg-primary;

    QAbsractScrollArea {
        background: $bg-primary;
    }

    QHeaderView {
        background: $bg-secondary;
        border: 0px;
    }

    QHeaderView::section:checked {
        background-color: $secondary;
    }

    QTableCornerButton::section {
        background: $bg-primary;
        border: 1px solid transparent;
    }
}


/**********************************************************
  Special Widgets
**********************************************************/
#AnimatedGIFWarningLabel {
    background: $bg-secondary;
    border: 1px solid rgba(orange, 0.5);
    color: orange;
    padding: 5px;
}
