@import "../../../ui/imports/colours";

#customfields-container {
    padding-top: 20px;
    min-height: 100px;
    position: relative;

    &.active::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1;
        background-color: var(--ds-surface, #fff);
        opacity: 0.5;
    }

    #custom-fields-table {
        table-layout: fixed;
        width: 100%;

        td,
        div.secondary-text,
        strong.customfield-name,
        .buttons {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .customfield-head-wrapper {
            display: flex;
        }

        .customfield-name-wrapper {
            min-width: 30px; // allows to do text-ellipsis in strong.customfield-name
        }

        strong.customfield-name {
            display: inline-block;
            max-width: 100%;
        }

        .custom-fields-bulk-delete {
            margin-left: 20px;
        }

        .customfields-bulk-delete-meta {
            display: none;
        }

        .custom-fields-header-bulk {
            th:not(.customfield-checkbox) {
                pointer-events: none;
                background: none;
                div {
                    visibility: hidden;
                }
            }

            th.customfield-checkbox {
                white-space: nowrap;
            }

            .customfields-bulk-delete-meta {
                display: inline-block;
            }

            form.aui {
                display: inline-block;
                width: 35px;
            }
        }

        .custom-fields-checkbox-label {
            height: 14px;
            display: inline-block;
        }

        /* Column widths are based on these cells */

        th.customfield-checkbox {
            width: 15px;
        }

        th.customfield-name {
            width: 45%;
        }

        th.customfield-type {
            width: 15%;
        }

        th.customfield-contexts {
            width: 15%;
        }

        th.customfield-screens {
            width: 15%;
        }

        th.customfield-actions {
            width: 10%;
        }

        th.customfield-values {
            width: 13%;
            text-align: right;
        }

        th.customfield-updates {
            width: 17%;
        }

        &.custom-fields-identification-header {
            th.customfield-name {
                width: 20%;
            }

            th.customfield-type {
                width: 15%;
            }

            th.customfield-contexts {
                width: 10%;
            }

            th.customfield-screens {
                width: 10%;
            }
        }

        .customfield-highlight {
            background-color: var(--ds-surface-pressed, @aui-color-B50);
        }

        span.aui-lozenge {
            margin-left: 10px;
        }

        td.customfield-values-cell {
            text-align: right;
        }

        + #pagination-container {
            margin-top: 10px;
            clear: both; // clear the floated pagination so that loading indicator can block it
            &::after {
                content: '';
                display: block;
                visibility: hidden;
                clear: both;
            }
        }
    }
}

.customfields-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.customfield-text-input-wrapper {
    position: relative;

    .aui-icon {
        pointer-events: none;
        position: absolute;
        top: 50%;
        z-index: 2;
        margin-top: -8px;
        right: 5px;
    }
}

form.aui .customfield-filter-item {
    display: inline-block;
    position: relative;

    .text {
        // leave enough room for the icon to prevent the user from typing over the icon
        width: 255px;
        padding: 0 24px 0 6px;
    }

    .customfield-filter-text-search {
        box-sizing: border-box;
        position: relative;
        padding: 5px 10px 0;

        .aui-icon {
            position: absolute;
            top: 50%;
            margin-top: -6px;
            right: 15px;
            z-index: 2;
        }

        .customfield-filter-text-search-input {
            // override default AUI styles so the input is not too narrow when a scrollbar is visible inside the dropdown
            width: 100%;
            max-width: unset;
        }
    }
}

.customfield-filter-form {
    .customfield-filter-items {
        display: flex;
        box-sizing: border-box;
        max-width: 100%;
        flex-flow: row wrap;
        justify-content: start;
        align-items: center;

        .customfield-filter-item {
            margin-bottom: 10px;
            margin-right: 10px;
            max-width: 350px;
            min-width: 150px;
            // filtering search box
            &:first-child {
                flex: none;
            }
        }

        .customfield-filter-dropdown-trigger {
            width: 100%;
            overflow: hidden;
            text-align: left;
            text-overflow: ellipsis;
        }
    }
}

#last-value-update-filter-dropdown {
    width: 200px;
}

.customfield-filter-dropdown-item {
    display: flex;
    padding: 6px 10px;
    cursor: default;
    color: var(--aui-body-text);

    &:focus {
        color: var(--aui-body-text);
    }

    &:hover {
        background-color: var(--ds-surface-hovered, @aui-color-B50);
        text-decoration: none;
        color: var(--aui-body-text);
    }

    .customfield-filter-image {
        flex: 0 0;
        margin-right: 4px;
        line-height: 16px;
    }

    .customfield-filter-text {
        flex: 1 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.customfield-filter-spinner {
    margin: 15px auto;
}

.customfield-filter-clear {
    padding: 5px 10px;
}

.customfield-filter-text-search-input {
    box-sizing: border-box;
    border-radius: 3px;
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 28px;
    height: 0;
    border: 1px solid var(--ds-border-input, #c1c7d0);
    padding: 0 24px 0 6px;
    box-shadow: var(--ds-shadow-overlay, #bbbbbb 0 7px 2px -7px inset);
    margin: 0;
    font-size: 14px;
    font-family: inherit;
}

#types-filter-dropdown,
#projects-filter-dropdown,
#screens-filter-dropdown {
    min-height: 50px;

    .customfield-filter-scroll {
        max-height: 400px;
        overflow-y: auto;
        position: relative;
    }

    .no-suggestions {
        padding: 7px 11px 6px;
        background: var(--ds-background-input, rgb(242, 242, 242));
        display: block;
        font-style: italic;
        margin: 0;
    }
}

.customfields-select-dropdown .aui-inline-dialog-contents {
    padding: 0;
}

.customfields-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 30px;
    font-size: 13px;
}

.customfields-pagination-details {
    color: var(--ds-text-subtle, @aui-color-N200);
    font-size: 12px;
    font-weight: 600;
}

.customfield-help-icon {
    color: var(--ds-icon, @aui-color-N400);
    display: inline-block;
    margin-left: 3px;
}

.customfields-calendar-item {
    padding: 6px 10px;
    border-top: 1px solid var(--aui-dropdown-border-color);

    form.aui .customfields-calendar-input {
        width: 100%;
        max-width: 100%;
    }
}

.customfield-delete-dialog-content.aui-dialog2-content {
    min-height: 120px;
}

.customfield-delete-dialog-spinner {
    float: right;
}