@import './var.less';
@import '../style/mixins/hairline';

:root {
  --van-cell-font-size: @cell-font-size;
  --van-cell-line-height: @cell-line-height;
  --van-cell-vertical-padding: @cell-vertical-padding;
  --van-cell-horizontal-padding: @cell-horizontal-padding;
  --van-cell-text-color: @cell-text-color;
  --van-cell-background-color: @cell-background-color;
  --van-cell-border-color: @cell-border-color;
  --van-cell-active-color: @cell-active-color;
  --van-cell-required-color: @cell-required-color;
  --van-cell-label-color: @cell-label-color;
  --van-cell-label-font-size: @cell-label-font-size;
  --van-cell-label-line-height: @cell-label-line-height;
  --van-cell-label-margin-top: @cell-label-margin-top;
  --van-cell-title-value-gap: @cell-title-value-gap;
  --van-cell-description-color: @cell-description-color;
  --van-cell-description-font-size: @cell-description-font-size;
  --van-cell-description-line-height: @cell-description-line-height;
  --van-cell-description-margin-top: @cell-description-margin-top;
  --van-cell-value-color: @cell-value-color;
  --van-cell-icon-size: @cell-icon-size;
  --van-cell-right-icon-color: @cell-right-icon-color;
  --van-cell-large-vertical-padding: @cell-large-vertical-padding;
  --van-cell-large-title-font-size: @cell-large-title-font-size;
  --van-cell-large-label-font-size: @cell-large-label-font-size;
  --van-cell-large-description-font-size: @cell-large-description-font-size;
  --van-cell-large-value-font-size: @cell-large-value-font-size;
  --van-cell-blue-mark-width: @cell-blue-mark-width;
}

