@use "sass:map";
@use "@/styles/cunningham-tokens-sass" as *;

$tablet: map.get($themes, "default", "globals", "breakpoints", "tablet");

.explorer__tree__item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--c--globals--spacings--xs);
  overflow: hidden;
  height: 24px;

  &__title {
    font-size: var(--c--globals--font--sizes--sm);
    font-weight: 500;
    color: var(--c--contextuals--content--semantic--neutral--primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  &__droppable {
    border: 1.5px solid transparent;
    border-radius: 4px;
    &.over {
      background-color: var(
        --c--contextuals--background--semantic--brand--tertiary
      );
      border: 1.5px solid
        var(--c--contextuals--border--semantic--brand--primary);
    }
  }
  &:hover {
    .explorer__tree__item__actions {
      display: flex;
    }
  }

  &__content {
    display: flex;
    align-items: center;
    gap: var(--c--globals--spacings--xs);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__actions {
    display: none;
    gap: 4px;
    align-items: center;
    padding-right: 4px;

    .c__dropdown-menu-trigger {
      display: flex;
      align-items: center;
    }

    &--open {
      display: flex;
    }

    &__button-more {
      .material-icons {
        font-size: 20px;
      }
    }

    &__button-add {
      width: 18px !important;
      height: 18px !important;
      padding: 0;
      border-radius: 2px;
    }
  }
}

.explorer__tree__item-standalone {
  padding-left: 4px;
}

.explorer__tree__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 0.75rem;
  padding: 0 12px;

  &__item {
    cursor: pointer;
    display: flex;
    border-radius: 4px;
    align-items: center;
    gap: var(--c--globals--spacings--xs);
    height: 34px;
    padding-left: 22px;
    font-size: var(--c--globals--font--sizes--sm);
    color: var(--c--contextuals--content--semantic--neutral--primary);
    font-weight: 500;

    &.active {
      background-color: var(
        --c--contextuals--background--semantic--contextual--primary
      );
      font-weight: 700;
    }

    &:hover {
      background-color: var(
        --c--contextuals--background--semantic--contextual--primary
      );
    }

    &__icon {
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--c--contextuals--content--semantic--neutral--tertiary);
    }
  }
}

.explorer__tree {
  display: flex;
  flex-direction: column;
  height: 100%;

  &__nav {
    padding: 0 12px;

    &__icon {
      width: 16px;
      height: 16px;
      color: var(--c--contextuals--content--semantic--neutral--tertiary);
    }
  }

  &__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding: 12px;

    &__left {
      display: flex;
      gap: 8px;
      align-items: center;
    }

    @media (max-width: $tablet) {
      .explorer__search__button {
        display: none;
      }

      .explorer__tree__actions__left {
        flex-grow: 1;

        .c__dropdown-menu-trigger {
          flex-grow: 1;

          button {
            flex-grow: 1;
            justify-content: center;
          }
        }
      }
    }
  }

  .c__tree-view--container {
    @media (max-width: $tablet) {
      display: none;
    }
  }

  &__mobile {
    display: flex;

    flex-direction: column;
    padding: 12px 0;
    gap: 2px;

    @media (max-width: $tablet) {
    }

    &__item {
      font-size: 14px;
      margin: 0 12px;
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;

      &:hover {
        background-color: var(
          --c--contextuals--background--semantic--contextual--primary
        );
      }

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

    &__title {
      font-weight: 700;
      height: 30px;
    }

    &__node {
      padding: 6px;
      font-weight: 500;
      border-radius: 4px;
      border: none;
      outline: none;
      background-color: transparent;
      font-family: inherit;
      flex-grow: 1;

      &--selected {
        background-color: var(
          --c--contextuals--background--semantic--contextual--primary
        );
      }
    }
  }

  .explorer__tree__mobile-navs {
    display: none;
  }

  @media (max-width: $tablet) {
    .explorer__tree__mobile-navs {
      display: flex;
      flex-direction: column;
      flex: 1;

      .c__dropdown-menu-trigger {
        width: 100%;
      }
    }
  }
}
