@use "./steps";
@use "./attachments_dnd";

$attachments-gap: var(--tlp-small-spacing) / 2;
$attachment-height: var(--tlp-large-spacing);
$attachment-progress-bar-bg-color: var(--tlp-dimmed-color-lighter-50);

.current-test {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    margin: 0;
    overflow: hidden;
    border: 0;

    &.passed > .tlp-pane-container {
        > .current-test-header-container {
            background: var(--tlp-success-color);

            > .current-test-latest-result {
                background: linear-gradient(0deg, rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
                    var(--tlp-success-color);
            }
        }

        > .current-test-automated-message > .empty-state-title,
        > .current-test-automated-message > .empty-state-text {
            color: var(--tlp-success-color);
        }
    }

    &.failed > .tlp-pane-container {
        > .current-test-header-container {
            background: var(--tlp-danger-color);

            > .current-test-latest-result {
                background: linear-gradient(0deg, rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
                    var(--tlp-danger-color);
            }
        }

        > .current-test-automated-message > .empty-state-title,
        > .current-test-automated-message > .empty-state-text {
            color: var(--tlp-danger-color);
        }
    }

    &.blocked > .tlp-pane-container {
        > .current-test-header-container {
            background: var(--tlp-info-color);

            > .current-test-latest-result {
                background: linear-gradient(0deg, rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
                    var(--tlp-info-color);
            }
        }

        > .current-test-automated-message > .empty-state-title,
        > .current-test-automated-message > .empty-state-text {
            color: var(--tlp-info-color);
        }
    }

    &.notrun > .tlp-pane-container {
        > .current-test-header-container {
            background: var(--tlp-dimmed-color);

            > .current-test-latest-result {
                background: linear-gradient(0deg, rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
                    var(--tlp-dimmed-color);
            }
        }

        > .current-test-automated-message > .empty-state-title,
        > .current-test-automated-message > .empty-state-text {
            color: var(--tlp-dimmed-color);
        }
    }

    > .tlp-pane-container {
        min-height: 0;
    }

    &.comment-expanded {
        .current-test-content {
            flex: 0;
            padding: 0;
        }

        .current-test-footer-section-comment {
            flex: 1 1 auto;
            min-height: 0;

            &:not(.current-test-footer-section-readonly-comment-container)
                .current-test-results-container {
                max-height: none;
            }
        }

        .current-test-comment {
            height: 100%;
            max-height: none;
        }

        .current-test-comment-displayer {
            max-height: none;
            overflow-y: auto;

            img {
                max-height: none;
            }
        }

        .current-test-results-container {
            flex-direction: column-reverse;
            justify-content: flex-end;
            max-height: none;
        }

        .current-test-comment-attachments {
            flex: 1;
            flex-flow: row wrap;
        }

        .current-test-comment-attachements-container {
            flex-direction: row;
            width: 100%;
            margin: var(--tlp-small-spacing) 0 0;
        }

        .current-test-comment-attachements-controls {
            flex-direction: row;

            &.current-test-comment-attachements-controls-no-placeholder {
                align-items: flex-start;
            }
        }

        .test-files-empty-placeholder {
            margin: 0 var(--tlp-small-spacing) 0;
        }

        .test-files-upload-button-label {
            margin: 0 var(--tlp-small-spacing);
        }
    }
}

.current-test-header-container {
    border-top: 1px solid var(--tlp-neutral-normal-color);
    border-right: 1px solid var(--tlp-neutral-normal-color);
    border-left: 1px solid var(--tlp-neutral-normal-color);
    border-top-left-radius: var(--tlp-large-radius);
    border-top-right-radius: var(--tlp-large-radius);
}

.linked-issue-alert {
    display: flex;
}

.linked-issue-alert-text {
    flex: 1 1 auto;
}

.linked-issue-alert-close.tlp-button-outline {
    border: 0;
    box-shadow: unset;
}

.current-test-header-container > .loader {
    margin-top: var(--tlp-x-large-spacing);
}

.current-test-header {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--tlp-medium-spacing) var(--tlp-medium-spacing) var(--tlp-small-spacing);

    &:only-child {
        padding: var(--tlp-medium-spacing);
    }

    + .current-test-latest-result {
        margin-top: 0;
    }
}

.current-test-header-title {
    margin: 0;
    color: var(--tlp-white-color);
    font-size: 1.3rem;
    line-height: 1.7rem;
}

.current-test-title-icon-auto {
    position: relative;
    top: 1px;
    margin: 0 var(--tlp-small-spacing) 0;
}

.current-test-header-actions {
    display: flex;
    flex: 0 0 auto;
    margin-top: -2px;
}

.current-test-header-action {
    width: var(--tlp-x-large-spacing);
    height: var(--tlp-x-large-spacing);
    margin: 0 0 0 var(--tlp-small-spacing);
    border: 0;
    border-radius: 50%;
    background-color: transparent;
    box-shadow: none;
    color: var(--tlp-white-color);
    font-size: 1rem;

    &:hover,
    &:focus {
        background: var(--tlp-white-color-transparent-80);
        box-shadow: var(--tlp-button-shadow-hover);
    }
}

.artifact-link-graph-dot {
    fill: var(--tlp-white-color);
}

.artifact-link-graph-path {
    stroke: var(--tlp-white-color);
}

.current-test-requirement-or-bug {
    display: flex;
    flex: 0 0 auto;
    align-items: baseline;
    margin: 0 0 calc(var(--tlp-small-spacing) / 2);
    padding: 0 var(--tlp-medium-spacing) 0 calc(var(--tlp-medium-spacing) + 2px);
    border: 0;

    &:last-child {
        padding-bottom: var(--tlp-medium-spacing);
    }

    > .current-test-requirement-or-bug-icon {
        flex: 0 0 auto;
        margin: 0 var(--tlp-small-spacing) 0 0;
        color: var(--tlp-white-color);
        vertical-align: middle;
    }

    > a {
        display: flex;
        flex: 1 1 auto;
        align-items: baseline;
        color: var(--tlp-white-color);
        font-size: 0.875rem;
        line-height: 1.125rem;

        @media screen and (max-width: 1000px) {
            flex-wrap: wrap;
        }

        .current-test-requirement-or-bug-badge {
            margin: 0 4px 0 0;
            border-color: var(--tlp-white-color);
            background: var(--tlp-white-color-transparent-80);
            color: var(--tlp-white-color);
        }
    }

    > .tlp-dropdown {
        > .tlp-badge-success,
        > .tlp-badge-danger,
        > .tlp-badge-info,
        > .tlp-badge-secondary {
            border: 0;
            background: linear-gradient(0deg, rgb(0 0 0 / 20%), rgb(0 0 0 / 20%)),
                var(--badge-color);
            background-blend-mode: overlay, normal;
            mix-blend-mode: normal;
            cursor: pointer;

            &:first-child {
                margin: 0 var(--tlp-small-spacing) 0 0;
            }
        }

        > .tlp-badge-success {
            --badge-color: var(--tlp-success-color);
        }

        > .tlp-badge-danger {
            --badge-color: var(--tlp-danger-color);
        }

        > .tlp-badge-info {
            --badge-color: var(--tlp-info-color);
        }

        > .tlp-badge-secondary {
            --badge-color: var(--tlp-neutral-dark-color);
        }
    }
}

.current-test-latest-result {
    display: flex;
    align-items: center;
    margin: var(--tlp-small-spacing);
    padding: var(--tlp-small-spacing);
    border-radius: var(--tlp-medium-radius);
    background-blend-mode: overlay, normal;
    mix-blend-mode: normal;
    color: var(--tlp-white-color);
}

.current-test-status {
    margin: 0 var(--tlp-small-spacing) 0 0;
    font-size: 1.5rem;
}

.current-test-header-who {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5rem;
}

.current-test-content {
    flex: 1 1 50%;
    overflow-y: auto;
    border-right: 1px solid var(--tlp-neutral-normal-color);
    border-bottom: 0;
    border-left: 1px solid var(--tlp-neutral-normal-color);

    p,
    ul,
    ol {
        font-size: 0.875rem;
        line-height: 1.125rem;
    }
}

.current-test-footer-section {
    background: var(--tlp-fade-background-color);

    &.current-test-footer-top {
        border-top: 1px solid var(--tlp-neutral-light-color);
        border-right: 1px solid var(--tlp-neutral-normal-color);
        border-bottom: 0;
        border-left: 1px solid var(--tlp-neutral-normal-color);
    }

    &.current-test-footer-bottom {
        border-top: 1px solid var(--tlp-neutral-light-color);
        border-right: 1px solid var(--tlp-neutral-normal-color);
        border-bottom: 1px solid var(--tlp-neutral-normal-color);
        border-left: 1px solid var(--tlp-neutral-normal-color);
        border-bottom-right-radius: var(--tlp-large-radius);
        border-bottom-left-radius: var(--tlp-large-radius);
    }
}

.current-test-footer-section-comment {
    display: flex;
    flex-direction: column;
    min-height: 0;

    &:not(.current-test-footer-section-readonly-comment-container) .current-test-results-container {
        max-height: calc(14 * 1.125rem);
        overflow-y: auto;
    }
}

.current-test-warning-status-changed {
    margin: 0 var(--tlp-small-spacing) 0 0;
}

.current-test-footer-section-readonly-comment-container {
    padding: var(--tlp-medium-spacing) var(--tlp-medium-spacing) 0;
}

.current-test-footer-section-buttons-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--tlp-medium-spacing);
}

.current-test-edit-comment-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--tlp-medium-spacing);
}

