/* === Lists === */
@listBlockBorderColor: @color-split;
@listBlockBg: #fff;
@dividerBg: #F7F7F7;
@dividerColor: @color-split;
.list-block {
    margin: 1.75rem 0;
    font-size: 0.85rem;
    ul {
        background: @listBlockBg;
        list-style: none;
        padding: 0;
        margin: 0;
        position: relative;
        .hairline(top, @listBlockBorderColor);
        .hairline(bottom, @listBlockBorderColor);
        ul {
            .hairline-remove(top);
            .hairline-remove(bottom);
            padding-left: 2.25rem;
        }
    }

    .align-top, .align-top .item-content, .align-top .item-inner {
        .align-items(flex-start);
    }
    
    .inset() {
        margin-left: 0.75rem;
        margin-right: 0.75rem;
        border-radius: 0.35rem;
        .content-block-title {
            margin-left: 0;
            margin-right: 0;
        }
        ul {
            border-radius: 0.35rem;
            .hairline-remove(top);
            .hairline-remove(bottom);
        }
        li:first-child > a{
            border-radius: 0.35rem 0.35rem 0 0;
        }
        li:last-child > a{
            border-radius: 0 0 0.35rem 0.35rem;
        }
        li:first-child:last-child > a {
            border-radius: 0.35rem;
        }
    }
    &.inset {
        .inset()
    }
    &.tablet-inset {
        @media all and (min-width:768px) {
            .inset();
        }
    }

    // List items
    li {
        box-sizing: border-box;
        position: relative;
    }
    
    .item-media {
        .flexbox();
        .flex-shrink(0);
        .flex-wrap(nowrap);
        box-sizing: border-box;
        .align-items(center);
        padding-top: 0.35rem;
        padding-bottom: 0.4rem;
        i + i {
            margin-left: 0.25rem;
        }
        i + img {
            margin-left: 0.25rem;
        }
    }
    .item-media + .item-inner {
        margin-left: 0.75rem;
    }
    .item-inner {
        padding-right: 0.75rem;
        position: relative;
        .hairline(bottom, @listBlockBorderColor);
        width: 100%;
        padding-top: 0.4rem;
        padding-bottom: 0.35rem;
        min-height: 2.2rem;
        overflow: hidden;
        box-sizing: border-box;
        .flexbox();
        -webkit-box-flex:1;
        -ms-flex:1;
        .justify-content(space-between);
        .align-items(center);
    }
    .item-title {
        .flex-shrink(1);
        white-space: nowrap;
        position: relative;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;

        &.label {
            width: 35%;
            .flex-shrink(0);
            margin: 4px 0;
        }
    }
    .item-input {
        width: 100%;
        margin-top: -0.4rem;
        margin-bottom: -0.35rem;
        -webkit-box-flex:1;
        -ms-flex:1;
        .flex-shrink(1);
    }
    .item-after {
        white-space: nowrap;
        color: @color-text-secondary;
        .flex-shrink(0);
        margin-left: 0.25rem;
        .flexbox();
        max-height: 1.4rem;
    }
    .smart-select .item-after {
        max-width: 70%;
        overflow: hidden;
        text-overflow:ellipsis;
        position: relative;
    }
    .item-link {
        transition-duration: 300ms;
        display: block;
        color: inherit;

        .item-inner {
          padding-right: 1.5rem;
          background-image: url("@{imgBaseUrl}/i-list-chevron-right.png");
          background-size: 0.7rem;
          background-repeat: no-repeat;
          background-position: 97% center;
          background-position: -webkit-calc(~"100% - .5rem") center;
          background-position: calc(~"100% - .5rem") center;
        }

        html:not(.watch-active-state) &:active, &.active-state {
            transition-duration: 0ms;
            background-color: #d9d9d9;
            .item-inner {
                .hairline-color(bottom, transparent);
            }
        }
        &.list-button {
            padding: 0 0.75rem;
            text-align: center;
            color: @color-primary;
            display: block;
            .hairline(bottom, @listBlockBorderColor);
            line-height: 2.15rem;
        }
    }
    .item-content {
        box-sizing: border-box;
        padding-left: 0.75rem;
        min-height: 2.2rem;
        .flexbox();
        .justify-content(space-between);
        .align-items(center);
    }
    // Label after List block
    .list-block-label {
        margin: 0.5rem 0 1.75rem;
        padding: 0 0.75rem;
        font-size: 0.7rem;
        color: @color-text-secondary;
    }

    // Swipe outs
    .swipeout {
        overflow: hidden;
        -webkit-transform-style: preserve-3d;
        transform-style: preserve-3d;
    }
    .swipeout.deleting {
        transition-duration: 300ms;
        .swipeout-content {
            transform: translateX(-100%);
        }
    }
    .swipeout.transitioning {
        .swipeout-content, .swipeout-actions-right a, .swipeout-actions-left a, .swipeout-overswipe {
            -webkit-transition: 300ms;
            transition: 300ms;
        }    
    }
    .swipeout-content {
        position: relative;
        z-index: 10;
    }
    .swipeout-overswipe {
        -webkit-transition: 200ms left;
        transition: 200ms left;
    }
    .swipeout-actions-left, .swipeout-actions-right {
        position: absolute;
        top: 0;
        height: 100%;
        .flexbox();
        a {
            padding: 0 1.5rem;
            color:#fff;
            background: #c7c7cc;
            .flexbox();
            .align-items(center);
            position: relative;
            left: 0;
            &:after {
                content:'';
                position: absolute;
                top: 0;
                width: 600%;
                height: 100%;
                background: inherit;
                z-index: -1;
            }
        }
        a.swipeout-delete {
            background: @color-danger;
        }
    }
    .swipeout-actions-right {
        right: 0%;
        transform: translateX(100%);
        a:after {
            left: 100%;
            margin-left: -1px;
        }
    }
    .swipeout-actions-left {
        left: 0%;
        transform: translateX(-100%);
        a:after {
            right: 100%;
            margin-right: -1px;
        }
    }
    .item-subtitle {
        font-size: 0.75rem;
        position: relative;
        overflow: hidden;
        white-space: nowrap;
        max-width: 100%;
        text-overflow: ellipsis;
    }
    .item-text {
        font-size: 0.75rem;
        color: @color-text-secondary;
        line-height: 1.05rem;
        position: relative;
        overflow: hidden;
        height: 2.1rem;
        text-overflow:ellipsis;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        display: -webkit-box;
    }
    &.media-list, li.media-item {
        .item-title {
            font-weight: 500;
        }
        .item-inner {
            display: block;
            padding-top: 0.5rem;
            padding-bottom: 0.45rem;
            .align-self(stretch);
        }
        .item-media {
            padding-top: 0.45rem;
            padding-bottom: 0.5rem;
            img {
                display: block;
            }
        }
        .item-title-row {
            .flexbox();
            .justify-content(space-between);
        }
    }
    .list-group {
        ul {
            &:after, &:before {
                z-index: 11;
            }
        }
        + .list-group ul {
            .hairline-remove(top);   
        }
    }
    .item-divider, .list-group-title {
        background: @dividerBg;
        .hairline(top, @listBlockBorderColor);
        margin-top: -1px;
        padding: 0.2rem 0.75rem;
        white-space: nowrap;
        position: relative;
        max-width: 100%;
        text-overflow: ellipsis;
        overflow: hidden;
        color: @dividerColor;
    }
    .list-group-title {
        position: relative;
        position: -webkit-sticky;
        position: -moz-sticky;
        position: sticky;
        top: 0;
        z-index: 20;
        margin-top: 0;
        .hairline-remove(top);
    }
    // Sortable

    .sortable-handler {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 1px;
        z-index: 10;
        background-repeat: no-repeat;
        background-size: 0.9rem 0.6rem;
        background-image: url("@{imgBaseUrl}/i-sortable-handler.png");
        background-position: center;
        width: 1.75rem;
        opacity: 0;
        visibility: hidden;
        right: 0;
    }
    &.sortable {
        .item-inner {
            transition-duration: 300ms;
        }
    }
    &.sortable-opened {
        .sortable-handler {
            visibility: visible;
            opacity: 1;
        }
        .item-inner, .item-link .item-inner {
            padding-right: 1.5rem;
        }
        .item-link .item-inner, .item-link .item-title-row {
            background-image: none;
        }
    }
    &.sortable-sorting {
        li {
            transition-duration: 300ms;
        }
    }
    li.sorting {
        z-index: 50;
        background: rgba(255,255,255,0.8);
        box-shadow: 0 0.1rem 0.4rem rgba(0,0,0,0.6);
        transition-duration: 0ms;
        .item-inner {
            .hairline-remove(bottom);
        }
    }

    // Last-childs
    li {
        &:last-child {
            .list-button {
                .hairline-remove(bottom);
            }
        }
        &:last-child, &:last-child li:last-child {
            .item-inner {
                .hairline-remove(bottom);
            }
        }
        li:last-child, &:last-child li {
            .item-inner {
                .hairline(bottom, @listBlockBorderColor);
            }
        }
    }
}
