@use '../../../../styles/_globals.scss' as *;

:host {
  display: block;
  text-align: start;
  min-width: 240px;

  &.global {
    position: fixed;
    top: var(--s);
    left: var(--s);
    right: var(--s);
    overflow: visible;
    transform-origin: left top;

    @include mq(xs, max) {
      transform: translateX(0) !important;
      left: 4px;
      right: 4px;
    }

    @include mq(xs) {
      margin-top: 20px;
      max-width: 720px;
      width: 90%;
      top: var(--s6);
      left: 50%;
      right: auto;
      transform: translateX(-50%);
    }
  }
}

:host-context(.isTouchOnly).global {
  top: auto;
  bottom: calc(var(--keyboard-height) + var(--s));
  transition: bottom 0.3s ease-out;
}

.add-task-container {
  width: 100%;
  position: relative;
  background-color: var(--bg-lighter);
  color: var(--text-color-most-intense);

  box-shadow: var(--whiteframe-shadow-3dp);
  border-radius: var(--card-border-radius);

  &.isGlobalBarVariant {
    box-shadow: var(--whiteframe-shadow-12dp);
  }
}

.input-section {
  position: relative;
  display: flex;
  color: var(--text-color-most-intense);

  .main-input {
    flex: 1;
    display: block;
    width: 100%;
    height: 42px;
    font-size: 16px;
    box-sizing: border-box;
    border-style: solid;
    border-width: 0;
    outline: 0;
    padding-left: var(--s2);
    // enough space for three buttons
    line-height: 42px;
    background: transparent;
    color: inherit;
    font-family: var(--font-primary-stack);

    padding-right: 84px;

    &.nr-of-btns-3 {
      padding-right: 126px;
    }

    &.nr-of-btns-4 {
      padding-right: 166px;
    }

    &::placeholder {
      opacity: 0.6;
    }
  }

  .right-button-controls {
    margin-left: auto;
    z-index: 2;
    display: flex;
    position: absolute;
    top: 0;
    right: 0;
  }

  .separator-box {
    border-right: 1px dashed var(--extra-border-color);
    border-left: 1px dashed var(--extra-border-color);
    border-color: var(--extra-border-color);
  }

  .switch-add-to-btn,
  .switch-add-to-bot-btn {
    opacity: 0.4;

    &:hover {
      opacity: 1;
    }
  }

  .search-toggle-btn {
    opacity: 0.4;

    &:hover {
      opacity: 1;
    }

    &.active {
      opacity: 1;
      background-color: var(--primary-light);
      color: var(--primary);
    }
  }

  .search-input {
    padding-right: 40px; // Make room for spinner
  }
}

.add-issue-info-text {
  height: 38px;
  padding: 0 8px;
  line-height: 38px;
  border-top: 1px dashed var(--extra-border-color);
  color: var(--text-color-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;

  &.bold {
    opacity: 1;
    color: var(--text-color-most-intense);
    font-weight: bold;
  }
}

.spinner {
  animation: 200ms fadeIn;
  position: absolute;
  right: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  z-index: 333333;
  border-radius: 50%;
  background: var(--card-bg);
  padding: 6px;
  margin-top: 4px;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

//// Autocomplete panel styles
::ng-deep .isTouchPrimary .add-task-bar-panel {
  top: auto;
  bottom: 4px;
}

::ng-deep .add-task-bar-panel {
  position: absolute;
  padding: 0 !important;
  top: 40px;
  min-width: 300px;

  .mat-mdc-option {
    display: flex;
    align-items: center;
    gap: 8px;

    .project-icon {
      font-size: 16px;
      width: 16px;
      height: 16px;
      margin-left: 8px;
      opacity: 0.7;
      margin-right: 0;
    }

    .project-title {
      opacity: 0.7;
      font-size: 0.9em;
      margin-left: 4px;
    }

    mat-icon:first-child {
      margin-right: 0;
      flex-shrink: 0;
    }
  }

  .suggestion-option {
    min-height: 48px;
    padding: 8px 16px;

    .option-content {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;

      .option-icon {
        flex-shrink: 0;
        color: var(--text-color-dimmed);

        &.archived {
          color: var(--color-accent);
        }
      }

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

      .issue-id {
        flex-shrink: 0;
        font-size: 0.9em;
        color: var(--text-color-dimmed);
        opacity: 0.7;
      }
    }
  }
}
