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

.chat-message {
  .message-text {
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0px 1px 2px $boxShadowSoft;
    font-size: 14px;
    line-height: 1.4;
    color: $mainFontColor;
    white-space: pre-wrap;
    word-break: break-word;
    background-color: $lightBlueColor;
    transition: all 0.3s ease;

    // Highlighted message styling
    &.highlighted-message-content {
      border: 2px solid $primaryColor;
      box-shadow: 0px 0px 8px rgba($primaryColor, 0.3);
      animation: highlightScalePulse 1.5s infinite;
    }

    .priority-container {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-bottom: 12px;
      .priority-label {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 14px;
      }
    }

    &.low {
      border-left: 3px solid $avatarBgColor;
    }

    &.medium {
      border-left: 3px solid $warningAlertIcon;
    }

    &.high {
      border-left: 3px solid $destructiveBg;
    }

    &.normal {
      border-left: 3px solid $primaryColor;
    }

    p {
      margin: 0 0 8px 0;
      color: $textButtonFontColor;
      font-size: 14px;
      font-style: normal;
      font-weight: 500;
      line-height: 160%;
      letter-spacing: 0.14px;
      text-align: left;

      &:last-child {
        margin-bottom: 0;
      }
    }

    // Message content container for HTML rendering
    .message-content {
      margin: 0;

      p {
        margin: 0 0 8px 0;
        color: $textButtonFontColor;
        font-size: 14px;
        font-style: normal;
        font-weight: 500;
        line-height: 160%;
        letter-spacing: 0.14px;
        text-align: left;
        margin-bottom: 0;

        &:last-child {
          margin-bottom: 0;
        }
      }

      // Mention styling
      .mention {
        background-color: rgba($primaryColor, 0.1);
        border: 1px solid rgba($primaryColor, 0.3);
        border-radius: 4px;
        color: $primaryColor;
        font-weight: 600;
        padding: 0px 6px;
        text-decoration: none;
        display: inline-block;
        margin: 0px 2px;
        transition: all 0.2s ease;

        &:hover {
          background-color: rgba($primaryColor, 0.15);
          border-color: rgba($primaryColor, 0.5);
        }
      }

      // Text formatting styles
      strong {
        font-weight: 700;
        color: $textButtonFontColor;
      }

      em {
        font-style: italic;
        color: $textButtonFontColor;
      }

      u {
        text-decoration: underline;
        color: $textButtonFontColor;
      }

      // Highlight styling
      mark {
        background-color: #fef3c7;
        border-radius: 4px;
        padding: 2px 4px;
        color: $textButtonFontColor;
      }

      // Link styling
      a {
        color: $primaryColor;
        text-decoration: underline;

        &:hover {
          color: darken($primaryColor, 10%);
        }
      }

      // List styling
      ul,
      ol {
        margin: 8px 0;
        padding-left: 20px;

        li {
          margin: 4px 0;
          color: $textButtonFontColor;
        }
      }

      // Heading styles
      h1,
      h2,
      h3,
      h4,
      h5,
      h6 {
        margin: 12px 0 8px 0;
        color: $textButtonFontColor;
        font-weight: 600;

        &:first-child {
          margin-top: 0;
        }
      }

      h1 {
        font-size: 20px;
      }
      h2 {
        font-size: 18px;
      }
      h3 {
        font-size: 16px;
      }
      h4 {
        font-size: 15px;
      }
      h5 {
        font-size: 14px;
      }
      h6 {
        font-size: 13px;
      }
    }

    .message-action-info-container {
      display: flex;
      align-items: center;
      gap: 8px;

      .pin-button {
        // Always visible when showPinned is true
        display: flex;
      }

      .pin-button-hover {
        // Hidden by default, shown on hover
        display: none;
      }
    }

    // Show hover pin button when hovering over message-text
    &:hover {
      .message-action-info-container {
        .pin-button-hover {
          display: flex;
        }
      }
    }
  }
  .flex-end {
    justify-content: flex-end;
    min-height: 24px;
  }
}

.chat-message.assistant-message {
  .message-text {
    background: linear-gradient(
      92.25deg,
      $disabledSecondaryBg -0.92%,

      $inactiveInputBackground 98.11%
    );
    margin-right: 60px;
    margin-left: 0;
    color: $textButtonFontColor;
  }
}

.message-header {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;

  .message-action-container {
    visibility: hidden;
    display: flex;
    align-items: center;
    gap: 4px;
    img,
    svg {
      cursor: pointer;
      color: $lightGrayColor;
      width: 14px;
    }
  }
  .visibility-enabled {
    visibility: visible;
  }
}

.btn_border_default {
  border: none !important;
  background-color: transparent !important;
}

.message-timestamp {
  color: $inputInfoColor;
  font-size: 12px;
  font-weight: 400;

  .edited-label {
    color: $inputInfoColor;
    font-style: italic;
    opacity: 0.8;
  }
}

// Animation for highlighted message with scale effect
@keyframes highlightScalePulse {
  0% {
    transform: scale(1);
    box-shadow: 0px 0px 0px rgba($primaryColor, 0);
  }
  30% {
    transform: scale(1.03);
    box-shadow: 0px 0px 12px rgba($primaryColor, 0.6);
  }
  60% {
    transform: scale(0.98);
    box-shadow: 0px 0px 10px rgba($primaryColor, 0.4);
  }
  100% {
    transform: scale(1);
    box-shadow: 0px 0px 8px rgba($primaryColor, 0.3);
  }
}
