@use '@scssutils' as *;

.connected-user-card {
  background-color: var(--white);
  border-radius: 15px;
  position: relative;
  border: 1px solid var(--white);
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: min-content 0fr;
  height: min-content;

  &:hover {
    border-color: var(--gray-border);
  }

  &.expanded {
    grid-template-rows: min-content min-content;
    border-color: var(--gray-border);
  }

  & > .card-expand {
    width: 40px;
    height: 40px;
    border: 0 solid transparent;
    background-color: transparent;
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
  }

  & > .devices {
    grid-row: 2;
    grid-column: 1 / 2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;

    & > .device {
      display: grid;
      grid-template-rows: auto 50px;
      grid-template-columns: 1fr;
      width: 100%;
      row-gap: 20px;
      box-sizing: border-box;
      padding: 20px;
      overflow: hidden;
      border-top: 1px solid var(--gray-border);

      & > .upper {
        grid-row: 1;
        grid-column: 1 / 2;
        display: grid;
        grid-template-columns: 22px 40px 1fr;
        grid-template-rows: 1fr;
        align-items: center;
        justify-content: start;
        column-gap: 10px;
        width: 100%;
        height: 100%;
      }

      & > .lower {
        grid-row: 2;
        grid-column: 1 / 2;
        display: grid;
        grid-template-rows: 1fr;
        grid-template-columns: 1fr 3fr;
        width: 100%;
        height: 100%;
        max-height: 100%;
        overflow: hidden;
        column-gap: 10px;
      }
    }
  }

  & > .user-info {
    grid-row: 1;
    grid-column: 1 / 2;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 40px 100px;
    row-gap: 20px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    padding: 20px;

    @media (min-width: 400px) {
      grid-template-rows: 40px 50px;
    }

    & > .upper {
      width: 100%;
      max-width: 100%;
      overflow: hidden;
      display: grid;
      grid-template-columns: 40px 1fr;
      grid-template-rows: 1fr;
      column-gap: 10px;
      box-sizing: border-box;
      padding-right: 25px;

      & > .user-initials-box {
        grid-row: 1;
        grid-column: 1 / 2;
      }

      & > .name-box {
        grid-row: 1;
        grid-column: 2 / 3;
      }

      .avatar-icon {
        min-width: 40px;
        min-height: 40px;

        svg {
          width: 30px;
          height: 30px;
        }
      }
    }

    & > .lower {
      width: 100%;

      display: grid;
      grid-template-rows: 1fr 1fr;
      grid-template-columns: 1fr 1fr;
      row-gap: 10px;
      column-gap: 10px;
      align-items: center;
      justify-items: start;
      justify-content: space-evenly;

      &:not(.device) {
        grid-template-areas:
          'time devices'
          'usage usage';

        @media (min-width: 400px) {
          grid-template-rows: 1fr;
          grid-template-columns: 100px 100px 1fr;
          grid-template-areas: 'time devices usage';
          row-gap: 0;
          column-gap: 10px;
        }
      }

      &.device {
        grid-template-areas:
          'time'
          'usage';

        @media (min-width: 400px) {
          grid-template-rows: 1fr;
          grid-template-columns: 100px 1fr;
          grid-template-areas: 'time usage';
          row-gap: 0;
          column-gap: 10px;
        }
      }

      .connection-time {
        grid-area: time;
      }

      .active-devices {
        grid-area: devices;
      }

      .network-usage-summary {
        grid-area: usage;
      }
    }
  }

  .lower-box {
    row-gap: 5px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;

    & > .content-wrapper {
      display: flex;
      flex-direction: row;
      align-items: center;
      align-content: center;
      justify-content: center;
    }
  }

  .active-devices {
    .content-wrapper {
      display: grid;
      grid-template-columns: 30px 30px 30px;
      grid-template-rows: 30px;
      column-gap: 5px;

      .avatar-icon {
        width: 30px;
        height: 30px;
      }

      .count-box {
        width: 30px;
        height: 30px;
        display: flex;
        flex-direction: column;
        align-items: center;
        align-content: center;
        justify-content: center;
        border-radius: 10px;
        box-sizing: border-box;
        background-color: var(--bg-light);

        & > span {
          @include typography-legacy(12px, 14px, medium, var(--gray-light));
        }
      }
    }
  }

  .name-box {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    row-gap: 8px;
    overflow: hidden;

    & > .name {
      grid-row: 1;
      grid-column: 1 / 2;
      @include typography-legacy(15px, 21px, medium, $font-family: 'Poppins');
      @include text-overflow-dots;
      user-select: none;
    }

    & > .lower {
      grid-row: 2;
      grid-column: 1 / 2;
      display: flex;
      flex-flow: row wrap;
      overflow: hidden;
      align-items: center;
      align-content: center;
      justify-content: flex-start;
      gap: 5px;
    }
  }

  .connection-time {
    display: grid;
    grid-template-rows: auto 30px;
    grid-template-columns: auto;

    & > .time {
      display: flex;
      flex-flow: row nowrap;
      column-gap: 5px;
      align-items: center;
      justify-content: center;
      height: 100%;

      & > span {
        @include typography-legacy(15px, 18px, medium);
        @include text-overflow-dots;

        text-align: left;
      }
    }
  }

  .network-usage {
    @include typography-legacy(12px, 14px, medium);
  }

  .network-usage-summary {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 15px 30px;
    row-gap: 5px;
    width: 100%;
    height: 100%;

    & > .network-usage-stats {
      grid-row: 1;
      grid-column: 1 / 2;
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      justify-content: space-between;

      .speed-value {
        font-size: 12px;
        line-height: 1.2;
      }
    }

    & > .chart {
      grid-row: 2;
      grid-column: 1 / 2;
    }
  }

  span {
    &.label {
      user-select: none;
      @include typography-legacy(12px, 14px, medium, var(--gray-light));
    }
  }
}
