/*

See Qt documentation:

  - https://doc.qt.io/qt-5/stylesheet.html
  - https://doc.qt.io/qt-5/stylesheet-reference.html
  - https://doc.qt.io/qt-5/stylesheet-examples.html

--------------------------------------------------------------------------- */


/* QWidget ----------------------------------------------------------------

--------------------------------------------------------------------------- */
QWidget {
    background-color: $COLOR_BACKGROUND_DARK;
    border: 0px solid $COLOR_BACKGROUND_NORMAL;
    padding: 0px;
    color: $COLOR_FOREGROUND_LIGHT;
    selection-background-color: $COLOR_SELECTION_NORMAL;
    selection-color: $COLOR_FOREGROUND_LIGHT;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
        selection-background-color: $COLOR_SELECTION_DARK;
        selection-color: $COLOR_FOREGROUND_DARK;
    }

    &::item {

        &:selected {
            background-color: $COLOR_SELECTION_NORMAL;
        }

        &:hover {
            background-color: $COLOR_SELECTION_LIGHT;
            color: $COLOR_BACKGROUND_NORMAL;
        }
    }
}

/* QMainWindow ------------------------------------------------------------

This adjusts the splitter in the dock widget, not qsplitter
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qmainwindow

--------------------------------------------------------------------------- */
QMainWindow {

    &::separator {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: 0px solid $COLOR_BACKGROUND_DARK;
        spacing: 0px;
        padding: 2px;

        &:hover {
            background-color: $COLOR_BACKGROUND_LIGHT;
            border: 0px solid $COLOR_SELECTION_LIGHT;
        }

        &:horizontal {
            width: 5px;
            margin-top: 2px;
            margin-bottom: 2px;
            image: url($PATH_RESOURCES + '/rc/toolbar_separator_vertical.png');
        }

        &:vertical {
            height: 5px;
            margin-left: 2px;
            margin-right: 2px;
            image: url($PATH_RESOURCES + '/rc/toolbar_separator_horizontal.png');
        }
    }
}

/* QToolTip ---------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtooltip

--------------------------------------------------------------------------- */
QToolTip {
    background-color: $COLOR_SELECTION_LIGHT;
    border: $BORDER_DARK;
    color: $COLOR_BACKGROUND_DARK;

    /* Remove padding, for fix combo box tooltip */
    padding: 0px;

    /* Remove opacity, fix #174 - may need to use RGBA */
}

/* QStatusBar -------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qstatusbar

--------------------------------------------------------------------------- */
QStatusBar {
    border: $BORDER_NORMAL;

    /* Fixes Spyder #9120, #9121 */
    background: $COLOR_BACKGROUND_NORMAL;

    /* Fixes #205, white vertical borders separating items */
    &::item {
        border: none;
    }

    QToolTip {
        background-color: $COLOR_SELECTION_LIGHT;
        border: $BORDER_DARK;
        color: $COLOR_BACKGROUND_DARK;

        /* Remove padding, for fix combo box tooltip */
        padding: 0px;

        /* Reducing transparency to read better */
        opacity: $OPACITY_TOOLTIP;
    }

    QLabel {
        /* Fixes Spyder #9120, #9121 */
        background: transparent;
    }
}

/* QCheckBox --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcheckbox

--------------------------------------------------------------------------- */
QCheckBox {
    background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;
    spacing: 4px;
    outline: none;
    padding-top: 4px;
    padding-bottom: 4px;

    &:focus {
        border: none;
    }

    QWidget:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }

    &::indicator {
        margin-left: 4px;
        height: 16px;
        width: 16px;

        &:unchecked {
            image: url($PATH_RESOURCES + '/rc/checkbox_unchecked.png');

            &:hover,
            &:focus,
            &:pressed {
                border: none;
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_focus.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_disabled.png');
            }
        }

        &:checked {
            image: url($PATH_RESOURCES + '/rc/checkbox_checked.png');

            &:hover,
            &:focus,
            &:pressed {
                border: none;
                image: url($PATH_RESOURCES + '/rc/checkbox_checked_focus.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/checkbox_checked_disabled.png');
            }
        }

        &:indeterminate {
            image: url($PATH_RESOURCES + '/rc/checkbox_indeterminate.png');

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/checkbox_indeterminate_disabled.png');
            }

            &:focus,
            &:hover,
            &:pressed {
                image: url($PATH_RESOURCES + '/rc/checkbox_indeterminate_focus.png');
            }
        }
    }
}

/* QGroupBox --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qgroupbox

--------------------------------------------------------------------------- */
QGroupBox {
    font-weight: bold;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;
    padding: 4px;
    margin-top: 16px;

    &::title {
        subcontrol-origin: margin;
        subcontrol-position: top left;
        left: 3px;
        padding-left: 3px;
        padding-right: 5px;
        padding-top: 8px;
        padding-bottom: 16px;
    }

    &::indicator {
        margin-left: 2px;
        height: 16px;
        width: 16px;

        &:unchecked {
            border: none;
            image: url($PATH_RESOURCES + '/rc/checkbox_unchecked.png');

            &:hover,
            &:focus,
            &:pressed {
                border: none;
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_focus.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_disabled.png');
            }
        }

        &:checked {
            border: none;
            image: url($PATH_RESOURCES + '/rc/checkbox_checked.png');


            &:hover,
            &:focus,
            &:pressed {
                border: none;
                image: url($PATH_RESOURCES + '/rc/checkbox_checked_focus.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/checkbox_checked_disabled.png');
            }
        }
    }
}

/* QRadioButton -----------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qradiobutton

--------------------------------------------------------------------------- */
QRadioButton {
    background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;
    spacing: 4px;
    padding: 0px;
    border: none;
    outline: none;

    &:focus {
        border: none;
    }

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
        border: none;
        outline: none;
    }

    QWidget {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_LIGHT;
        spacing: 0px;
        padding: 0px;
        outline: none;
        border: none;
    }

    &::indicator {
        border: none;
        outline: none;
        margin-left: 4px;
        height: 16px;
        width: 16px;

        &:unchecked {
            image: url($PATH_RESOURCES + '/rc/radio_unchecked.png');

            &:hover,
            &:focus,
            &:pressed {
                border: none;
                outline: none;
                image: url($PATH_RESOURCES + '/rc/radio_unchecked_focus.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/radio_unchecked_disabled.png');
            }
        }

        &:checked {
            border: none;
            outline: none;
            image: url($PATH_RESOURCES + '/rc/radio_checked.png');

            &:hover,
            &:focus,
            &:pressed {
                border: none;
                outline: none;
                image: url($PATH_RESOURCES + '/rc/radio_checked_focus.png');
            }

            &:disabled {
                outline: none;
                image: url($PATH_RESOURCES + '/rc/radio_checked_disabled.png');
            }
        }
    }
}

