// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

@use "common/refactor/common-refactor.scss" as *;
@use "common/refactor/common-dashboard";

.dashboard-sidebar {
  grid-row: 1 / span 2;
  grid-column: 1 / span 2;

  background-color: $db-primary;
  border-right: $s-1 solid $db-cuaternary;
  margin: 0 $s-16 0 0;
  padding: $s-16 0 0 0;

  z-index: $z-index-1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 0;

  hr {
    border-color: transparent;
    margin: $s-12 $s-16;
  }
}

.sidebar-team-switch {
  position: relative;
  display: flex;
  margin: $s-4 $s-16;

  .switch-content {
    background-color: $db-tertiary;
    border-radius: $br-8;
    height: $s-48;
    display: flex;
    width: 100%;
    border: $s-1 solid transparent;
    align-items: center;

    svg {
      fill: #8f9da3;
    }
  }

  .switch-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    svg {
      fill: $df-secondary;
      width: $s-12;
      height: $s-12;
    }
  }

  .current-team {
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-grow: 1;
    font-size: $fs-14;
    padding: 0 $s-12;
    background-color: transparent;
    border: none;
    border-right: $s-1 solid $db-primary;
  }

  .team-name {
    flex-grow: 1;
    display: flex;
    height: $s-40;
    align-items: center;
  }

  .team-text {
    color: $df-primary;
    width: $s-144;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
  }

  .team-icon {
    display: flex;
    align-items: center;
    padding-right: $s-12;

    img {
      border-radius: 50%;
      flex-shrink: 0;
      height: $s-24;
      width: $s-24;
    }

    svg {
      width: $s-24;
      height: $s-24;
    }
  }

  .switch-options {
    display: flex;
    max-width: $s-24;
    min-width: $s-28;
    border-left: $s-1 solid $df-primary;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background-color: transparent;
    border: none;
    height: 100%;

    svg {
      fill: $df-secondary;
      width: $s-16;
      height: $s-12;
    }
  }

  .dropdown {
    right: $s-2;
    top: $s-52;
    min-width: $s-160;
    max-height: $s-480;
  }
}

.dropdown {
  @include menuShadow;
  position: absolute;
  z-index: $z-index-4;
  background-color: $db-tertiary;
  border: $s-1 solid $db-cuaternary;
  border-radius: $br-8;

  .separator {
    border-color: transparent;
    margin-top: $s-12;
  }

  li {
    border-radius: $br-8;
    height: $s-40;
    margin: $s-6;

    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: $fs-14;
    padding: $s-6 $s-16;

    .warning {
      color: var(--dark-warning-color);
    }

    &:hover {
      background-color: $db-cuaternary;
    }
    svg {
      height: $s-12;
      width: $s-12;
    }
  }

  hr {
    border-color: transparent;
    margin: 0;
  }

  &.options-dropdown {
    li {
      color: $df-primary;
      &.warning {
        color: var(--dark-warning-color);
      }
    }
  }
}

.teams-dropdown {
  background-color: $db-tertiary;
  border-radius: $br-8;
  border: $s-1 solid $db-cuaternary;
  min-width: $s-248;

  left: 0;
  top: $s-52;

  max-height: $s-480;
  overflow-x: hidden;
  overflow-y: auto;

  li {
    border-radius: $br-8;
    height: $s-40;
    padding: 0 $s-6;
    margin: $s-6;

    svg {
      fill: $df-secondary;
    }

    &:hover {
      background-color: $db-cuaternary;
      .team-icon {
        &.new-team {
          background-color: $da-primary;
          svg {
            fill: $db-secondary;
          }
        }
      }
    }
    .team-icon {
      display: flex;
      align-items: center;
    }
    .team-text {
      color: $df-primary;
      width: $s-168;
    }

    .new-team {
      background-color: $db-cuaternary;
    }

    &.action {
      .team-icon {
        background-color: #2e3434;
        border-radius: 50%;
        height: $s-24;
        margin-right: $s-12;
        padding: $s-6;
        width: $s-24;

        svg {
          height: $s-12;
          width: $s-12;
        }
      }
    }
  }
}

