$border-today: 2px solid var(--accent-color-bg);
$border-table-thick: 2px solid #e1e3ed;
$border-table-thin: 1px solid #e1e3ed;
$border-progress: 0.5px solid var(--color-gray-eee);
$background-content: #eef0fb;

:host {
  display: flex;
  border-left: $border-table-thin;
}

.table {
  display: grid;
  flex: 1;
  align-self: flex-start;

  .cell {
    display: flex;
    align-items: center;

    min-height: 56px;
    padding: 10px 15px;

    border-top: $border-table-thin;
    border-right: $border-table-thin;
    border-bottom: $border-table-thin;

    &.stable-a,
    &.stable-b,
    &.stable-c {
      position: sticky;
      z-index: 1;
      background-color: var(--color-gray-fff);
    }

    &.stable-a {
      left: 0;
      width: 300px;
      border-right: none;
    }

    &.stable-b {
      left: 300px;
      width: 10px;
      border-right: none;
    }

    &.stable-c {
      left: 310px;

      width: 100px;

      clip-path: inset(0 -15px 0 0);
      border-right: none;
      box-shadow: -7px 0 15px 5px var(--color-gray-aaa);
    }

    &.available-hours {
      justify-content: space-around;

      .swap-plans-icon {
        cursor: pointer;
        opacity: 0;
      }

      &:hover {
        .swap-plans-icon {
          opacity: 1;
        }
      }
    }

    &.history-title {
      cursor: pointer;
      position: relative;
      justify-content: center;

      &.weekend {
        background-color: $background-content;
      }

      &.dash-enabled:hover {
        border: 2px dashed black;
      }

      .progress-border {
        position: absolute;
        bottom: 0;
        left: 8px;

        width: calc(100% - 16px);
        height: 4px;

        border: $border-progress;
      }

      .progress-filling {
        position: absolute;
        bottom: 0;
        left: 8px;
        height: 4px;
      }

      .plus-icon {
        display: none;
      }

      .time-planned {
        font-weight: bold;
      }

      &:hover:not(.dash-enabled) {
        background-color: rgb(0 73 118 / 16%);

        .plus-icon {
          display: flex;
        }

        .time-planned {
          display: none;
        }

        .progress-filling,
        .progress-border {
          display: none;
        }
      }
    }

    &.expanded-content {
      display: flex;
      flex-direction: column;

      padding: 8px 10px 8px 8px;

      background-color: $background-content;
      border-top: 1px solid $background-content;
      border-right: $border-table-thin;
      border-bottom: 3px solid $background-content;
      border-left: 3px solid $background-content;

      &.history.dash-enabled:hover {
        border: 2px dashed black;
      }

      .table-plans {
        display: flex;
        gap: 5px;
        align-items: center;
        align-self: flex-start;

        height: 40px;
        margin-left: 45px;
      }

      .card-list {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin-bottom: 8px;
      }

      .pluseg {
        cursor: pointer;

        display: flex;
        gap: 10px;
        align-items: center;
        justify-content: center;

        width: 100%;
        height: 28px;

        .line {
          width: 0;
          height: 1px;
          background-color: var(--accent-color-bg);
          transition: width 0.3s ease-in-out;
        }

        .plus-icon {
          opacity: 0;
          transition: opacity 0.3s ease-in-out;
        }
      }

      &:hover {
        .pluseg {
          .line {
            width: 100%;
          }

          .plus-icon {
            opacity: 1;
          }
        }
      }
    }
  }

  .table-person,
  .table-task {
    display: flex;
    gap: 4px;
    align-items: center;
    padding-right: 0;

    .title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .person-icon {
      cursor: pointer;
      transition: all 0.2s ease-in-out;

      &.expanded {
        transform: rotateZ(90deg);
      }
    }

    a {
      cursor: pointer;
      color: var(--color-href);
    }
  }

  .table-title {
    position: sticky;
    z-index: 2;
    top: 0;

    height: 40px;
    min-height: 40px;

    font-weight: 600;

    background-color: var(--color-gray-fff);
    border-top: $border-table-thin;

    &.d {
      cursor: pointer;

      &:hover {
        background-color: $background-content;
      }
    }

    &.stable-a,
    &.stable-b,
    &.stable-c {
      z-index: 3;
    }

    &.today {
      border-bottom: $border-today;
    }

    &.date {
      display: flex;
      gap: 10px;
      justify-content: center;
      text-transform: uppercase;

      .month {
        color: var(--accent-color-bg);
      }

      .day {
        font-weight: 400;
      }
    }
  }

  .table-row {
    display: contents;
  }
}

app-cmf-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

app-cmf-gravatar {
  display: flex;
}

.card.resizing {
  pointer-events: none;
}

.card.is-fake {
  opacity: 0.5;
}

.cdk-drag-preview,
.card {
  touch-action: none;
  cursor: pointer;
  user-select: none;

  position: relative;

  display: flex;
  gap: 8px;

  width: 100%;
  height: 80px;
  margin-bottom: 8px;
  padding: 8px;

  font-size: 14px;
  text-decoration: none;

  background: var(--color-gray-fff);
  border: 1px solid #c3c6cf;
  border-radius: 4px;
  box-shadow: rgb(0 0 0 / 8%) 0 1px 3px 0;

  transition:
    min-height 0.3s ease 0s,
    box-shadow 0.3s ease-in-out 0s;

  .resize-bar {
    cursor: ew-resize;

    position: absolute;
    top: 0;
    right: -1px;
    bottom: 0;

    justify-self: flex-end;

    width: 4px;

    opacity: 0;
    background: var(--tui-support-12);
    background-clip: content-box;
    border-left: 2px solid transparent;

    &:hover,
    &:active {
      opacity: 1;
    }
  }

  .color-line {
    flex: 0 0 4px;
    height: 100%;
    background-color: #27b0ed;
    border-radius: 2px;
  }

  .close-icon {
    position: absolute;
    z-index: 1;
    top: -8px;
    right: -8px;
    transform: scale(0.5);

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

    width: 20px;
    height: 20px;

    font-size: 20px;
    font-weight: bold;
    color: #fff;

    opacity: 0;
    background-color: var(--accent-color-bg);
    border-radius: 50%;

    transition: all ease-in-out 0.2s;
  }

  &:hover {
    .close-icon {
      transform: scale(1);
      opacity: 1;
    }
  }

  .card-content {
    overflow: hidden;
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;

    .top {
      display: flex;
      justify-content: space-between;

      .title {
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;

        font-size: 14px;
        font-weight: bold;
        hyphens: auto;
        text-align: left;
        text-overflow: ellipsis;
        word-break: inherit;
        overflow-wrap: break-word;
        white-space: normal;

        -webkit-line-clamp: 2;
      }
    }

    .bottom {
      display: flex;
      gap: 3px;
      align-items: center;
      max-width: 100%;

      .code {
        cursor: pointer;

        overflow: hidden;

        font-size: 12px;
        color: var(--color-gray-666);
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .time {
        margin-left: auto;
        font-size: 12px;
        font-weight: bold;
        white-space: nowrap;
      }
    }
  }
}

.cdk-drag-preview {
  opacity: 0.85;
}