.current-comment-header-section {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 var(--tlp-small-spacing);

    > label {
        margin: 0;
    }

    > .current-comment-header-toggler {
        display: flex;
        align-items: center;
        justify-content: center;
        width: var(--tlp-large-spacing);
        height: var(--tlp-large-spacing);
        margin: calc(-1 * var(--tlp-small-spacing)) calc(-1 * var(--tlp-small-spacing)) 0 0;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: none;
        box-shadow: none;
        color: var(--tlp-dimmed-color);

        &:focus,
        &:hover {
            background: var(--tlp-neutral-normal-color);
        }

        &:focus {
            box-shadow: var(--tlp-shadow-focus);
        }

        > .tlp-button-icon {
            margin: 0;
        }
    }
}

.current-test-footer-section-closed-campaign {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    background: var(--tlp-fade-background-color);
    color: var(--tlp-dimmed-color);
    font-size: 0.875rem;
    line-height: 1.375rem;
}

.current-test-results-container {
    display: flex;
    gap: var(--tlp-medium-spacing);
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(6 * (#{$attachment-height} + #{$attachments-gap}) - #{$attachment-height});
    overflow-y: auto;
}

.current-test-comment {
    padding: var(--tlp-small-spacing) 12px;
    overflow-y: auto;
    transition: border-color ease-out 150ms;
    border: 1px solid var(--tlp-neutral-normal-color);
    border-radius: var(--tlp-medium-radius);
    background: var(--tlp-white-color);

    // stylelint-disable selector-class-pattern
    &:focus,
    &.cke_focus {
        // stylelint-enable
        min-height: calc(8 * 1.125rem);
        border-radius: 0 var(--tlp-medium-radius) var(--tlp-medium-radius);
        border-color: var(--tlp-main-color);
    }

    img {
        height: auto !important;
    }
}

.current-test-comment-attachments {
    display: flex;
    gap: calc(#{$attachments-gap});
    flex: 0 0 auto;
    flex-direction: column;
    width: 200px;
    margin: 0 0 var(--tlp-medium-spacing);
}

.current-test-comment-attachment {
    display: flex;
    align-items: center;
    gap: calc(var(--tlp-small-spacing) / 2);
    height: $attachment-height;
    padding: var(--tlp-small-spacing)
        calc(
            (#{$attachment-height} - (var(--tlp-medium-spacing) + var(--tlp-small-spacing) / 2)) / 2
        )
        var(--tlp-small-spacing) var(--tlp-small-spacing);
    border-radius: calc(var(--tlp-large-spacing) / 2);
    background: var(--tlp-background-color-darker-05);
    color: var(--tlp-dark-color);
    font-size: 0.75rem;
    line-height: 1rem;

    &:is(a):hover {
        background: var(--tlp-background-color-darker-10);
        text-decoration: none;

        > .current-test-comment-attachment-label {
            text-decoration: underline;

            &.current-test-comment-attachment-label-deleted {
                text-decoration: underline line-through;
            }
        }
    }

    > .current-test-comment-attachment-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;

        &.current-test-comment-attachment-label-deleted {
            text-decoration-line: line-through;
        }
    }

    > .current-test-comment-attachment-buttons-container {
        display: flex;
        flex: 1;
        justify-content: flex-end;
    }

    &.current-test-comment-attachment-upload-error {
        background: var(--tlp-alert-warning-background);
        color: var(--tlp-alert-warning-color);
    }

    .current-test-comment-attachment-button {
        width: calc(var(--tlp-medium-spacing) + var(--tlp-small-spacing) / 2);
        height: calc(var(--tlp-medium-spacing) + var(--tlp-small-spacing) / 2);
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: inherit;
        box-shadow: none;

        &:hover {
            background: var(--tlp-background-color-darker-20);
            cursor: pointer;
        }

        > .current-test-comment-attachment-button-icon {
            margin: 0;
        }
    }
}

.current-test-comment-displayer {
    padding: 0 var(--tlp-medium-spacing) var(--tlp-medium-spacing) 0;
    border: 0;

    img {
        max-height: 3rem;
        border-radius: var(--tlp-small-radius);
    }
}

.current-test-comment,
.current-test-comment-displayer {
    width: 100%;

    p {
        margin: 0 0 var(--tlp-medium-spacing);
        font-size: 0.875rem;
        line-height: 1.125rem;

        &:last-child {
            margin: 0;
        }
    }
}

.current-test-results {
    display: flex;
}

.current-test-result {
    flex: 0 0 auto;
    width: calc(5 * var(--tlp-small-spacing));
    height: calc(5 * var(--tlp-small-spacing));
    margin: 0 0 0 var(--tlp-small-spacing);
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;

    &.tlp-button-info,
    &.tlp-button-secondary {
        font-size: 0.8rem;
    }

    &.tlp-button-secondary {
        border-color: var(--tlp-dimmed-color);
        background: var(--tlp-dimmed-color);
        color: var(--tlp-white-color);

        &:disabled,
        &:disabled:hover {
            border-color: transparent;
            background: var(--tlp-dimmed-color-lighter-30);
            color: var(--tlp-white-color-transparent-40);
        }

        &:hover {
            border-color: var(--tlp-dimmed-color-darker-10);
            background: var(--tlp-dimmed-color-darker-10);
        }
    }

    &:focus {
        box-shadow: 0 0 0 2px var(--tlp-main-color);
    }

    &:first-child {
        margin: 0;
    }
}

.linked-issues-dropdown-content-badge {
    margin: 0 5px 0 0;
}

.dropdown-link-bug-menu.tlp-dropdown-menu.tlp-dropdown-menu-on-icon.tlp-dropdown-shown {
    transform: translateX(4px);
}

.current-test-message-warning {
    margin: 0 0 var(--tlp-medium-spacing);
    padding: var(--tlp-small-spacing) var(--tlp-small-spacing) var(--tlp-small-spacing)
        var(--tlp-x-large-spacing);
    font-size: 0.875rem;
    line-height: 1.125rem;

    &::before {
        top: calc(var(--tlp-small-spacing) + 1px);
        left: var(--tlp-small-spacing);
        font-size: 0.9rem;
    }
}

.current-test-message-warning-actions {
    display: flex;
    flex: 0 0 auto;
    gap: var(--tlp-small-spacing);
    margin: var(--tlp-small-spacing) 0 0;
}

#test-files-upload-button {
    display: none;
}

.test-files-upload-button-label {
    width: max-content;
    margin: var(--tlp-small-spacing) 0;
}

.current-test-comment-attachements-container {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.current-test-comment-attachements-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.test-files-empty-placeholder {
    color: var(--tlp-dimmed-color);
    font-size: 0.875rem;
    line-height: 1.125rem;
    text-align: center;
}

.execution-attachment-progress {
    display: flex;
    align-items: center;
}

.execution-attachment-upload-progress-bar-value {
    margin: 0 5px;
    color: var(--tlp-success-color);
    font-size: 12px;
    font-weight: 600;
}

.execution-attachment-upload-progress-bar::-moz-progress-bar {
    border-radius: 20px;
    background: var(--tlp-success-color);
}

.execution-attachment-upload-progress-bar::-webkit-progress-bar {
    border-radius: 20px;
    background: $attachment-progress-bar-bg-color;
}

.execution-attachment-upload-progress-bar::-webkit-progress-value {
    border-radius: 20px;
    background: var(--tlp-success-color);
}

.execution-attachment-upload-progress-bar[value] {
    appearance: none;
    height: 5px;
}

.execution-attachment-upload-progress-bar {
    width: 100%;
    min-width: 50px;
    border: 0;
    border-radius: 20px;
    background: $attachment-progress-bar-bg-color;
    color: var(--tlp-success-color);
}

.attachment-upload-cancel {
    margin: 0 0 0 var(--tlp-small-spacing);
    transition: color ease-in-out 150ms;
    color: var(--tlp-success-color);
    font-size: 15px;
    cursor: pointer;

    &:hover {
        color: var(--tlp-danger-color);
    }
}

.attachments-uploads-error-list {
    padding: 0;

    > .attachment-upload-error {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        justify-content: center;
        margin: 0;
        border-bottom: 1px solid var(--tlp-neutral-light-color);

        &:last-child {
            border-bottom: 0;
        }

        > .attachment-upload-error-file-name {
            margin: 0 0 var(--tlp-small-spacing);
            overflow: hidden;
            font-weight: 600;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }
}

.current-test-empty-pane {
    flex: 1;
    border-top: 1px solid var(--tlp-neutral-light-color);
    border-right: 1px solid var(--tlp-neutral-normal-color);
    border-bottom: 1px solid var(--tlp-neutral-normal-color);
    border-left: 1px solid var(--tlp-neutral-normal-color);
    border-bottom-right-radius: var(--tlp-large-radius);
    border-bottom-left-radius: var(--tlp-large-radius);
}
