/*
 * SPDX-License-Identifier: BSD-2-Clause
 * SPDX-FileCopyrightText: 2025 Akseli Lahtinen <akselmo@akselmo.dev>
 */

treeviewdelegate,
tableviewdelegate {
    width: var(--medium-element-size);
    height: var(--medium-element-size);

    padding: var(--small-spacing);
    spacing: var(--small-spacing);
    border-radius: 0px;

    layout-alignment: content fill center 0;
    icon-alignment: content start center 1;
    text-alignment: content fill center 2;

    icon-width: var(--icon-size-small);
    icon-height: var(--icon-size-small);

    color: var(--view-text-color);
    background-color: var(--view-background-color);

    &.alternating-colors {
        background-color: var(--view-background-alternate-color);
    }

    &:hovered,
    &:active-focus {
        border: 1px solid var(--highlight-color);
        background-color: transparent;
    }

    &:visual-focus {
        outline: 1px solid var(--focus-color);
    }

    &:highlighted,
    &.selected {
        color: var(--highlight-text-color);
        border: 1px solid var(--highlight-color);
        background-color: var(--highlight-color);
    }

    &.selected > label {
        color: var(--highlight-text-color);
    }

    &.editing {
        border: 1px solid var(--highlight-color);
    }

    &:disabled {
        color: var(--view-disabled-text-color);
        background-color: var(--view-disabled-background-color);
    }
}

treeviewdelegate {
    spacing: 0px;

    & > * {
        layout-alignment: content fill fill 0;
    }

    & > indentation {
        width: var(--medium-element-size);
        layout-alignment: item start center 0;
    }

    & > indicator {
        width: var(--medium-element-size);
        height: var(--icon-size-small);
        color: var(--view-text-color);
        icon-name: "arrow-right-symbolic";
        layout-alignment: item start center 1;
    }

    & > radiobutton,
    & > checkbox {
        text-wrap-mode: no-wrap;
        layout-alignment: content fill center 0;
        icon-alignment: content start center 1;
        text-alignment: content fill center 2;
    }

    &.expanded > indicator {
        icon-name: "arrow-down-symbolic"
    }

    &:disabled {
        color: var(--view-disabled-text-color);
        background-color: var(--view-disabled-background-color);

        & > indicator {
            color: var(--view-disabled-text-color);
        }
    }
}

headerviewdelegate
{
    width: var(--large-element-size);
    height: var(--large-element-size);
    padding: var(--small-spacing);

    border-bottom: 1px solid var(--button-active-border-color);
    border-right: 1px solid var(--button-active-border-color);

    background-color: var(--button-active-background-color);
    color: var(--button-active-text-color);

    layout-alignment: content fill center 0;
    text-alignment: content center center 0;
    icon-alignment: content end center 0;

    icon-size: var(--icon-size-small);

    &:disabled
    {
        border: 1px solid var(--button-disabled-border-color);
        color: var(--button-disabled-text-color);
        background-color: var(--button-disabled-background-color);
    }

    &.sort-ascending
    {
        icon-name: "arrow-up";
    }

    &.sort-descending
    {
        icon-name: "arrow-down";
    }
}

selectionrectangle {
    color: var(--highlight-color);
    border: 1px solid var(--highlight-color);
    border-radius: var(--corner-radius);
    background-color: var(--highlight-color);

    &:disabled {
        border: 1px solid var(--highlight-disabled-color);
        color: var(--highlight-disabled-color);
        background-color: var(--highlight-disabled-color);
    }
}

selectionrectanglehandle {
    width: var(--small-element-size);
    height: var(--small-element-size);
    background-color: var(--bar-handle-active-background-color);
    border: 1px solid var(--bar-active-border-color);
    border-radius: var(--small-element-size);

    &:visual-focus {
        border-color: var(--highlight-color);
        outline: var(--focus-outline);
    }

    &:disabled {
        color: var(--highlight-disabled-color);
        background-color: var(--bar-handle-disabled-background-color);
        border: 1px solid var(--bar-disabled-border-color);
    }
}
