/*
 * Copyright 2023 Harness, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import 'src/utils/utils';

.main {
  --color-border: var(--grey-200);
  --box-radius: 5px;

  background-color: var(--grey-50);
  border-bottom-left-radius: var(--box-radius);
  border-bottom-right-radius: var(--box-radius);
  position: relative;

  &:focus-within {
    --color-border: var(--primary-7);
  }

  &.withPreview {
    --color-border: var(--grey-200);
  }

  > div:first-child {
    padding-top: 0 !important;
  }

  .tabs {
    :global {
      .bp3-tab-list {
        border: none;
        background-color: transparent !important;
        position: absolute;
        top: -4px;
        left: 0px;
        z-index: 2;
        padding: 0;

        .bp3-tab {
          margin: 0 !important;
          padding: 6px 10px !important;
          border-bottom: 1px solid transparent !important;

          &[aria-selected='true'] {
            background-color: var(--white) !important;
            border-top: 1px solid var(--color-border);
            border-left: 1px solid var(--color-border);
            border-right: 1px solid var(--color-border);
            border-top-left-radius: var(--box-radius);
            border-top-right-radius: var(--box-radius);
          }

          &:not([aria-selected='true']) {
            border-bottom: 1px solid transparent !important;
          }
        }

        .bp3-tab-indicator-wrapper {
          display: none;
        }
      }

      .bp3-tab {
        font-size: var(--font-size-normal);
        line-height: 19px;
        color: var(--grey-700);
      }

      .bp3-tab[aria-selected='true'] {
        color: var(--grey-900);
        font-weight: 600;
      }

      .bp3-tab[aria-disabled='true'] {
        opacity: 50%;
        cursor: not-allowed;
      }

      .bp3-tab-panel {
        margin-top: 0;
      }
    }
  }

  .preview {
    background-color: var(--white);
    margin-top: 28px !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--box-radius);
    max-height: 400px;
    overflow: auto;

    :global {
      .wmde-markdown {
        .anchor {
          display: none;
        }
      }
    }
  }

  .markdownEditor {
    :global {
      // .cm-editor .cm-line {
      //   &,
      //   * {
      //     @include mono-font;
      //   }
      // }
      .cm-line {
        > .aidaGenText {
          background: var(--ai-purple-800) !important;
        }
      }

      .md-editor {
        background-color: transparent !important;
        box-shadow: none !important;

        .md-editor-content {
          border: 1px solid var(--color-border) !important;
          border-bottom-left-radius: var(--box-radius);
          border-bottom-right-radius: var(--box-radius);
          border-top-right-radius: var(--box-radius);
        }
      }

      .md-editor-toolbar-warp,
      .md-editor-toolbar-warp:not(.md-editor-toolbar-bottom) {
        border-bottom: none !important;
      }

      .md-editor-preview {
        display: none;
      }

      .md-editor-toolbar {
        margin-left: auto;
        margin-right: 0;
        position: relative;
      }

      .md-editor-content {
        padding: var(--spacing-small);
        background-color: var(--white);
        height: var(--editor-height, auto);
        min-height: var(--editor-height, auto);
        max-height: var(--max-editor-height, var(--editor-height, auto));

        .ͼ1.cm-editor.cm-focused {
          outline: none !important;
        }
      }

      .cm-content {
        min-height: 46px;
      }
    }
  }
}

.container {
  --tab-border-primary: rgba(176, 177, 195, 0.5);
  --radius: 5px;

  box-shadow: var(--elevation-2);
  border-radius: var(--radius);
  border: 1px solid var(--tab-border-primary);
  border-bottom: none;
  background-color: var(--white);

  &.noBorder {
    border: none;
    box-shadow: none;
  }

  position: relative;

  scroll-margin-top: 10px;
  scroll-margin-bottom: 10px;

  .tabs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    padding: 15px 15px 0;
    border-bottom: 1px solid var(--tab-border-primary);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);

    li {
      a {
        padding: 6px 15px;
        display: block;
        font-style: normal;
        font-weight: 500;
        font-size: 13px;
        line-height: 18px;
        text-decoration: none;
        color: var(--grey-900);

        position: relative;
        border: 1px solid transparent;
        border-bottom: none;
        border-top-left-radius: var(--radius);
        border-top-right-radius: var(--radius);

        &::after {
          content: '';
          right: 0;
          left: 0;
          bottom: -1px;
          height: 1px;
          width: 100%;
          position: absolute;
          background-color: transparent;
        }

        &[aria-selected='true'] {
          background-color: var(--white);
          border-color: var(--tab-border-primary);

          &::after {
            background-color: var(--white);
          }
        }
      }
    }
  }

  .toolbar {
    position: absolute;
    top: 12px;
    right: 16px;
    margin: 0;
    padding: 0;
    display: flex;
  }

  .tabContent {
    padding: var(--spacing-large);
    background-color: var(--white);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
  }

  .buttonsBar {
    padding: 0 var(--spacing-large) var(--spacing-large);
    background-color: var(--white);
    border-radius: var(--radius);
  }

  .hidden {
    display: none;
  }
}
.dialog {
  width: 610px !important;
  .uploadContainer {
    border-radius: 4px;
    border: 1px dashed var(--grey-200);
    background: var(--grey-50);
  }
}

.aidaGenText {
  background: var(--ai-purple-800) !important;
  font-weight: bold !important;
}

.feedbackContainer {
  position: relative;
  //  overwriting the extra close button in feedback form UsefulOrNot
  > div {
    > div {
      > button {
        span[data-icon='main-close'] {
          display: none !important;
        }
      }
    }
  }

  .aidaFeedback {
    margin: 0 0 9px 0 !important;
    padding: 7px 10px !important;
    width: 100%;
    background-color: var(--ai-purple-100) !important;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  }

  .closeButton {
    position: absolute;
    top: 3px;
    right: 3px;
  }
}
