@import "../../../styles/mixins";

.SymbolMenu {
  &.mobile-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-background);
    z-index: 1;

    transition: transform var(--layer-transition);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    transform: translate3d(
      0,
      calc(var(--symbol-menu-height) + var(--symbol-menu-footer-height) + env(safe-area-inset-bottom)),
      0
    );

    &.open {
      transform: translate3d(0, 0, 0);

      body.is-media-viewer-open & {
        transform: translate3d(0, calc(var(--symbol-menu-height) + var(--symbol-menu-footer-height)), 0);
      }
    }

    body.animation-level-0 & {
      transition: none;
    }

    &.left-column-open {
      transform: translate3d(100vw, 0, 0) !important;
    }
  }

  &-main {
    height: var(--symbol-menu-height);
    max-height: calc(100vh - var(--symbol-menu-footer-height) - env(safe-area-inset-bottom));
  }

  &-footer {
    height: var(--symbol-menu-footer-height);
    border-top: 1px solid var(--color-borders);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 2px var(--color-default-shadow);
    position: relative;

    .Button {
      flex-shrink: 0;
      width: 2.125rem !important;
      height: 2.125rem;
      margin: 0 0.25rem;
      padding: 0;

      &.activated {
        pointer-events: none;
      }

      &.symbol-tab-button {
        margin: 0 0.75rem;
      }

      &.symbol-search-button {
        position: absolute;
        left: 0.25rem;
      }

      &.symbol-delete-button {
        position: absolute;
        right: 0.25rem;
      }
    }
  }

  .Transition.slide {
    height: 100%;

    .Loading {
      height: var(--symbol-menu-height);
    }
  }

  .is-pointer-env & {
    > .backdrop {
      position: absolute;
      top: -1rem;
      left: 0;
      right: auto;
      width: 3.5rem;
      height: 4.5rem;
    }
  }

  // TODO Remove this monster with context menu refactor
  .Button.bot-menu:not(.open) ~ &,
  .Button.bot-commands ~ &,
  .Button.send-as-button ~ & {
    .is-pointer-env & > .backdrop {
      left: 3rem;
      width: 3.25rem;
    }
  }

  .Button.bot-menu.open ~ & {
    .is-pointer-env & > .backdrop {
      left: calc(var(--bot-menu-text-width, 0) + 3rem);
    }
  }

  .bubble {
    width: calc(var(--symbol-menu-width) + 0.25rem); // Reserve width for scrollbar
    padding: 0;
    overflow: hidden;

    @supports (overflow: overlay) {
      width: var(--symbol-menu-width);
    }
  }

  .picker-disabled {
    height: var(--symbol-menu-height);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
  }

  .symbol-close-button {
    display: none;
    position: absolute;
    right: max(calc(0.25rem), env(safe-area-inset-right));
    top: max(calc(0.25rem), env(safe-area-inset-top));
  }

  @media (orientation: landscape) {
    .symbol-close-button {
      display: block;
    }
  }
}

.symbol-set {
  margin-bottom: 1rem;

  &-header {
    display: flex;
    align-items: center;
    color: rgba(var(--color-text-secondary-rgb), 0.75);
  }

  &-name {
    font-size: 1rem;
    line-height: 1.6875rem;
    font-weight: 500;
    margin: 0;
    padding-left: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: initial;
    unicode-bidi: plaintext;
    flex-grow: 1;
  }

  &-remove {
    font-size: 1rem;
    cursor: pointer;
  }

  &-container {
    text-align: initial;
  }

  &-button {
    flex-shrink: 0;
    width: 2.125rem !important;
    height: 2.125rem;
    margin: 0 0.25rem;
    padding: 0;
  }

  @include while-transition() {
    overflow: hidden;
  }

  .symbol-set-container {
    &:not(.shown) {
      display: block;
    }

    &.closing {
      transition: none;
    }
  }
}
