@import "../../../../styles/index.scss";

.ProseMirror-focused {
  outline: none;
}

.tiptap {
  :first-child {
    margin-top: 0;
  }

  p {
    margin: 0.5em 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Heading styles */
  h1 {
    font-size: 2em;
    font-weight: 600;
    margin: 1em 0 0.5em;
    color: #1a202c;
  }

  h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.83em 0 0.5em;
    color: #1a202c;
  }

  h3 {
    font-size: 1.17em;
    font-weight: 600;
    margin: 0.67em 0 0.5em;
    color: #1a202c;
  }

  h4 {
    font-size: 1em;
    font-weight: 600;
    margin: 0.5em 0;
    color: #1a202c;
  }

  h5 {
    font-size: 0.83em;
    font-weight: 600;
    margin: 0.5em 0;
    color: #1a202c;
  }

  h6 {
    font-size: 0.67em;
    font-weight: 600;
    margin: 0.5em 0;
    color: #1a202c;
  }

  /* Text formatting styles */
  strong {
    font-weight: 600;
  }

  em {
    font-style: italic;
  }

  s {
    text-decoration: line-through;
    text-decoration-thickness: 0.1em;
    color: #666666;
  }

  .highlight {
    background-color: #fef3c7 !important;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 2px;
  }

  mark {
    background-color: #fef3c7;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0 2px;
  }

  a {
    color: #2b6cb0;
    text-decoration: none;
    border-bottom: 1px solid #2b6cb0;
    transition: all 0.2s ease;

    &:hover {
      color: #1a4971;
      border-bottom-color: #1a4971;
    }
  }

  img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.5em 0;
  }

  /* Mention styles */
  .mention {
    background-color: #f0f4f8;
    border-radius: 4px;
    box-decoration-break: clone;
    color: #2b6cb0;
    font-weight: 500;
    padding: 2px 6px;
    text-decoration: none;
    transition: background-color 0.2s ease;
    white-space: nowrap;

    &:hover {
      background-color: #e2e8f0;
      cursor: pointer;
    }
  }

  /* Active state styles */
  .is-active {
    background-color: #f0f4f8;
  }

  /* List styles */
  ul,
  ol {
    padding-left: 1.2em;
    margin: 0.5em 0;
  }

  ul li,
  ol li {
    margin: 0.2em 0;
    padding-left: 0;
    line-height: 1.2;

    p {
      margin: 0; /* Remove paragraph margins inside list items */
      display: inline-block; /* Better handling of nested content */
    }
  }

  ul li {
    list-style-type: disc;
  }

  ol li {
    list-style-type: decimal;
  }

  /* Nested list styles */
  ul ul,
  ol ol,
  ul ol,
  ol ul {
    margin: 0.2em 0 0.2em 0.5em; /* Add indentation for nested lists */
  }

  ul ul li {
    list-style-type: circle;
  }

  ul ul ul li {
    list-style-type: square;
  }

  ol ol li {
    list-style-type: lower-alpha;
  }

  ol ol ol li {
    list-style-type: lower-roman;
  }

  /* Active list styles */
  ul[data-type="bulletList"],
  ol[data-type="orderedList"] {
    li {
      position: relative;

      &::before {
        content: "";
        position: absolute;
        left: -1em;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
      }
    }
  }

  .highlight {
    background-color: #fef3c7;
    border-radius: 2px;
    padding: 0 2px;
  }

  /* Code block styles */
  code {
    background-color: #f7fafc;
    border-radius: 4px;
    padding: 0.2em 0.4em;
    font-family: monospace;
  }

  /* Blockquote styles */
  blockquote {
    border-left: 3px solid #e2e8f0;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #4a5568;
  }
}

/* Character count */
.character-count {
  align-items: center;
  color: var(--gray-5);
  display: flex;
  font-size: 0.75rem;
  gap: 0.5rem;
  margin: 1.5rem;

  svg {
    color: var(--purple);
  }

  &--warning,
  &--warning svg {
    color: var(--red);
  }
}

// main container styles

.tiptap-editor {
  width: 88%;
  max-height: 100px;
  margin-right: 10px;
  overflow-y: auto;

  .ProseMirror {
    outline: none;
    padding: 8px 12px;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    word-wrap: break-word;

    &::-webkit-scrollbar {
      width: 4px;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.2);
      border-radius: 2px;
    }

    &::-webkit-scrollbar-thumb:hover {
      background: rgba(0, 0, 0, 0.3);
    }
  }
}
