@use '../../shared/styles/variables' as *;

.employees-page {
  display: flex;
  flex-direction: column;
  gap: 10px;

  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: calc(100% - 56px);
  overflow: visible;
  padding: 20px 20px 36px;
}

.employees-page__section {
  display: flex;
  flex: 1;
  gap: 10px;
  min-height: 0;
  flex-direction: column;
}

.employees-page__table-motion {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.employees-toolbar--organisations {
  justify-content: flex-start;
}

.employees-table-container {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  //overflow: hidden;
  border-radius: 20px;
}

.employees-table-card {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  //overflow: hidden;
  //box-shadow: $shadow-card;

  border-radius: 20px;
  background: $color-surface;

  .simplebar-content-wrapper {
    border-radius: 20px;
  }


  .simplebar-track.simplebar-vertical {
    top: 48px;
    bottom: 14px;
    width: 14px;
    right: -7px;
  }

  .simplebar-scrollbar::before {
    background: color-mix(in srgb, var(--gray50) 85%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 0 0 1px var(--gray30), -2px 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 4px;

    opacity: 1;
  }

  .simplebar-track.simplebar-horizontal {
    left: 12px;
    right: 12px;
    height: 8px;
  }
}

.employees-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  overflow: hidden;
  border-radius: 20px;

  thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: $color-surface;
  }

  th {
    padding: 14px 20px;
    line-height: 1;
    border-bottom: 1px solid $gray20;

    color: $gray50;
    font-size: $font-size-16;
    font-weight: 450;
    text-align: left;
    background: $color-surface;
  }

  td {
    height: 68px;
    padding: 14px 20px;
    border-bottom: 1px solid $gray20;
    vertical-align: middle;
    text-align: left;

    color: $color-text;
    font-size: $font-size-17;
    font-weight: 400;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 30%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: 28%;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: 160px;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 170px;
  }

  th:nth-child(5),
  td:nth-child(5) {
    width: 300px;
  }
}

.organisations-table {
  min-width: 900px;

  th:nth-child(1),
  td:nth-child(1) {
    width: 120px;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: auto;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: 330px;
  }
}

