@use "../base/mixins";
@use "../vars/variables";

.responsive-table {
  width: 100%;
  border-collapse: collapse;

  tbody {
    tr {
      border-top: 1px solid var(--uc-theme-color-20);
    }
  }

  th,
  td {
    @include mixins.body-extrasmall;
    padding: 0.75rem 0.125rem;
    text-align: left;
    vertical-align: middle;

    &:first-child {
      padding-left: 0;
    }

    &:last-child {
      text-align: right;
      padding-right: 0;
    }
  }

  th {
    color: var(--uc-theme-color-70);

    @media screen and (min-width: variables.$bp-phone-plus) {
      padding-right: 0.5rem;
    }
  }

  td {
    @include mixins.body-small;
    color: var(--uc-foreground);

    @media screen and (min-width: variables.$bp-phone-plus) {
      padding-right: 0.5rem;
    }

    & > div {
      display: inline-flex;
    }

    .td-content {
      display: flex;
      justify-content: flex-start;
      align-items: stretch;
      gap: 0.5rem;
      height: 100%;
    }

    .td-item {
      display: flex;
      align-items: center;
    }

    &:last-child {
      .td-content {
        justify-content: flex-end;
      }
    }
  }

  @media screen and (max-width: variables.$bp-phone) {
    thead {
      display: none;
    }

    &,
    tbody,
    tr,
    td {
      display: block;
      width: 100%;
    }

    tr {
      margin-bottom: 1rem;
      padding: 0.75rem;
    }

    td {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border: none;
      padding: 0.35rem 0;

      &::before {
        content: attr(data-label);
        margin-right: 1rem;
        min-width: 5rem;
      }
    }
  }
}