/* QMenuBar ---------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qmenubar

--------------------------------------------------------------------------- */
QMenuBar {
    background-color: $COLOR_BACKGROUND_NORMAL;
    padding: 2px;
    border: $BORDER_DARK;
    color: $COLOR_FOREGROUND_LIGHT;

    &:focus {
        border: $BORDER_SELECTION_LIGHT;
    }

    &::item {
        background: transparent;
        padding: 4px;

        &:selected {
            padding: 4px;
            background: transparent;
            border: 0px solid $COLOR_BACKGROUND_NORMAL;
        }

        &:pressed {
            padding: 4px;
            border: 0px solid $COLOR_BACKGROUND_NORMAL;
            background-color: $COLOR_SELECTION_LIGHT;
            color: $COLOR_FOREGROUND_LIGHT;
            margin-bottom: 0px;
            padding-bottom: 0px;
        }
    }
}

/* QMenu ------------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qmenu

--------------------------------------------------------------------------- */
QMenu {
    border: 0px solid $COLOR_BACKGROUND_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    margin: 0px;

    &::separator {
        height: 1px;
        background-color: $COLOR_BACKGROUND_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &::icon {
        margin: 0px;
        padding-left: 8px;
    }

    &::item {
        background-color: $COLOR_BACKGROUND_NORMAL;
        padding: 4px 24px 4px 24px;
        /* Reserve space for selection border */
        border: 1px transparent $COLOR_BACKGROUND_NORMAL;

        &:selected {
            color: $COLOR_FOREGROUND_LIGHT;
        }
    }

    &::indicator {
        width: 12px;
        height: 12px;
        padding-left: 6px;

        /* non-exclusive indicator = check box style indicator (see QActionGroup::setExclusive) */
        &:non-exclusive {

            &:unchecked {
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked.png');

                &:selected {
                    image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_disabled.png');
                }
            }

            &:checked {
                image: url($PATH_RESOURCES + '/rc/checkbox_checked.png');

                &:selected {
                    image: url($PATH_RESOURCES + '/rc/checkbox_checked_disabled.png');
                }
            }
        }

        /* exclusive indicator = radio button style indicator (see QActionGroup::setExclusive) */
        &:exclusive {

            &:unchecked {
                image: url($PATH_RESOURCES + '/rc/radio_unchecked.png');

                &:selected {
                    image: url($PATH_RESOURCES + '/rc/radio_unchecked_disabled.png');
                }
            }

            &:checked {
                image: url($PATH_RESOURCES + '/rc/radio_checked.png');

                &:selected {
                    image: url($PATH_RESOURCES + '/rc/radio_checked_disabled.png');
                }
            }
        }
    }

    &::right-arrow {
        margin: 5px;
        image: url($PATH_RESOURCES + '/rc/arrow_right.png');
        height: 12px;
        width: 12px;
    }
}

/* QAbstractItemView ------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox

--------------------------------------------------------------------------- */
QAbstractItemView {
    alternate-background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;

    QLineEdit {
        padding: 2px;
    }
}

/* QAbstractScrollArea ----------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qabstractscrollarea

--------------------------------------------------------------------------- */
QAbstractScrollArea {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;
    padding: 2px;
    /* fix #159 */
    min-height: 1.25em;
    /* fix #159 */
    color: $COLOR_FOREGROUND_LIGHT;

    &:disabled {
        color: $COLOR_FOREGROUND_DARK;
    }
}

/* QScrollArea ------------------------------------------------------------

--------------------------------------------------------------------------- */
QScrollArea QWidget QWidget:disabled {
    background-color: $COLOR_BACKGROUND_DARK;
}

/* QScrollBar -------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qscrollbar

--------------------------------------------------------------------------- */
QScrollBar {

    &:horizontal {
        height: 16px;
        margin: 2px 16px 2px 16px;
        border: $BORDER_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
        background-color: $COLOR_BACKGROUND_DARK;
    }

    &:vertical {
        background-color: $COLOR_BACKGROUND_DARK;
        width: 16px;
        margin: 16px 2px 16px 2px;
        border: $BORDER_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
    }

    &::handle {

        &:horizontal {
            background-color: $COLOR_FOREGROUND_DARK;
            border: $BORDER_NORMAL;
            border-radius: $SIZE_BORDER_RADIUS;
            min-width: 8px;

            &:hover {
                background-color: $COLOR_SELECTION_LIGHT;
                border: $BORDER_SELECTION_LIGHT;
                border-radius: $SIZE_BORDER_RADIUS;
                min-width: 8px;
            }

            &:focus {
                border: $BORDER_SELECTION_NORMAL;
            }
        }

        &:vertical {
            background-color: $COLOR_FOREGROUND_DARK;
            border: $BORDER_NORMAL;
            min-height: 8px;
            border-radius: $SIZE_BORDER_RADIUS;

            &:hover {
                background-color: $COLOR_SELECTION_LIGHT;
                border: $BORDER_SELECTION_LIGHT;
                border-radius: $SIZE_BORDER_RADIUS;
                min-height: 8px;
            }

            &:focus {
                border: $BORDER_SELECTION_NORMAL;
            }
        }
    }

    &::add-line {

        &:horizontal {
            margin: 0px 0px 0px 0px;
            border-image: url($PATH_RESOURCES + '/rc/arrow_right_disabled.png');
            height: 12px;
            width: 12px;
            subcontrol-position: right;
            subcontrol-origin: margin;

            &:hover,
            &:on {
                border-image: url($PATH_RESOURCES + '/rc/arrow_right.png');
                height: 12px;
                width: 12px;
                subcontrol-position: right;
                subcontrol-origin: margin;
            }
        }

        &:vertical {
            margin: 3px 0px 3px 0px;
            border-image: url($PATH_RESOURCES + '/rc/arrow_down_disabled.png');
            height: 12px;
            width: 12px;
            subcontrol-position: bottom;
            subcontrol-origin: margin;

            &:hover,
            &:on {
                border-image: url($PATH_RESOURCES + '/rc/arrow_down.png');
                height: 12px;
                width: 12px;
                subcontrol-position: bottom;
                subcontrol-origin: margin;
            }
        }
    }

    &::sub-line {
        &:horizontal {
            margin: 0px 3px 0px 3px;
            border-image: url($PATH_RESOURCES + '/rc/arrow_left_disabled.png');
            height: 12px;
            width: 12px;
            subcontrol-position: left;
            subcontrol-origin: margin;

            &:hover,
            &:on {
                border-image: url($PATH_RESOURCES + '/rc/arrow_left.png');
                height: 12px;
                width: 12px;
                subcontrol-position: left;
                subcontrol-origin: margin;
            }
        }

        &:vertical {
            margin: 3px 0px 3px 0px;
            border-image: url($PATH_RESOURCES + '/rc/arrow_up_disabled.png');
            height: 12px;
            width: 12px;
            subcontrol-position: top;
            subcontrol-origin: margin;

            &:hover,
            &:on {
                border-image: url($PATH_RESOURCES + '/rc/arrow_up.png');
                height: 12px;
                width: 12px;
                subcontrol-position: top;
                subcontrol-origin: margin;
            }
        }
    }

    &::up-arrow:horizontal,
    &::down-arrow:horizontal {
        background: none;
    }

    &::up-arrow:vertical,
    &::down-arrow:vertical {
        background: none;
    }

    &::add-page:horizontal,
    &::sub-page:horizontal {
        background: none;
    }

    &::add-page:vertical,
    &::sub-page:vertical {
        background: none;
    }
}

/* QTextEdit --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-specific-widgets

--------------------------------------------------------------------------- */
QTextEdit {
    background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;
    border: $BORDER_NORMAL;

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

    &:selected {
        background: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }
}

/* QPlainTextEdit ---------------------------------------------------------

--------------------------------------------------------------------------- */
QPlainTextEdit {
    background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;
    border: $BORDER_NORMAL;

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

    &:selected {
        background: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }
}

/* QSizeGrip --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qsizegrip

--------------------------------------------------------------------------- */
QSizeGrip {
    background: transparent;
    width: 12px;
    height: 12px;
    image: url($PATH_RESOURCES + '/rc/window_grip.png');
}

/* QStackedWidget ---------------------------------------------------------

--------------------------------------------------------------------------- */
QStackedWidget {
    padding: 2px;
    border: $BORDER_NORMAL;
    border: $BORDER_DARK;
}

/* QToolBar ---------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtoolbar

--------------------------------------------------------------------------- */
QToolBar {
    background-color: $COLOR_BACKGROUND_NORMAL;
    border-bottom: $BORDER_DARK;
    padding: 2px;
    font-weight: bold;
    spacing: 2px;

    QToolButton {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: $BORDER_NORMAL;

        &:hover {
            border: $BORDER_SELECTION_LIGHT;
        }

        &:checked {
            border: $BORDER_DARK;
            background-color: $COLOR_BACKGROUND_DARK;

            &:hover {
                border: $BORDER_SELECTION_LIGHT;
            }
        }
    }

    &::handle {

        &:horizontal {
            width: 16px;
            image: url($PATH_RESOURCES + '/rc/toolbar_move_horizontal.png');
        }

        &:vertical {
            height: 16px;
            image: url($PATH_RESOURCES + '/rc/toolbar_move_vertical.png');
        }
    }

    &::separator {

        &:horizontal {
            width: 16px;
            image: url($PATH_RESOURCES + '/rc/toolbar_separator_horizontal.png');
        }

        &:vertical {
            height: 16px;
            image: url($PATH_RESOURCES + '/rc/toolbar_separator_vertical.png');
        }
    }
}

QToolButton#qt_toolbar_ext_button {
    background: $COLOR_BACKGROUND_NORMAL;
    border: 0px;
    color: $COLOR_FOREGROUND_LIGHT;
    image: url($PATH_RESOURCES + '/rc/arrow_right.png');
}

