@use "@choiceform/design-tokens/functions.scss" as fn;
@use "@choiceform/design-tokens/mixins.scss" as mx;
@use "@choiceform/design-tokens/tokens.scss" as *;

$max-height: 240px;

.ͼ2 .cm-tooltip-below {
  z-index: fn.z-index("tooltip");
  box-shadow: fn.shadow("md");
  border: none;
  border-radius: fn.radius("lg");
  background-color: fn.color("background.default");
  overflow: hidden;
}

.ͼ2 .cm-tooltip-above {
  z-index: fn.z-index("tooltip");
  box-shadow: fn.shadow("md");
  border: none;
  border-radius: fn.radius("lg");
  background-color: fn.color("background.default");
  overflow: hidden;
}

.ͼ1 .cm-diagnostic-error {
  border-left: none;
  &::before {
    background-color: fn.color("text.danger");
  }
}

.ͼ1 .cm-diagnostic-warning {
  border-left: none;
  &::before {
    background-color: fn.color("text.warning");
  }
}

.ͼ1 .cm-diagnostic {
  display: block;
  position: relative;
  margin-left: -1px;
  padding: 4px 8px 4px 16px;
  white-space: pre-wrap;
  &::before {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 8px;
    border-radius: 2px;
    width: 3px;
    content: "";
  }
}

.ͼ2 .cm-tooltip-section:not(:first-child) {
  border-top-color: fn.color("border.default");
}

.ͼ2 .cm-tooltip-autocomplete {
  display: flex;
  align-items: stretch;
  z-index: fn.z-index("tooltip");
  padding: 0;
  max-height: $max-height;
  overflow: hidden;
  font-size: fn.font-size("sm");
  font-family: var(--font-sans);
}

.ͼ1 .cm-tooltip.cm-tooltip-autocomplete > ul {
  margin: 0;
  padding: 0;
  min-width: 200px;
  max-width: 240px;
  max-height: $max-height;
  overflow-y: auto;
  list-style: none;
  & > li {
    @include mx.text-ellipsis();
    cursor: default;
    margin: 0;
    border-bottom: none;
    padding: 0 0.5rem;
    height: 1.5rem;
    scroll-margin: 40px;
    scroll-padding: 40px;
    font-size: fn.font-size("sm");
    line-height: 1.5rem;
    &[role="option"] {
      &:hover {
        background-color: fn.color("background.secondary");
      }
    }
    &[aria-selected] {
      background-color: fn.color("background.selected");
      color: fn.color("text.accent");
    }
    .cm-completionLabel {
      flex: 1;
    }
    .cm-completionDetail {
      margin-left: 0.5rem;
      color: fn.color("text.secondary");
      font-style: normal;
    }
    .cm-section-title {
      color: fn.color("text.secondary");
      @include mx.text-ellipsis();
    }
  }
}

.ͼ2 .cm-tooltip-expression-info {
  z-index: fn.z-index("tooltip");
  padding: 0.5rem;
  height: 100%;
}

.ͼ1 .cm-tooltip.cm-completionInfo {
  display: flex;
  position: relative;
  top: 0 !important;
  right: 0;
  left: 0;
  flex: 1;
  flex-direction: column;
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid fn.color("border.default");
  background-color: fn.color("background.secondary");
  padding: 0;
  width: 280px;
  max-width: 280px !important;
  max-height: $max-height;
  overflow: hidden;
  font-family: var(--font-sans);
}

.ͼ1 .cm-completionInfo.cm-completionInfo-right {
  border-left: 1px solid fn.color("border.default");
}

.ͼ2 .autocomplete-info-container {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  cursor: default;
  background-color: fn.color("background.secondary");
  padding: 0.5rem;
  min-width: 240px;
  max-width: 320px;
  height: 100%;
  overflow-y: auto;
}

.autocomplete-info-header {
  color: fn.color("text.secondary");
}

.autocomplete-info-name {
  margin-right: 0.25rem;
  color: fn.color("text.accent");
  font-weight: fn.font-weight("medium");
}

.autocomplete-info-description {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  & a {
    cursor: pointer;
    color: fn.color("text.accent");
    text-decoration: underline;
  }
}

.autocomplete-info-examples-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 1rem;
}

.autocomplete-info-example {
  border: 1px solid fn.color("border.default");
  border-radius: fn.radius("md");
  background-color: fn.color("background.default");
  padding: 0.5rem;
  font-family: var(--font-mono);
  code {
    white-space: pre-wrap;
    word-break: break-all;
  }
}

.autocomplete-info-example-comment {
  color: fn.color("text.secondary");
  font-style: italic;
}

.autocomplete-info-section-title {
  margin-bottom: 0.25rem;
  color: fn.color("text.accent");
  font-weight: fn.font-weight("medium");
}

.autocomplete-info-args {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.75rem;
  & li {
    list-style: disc;
    word-break: break-all;
  }
  & .autocomplete-info-args {
    margin-top: 0.5rem;
  }
}

.autocomplete-info-arg-name {
  color: fn.color("text.secondary");
}

.ͼ1 .cm-completionMatchedText {
  color: fn.color("text.accent");
  text-decoration: none;
}