.launch-importer {
    cursor: pointer;
}

/* .importer-modal { */
    /* display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);

    .modal-pane {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90vw;
        height: 90vh;
        background-color: #fff;
        box-shadow: 0 5px 15px rgba(0,0,0,.5);
        padding: 2rem;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    } */

.importer {
    --new-item: Fuchsia;
    --has-changes: DarkOrange;
    --no-changes: ForestGreen;
    --error: DarkRed;

    width: 100%;
    min-height: calc(100vh - 90px);
    position: relative;

    &.--processing {
        /* &::before {
            content: '';
            position: absolute;
            top: 50%;
            right: 50%;
            transform: translate(-50%, -50%);
            width: 60px;
            height: 60px;
            border: 4px solid #ccc;
            border-top: 4px solid #333;
            border-radius: 50%;
            animation: spinner 1s linear infinite;
        } */
        .importer-spinner {
            display: block;
        }
    }

    .importer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
        flex: 0 0 auto;
        position: sticky;
        top: 50px;
        z-index: 100;
        border-bottom: 1px solid #ccc;
        background-color: #fff;
        padding: 1rem 0;
        margin-top: -1rem;

        h3 {
            margin: 0;
        }
    }

    .importer-header-controls {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    .importer-status {
        display: flex;
        align-items: center;
        gap: 1rem;
    }

    .importer-spinner {
        display: none;
        width: 2rem;
        height: 2rem;
        border: 2px solid #ccc;
        border-top: 2px solid DodgerBlue;
        border-radius: 50%;
        animation: spinner 1s linear infinite;
        flex: none;
    }

    .importer-close-x {
        display: block;
        font-size: 2rem;
        line-height: 2rem;
        width: 3rem;
        padding: 0.5rem;
        cursor: pointer;
    }

    .importer-body {
        height: calc(100% - 40px);
        flex: 1;
    }

    .importer-footer {
        height: 2rem;
        border-top: 1px solid #ccc;
        position: fixed;
        bottom: 0;
        left: calc(16.6666vw + 4rem);
        right: 4rem;
        height: 4rem;
        background-color: #fff;
        z-index: 100;
        padding-top: 0.5rem;
        z-index: 1000;
    }

    .importer-content {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .importer-instructions {
        flex: 0;
    }

    .importer-form {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: calc(100% - 30px);
    }

    .importer-studios-container {
        flex: 1;
        margin-bottom: 5rem;
    }

    .importer-actions {
        flex: 0;
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        /* border-top: 1px solid #ccc; */
        /* padding-top: 1rem; */
    }

    .list-item {
        /* border-bottom: 1px solid #ccc; */
        border-left: 1px solid #ccc;
        position: relative;
        
        /* &:first-child, */
        &:last-child {
            position: relative;
            
            &::before {
                content: '';
                position: absolute;
                top: 0;
                left: 0;
                height: 2rem;
                width: 1px;
                background-color: #ccc;
                z-index: 5;
            }
        }

        /* &:first-child {
            &::before {
                background-color: #fff;
                left: -2px;
                width: 3px;
            }
        } */

        &:last-child {
            border: none;
        }

        &::after {
            content: '';
            position: absolute;
            top: 2rem;
            left: 0;
            height: 1px;
            width: 1rem;
            background-color: #ccc;
        }

        &.--Studio > .item-content {
            position: sticky;
            top: 105px;
            z-index: 50;
            background-color: #fff;
        }

        &.--has-upstream-changes > .item-content .item-title,
        &.--has-upstream-changes > .item-content .item-controls svg,
        &.--has-upstream-changes > .item-content .item-meta svg,
        &.--children-have-upstream-changes > .item-content .item-title,
        &.--children-have-upstream-changes > .item-content .item-meta svg,
        &.--children-have-upstream-changes > .item-content .item-controls svg {
            color: var(--has-changes);
        }

        &.--no-internal-item > .item-content .item-title,
        &.--no-internal-item > .item-content .item-controls svg,
        &.--no-internal-item > .item-content .item-meta svg,
        &.--children-missing-internal-item > .item-content .item-title,
        &.--children-missing-internal-item > .item-content .item-meta svg,
        &.--children-missing-internal-item > .item-content .item-controls svg {
            color: var(--new-item);
        }

        &.--item-processing,
        &.--children-processing,
        &:has(.--item-processing) {
            > .item-content {
                .item-controls {
                    position: relative;

                    &::before {
                        content: '';
                        position: absolute;
                        top: 1rem;
                        right: 1rem;
                        transform: translate(0, -50%);
                        width: 2rem;
                        height: 2rem;
                        border: 3px solid #ccc;
                        border-top: 3px solid DodgerBlue;
                        border-radius: 50%;
                        animation: spinner 1s linear infinite;
                    }

                    > .item-control {
                        opacity: 0;
                        pointer-events: none;
                    }
                }
                
            }
        }
        

        &.--marked-for-import > .item-content,
        &:has(.--marked-for-import) > .item-content {
            /* color: DodgerBlue; */
            background-color: lightcyan;
            
            .item-title,
            .item-meta svg,
            .item-controls svg {
                color: DodgerBlue;
            }
        }

        &.--import-completed > .item-content {
            background-color: #EBFFD1;
            color: darkgreen;
        }

        &.--has-error > .item-content {
            background-color: #F8BFBF;
        }

        &.--has-error > .item-content,
        &.--has-error > .item-content svg,
        &.--children-have-errors > .item-content svg,
        &:has(.--has-error) > .item-content svg {
            color: darkred;
        }

        .--processing & {
            opacity: 0.75;

            > .item-content,
            > .item-content .item-icon {
                color: black;
                font-weight: normal;
            }
        }
        
        .item-content {
            display: flex;
            justify-content: space-between;
            align-items: center;

            &:hover {
                background-color: #f0f0f0;

                .--marked-for-import > & {
                    background-color: PaleTurquoise;
                }
            }

        }

        .item-meta {
            display: flex;
            align-items: center;
            gap: 1rem;
            flex: 1;
            margin-left: 2rem;
        }

        .item-icon {
            display: flex;
            gap: 0.5rem;
            align-items: center;
            flex: 0;

            svg {
                width: 2rem !important;
                height: auto !important;
            }
        }
        
        .item-title {
            width: 25rem;

            &:hover + .item-children-label {
                opacity: 0;
            }
        }

        .item-title-text {
            width: 100%;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 2rem;

            &:hover {
                width: max-content;
                padding-right: 2rem;
                background-color: inherit;
            }
        }

        .item-option-selector {
            color: black;
        }

        .item-children-label {
            width: 25rem;
            opacity: 1;
            transition: opacity 0.2s;
            transition-delay: 0.1s;
        }

        .item-content-group {
            display: flex;
            align-items: center;
            gap: 1rem;
            flex: 0;
        }

        .item-statuses {
            display: flex;
            gap: 0.6rem;
            justify-content: end;

            .item-status {
                color: lightgrey;
                position: relative;

                svg {
                    height: 2rem;
                    width: auto;
                }

                &.--not-applicable svg,
                &.--has-options svg {
                    color: rgb(56, 38, 38);
                    opacity: 0.25;
                    pointer-events: none;
                }

                &.--no-match svg,
                &.--needs-option svg {
                    color: var(--new-item);
                }

                &.--half-match svg {
                    color: var(--has-changes);
                }

                &.--full-match svg {
                    color: var(--no-changes);
                }

                &.--error svg {
                    color: var(--error);
                }

                &:hover .item-tooltip {
                    display: block;
                }
            }

            .--processing & {
                display: none;
            }
        }

        .item-tooltip {
            position: absolute;
            top: calc(100% + 0.5rem);
            /* left: 50%;
            transform: translate(-50%, 0); */
            right: 0;
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 0.5rem;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            padding: 0.5rem 1rem;
            z-index: 10;
            white-space: nowrap;
            display: none;
            color: black;
            font-weight: normal;
            font-family: monospace;
            line-height: 2;

            .item-tooltip-row {
                border-bottom: 1px solid #ccc;
                
                &:last-child {
                    border: none;
                }

                th, td {
                    padding: 0.25rem 0.5rem;
                    border-left: 1px solid #ccc;

                    &:first-child {
                        border: none;
                    }
                }

                th {
                    color: #b9b9b9;
                    vertical-align: top;
                }
            }
        }

        .item-styles {
            /* display: flex; */
            display: none;
            gap: 0.5rem;
            justify-content: end;

            .item-style {
                font-size: 1.2rem;
                white-space: nowrap;

                &.--matched {
                    color: darkgreen;
                }

                &.--unmatched {
                    color: darkred;
                }
            }

            .--processing & {
                display: none;
            }
        }

        .item-upstream-changes {
            white-space: nowrap;
            /* display: flex; */
            display: none;
            gap: 0.5rem;
            min-width: 5rem;

            svg {
                height: 2rem;
                width: auto;
            }

            .--processing & {
                display: none;
            }

            .upstream-change {
                position: relative;
                
                &:hover .upstream-change-details {
                    display: block;
                }
            }

            .upstream-change-details {
                position: absolute;
                bottom: 100%;
                right: 0;
                display: none;
            }
        }

        .item-internal-id {
            display: none;
            white-space: nowrap;
            min-width: 12rem;

            .--processing & {
                display: none;
            }
        }

        .item-last-imported {
            white-space: nowrap;
            width: 10rem;
            text-align: right;
        }

        .item-controls {
            display: flex;
            gap: 0rem;

            .--processing & {
                pointer-events: none;
                opacity: 0.5;
            }
        }

        .item-control {
            width: 4rem;
            height: 4rem;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            background-color: rgba(0,0,0,0);
            transition: background-color 0.2s;

            svg {
                width: 2rem !important;
                height: auto !important;
                transform: scale(1);
                transition: transform 0.2s;
            }

            &:hover {
                background-color: rgba(0,0,0,0.1);

                svg {
                    transform: scale(1.1);
                }
            }
        }

        .item-control--edit {
            display: none;
        }

        .item-control--expand {
            /* margin-left: 0.5rem; */
            padding-left: 0.25rem;
            transform: rotate(-90deg);

            &.--expanded {
                transform: rotate(0deg);
            }

            + .item-meta {
                margin-left: 0;
            }
        }

        .item-children {
            display: none;
            /* border-top: 1px solid #ccc; */
            margin-left: 2rem;

            &.--expanded {
                display: block;
            }
        }
    }

    .importer-edit-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 33vw;
        background-color: #fff;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        z-index: 1000;
    }

}

@keyframes spinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}