.sidebar-empty-placeholder {
  padding: $s-12;
  color: $df-secondary;
  display: flex;
  align-items: flex-start;

  .icon {
    padding: 0 $s-12;
    svg {
      fill: $df-secondary;
      width: $s-12;
      height: $s-12;
    }
  }
  .text {
    font-size: $fs-12;
  }
}

.sidebar-search {
  align-items: center;
  border: $s-1 solid transparent;
  display: flex;
  margin: $s-6 $s-16;

  background-color: $db-tertiary;
  border-radius: $br-8;
  margin-bottom: $s-32;
  margin-top: 0;
  position: relative;

  .input-text {
    background: transparent;
    border: 0;
    font-size: $fs-14;
    margin: 0;
    width: 100%;
    height: $s-40;

    border-radius: $br-8;
    color: $df-primary;
    max-width: 100%;
    padding: $s-6 $s-12;

    &:focus,
    &:focus-within {
      border: $s-1 solid $da-primary;
    }
  }
  ::placeholder {
    color: $df-secondary;
  }

  .search,
  .clear-search {
    align-items: center;
    cursor: pointer;
    display: flex;
    height: $s-24;
    margin-left: auto;
    padding: 0 $s-8;
    width: $s-32;

    position: absolute;
    top: calc(50% - $s-12);
    right: $s-2;

    svg {
      fill: $df-secondary;
      height: $s-16;
      width: $s-16;
    }
  }

  .clear-search svg {
    transform: rotate(45deg);

    &:hover {
      fill: var(--warning-color);
    }
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin: 0;
  user-select: none;

  &.no-overflow {
    overflow: unset;
  }

  & > li {
    align-items: center;
    cursor: pointer;
    display: flex;
    flex-shrink: 0;

    &.project-element {
      padding: $s-8 $s-8 $s-8 $s-24;
    }

    a {
      padding: $s-8 $s-8 $s-8 $s-24;
      font-weight: $fw400;
      width: 100%;
      &:hover {
        text-decoration: none;
      }
    }

    svg {
      fill: $db-secondary;
      margin-right: $s-8;
      height: $s-12;
      width: $s-12;
    }

    .element-title {
      color: $df-secondary;
      font-size: $fs-14;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    &.recent-projects {
      svg {
        fill: $df-primary;
      }
    }

    input.element-title {
      border: 0;
      height: $s-32;
      padding: $s-6;
      margin: 0;
      width: 100%;
      background-color: $df-primary;
    }

    .close {
      background-color: $df-primary;
      cursor: pointer;
      padding-left: $s-6;

      svg {
        fill: $df-secondary;
        height: $s-16;
        transform: rotate(45deg) translateY(7px);
        width: $s-16;
        margin: 0;
      }
    }

    .element-subtitle {
      color: $df-secondary;
      font-style: italic;
    }

    &:hover {
      background-color: $db-cuaternary;
    }

    &.current {
      background-color: $db-cuaternary;
      .element-title {
        color: $da-primary;
      }
    }
  }
}

.profile-section {
  align-items: center;
  cursor: pointer;
  display: flex;
  padding: $s-12 $s-16;
  position: relative;

  background-color: $db-tertiary;
  border-top: $s-1 solid $db-cuaternary;

  .profile {
    align-items: center;
    cursor: pointer;
    display: flex;
    flex-grow: 1;

    span {
      @include text-ellipsis;
      color: $df-primary;
      margin: $s-12;
      font-size: $fs-14;
      max-width: $s-160;
    }

    img {
      border-radius: 50%;
      flex-shrink: 0;
      height: $s-40;
      width: $s-40;
    }
    svg {
      height: $s-12;
      margin-left: auto;
      margin-right: $s-8;
      width: $s-12;
    }
  }

  .dropdown {
    left: $s-16;
    bottom: $s-44;

    background-color: $db-primary;
    border: $s-1 solid $db-tertiary;
    border-radius: $br-8;
    min-width: $s-252;

    @include animation(0, 0.2s, fadeInUp);

    li {
      font-size: $fs-14;
      padding: $s-8 $s-16;

      svg {
        fill: $df-secondary;
        margin-right: $s-8;

        height: $s-12;
        width: $s-12;
      }

      .text {
        color: $df-primary;
      }

      &.separator {
        border-top: $s-1 solid transparent;
      }
    }
  }
}