.employee-person {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: 0;

  .employee-person__avatar {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;

    border-radius: 50%;
    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;

    background:
      radial-gradient(circle at 30% 20%, rgba($white, 0.1), $transparent 28%),
      linear-gradient(135deg, $blue, $color-primary-hover);

    color: $color-text-inverse;
    font-size: $font-size-14;
    font-weight: 750;
    letter-spacing: 0.04em;

    box-shadow: inset 0 0 0 1px rgba($color-shadow-rgb, 0.06);

    &.transparent-backdrop {
      background: transparent;
    }

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  .employee-person__info {
    min-width: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;

    >span {
      color: $color-text;
      font-size: $font-size-17;
      font-weight: 600;
      line-height: 1.2;
    }

    small {
      color: $gray50;
      font-size: $font-size-14;
      font-weight: 500;
      line-height: 1.2;
    }
  }
}

.employee-organisation,
.employee-organisation-name {
  color: $gray50;
  font-size: $font-size-16;
  font-weight: 500;
}

.employee-organisation-name {
  color: $color-text;
  font-weight: 500;
}

.employee-role {
  display: inline-flex;
  align-items: center;

  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;

  background: $blue20;
  color: $blue;

  font-size: $font-size-15;
  font-weight: 600;
}

.employee-role--admin {
  background: $color-warning-tint !important;
  color: $orange !important;
}

.employee-credentials {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;

  span {
    overflow: hidden;
    color: $color-text;
    font-size: $font-size-16;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  small {
    color: $gray50;
    font-size: $font-size-14;
    font-weight: 500;
  }
}

.employee-created-at,
.employees-table-actions__muted {
  color: $gray50;
  font-size: $font-size-15;
  font-weight: 500;
}

.employees-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.employees-action-btn {
  height: 34px;
  padding: 0 12px;

  border: none;
  border-radius: 12px;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: $font-size-14;
  font-weight: 600;
  cursor: pointer;

  opacity: 0.88;

  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;

  &:hover {
    opacity: 1;
  }
}

.employees-action-btn--edit {
  background: $blue20;
  color: $blue;

  &:hover {
    box-shadow: inset 0 0 0 1px $blue, var(--shadow-primary);
  }
}

.employees-action-btn--delete {
  background: $color-danger-tint-strong;
  color: $red;

  &:hover {
    box-shadow: inset 0 0 0 1px $red;
  }
}

.employees-table__row {
  position: relative;
  transition: 0.2s ease;
  box-shadow: inset 0px 0 0 $transparent;
  cursor: pointer;
  overflow: hidden;

  &:hover {
    background-color: $color-primary-tint-soft;
    box-shadow: inset 3px 0 0 rgba($color-primary-rgb, 0.8);
  }

  &:last-child {
    td {
      border-bottom: none;
    }
  }
}

.employee-role {
  display: inline-flex;
  align-items: center;

  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;

  background: $color-primary-tint;
  color: $blue;

  font-size: $font-size-16;
  font-weight: 500;
}

.employees-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.employees-action-btn {
  height: 34px;
  padding: 0 12px;

  border: none;
  border-radius: 12px;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: $font-size-14;
  font-weight: 600;
  cursor: pointer;

  opacity: 0.88;

  box-shadow: inset 0px 0 0 $transparent;

  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;

  &:hover {
    opacity: 1;
  }
}

.employees-action-btn--edit {
  background-color: $blue20;
  color: $blue;

  &:hover {
    background-color: $blue;
    color: $white;
    box-shadow: inset 0 0 0 1px $blue, 0 8px 20px -8px rgba(var(--color-primary-rgb), 0.8);
  }
}

.employees-action-btn--delete {
  background-color: $color-danger-tint-strong;
  color: $red;

  &:hover {
    background-color: $red;
    color: $white;
    box-shadow: inset 0 0 0 1px $red, 0 8px 20px -8px rgba(var(--color-danger-rgb), 0.8);
  }
}

.employees-state {
  min-height: 220px;
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  color: $color-text-muted;
  font-size: $font-size-15;
  font-weight: 500;
}

.employees-state--error {
  color: $red;
}

[data-theme='dark'] {
  .employees-table__row:hover {
    background-color: rgba($color-primary-rgb, 0.03);
    box-shadow: inset 3px 0 0 rgba($color-primary-rgb, 0.36);
  }
}

@include laptop-down {
  .employee-person .employee-person__info>span {
    font-size: var(--font-size-15);
  }

  .employee-person .employee-person__info small {
    font-size: var(--font-size-14);
  }

  .employee-organisation,
  .employee-organisation-name {
    font-size: var(--font-size-15);
  }

  .employee-role {
    font-size: var(--font-size-14);
  }

  .employees-table {
    min-width: 1040px;

    th,
    td {
      padding-inline: 16px;
    }

    td {
      font-size: var(--font-size-15);
    }

    th:nth-child(1),
    td:nth-child(1) {
      width: 30%;
    }

    th:nth-child(2),
    td:nth-child(2) {
      width: 28%;
    }

    th:nth-child(3),
    td:nth-child(3) {
      width: 150px;
    }

    th:nth-child(4),
    td:nth-child(4) {
      width: 160px;
    }

    th:nth-child(5),
    td:nth-child(5) {
      width: 270px;
    }
  }

  .organisations-table {
    min-width: 820px;

    th:nth-child(1),
    td:nth-child(1) {
      width: 58px;
    }

    th:nth-child(2),
    td:nth-child(2) {
      width: 64%;
    }

    th:nth-child(3),
    td:nth-child(3) {
      width: 280px;
    }
  }

  .employee-person {
    gap: 10px;

    .employee-person__avatar {
      width: 44px;
      height: 44px;
      flex-basis: 44px;
    }
  }
}

@include tablet-down {
  .employees-table {
    min-width: 960px;

    th,
    td {
      padding-inline: 14px;
    }

    th:nth-child(1),
    td:nth-child(1) {
      width: 30%;
    }

    th:nth-child(2),
    td:nth-child(2) {
      width: 28%;
    }

    th:nth-child(3),
    td:nth-child(3) {
      width: 140px;
    }

    th:nth-child(4),
    td:nth-child(4) {
      width: 150px;
    }

    th:nth-child(5),
    td:nth-child(5) {
      width: 240px;
    }
  }

  .organisations-table {
    min-width: 760px;

    th:nth-child(1),
    td:nth-child(1) {
      width: 86px;
    }

    th:nth-child(3),
    td:nth-child(3) {
      width: 230px;
    }
  }

}