.van-cell {
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  padding: var(--van-cell-vertical-padding) var(--van-cell-horizontal-padding);
  overflow: hidden;
  color: var(--van-cell-text-color);
  font-size: var(--van-cell-font-size);
  line-height: var(--van-cell-line-height);
  background: var(--van-cell-background-color);

  &::after {
    .hairline-bottom(var(--van-cell-border-color), var(--van-padding-md), var(--van-padding-md));
  }

  &:last-child::after,
  &--borderless::after {
    display: none;
  }
  &-error-border::after{
    .hairline-bottom(var(--van-field-input-error-text-color), var(--van-padding-md), var(--van-padding-md));
  }
  &-error-border:last-child::after{
    display: inline-block;
  }

  &__title,
  &__label,
  &__description,
  &__value,
  &__multi-line-note {
    white-space: pre-line;
  }

  &__label {
    display: flex;
    align-items: center;
    margin-top: var(--van-cell-label-margin-top);
    color: var(--van-cell-label-color);
    font-size: var(--van-cell-label-font-size);
    line-height: var(--van-cell-label-line-height);

    &--clickable {
      color: var(--van-primary-color);
      font-weight: var(--van-font-weight-bold);
      cursor: pointer;
    }
  }

  &__label-icon {
    flex: none;
    width: 12px;
    height: 12px;
    margin-right: 2px;
    color: inherit;
    font-size: 12px;
    line-height: 12px;
  }

  &__description {
    margin-top: var(--van-cell-description-margin-top);
    color: var(--van-cell-description-color);
    font-size: var(--van-cell-description-font-size);
    line-height: var(--van-cell-description-line-height);

    &--clickable {
      color: var(--van-primary-color);
      cursor: pointer;
    }
  }

  &__multi-line-notes {
    margin-top: var(--van-padding-base);
    color: var(--van-cell-label-color);
    font-size: var(--van-cell-label-font-size);
    line-height: var(--van-cell-label-line-height);
  }

  &__multi-line-note + &__multi-line-note {
    margin-top: 2px;
  }

  &__title {
    flex: 1;
    min-width: 0;
  }

  &--three-line-ellipsis {
    .van-cell__title-content,
    .van-cell__label-content,
    .van-cell__description,
    .van-cell__value > span {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .van-cell__title-content,
    .van-cell__label-content,
    .van-cell__description {
      min-width: 0;
    }

    .van-cell__label-content {
      flex: 1;
    }

    .van-cell__value {
      flex: 0 1 50%;
    }
  }

  &__title-row {
    display: flex;
    align-items: center;
    min-width: 0;

    &--collapsible {
      cursor: pointer;
    }
  }

  &__title-collapse-action,
  &__right-icon-action {
    align-self: flex-start;
    display: flex;
    flex: none;
    height: var(--van-cell-line-height);
    align-items: center;
  }

  &__title-collapse-action {
    width: var(--van-cell-icon-size);
    margin-right: var(--van-padding-base);
    color: var(--van-text-color-2);
  }

  &__title-collapse-icon {
    width: var(--van-cell-icon-size);
    font-size: var(--van-cell-icon-size);
    line-height: var(--van-cell-line-height);
    transition: transform var(--van-animation-duration-fast);

    &--collapsed {
      transform: rotate(-90deg);
    }
  }

  &__value {
    flex: none;
    min-width: 0;
    margin-left: var(--van-cell-title-value-gap);
    position: relative;
    overflow: hidden;
    color: var(--van-cell-value-color);
    text-align: right;
    vertical-align: middle;
    word-wrap: break-word;

    &--alone {
      margin-left: 0;
      color: var(--van-text-color);
      text-align: left;
    }
  }

  &__left-icon,
  &__right-icon,
  &__left-select,
  &__right-select,
  &__title-icon {
    flex: none;
    height: var(--van-cell-line-height);
    font-size: var(--van-cell-icon-size);
    line-height: var(--van-cell-line-height);
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  &__left-icon {
    margin-right: var(--van-padding-base);
  }

  &__right-icon {
    color: var(--van-cell-right-icon-color);
  }

  &__right-icon-action {
    margin-left: var(--van-padding-base);
    color: var(--van-cell-right-icon-color);
  }

  &--multi-line-notes {
    align-items: flex-start;

    .van-cell__left-select,
    .van-cell__right-select {
      align-self: flex-start;
    }
  }

  &__left-select {
    display: flex;
    flex: none;
    align-items: center;
    align-self: center;
    margin-right: var(--van-padding-base);
  }

  &__right-select {
    display: flex;
    flex: none;
    align-items: center;
    align-self: center;
    margin-left: var(--van-padding-base);
  }

  &__left-avatar,
  &__right-avatar {
    flex: none;
    width: var(--van-cell-line-height);
    height: var(--van-cell-line-height);
    object-fit: cover;
    border: var(--van-border-width-base) solid var(--van-gray-1);
    border-radius: var(--van-border-radius-md);
  }

  &__left-avatar {
    margin-right: var(--van-padding-base);
  }

  &__right-avatar {
    margin-left: var(--van-padding-base);
  }

  &__blue-mark {
    flex: none;
    align-self: center;
    width: var(--van-cell-blue-mark-width);
    height: var(--van-font-size-sm);
    margin-right: var(--van-padding-base);
    background: var(--van-primary-color);
  }

  &__tags {
    display: flex;
    flex: none;
    gap: var(--van-padding-base);
    margin-left: var(--van-padding-base);
  }

  &__tag {
    padding: 0 var(--van-padding-base);
    color: var(--van-text-color);
    font-size: var(--van-font-size-sm);
    line-height: var(--van-line-height-sm);
    background: var(--van-gray-2);
    border-radius: var(--van-border-radius-sm);
  }

  &__wrap-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--van-padding-base);
    margin-top: var(--van-padding-base);
  }

  &__title-icon {
    margin-left: var(--van-padding-base);
    color: var(--van-text-color-2);

    &--clickable {
      display: inline-flex;
      align-items: center;
      padding: 0;
      color: inherit;
      line-height: inherit;
      background: transparent;
      border: 0;
      cursor: pointer;
    }
  }

  &__title-tag {
    display: flex;
    flex: none;
    margin-left: var(--van-padding-base);
  }

  &__note {
    align-self: flex-start;
    flex: none;
    margin-left: var(--van-padding-base);
    color: var(--van-text-color-2);
    font-size: var(--van-font-size-md);
    line-height: var(--van-cell-line-height);
    white-space: nowrap;

    &--bold { font-weight: var(--van-font-weight-bold); }

    &--clickable {
      padding: 0;
      color: var(--van-primary-color);
      font-family: inherit;
      font-size: inherit;
      line-height: inherit;
      background: transparent;
      border: 0;
      cursor: pointer;
    }
  }

  &__badge {
    display: flex;
    flex: none;
    align-items: center;
    align-self: center;
    margin-left: var(--van-padding-base);

    > .van-badge {
      position: static;
      transform: none;
    }
  }

  &--clickable {
    cursor: pointer;

    &:active {
      background-color: var(--van-cell-active-color);
    }
  }

  &--required {
    overflow: visible;

    &::before {
      position: absolute;
      left: var(--van-padding-xs);
      color: var(--van-cell-required-color);
      font-size: var(--van-cell-font-size);
      content: '*';
    }
  }

  &--center {
    align-items: center;
  }

  &--large {
    padding-top: var(--van-cell-large-vertical-padding);
    padding-bottom: var(--van-cell-large-vertical-padding);

    .van-cell__title {
      font-size: var(--van-cell-large-title-font-size);
    }

    .van-cell__label {
      font-size: var(--van-cell-large-label-font-size);
      margin-top: var(--van-padding-base);
    }

    .van-cell__description {
      font-size: var(--van-cell-large-description-font-size);
      margin-top: var(--van-padding-base);
    }

    .van-cell__value {
      font-size: var(--van-cell-large-value-font-size);
    }
  }

  &--title-bold {
    .van-cell__title { font-weight: var(--van-font-weight-bold); }
  }

}
