@use "sass:map";
@use "../../../node_modules/quill/dist/quill.core.css";
@use "../../../node_modules/quill/dist/quill.snow.css" as snow;
@use "../../wc";

:host, zn-editor {
  width: 100%;
}

:host {
  @include wc.scrollbars;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 170px;

  display: flex;
  flex-direction: column;
  background-color: rgba(var(--zn-panel), var(--zn-panel-opacity));
  margin: 0;
  padding: 0;
  max-height: 100%;
  flex: 1;
  overflow: hidden;

  .ql-container {
    border: none;
    appearance: none;
    background-color: transparent;
    resize: none;
    padding: 20px 20px 0;
  }

  .ql-toolbar {
    border: 0 solid rgb(var(--zn-border-color));
    color: rgb(var(--zn-text-heading));
    display: flex;
    flex-wrap: wrap;
    gap: 5px;

    > span.ql-formats {
      margin: 0;
    }

    > span {
      padding-top: 2px;
      padding-bottom: 2px;
    }

    &:after {
      display: none;
    }
  }

  .ql-editor {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    flex-grow: 1;
    color: rgb(var(--zn-text));
    background-color: rgba(var(--zn-panel), var(--zn-panel-opacity));
    font-size: 15px;
    padding: 0 var(--zn-spacing-medium);

    img {
      height: auto;
    }
  }

  .ql-editor.ql-blank:before {
    right: var(--zn-spacing-medium);
    left: var(--zn-spacing-medium);
    color: rgb(var(--zn-text));
  }

  #editor {
    flex: 1;
    height: 0;
    padding: 0;
  }

  #toolbar-container, #action-container {
    justify-content: space-between;
    align-items: center;

    .wrap {
      flex-grow: 1;
    }
  }

  #action-container.ql-toolbar {
    border-bottom-width: 0;
  }

  .ql-stroke {
    stroke: rgb(var(--zn-text-heading));
  }

  .ql-fill {
    fill: rgb(var(--zn-text-heading));
  }

  .ql-picker-label:before {
    color: rgb(var(--zn-text-heading));
  }

  .ql-image svg {
    fill: currentColor;
  }
}

.ql-placeholder {
  width: 110px;
}

.ql-placeholder .ql-picker-label::before {
  content: 'Placeholder';
}

.ql-code-block-container .ql-ui {
  color: rgb(var(--zn-text))
}

.ql-code-block {
  font-size: 90%;
}

/* Editor toolbar custom active states */
:host #toolbar zn-button.ql-active .button {
  background-color: rgba(var(--zn-primary), 0.2);
}

:host #toolbar zn-dropdown zn-menu zn-menu-item[checked] .menu-item {
  background-color: rgba(var(--zn-panel-highlight), var(--zn-panel-highlight-opacity));
  color: rgb(var(--zn-primary));
}

:host .ql-editor hr,
:host .ql-editor .ql-hr {
  border: none;
  border-top: 1px solid rgb(var(--zn-border-color));
  height: 0;
  margin: var(--zn-spacing-small) 0;
  opacity: 1;
}

#toolbar {
  padding: 4px;
}