/* QAbstractSpinBox -------------------------------------------------------

--------------------------------------------------------------------------- */
QAbstractSpinBox {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;

    /* This fixes 103, 111 */
    padding-top: 2px;

    /* This fixes 103, 111 */
    padding-bottom: 2px;
    padding-left: 4px;
    padding-right: 4px;
    border-radius: $SIZE_BORDER_RADIUS;
    /* min-width: 5px; removed to fix 109 */

    &:up-button {
        background-color: transparent $COLOR_BACKGROUND_DARK;
        subcontrol-origin: border;
        subcontrol-position: top right;
        border-left: $BORDER_NORMAL;
        border-bottom: $BORDER_NORMAL;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        margin: 1px;
        width: 12px;
        margin-bottom: -1px;
    }

    &::up-arrow,
    &::up-arrow:disabled,
    &::up-arrow:off {
        image: url($PATH_RESOURCES + '/rc/arrow_up_disabled.png');
        height: 8px;
        width: 8px;
    }

    &::up-arrow:hover {
        image: url($PATH_RESOURCES + '/rc/arrow_up.png');
    }

    &:down-button {
        background-color: transparent $COLOR_BACKGROUND_DARK;
        subcontrol-origin: border;
        subcontrol-position: bottom right;
        border-left: $BORDER_NORMAL;
        border-top: $BORDER_NORMAL;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        margin: 1px;
        width: 12px;
        margin-top: -1px;
    }

    &::down-arrow,
    &::down-arrow:disabled,
    &::down-arrow:off {
        image: url($PATH_RESOURCES + '/rc/arrow_down_disabled.png');
        height: 8px;
        width: 8px;
    }

    &::down-arrow:hover {
        image: url($PATH_RESOURCES + '/rc/arrow_down.png');
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

    &:selected {
        background: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }
}

/* ------------------------------------------------------------------------ */
/* DISPLAYS --------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */

/* QLabel -----------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qframe

--------------------------------------------------------------------------- */
QLabel {
    background-color: $COLOR_BACKGROUND_DARK;
    border: 0px solid $COLOR_BACKGROUND_NORMAL;
    padding: 2px;
    margin: 0px;
    color: $COLOR_FOREGROUND_LIGHT;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        border: 0px solid $COLOR_BACKGROUND_NORMAL;
        color: $COLOR_FOREGROUND_DARK;
    }
}

