@import '../../style/mixins';
@import '../../style/colors';
@import '~codemirror/lib/codemirror.css';

.compare-helper {
  position: absolute;
  left: -9000px;
  top: 0;

  img,
  iframe {
    max-width: 100%;
  }
}

.CodeMirror-ContextMenu {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 999;
  background: $white;
  padding: 6px;
  border-radius: 8px;
  width: auto;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);

  .ContextMenu-Item,
  .ContextMenu-Item-No-Suggestion {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 500;
    color: $charcoal-grey;
  }

  .ContextMenu-Item-No-Suggestion {
    opacity: 0.2;
  }

  .ContextMenu-Item {
    cursor: pointer;

    &:not(:last-child) {
      margin-bottom: 4px;
    }

    &:hover {
      background: $dark-sky-blue;
      color: $white;
    }

    &.disabled {
      opacity: 0.2;
      pointer-events: none;
    }
  }

  .ContextMenu-Separator {
    height: 1px;
    overflow: hidden;
    border-bottom: 1px solid rgba(196, 196, 196, 0.2);
    margin: 10px 0;
  }
}

.editor-form {
  .editor-widget {
    margin: auto;
    width: 99%;
    background-color: #ebebeb;
    overflow: hidden;
    opacity: 0.2;
    border-radius: 8px;

    img {
      max-width: 100%;
      height: auto;
    }

    .iframe-embed {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;

      .mi {
        font-size: 60px;
      }
    }
  }

  /* CodeMirror */
  .react-codemirror2 {
    height: 100%;
  }

  .CodeMirror {
    font-family: 'Lucida Console', Monaco, monospace;
    font-size: 15px;
    height: 100%;
    line-height: 1.6em;
  }

  .CodeMirror-lines {
    // padding-bottom: 700px;
  }

  .CodeMirror-misspelled {
    border-bottom: 1px dashed $red2;
  }

  /* CodeMirror day theme */
  .cm-s-day.CodeMirror {
    background: transparent;

    @include themify(day) {
      color: $steel-grey;
    }

    @include themify(night) {
      color: $pinkish-grey;
    }
  }

  .CodeMirror-cursor {
    @include themify(day) {
      border-color: $steel-grey;
    }

    @include themify(night) {
      border-color: $pinkish-grey;
    }
  }

  .cm-s-day div.CodeMirror-selected {
    @include themify(day) {
      background: lighten($powder-blue, 5);
    }

    @include themify(night) {
      background: $dark;
    }
  }

  .cm-s-day span.cm-link {
    color: $dark-sky-blue;
  }

  .cm-s-day span.cm-header {
    font-size: 28px;
    font-weight: 700;

    &.cm-header-2,
    &.cm-header-3,
    &.cm-header-4,
    &.cm-header-5,
    &.cm-header-6 {
      font-weight: 700;
      margin-bottom: 0.7em;
    }

    &.cm-header-2 {
      font-size: 24px;
    }

    &.cm-header-3 {
      font-size: 20px;
    }

    &.cm-header-4 {
      font-size: 18px;
    }

    &.cm-header-5 {
      font-size: 16px;
    }

    &.cm-header-6 {
      font-size: 14px;
    }
  }

  .cm-s-day span.cm-tag {
    color: $dark-sky-blue;
  }

  .cm-s-day span.cm-url {
    color: $green1;
  }

  .cm-s-day.CodeMirror pre.CodeMirror-placeholder {
    @include themify(day) {
      color: lighten($steel-grey, 40);
    }

    @include themify(night) {
      color: #6b86ab; // same color with input placeholder
    }
  }

  .cm-s-day.CodeMirror .cm-matchhighlight {
    @include themify(day) {
      background-color: $green2;
    }

    @include themify(night) {
      background-color: $green1;
    }
  }

  .tag-select-options {
    .ant-select-dropdown-menu-item {
      font-family: 'Lucida Console', Monaco, monospace;
    }
  }
}

.editor-form {
  .editor-toolbar {
    align-items: center;
    border-bottom-right-radius: 22px;
    border-top-right-radius: 22px;
    display: flex;
    height: 44px;
    padding-left: 4px;

    @include themify(day) {
      background: $white-three;
    }

    @include themify(night) {
      background: lighten($dark-six, 4);
    }

    .editor-tool {
      align-items: center;
      cursor: pointer;
      display: flex;
      height: 100%;
      justify-content: center;
      position: relative;
      width: 39px;

      @include themify(day) {
        color: $steel-grey;

        &:hover {
          background: darken($white-three, 5);
        }
      }

      @include themify(night) {
        color: $pinkish-grey;

        &:hover {
          background: darken($dark-six, 8);
        }
      }

      .tool-icon {
        font-size: 22px;
      }

      .sub-tool-menu {
        border-bottom-left-radius: 10px;
        border-bottom-right-radius: 10px;
        display: none;
        left: 0;
        padding: 6px;
        position: absolute;
        top: 100%;
        white-space: nowrap;
        width: auto;
        z-index: 2;
        min-width: 100%;

        @include themify(day) {
          background: $white-three;
        }

        @include themify(night) {
          background: lighten($dark-six, 4);
        }

        .sub-tool-menu-item {
          padding: 3px;

          &:not(:last-child) {
            margin-bottom: 8px;
          }
          &:first-child {
          }
          &:hover {
            @include themify(day) {
              background: darken($white-three, 5);
            }

            @include themify(night) {
              background: lighten($dark-six, 8);
            }
          }
        }
      }

      &:hover {
        .sub-tool-menu {
          display: block;
        }

        .emoji-picker {
          display: block;
        }
      }

      .emoji-picker {
        top: 44px;
      }
    }

    .tool-separator {
      height: 24px;
      margin: 0 6px;
      width: 1px;

      @include themify(day) {
        background: $white-four;
      }

      @include themify(night) {
        background: $dark-two;
      }
    }
  }

  .body-input {
    position: relative;
    z-index: 1;
  }
}

.emoji-picker {
  display: none;
  width: 300px;
  height: 240px;
  position: absolute;
  left: 0;
  z-index: 100;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-bottom-left-radius: 8px;
  padding: 14px 6px;
  overflow: auto;

  @include themify(day) {
    background: darken($white-three, 5);
  }

  @include themify(night) {
    background: lighten($dark-six, 4);
  }

  .search-box {
    margin-bottom: 20px;
  }

  .emoji-cat-list,
  .emoji-search-results {
    .emoji-cat {
      .cat-title {
        font-weight: 600;
        font-size: 16px;
        margin: 4px 0 10px 0;

        @include themify(day) {
          color: $charcoal-grey;
        }

        @include themify(night) {
          color: $pinkish-grey;
        }
      }

      .emoji-list {
        @include clearfix();
        display: flex;
        flex-wrap: wrap;

        .emoji {
          cursor: pointer;
          font-size: 22px;
          margin: 5px;
          align-items: center;
          justify-content: center;
          display: flex;
          font-family: 'Segoe UI Emoji', 'Segoe UI Symbol', 'Segoe UI',
            'Apple Color Emoji';
        }
      }
    }
  }
}
