@import '../../core/stylesheets/variables.scss';

.md-list {
  margin: 0;
  padding: 8px 0;
  display: flex;
  flex-flow: column nowrap;
  position: relative;
  list-style: none;

  &.md-dense {
    padding: 4px 0;

    .md-list-item {
      &.md-inset .md-list-item-container {
        padding-left: 72px;
      }

      .md-list-item-container {
        min-height: 40px;
        font-size: 13px;

        .md-avatar,
        .md-list-action {
          &:first-child {
            margin-right: 24px;
          }
        }
      }
    }

    .md-avatar {
      width: 32px;
      min-width: 32px;
      height: 32px;
      min-height: 32px;
    }

    .md-list-item-expand {
      min-height: 40px;
    }
  }

  &.md-double-line {
    &.md-dense {
      .md-list-item {
        .md-list-item-container {
          min-height: 60px;
        }

        .md-avatar {
          width: 36px;
          min-width: 36px;
          height: 36px;
          min-height: 36px;

          .md-avatar,
          .md-list-action {
            &:first-child {
              margin-right: 20px;
            }
          }
        }
      }

      .md-list-text-container {
        > :nth-child(1) {
          font-size: 13px;
        }

        > :nth-child(2) {
          font-size: 13px;
        }
      }
    }

    .md-list-item {
      .md-list-item-container {
        min-height: 72px;
      }
    }
  }

  &.md-triple-line {
    &.md-dense {
      .md-list-item {
        .md-list-item-container {
          min-height: 76px;
        }

        .md-avatar {
          width: 36px;
          min-width: 36px;
          height: 36px;
          min-height: 36px;

          .md-avatar,
          .md-list-action {
            &:first-child {
              margin-right: 20px;
            }
          }
        }
      }

      .md-list-text-container {
        > :nth-child(1) {
          font-size: 13px;
        }

        > :nth-child(2) {
          font-size: 13px;
        }
      }
    }

    .md-list-item {
      .md-list-item-container {
        min-height: 88px;
      }
    }

    .md-avatar {
      margin: 0;
    }
  }

  .md-subheader {
    &.md-inset {
      padding-left: 72px;
    }
  }

  > .md-subheader:first-of-type {
    margin-top: -8px;
  }
}

.md-list-item {
  height: auto;
  position: relative;
  z-index: 2;

  &.md-disabled {
    cursor: default;
    pointer-events: none;
  }

  &.md-inset {
    .md-list-item-container {
      padding-left: 72px;
    }
  }

  .md-button-ghost {
    width: 100%;
    margin: 0;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    border-radius: 0;
  }

  .md-button:not(.md-button-ghost):not(.md-list-item-container) {
    position: relative;
    z-index: 2;

    .md-icon {
      position: relative;
    }
  }

  .md-list-item-container {
    min-height: 48px;
    margin: 0;
    padding: 0 16px;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    position: relative;
    font-size: 16px;
    font-weight: 400;
    text-align: left;
    text-transform: none;

    &:hover {
      text-decoration: none;
    }

    > .md-icon:first-child {
      margin-right: 32px;
    }

    .md-avatar,
    .md-list-action {
      &:first-child {
        margin-right: 16px;
      }
    }

    .md-list-action {
      margin: 0 -10px 0 0;

      &:nth-child(3) {
        margin: 0 -10px 0 16px;
      }
    }
  }

  .md-divider {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
  }

  .md-icon,
  .md-avatar,
  .md-list-action:first-child {
    margin: 0;

    &:first-of-type + * {
      flex: 1 1 auto;
    }
  }

  .md-avatar {
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .md-icon {
    color: rgba(#000, .54);
  }

  .md-ink-ripple {
    border-radius: 0;
  }
}

.md-list-item-expand {
  min-height: 48px;
  flex-flow: column wrap;
  overflow: hidden;
  transform: translate3D(0, 0, 0);

  &:before,
  &:after {
    height: 1px;
    position: absolute;
    right: 0;
    left: 0;
    z-index: 3;
    transition: $swift-ease-out;
    content: " ";
  }

  &:before {
    top: 0;
  }

  &:after {
    bottom: 0;
  }

  &.md-active {
    position: relative;

    &:before,
    &:after {
      background-color: rgba(#000, .12);
    }

    &:first-of-type {
      &:before {
        background: none;
      }
    }

    &:last-of-type {
      &:after {
        background: none;
      }
    }

    &.md-active + .md-active:before {
      background: none;
    }

    > .md-list-item-container .md-list-expand-indicator {
      transform: rotateZ(180deg) translate3D(0, 0, 0);
    }

    > .md-list-expand {
      margin-bottom: 0 !important;
    }
  }

  .md-expansion-indicator,
  .md-list-item-container,
  .md-icon {
    transition: $swift-ease-out;
  }

  .md-list-expand {
    position: relative;
    z-index: 1;
    transform: translate3D(0, 0, 0);
    will-change: margin-bottom;
    transition: $swift-ease-in-out;

    &.md-transition-off {
      transition: none !important;
    }

    .md-list {
      padding: 0;
    }
  }
}

.md-list-text-container {
  display: flex;
  flex-flow: column nowrap;
  flex: 1;
  overflow: hidden;
  line-height: 1.25em;
  white-space: normal;

  > * {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  > :nth-child(1) {
    font-size: 16px;
  }

  > :nth-child(2),
  > :nth-child(3) {
    margin: 0;
    color: rgba(#000, .54);
    font-size: 14px;
  }

  > :nth-child(2):not(:last-child) {
    color: rgba(#000, .87);
  }
}