/* QTextBrowser -----------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qabstractscrollarea

--------------------------------------------------------------------------- */
QTextBrowser {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_NORMAL;
        color: $COLOR_FOREGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;
    }

    &:hover,
    &:!hover,
    &:selected,
    &:pressed {
        border: $BORDER_NORMAL;
    }
}

/* QGraphicsView ----------------------------------------------------------

--------------------------------------------------------------------------- */
QGraphicsView {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_NORMAL;
        color: $COLOR_FOREGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;
    }

    &:hover,
    &:!hover,
    &:selected,
    &:pressed {
        border: $BORDER_NORMAL;
    }
}

/* QCalendarWidget --------------------------------------------------------

--------------------------------------------------------------------------- */
QCalendarWidget {
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }
}

/* QLCDNumber -------------------------------------------------------------

--------------------------------------------------------------------------- */
QLCDNumber {
    background-color: $COLOR_BACKGROUND_DARK;
    color: $COLOR_FOREGROUND_LIGHT;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }
}

/* QProgressBar -----------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qprogressbar

--------------------------------------------------------------------------- */
QProgressBar {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;
    text-align: center;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_NORMAL;
        color: $COLOR_FOREGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;
        text-align: center;
    }

    &::chunk {
        background-color: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;

        &:disabled {
            background-color: $COLOR_SELECTION_DARK;
            color: $COLOR_FOREGROUND_DARK;
            border-radius: $SIZE_BORDER_RADIUS;
        }
    }
}

/* ------------------------------------------------------------------------ */
/* BUTTONS ---------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */

