// out: false

@import "../../../../assets/less/core/boot.less";

.field-repeater {
    padding-top: 5px;

    .field-repeater-items {
        counter-reset: repeater-index-counter;
    }

    ul.field-repeater-items,
    li.field-repeater-item {
        padding: 0;
        margin: 0;
        list-style: none;
    }

    ul.field-repeater-items > li {
        &.dragged {
            opacity: .7;
            position: absolute;
            padding-top: 15px;
            padding-right: 15px;
            z-index: 2000;
            background-color: @body-bg;
            border: 1px dashed #dbdee0;

            .repeater-item-remove {
                opacity: 0;
            }

            .repeater-item-collapsed-title {
                top: 5px;
            }
        }

        &.placeholder {
            display: block;
            position: relative;
            height: 25px;
            margin-bottom: 5px;
            &:before {
                display: block;
                position: absolute;
                .icon(@chevron-right);
                color: #d35714;
                left: -10px;
                top: 8px;
                z-index: 2000;
            }
        }
    }

    li.field-repeater-item {
        position: relative;
        margin: 0 0 1em 1em !important;
        padding: 1.5em 1.25em 0 1.25em !important;
        background: #f5f5f5;
        border: 1px solid @input-border;
        border-radius: @border-radius-base;
        box-shadow: @input-box-shadow;
        min-height: 30px;

        &:before {
            color: #bdc3c7;
            .icon(@circle);
            font-size: 8px;
            position: absolute;
            left: -18px;
            top: -2px;
        }

        &:after {
            counter-increment: repeater-index-counter;
            content: counter(repeater-index-counter);
            display: block;
            position: absolute;
            font-size: 12px;
            left: -27px;
            color: #bdc3c7;
            top: 10px;
            width: 24px;
            text-align: center;
        }

        &.collapsed {
            .field-repeater-form {
                display:none;
            }

            .repeater-item-collapse {
                .repeater-item-collapse-one {
                    .transform(scale(1,-1));
                }
            }

            .repeater-item-collapsed-title {
                display: block;
            }
        }

        .repeater-item-collapsed-title {
            display: none;
            position: absolute;
            font-size: 13px;
            top: 50%;
            left: 10px;
            .transform(translateY(-50%));
        }

        .field-repeater-form {
            position: relative;
            top: -7px;
            .clearfix;
        }

        .repeater-item-handle {
            position: absolute;
            top: -6px;
            left: -25px;
            color: #bdc3c7;
            background: @body-bg;
            cursor: move;
            opacity: 0;
            border-radius: 999px;
            .transition(~'opacity 0.5s');
            &:hover {
                color: #999;
            }
        }

        .repeater-item-collapse {
            position: absolute;
            top: 5px;
            right: 30px;
            z-index: 90;

            a, button {
                .transition(~'transform 0.3s');
                color: #bdc3c7;
                line-height: 20px;
                display: block;
                font-size: 12px;

                &:hover,
                &:focus {
                    color: #999;
                    text-decoration: none;
                }
            }
        }

        .repeater-item-remove {
            position: absolute;
            top: 4px;
            right: 5px;
            z-index: 90;

            &.disabled {
                display: none;

                + .repeater-item-collapse {
                    right: 7px;
                }
            }

            .close {
                float: none;
                display: inline-block;
            }
        }

        .repeater-item-collapse,
        .repeater-item-handle,
        .repeater-item-remove {
            width: 20px;
            height: 20px;
            text-align: center;
        }

        &:hover, &:active {
            .repeater-item-collapse,
            .repeater-item-handle,
            .repeater-item-remove {
                opacity: 1;
            }
        }
    }

    .field-repeater-add-item {
        position: relative;
        margin-top: 10px;
        margin-left: 20px;
        border: 2px dotted #e0e0e0;
        border-radius: 5px;

        &:before {
            color: #bdc3c7;
            .icon(@plus);
            font-size: 16px;
            position: absolute;
            left: -23px;
            top: -11px;
        }

        > a {
            color: #bdc3c7;
            text-align: center;
            display: block;
            text-decoration: none;
            padding: 13px 15px;
            text-transform: uppercase;
            font-weight: 600;
            font-size: @font-size-base - 2;
        }

        &:hover, &:focus {
            background-color: @highlight-hover-bg;
            border-color: transparent;

            &:before {
                color: #999;
            }

            > a {
                color: @highlight-hover-text;
            }
        }

        &:active {
            background: @highlight-active-bg;
            border-color: transparent;
            > a {
                color: @highlight-active-text;
            }
        }

        &.in-progress {
            border-color: #e0e0e0 !important;
            background: transparent !important;
        }
    }

    &[data-mode="grid"] {
        > ul.field-repeater-items {
            display: grid;
            gap: 20px;

            > .field-repeater-item {
                margin-bottom: 0 !important;
            }

            > .field-repeater-add-item {
                margin-top: 0;

                > a {
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    height: 100%;
                }

                &:before {
                    display: none;
                }
            }
        }

        &[data-columns="2"] ul.field-repeater-items {
            grid-template-columns: repeat(2, 1fr);
        }
        &[data-columns="3"] ul.field-repeater-items {
            grid-template-columns: repeat(3, 1fr);
        }
        &[data-columns="4"] ul.field-repeater-items {
            grid-template-columns: repeat(4, 1fr);

            @media (max-width: 1600px) {
                grid-template-columns: repeat(3, 1fr);
            }
        }
        &[data-columns="5"] ul.field-repeater-items {
            grid-template-columns: repeat(5, 1fr);

            @media (max-width: 1600px) {
                grid-template-columns: repeat(4, 1fr);
            }
        }
        &[data-columns="6"] ul.field-repeater-items {
            grid-template-columns: repeat(6, 1fr);

            @media (max-width: 1600px) {
                grid-template-columns: repeat(4, 1fr);
            }
        }

        @media (min-width: @screen-sm-min) and (max-width: @screen-md-max) {
            > ul.field-repeater-items {
                grid-template-columns: repeat(2, 1fr) !important;;
            }
        }

        @media (max-width: @screen-xs-max) {
            > ul.field-repeater-items {
                grid-template-columns: 1fr !important;

                > .field-repeater-item,
                > .field-repeater-add-item {
                    min-height: 0 !important;
                }

                > .field-repeater-add-item {
                    margin-top: 10px;

                    &::before {
                        display: block;
                    }
                }
            }
        }
    }
}