/* QPushButton ------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qpushbutton

--------------------------------------------------------------------------- */
QPushButton {
    background-color: $COLOR_BACKGROUND_LIGHT;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;
    padding: 3px;
    outline: none;
    /* Issue #194 - Special case of QPushButton inside dialogs, for better UI */
    min-width: 80px;

    &:disabled {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: $BORDER_NORMAL;
        color: $COLOR_FOREGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;
        padding: 3px;
    }

    &:checked {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: $BORDER_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
        padding: 3px;
        outline: none;

        &:disabled {
            background-color: $COLOR_BACKGROUND_DARK;
            border: $BORDER_NORMAL;
            color: $COLOR_FOREGROUND_DARK;
            border-radius: $SIZE_BORDER_RADIUS;
            padding: 3px;
            outline: none;
        }

        &:selected {
            background: $COLOR_SELECTION_NORMAL;
            color: $COLOR_BACKGROUND_NORMAL;
        }

    }

    &::menu-indicator {
        subcontrol-origin: padding;
        subcontrol-position: bottom right;
        bottom: 4px;
    }

    &:pressed {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_DARK;

        &:hover {
            border: $BORDER_SELECTION_LIGHT;
        }
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:selected {
        background: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

}

/* QToolButton ------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtoolbutton

--------------------------------------------------------------------------- */
QToolButton {
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: $SIZE_BORDER_RADIUS;
    margin: 0px;
    padding: 2px;

    &:checked {
        background-color: transparent;
        border: $BORDER_SELECTION_NORMAL;

        &:disabled {
            border: $BORDER_SELECTION_DARK;
        }
    }

    &:pressed {
        margin: 1px;
        background-color: transparent;
        border: $BORDER_SELECTION_NORMAL;
    }

    &:disabled {
        border: none;
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
    }

    /* The subcontrols below are used only in the DelayedPopup mode */
    &[popupMode="0"] {
        /* Only for DelayedPopup */
        padding-right: 2px;
    }

    /* The subcontrols below are used only in the MenuButtonPopup mode */
    &[popupMode="1"] {
        /* Only for MenuButtonPopup */
        padding-right: 20px;

        &::menu-button {
            border: none;

            &:hover {
                border: none;
                border-left: 1px solid $COLOR_SELECTION_LIGHT;
                border-radius: 0;
            }
        }
    }

    /* The subcontrol below is used only in the InstantPopup or DelayedPopup mode */
    &[popupMode="2"] {
        /* Only for InstantPopup */
        padding-right: 2px;
    }

    &::menu-button {
        padding: 2px;
        border-radius: $SIZE_BORDER_RADIUS;
        border: $BORDER_NORMAL;
        width: 12px;
        outline: none;

        &:hover {
            border: $BORDER_SELECTION_LIGHT;
        }

        &:checked {
            &:hover {
                border: $BORDER_SELECTION_LIGHT;
            }
        }
    }

    &::menu-indicator {
        image: url($PATH_RESOURCES + '/rc/arrow_down.png');
        height: 8px;
        width: 8px;
        top: 0;
        /* Exclude a shift for better image */
        left: -2px;
        /* Shift it a bit */
    }

    &::menu-arrow {
        image: url($PATH_RESOURCES + '/rc/arrow_down.png');
        height: 8px;
        width: 8px;

        &:hover {
            image: url($PATH_RESOURCES + '/rc/arrow_down_focus.png');
        }
    }
}

/* QCommandLinkButton -----------------------------------------------------

--------------------------------------------------------------------------- */
QCommandLinkButton {
    background-color: transparent;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    border-radius: $SIZE_BORDER_RADIUS;
    padding: 0px;
    margin: 0px;

    &:disabled {
        background-color: transparent;
        color: $COLOR_FOREGROUND_DARK;
    }
}

/* ------------------------------------------------------------------------ */
/* INPUTS - NO FIELDS ----------------------------------------------------- */
/* ------------------------------------------------------------------------ */

/* QComboBox --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox

--------------------------------------------------------------------------- */
QComboBox {
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;
    selection-background-color: $COLOR_SELECTION_NORMAL;
    padding-left: 4px;
    padding-right: 36px;
    /* 4 + 16*2 See scrollbar size */

    /* Fixes #103, #111 */
    min-height: 1.5em;

    /* padding-top: 2px;     removed to fix #132 */
    /* padding-bottom: 2px;  removed to fix #132 */
    /* min-width: 75px;      removed to fix #109 */

    QAbstractItemView {
        border: $BORDER_NORMAL;
        border-radius: 0;
        background-color: $COLOR_BACKGROUND_DARK;
        selection-background-color: $COLOR_SELECTION_NORMAL;

        &:hover {
            background-color: $COLOR_BACKGROUND_DARK;
            color: $COLOR_FOREGROUND_LIGHT;
        }

        &:selected {
            background: $COLOR_SELECTION_NORMAL;
            color: $COLOR_BACKGROUND_NORMAL;
        }

        &:alternate {
            background: $COLOR_BACKGROUND_DARK;
        }

    }

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

    &:on {
        selection-background-color: $COLOR_SELECTION_NORMAL;
    }

    /* Needed to remove indicator - fix #132 */
    &::indicator {
        border: none;
        border-radius: 0;
        background-color: transparent;
        selection-background-color: transparent;
        color: transparent;
        selection-color: transparent;

        /* Needed to remove indicator - fix #132 */
        &:alternate {
            background: $COLOR_BACKGROUND_DARK;
        }
    }

    &::item {

        &:alternate {
            background: $COLOR_BACKGROUND_DARK;
        }

        &:checked {
            font-weight: bold;
        }

        &:selected {
            border: 0px solid transparent;
        }
    }

    &::drop-down {
        subcontrol-origin: padding;
        subcontrol-position: top right;
        width: 12px;
        border-left: 1px solid $COLOR_BACKGROUND_NORMAL;
    }

    &::down-arrow {
        image: url($PATH_RESOURCES + '/rc/arrow_down_disabled.png');
        height: 8px;
        width: 8px;

        &:on,
        &:hover,
        &:focus {
            image: url($PATH_RESOURCES + '/rc/arrow_down.png');
        }
    }
}

/* QSlider ----------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qslider

--------------------------------------------------------------------------- */
QSlider {

    &:disabled {
        background: $COLOR_BACKGROUND_DARK;
    }

    &:focus {
        border: none;
    }

    &::groove {
        &:horizontal {
            background: $COLOR_BACKGROUND_NORMAL;
            border: $BORDER_NORMAL;
            height: 4px;
            margin: 0px;
            border-radius: $SIZE_BORDER_RADIUS;
        }

        &:vertical {
            background: $COLOR_BACKGROUND_NORMAL;
            border: $BORDER_NORMAL;
            width: 4px;
            margin: 0px;
            border-radius: $SIZE_BORDER_RADIUS;
        }
    }

    &::add-page {

        &:vertical {
            background: $COLOR_SELECTION_NORMAL;
            border: $BORDER_NORMAL;
            width: 4px;
            margin: 0px;
            border-radius: $SIZE_BORDER_RADIUS;

            :disabled {
                background: $COLOR_SELECTION_DARK;
            }
        }
    }

    &::sub-page {

        &:horizontal {
            background: $COLOR_SELECTION_NORMAL;
            border: $BORDER_NORMAL;
            height: 4px;
            margin: 0px;
            border-radius: $SIZE_BORDER_RADIUS;

            &:disabled {
                background: $COLOR_SELECTION_DARK;
            }
        }
    }

    &::handle {

        &:horizontal {
            background: $COLOR_FOREGROUND_DARK;
            border: $BORDER_NORMAL;
            width: 8px;
            height: 8px;
            margin: -8px 0px;
            border-radius: $SIZE_BORDER_RADIUS;

            &:hover {
                background: $COLOR_SELECTION_LIGHT;
                border: $BORDER_SELECTION_LIGHT;
            }

            &:focus {
                border: $BORDER_SELECTION_NORMAL;
            }
        }

        &:vertical {
            background: $COLOR_FOREGROUND_DARK;
            border: $BORDER_NORMAL;
            width: 8px;
            height: 8px;
            margin: 0 -8px;
            border-radius: $SIZE_BORDER_RADIUS;

            &:hover {
                background: $COLOR_SELECTION_LIGHT;
                border: $BORDER_SELECTION_LIGHT;
            }

            &:focus {
                border: $BORDER_SELECTION_NORMAL;
            }
        }
    }
}

/* QLineEdit --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qlineedit

--------------------------------------------------------------------------- */
QLineEdit {
    background-color: $COLOR_BACKGROUND_DARK;
    padding-top: 2px;
    /* This QLineEdit fix  103, 111 */
    padding-bottom: 2px;
    /* This QLineEdit fix  103, 111 */
    padding-left: 4px;
    padding-right: 4px;
    border-style: solid;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;
    color: $COLOR_FOREGROUND_LIGHT;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:focus {
        border: $BORDER_SELECTION_NORMAL;
    }

    &:selected {
        background-color: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }
}

/* QTabWiget --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

--------------------------------------------------------------------------- */
QTabWidget {
    padding: 2px;
    selection-background-color: $COLOR_BACKGROUND_NORMAL;

    QWidget {
        /* Fixes #189 */
        border-radius: $SIZE_BORDER_RADIUS;
    }

    &::pane {
        border: $BORDER_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
        margin: 0px;
        /* Fixes double border inside pane with pyqt5 */
        padding: 0px;

        &:selected {
            background-color: $COLOR_BACKGROUND_NORMAL;
            border: 1px solid $COLOR_SELECTION_NORMAL;
        }
    }
}

/* QTabBar ----------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

--------------------------------------------------------------------------- */
QTabBar {
    qproperty-drawBase: 0;
    border-radius: $SIZE_BORDER_RADIUS;
    margin: 0px;
    padding: 2px;
    border: 0;
    /* left: 5px; move to the right by 5px - removed for fix */

    &::close-button {
        border: 0;
        margin: 2px;
        padding: 2px;

        image: url($PATH_RESOURCES + '/rc/window_close.png');

        &:hover {
            image: url($PATH_RESOURCES + '/rc/window_close_focus.png');
        }

        &:pressed {
            image: url($PATH_RESOURCES + '/rc/window_close_pressed.png');
        }
    }
}

/* QTabBar::tab - selected ------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

--------------------------------------------------------------------------- */
QTabBar {

    &::tab {

        &:top:selected:disabled {
            border-bottom: 3px solid $COLOR_SELECTION_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_NORMAL;
        }

        &:bottom:selected:disabled {
            border-top: 3px solid $COLOR_SELECTION_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_NORMAL;
        }

        &:left:selected:disabled {
            border-right: 3px solid $COLOR_SELECTION_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_NORMAL;
        }

        &:right:selected:disabled {
            border-left: 3px solid $COLOR_SELECTION_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_NORMAL;
        }

        /* !selected and disabled ----------------------------------------- */
        &:top:!selected:disabled {
            border-bottom: 3px solid $COLOR_BACKGROUND_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_DARK;
        }

        &:bottom:!selected:disabled {
            border-top: 3px solid $COLOR_BACKGROUND_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_DARK;
        }

        &:left:!selected:disabled {
            border-right: 3px solid $COLOR_BACKGROUND_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_DARK;
        }

        &:right:!selected:disabled {
            border-left: 3px solid $COLOR_BACKGROUND_DARK;
            color: $COLOR_FOREGROUND_DARK;
            background-color: $COLOR_BACKGROUND_DARK;
        }

        /* selected ------------------------------------------------------- */
        &:top:!selected {
            border-bottom: 2px solid $COLOR_BACKGROUND_DARK;
            margin-top: 2px;
        }

        &:bottom:!selected {
            border-top: 2px solid $COLOR_BACKGROUND_DARK;
            margin-bottom: 3px;
        }

        &:left:!selected {
            border-left: 2px solid $COLOR_BACKGROUND_DARK;
            margin-right: 2px;
        }

        &:right:!selected {
            border-right: 2px solid $COLOR_BACKGROUND_DARK;
            margin-left: 2px;
        }

        &:top {
            background-color: $COLOR_BACKGROUND_NORMAL;
            color: $COLOR_FOREGROUND_LIGHT;
            margin-left: 2px;
            padding-left: 4px;
            padding-right: 4px;
            padding-top: 2px;
            padding-bottom: 2px;
            min-width: 5px;
            border-bottom: 3px solid $COLOR_BACKGROUND_NORMAL;
            border-top-left-radius: 3px;
            border-top-right-radius: 3px;

            &:selected {
                background-color: $COLOR_BACKGROUND_LIGHT;
                color: $COLOR_FOREGROUND_LIGHT;
                border-bottom: 3px solid $COLOR_SELECTION_NORMAL;
                border-top-left-radius: 3px;
                border-top-right-radius: 3px;
            }

            &:!selected:hover {
                border: $BORDER_SELECTION_LIGHT;
                border-bottom: 3px solid $COLOR_SELECTION_LIGHT;

                /* Fixes spyder-ide/spyder#9766 */
                padding-left: 4px;
                padding-right: 4px;
            }
        }

        &:bottom {
            color: $COLOR_FOREGROUND_LIGHT;
            border-top: 3px solid $COLOR_BACKGROUND_NORMAL;
            background-color: $COLOR_BACKGROUND_NORMAL;
            margin-left: 2px;
            padding-left: 4px;
            padding-right: 4px;
            padding-top: 2px;
            padding-bottom: 2px;
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 3px;
            min-width: 5px;

            &:selected {
                color: $COLOR_FOREGROUND_LIGHT;
                background-color: $COLOR_BACKGROUND_LIGHT;
                border-top: 3px solid $COLOR_SELECTION_NORMAL;
                border-bottom-left-radius: 3px;
                border-bottom-right-radius: 3px;
            }

            &:!selected:hover {
                border: $BORDER_SELECTION_LIGHT;
                border-top: 3px solid $COLOR_SELECTION_LIGHT;

                /* Fixes spyder-ide/spyder#9766 */
                padding-left: 4px;
                padding-right: 4px;
            }

        }

        &:left {
            color: $COLOR_FOREGROUND_LIGHT;
            background-color: $COLOR_BACKGROUND_NORMAL;
            margin-top: 2px;
            padding-left: 2px;
            padding-right: 2px;
            padding-top: 4px;
            padding-bottom: 4px;
            border-top-left-radius: 3px;
            border-bottom-left-radius: 3px;
            min-height: 5px;

            &:selected {
                color: $COLOR_FOREGROUND_LIGHT;
                background-color: $COLOR_BACKGROUND_LIGHT;
                border-right: 3px solid $COLOR_SELECTION_NORMAL;
            }

            &:!selected:hover {
                border: $BORDER_SELECTION_LIGHT;
                border-right: 3px solid $COLOR_SELECTION_LIGHT;
                padding: 0px;
            }
        }

        &:right {
            color: $COLOR_FOREGROUND_LIGHT;
            background-color: $COLOR_BACKGROUND_NORMAL;
            margin-top: 2px;
            padding-left: 2px;
            padding-right: 2px;
            padding-top: 4px;
            padding-bottom: 4px;
            border-top-right-radius: 3px;
            border-bottom-right-radius: 3px;
            min-height: 5px;

            &:selected {
                color: $COLOR_FOREGROUND_LIGHT;
                background-color: $COLOR_BACKGROUND_LIGHT;
                border-left: 3px solid $COLOR_SELECTION_NORMAL;

            }

            &:!selected:hover {
                border: $BORDER_SELECTION_LIGHT;
                border-left: 3px solid $COLOR_SELECTION_LIGHT;
                padding: 0px;
            }
        }
    }

    QToolButton {
        /* Fixes #136 */
        background-color: $COLOR_BACKGROUND_NORMAL;
        height: 12px;
        width: 12px;

        &:pressed {
            background-color: $COLOR_BACKGROUND_NORMAL;

            &:hover {
                border: $BORDER_SELECTION_LIGHT;
            }
        }

        &::left-arrow {
            &:enabled {
                image: url($PATH_RESOURCES + '/rc/arrow_left.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/arrow_left_disabled.png');
            }
        }

        &::right-arrow {
            &:enabled {
                image: url($PATH_RESOURCES + '/rc/arrow_right.png');
            }

            &:disabled {
                image: url($PATH_RESOURCES + '/rc/arrow_right_disabled.png');
            }
        }
    }
}

/* QDockWiget -------------------------------------------------------------

--------------------------------------------------------------------------- */
QDockWidget {
    outline: $BORDER_NORMAL;
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;
    titlebar-close-icon: url($PATH_RESOURCES + '/rc/window_close.png');
    titlebar-normal-icon: url($PATH_RESOURCES + '/rc/window_undock.png');



    &::title {
        /* Better size for title bar */
        padding: 6px;
        spacing: 4px;
        border: none;
        background-color: $COLOR_BACKGROUND_NORMAL;
    }

    &::close-button {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
        border: none;

        &:hover {
            image: url($PATH_RESOURCES + '/rc/window_close_focus.png');
        }

        &:pressed {
            image: url($PATH_RESOURCES + '/rc/window_close_pressed.png');
        }
    }

    &::float-button {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border-radius: $SIZE_BORDER_RADIUS;
        border: none;

        &:hover {
            image: url($PATH_RESOURCES + '/rc/window_undock_focus.png');
        }

        &:pressed {
            image: url($PATH_RESOURCES + '/rc/window_undock_pressed.png');
        }
    }
}

/* QTreeView QListView QTableView -----------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtreeview
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qlistview
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtableview

--------------------------------------------------------------------------- */
QTreeView {

    &:branch {

        &:selected,
        &:hover {
            background: url($PATH_RESOURCES + '/rc/transparent.png');
        }

        &:has-siblings:!adjoins-item {
            border-image: url($PATH_RESOURCES + '/rc/branch_line.png') 0;
        }

        &:has-siblings:adjoins-item {
            border-image: url($PATH_RESOURCES + '/rc/branch_more.png') 0;
        }

        &:!has-children:!has-siblings:adjoins-item {
            border-image: url($PATH_RESOURCES + '/rc/branch_end.png') 0;
        }

        &:has-children:!has-siblings:closed,
        &:closed:has-children:has-siblings {
            border-image: none;
            image: url($PATH_RESOURCES + '/rc/branch_closed.png');
        }

        &:open:has-children:!has-siblings,
        &:open:has-children:has-siblings {
            border-image: none;
            image: url($PATH_RESOURCES + '/rc/branch_open.png');
        }

        &:has-children:!has-siblings:closed:hover,
        &:closed:has-children:has-siblings:hover {
            image: url($PATH_RESOURCES + '/rc/branch_closed_focus.png');
        }

        &:open:has-children:!has-siblings:hover,
        &:open:has-children:has-siblings:hover {
            image: url($PATH_RESOURCES + '/rc/branch_open_focus.png');
        }
    }
}

QTreeView,
QListView {

    &::indicator {

        &:checked {
            image: url($PATH_RESOURCES + '/rc/checkbox_checked.png');

            &:hover,
            &:focus,
            &:pressed {
                image: url($PATH_RESOURCES + '/rc/checkbox_checked_focus.png');
            }
        }

        &:unchecked {
            image: url($PATH_RESOURCES + '/rc/checkbox_unchecked.png');

            &:hover,
            &:focus,
            &:pressed {
                image: url($PATH_RESOURCES + '/rc/checkbox_unchecked_focus.png');
            }
        }

        &:indeterminate {
            image: url($PATH_RESOURCES + '/rc/checkbox_indeterminate.png');

            &:hover,
            &:focus,
            &:pressed {
                image: url($PATH_RESOURCES + '/rc/checkbox_indeterminate_focus.png');
            }
        }
    }
}

QTreeView,
QListView,
QTableView,
QColumnView {
    background-color: $COLOR_BACKGROUND_DARK;
    border: $BORDER_NORMAL;
    color: $COLOR_FOREGROUND_LIGHT;
    gridline-color: $COLOR_BACKGROUND_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;

    &:disabled {
        background-color: $COLOR_BACKGROUND_DARK;
        color: $COLOR_FOREGROUND_DARK;
    }

    &:selected {
        background-color: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }

    &:hover {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_SELECTION_LIGHT;
    }

    &::item {

        &:pressed {
            background-color: $COLOR_SELECTION_NORMAL;
        }

        &:selected {

            &:hover {
                background: $COLOR_SELECTION_NORMAL;
                color: $COLOR_BACKGROUND_DARK;
            }

            &:active {
                background-color: $COLOR_SELECTION_NORMAL;
            }
        }

        &:!selected {

            &:hover {
                outline: 0;
                color: $COLOR_SELECTION_LIGHT;
                background-color: $COLOR_BACKGROUND_NORMAL;
            }
        }
    }
}

QTableCornerButton {
    &::section {
        background-color: $COLOR_BACKGROUND_DARK;
        border: 1px transparent $COLOR_BACKGROUND_NORMAL;
        border-radius: 0px;
    }
}

/* QHeaderView ------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qheaderview

--------------------------------------------------------------------------- */
QHeaderView {
    background-color: $COLOR_BACKGROUND_NORMAL;
    border: 0px transparent $COLOR_BACKGROUND_NORMAL;
    padding: 0px;
    margin: 0px;
    border-radius: 0px;

    &:disabled {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: 1px transparent $COLOR_BACKGROUND_NORMAL;
        padding: 2px;
    }

    &::section {
        background-color: $COLOR_BACKGROUND_NORMAL;
        color: $COLOR_FOREGROUND_LIGHT;
        padding: 2px;
        border-radius: 0px;
        text-align: left;

        &:checked {
            color: $COLOR_FOREGROUND_LIGHT;
            background-color: $COLOR_SELECTION_NORMAL;

            &:disabled {
                color: $COLOR_FOREGROUND_DARK;
                background-color: $COLOR_SELECTION_DARK;
            }
        }

        &::horizontal {
            padding-left: 4px;
            padding-right: 4px;
            border-left: $BORDER_DARK;

            &::first,
            &::only-one {
                border-left: $BORDER_NORMAL;
            }

            &:disabled {
                color: $COLOR_FOREGROUND_DARK;
            }
        }

        &::vertical {
            padding-left: 4px;
            padding-right: 4px;
            border-top: $BORDER_DARK;

            &::first,
            &::only-one {
                border-top: $BORDER_NORMAL;
            }

            &:disabled {
                color: $COLOR_FOREGROUND_DARK;
            }
        }
    }

    &::down-arrow {
        /* Those settings (border/width/height/background-color) solve bug */
        /* transparent arrow background and size */
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: none;
        height: 12px;
        width: 12px;
        padding-left: 2px;
        padding-right: 2px;
        image: url($PATH_RESOURCES + '/rc/arrow_down.png');
    }

    &::up-arrow {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: none;
        height: 12px;
        width: 12px;
        padding-left: 2px;
        padding-right: 2px;
        image: url($PATH_RESOURCES + '/rc/arrow_up.png');
    }
}

/* QToolBox --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtoolbox

--------------------------------------------------------------------------- */
QToolBox {
    padding: 0px;
    border: 0px;
    border: $BORDER_NORMAL;

    &:selected {
        padding: 0px;
        border: 2px solid $COLOR_SELECTION_NORMAL;
    }

    &::tab {
        background-color: $COLOR_BACKGROUND_DARK;
        border: $BORDER_NORMAL;
        color: $COLOR_FOREGROUND_LIGHT;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;

        &:disabled {
            color: $COLOR_FOREGROUND_DARK;
        }

        &:selected {
            background-color: $COLOR_BACKGROUND_LIGHT;
            border-bottom: 2px solid $COLOR_SELECTION_NORMAL;

            &:disabled {
                background-color: $COLOR_BACKGROUND_NORMAL;
                border-bottom: 2px solid $COLOR_SELECTION_DARK;
            }
        }

        &:!selected {
            background-color: $COLOR_BACKGROUND_NORMAL;
            border-bottom: 2px solid $COLOR_BACKGROUND_NORMAL;

            &:disabled {
                background-color: $COLOR_BACKGROUND_DARK;
            }

        }

        &:hover {
            border-color: $COLOR_SELECTION_LIGHT;
            border-bottom: 2px solid $COLOR_SELECTION_LIGHT;
        }
    }

    QScrollArea QWidget QWidget {
        padding: 0px;
        border: 0px;
        background-color: $COLOR_BACKGROUND_DARK;
    }
}

/* QFrame -----------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qframe
https://doc.qt.io/qt-5/qframe.html#-prop
https://doc.qt.io/qt-5/qframe.html#details
https://stackoverflow.com/questions/14581498/qt-stylesheet-for-hline-vline-color

--------------------------------------------------------------------------- */

/* (dot) .QFrame  fix #141, #126, #123 */

.QFrame {
    border-radius: $SIZE_BORDER_RADIUS;
    border: $BORDER_NORMAL;

    /* No frame */
    &[frameShape="0"] {
        border-radius: $SIZE_BORDER_RADIUS;
        border: 1px transparent $COLOR_BACKGROUND_NORMAL;
    }

    /* HLine */
    &[frameShape="4"] {
        max-height: 2px;
        border: none;
        background-color: $COLOR_BACKGROUND_NORMAL;
    }

    /* HLine */
    &[frameShape="5"] {
        max-width: 2px;
        border: none;
        background-color: $COLOR_BACKGROUND_NORMAL;
    }

}

/* QSplitter --------------------------------------------------------------

https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qsplitter

--------------------------------------------------------------------------- */
QSplitter {
    background-color: $COLOR_BACKGROUND_NORMAL;
    spacing: 0px;
    padding: 0px;
    margin: 0px;

    &::handle {
        background-color: $COLOR_BACKGROUND_NORMAL;
        border: 0px solid $COLOR_BACKGROUND_DARK;
        spacing: 0px;
        padding: 1px;
        margin: 0px;

        &:hover {
            background-color: $COLOR_FOREGROUND_DARK;
        }

        &:horizontal {
            width: 5px;
            image: url($PATH_RESOURCES + '/rc/line_vertical.png');
        }

        &:vertical {
            height: 5px;
            image: url($PATH_RESOURCES + '/rc/line_horizontal.png');
        }
    }
}

/* QDateEdit, QDateTimeEdit -----------------------------------------------

--------------------------------------------------------------------------- */
QDateEdit, QDateTimeEdit {
    selection-background-color: $COLOR_SELECTION_NORMAL;
    border-style: solid;
    border: $BORDER_NORMAL;
    border-radius: $SIZE_BORDER_RADIUS;

    /* This fixes 103, 111 */
    padding-top: 2px;

    /* This fixes 103, 111 */
    padding-bottom: 2px;
    padding-left: 4px;
    padding-right: 4px;
    min-width: 10px;

    &:on {
        selection-background-color: $COLOR_SELECTION_NORMAL;
    }

    &::drop-down {
        subcontrol-origin: padding;
        subcontrol-position: top right;
        width: 12px;
        border-left: 1px solid $COLOR_BACKGROUND_NORMAL;
    }

    &::down-arrow {
        image: url($PATH_RESOURCES + '/rc/arrow_down_disabled.png');
        height: 8px;
        width: 8px;

        &:on,
        &:hover,
        &:focus {
            image: url($PATH_RESOURCES + '/rc/arrow_down.png');
        }

    }

    QAbstractItemView {
        background-color: $COLOR_BACKGROUND_DARK;
        border-radius: $SIZE_BORDER_RADIUS;
        border: $BORDER_NORMAL;
        selection-background-color: $COLOR_SELECTION_NORMAL;
    }
}


/* QAbstractView ----------------------------------------------------------

--------------------------------------------------------------------------- */
QAbstractView {

    &:hover {
        border: $BORDER_SELECTION_LIGHT;
        color: $COLOR_FOREGROUND_LIGHT;
    }

    &:selected {
        background: $COLOR_SELECTION_NORMAL;
        color: $COLOR_BACKGROUND_NORMAL;
    }
}


/* PlotWidget -------------------------------------------------------------

--------------------------------------------------------------------------- */
PlotWidget {
    /* Fix cut labels in plots #134 */
    padding: 0px;
}
