@blue: #005c97;
@grey: #3d5265;
@teal: #00b3ae;
@citationCircleColor: #e6e7e8;
@citationCircleHoverColor: @blue;
@borderRadius: 0.4rem;
@marginBottom: 1.6em;

.include-scrollbar {
  overflow: auto;
  scrollbar-width: thin;
}

mark {
  background-color: #ff0;
  color: #000;
}

.chat-window,
.claim-modal {
  h2,
  h3,
  h4,
  h5 {
    margin: calc(2rem - 0.1em) 0 1rem;
  }

  h2 {
    font-size: 2rem;
  }

  h3 {
    font-size: 1.625rem;
  }

  h4 {
    font-size: 1.25rem;
  }

  h5 {
    font-size: 1.125rem;
  }

  ol li,
  ul li,
  p {
    font-size: inherit;
  }
}

.chat-window {
  margin: 1.5em 0;

  .ui.button.clear-chat,
  .ui.button.claims-btn {
    display: flex;
    align-items: center;
    margin: 0;

    svg {
      width: 18px;
      height: 18px;
    }
  }

  .messages ul {
    margin-bottom: 0;
  }

  .citation-text {
    overflow: auto;
    max-height: 350px;
  }

  .empty-state {
    margin-top: 2em;
  }

  .citations-header {
    margin-bottom: 0.5em;
    font-size: 15px;
    font-weight: bold;
  }

  .citation-buttons {
    padding: 0.5em 0.8em;
    border-radius: @borderRadius;
    margin-bottom: 1em;
    background-color: #f9f9f9;

    .citation-buttons-container {
      display: flex;
      flex-flow: wrap;
      gap: 0.3em;

      .ui.button {
        padding: 0;
        background-color: transparent;
        color: #3b82f6;
        font-size: 14px;
        font-weight: normal;
        text-decoration-line: underline;
      }

      .ui.button.toggle-text {
        font-weight: bold;
        text-decoration: none;
      }
    }
  }

  .comment {
    display: flex;
    margin-bottom: @marginBottom;
    gap: 0.8em;

    i.inverted.circular.grey.icon {
      background-color: @grey !important;
    }

    i.icon,
    i.icons {
      font-size: 1em;
    }

    ul,
    ol {
      li {
        padding-bottom: 0.5em;
      }
    }

    .tool_info {
      padding-bottom: 0.2em;
      font-size: small;
    }
  }

  .chat-related-questions {
    margin-bottom: 2em;
  }

  .sources {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    margin-bottom: @marginBottom;
    gap: 0.8em;

    .source-link:hover {
      .source {
        background-color: #f1f1f1;
      }
    }

    .source {
      display: flex;
      width: 200px;
      height: 100%;
      flex-direction: column;
      padding: 0.6em 0.7em;
      border-radius: @borderRadius;
      background-color: #f9f9f9;
      gap: 0.3em;

      @media screen and (max-width: 800px) {
        width: calc(50% - 0.4em);
      }

      @media screen and (max-width: 500px) {
        width: 100%;
      }
    }

    .source-header {
      @media screen and (max-width: 500px) {
        display: block !important;

        .source-title {
          display: inline;
          width: 100%;
        }

        svg.icon {
          position: relative;
          top: 2px;
        }
      }
    }

    .source-header,
    .source-header a {
      display: flex;
      width: 100%;
      align-items: center;
      color: @grey;
    }

    .source-title {
      padding-left: 0.2em;
      margin: 0 5px;
      font-size: 13px;
      font-weight: 600;
      @media screen and (min-width: 500px) {
        overflow: hidden;
        width: 140px;
        text-align: left;
        text-overflow: ellipsis;
        white-space: nowrap;
        word-break: break-all;
      }
    }

    .chat-citation {
      &:hover {
        border: 1px solid #dbd9d9;
        background-color: #e6e7e8;
        color: @grey;
      }
    }

    .source-date span {
      padding: 0.2em 0.4em;
      border-radius: 5px;
      background-color: #e5e7eb;
      color: @grey;
      font-size: 11px;
    }

    .source-desc {
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      color: @grey;
      font-size: 12px;
      -webkit-line-clamp: 3;
      line-clamp: 3;
      text-align: left;
      word-break: break-all;
    }
  }

  .loader {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 5px;
    margin-top: 1em;
    margin-left: 64px;
    animation: dot-flashing 1s infinite linear alternate;
    animation-delay: 0.5s;
    background-color: @grey;

    &:before,
    &:after {
      position: absolute;
      top: 0;
      display: inline-block;
      content: '';
    }

    &:before {
      left: -15px;
      width: 10px;
      height: 10px;
      border-radius: 5px;
      animation: dot-flashing 1s infinite alternate;
      animation-delay: 0s;
      background-color: @grey;
    }

    &:after {
      left: 15px;
      width: 10px;
      height: 10px;
      border-radius: 5px;
      animation: dot-flashing 1s infinite alternate;
      animation-delay: 1s;
      background-color: @grey;
    }
  }
}

.circle {
  display: flex;
  width: 30px;
  height: 30px;
  flex: none;
  flex-direction: column;
  justify-content: center;
  border-radius: 50%;
  text-align: center;

  &.user {
    background-color: @teal;
  }

  &.assistant {
    background-color: @grey;
  }

  svg {
    margin: 0 auto;
  }
}

.quality-check-toggle {
  margin-top: 1em;

  .ui.toggle.checkbox {
    input:checked ~ label {
      color: @grey !important;
    }

    label {
      color: @grey;

      &:before {
        border: none !important;
      }
    }
  }
}

.quality-check-popup.ui.popup {
  padding: 0.6em 0.9em;
  font-size: 14px;
}

.ui.modal.claim-modal {
  .chat-window {
    margin-top: 1em;
    margin-bottom: 0;
  }

  .header {
    display: flex;
    padding-bottom: 0;
    border-bottom: none;
    gap: 0.5em;
  }

  .claim-text {
    margin-top: 0;
    color: @grey !important;
    font-style: italic;
    font-weight: bold;
  }

  .claim-rationale {
    font-size: 14px;
    line-height: 1.2;
  }

  .claim-source-link {
    color: inherit;

    .claim-source-title {
      &:hover {
        opacity: 0.8;
      }

      svg {
        position: relative;
        top: 2px;
        left: 5px;
      }
    }
  }

  .claim-source-title {
    margin-bottom: 1em;
  }

  .claim-source {
    padding: 0.5em 0.8em;
    border: 1px solid #e5e7eb;
    border-radius: @borderRadius;
    font-size: 16px;

    .claim-score {
      margin-bottom: 0.5em;
      font-size: 18px;
      font-weight: bold;
    }
  }

  .ui.pointing.menu {
    position: relative;
    border: none;
    border-bottom: none;
    margin: 0;
    box-shadow: none;
    overflow-x: auto;
    overflow-y: hidden;

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

    &::before {
      position: absolute;
      z-index: 0;
      right: 0;
      bottom: 0.0625rem;
      width: 100%;
      border-top: 1px solid #bcbec0;
      content: ' ';
    }

    .item {
      max-width: 200px;
      padding: 0.8em 1em !important;
      margin: 0;
      color: #6c8295;

      &.active {
        border-width: 3px;
        border-color: @grey;
        color: @grey;
      }

      span {
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        font-size: 16px;
        font-weight: bold;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        text-align: left;
        word-break: break-all;
      }
    }
  }

  @media only screen and (min-width: 1200px) {
    width: 1100px;
  }
}

.verify-claims {
  display: flex;
  gap: 0.5em;
}

.related-questions-loader {
  display: flex;
  align-items: center;
  padding: 0.5em 1.5em;
  gap: 0.5em;
}

.starter-messages-container {
  display: grid;
  width: 100%;
  grid-gap: 0.7rem;
  grid-template-columns: repeat(2, 1fr);

  @media screen and (max-width: 580px) {
    grid-template-columns: 1fr;
  }
}

.relatedQuestionButton {
  margin-bottom: 0.3em;
  cursor: pointer;
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10 and IE 11 */
  user-select: none; /* Standard syntax */

  &:hover {
    color: rgba(61, 82, 101, 0.8);
  }
}

.feedback-modal {
  .ui.form textarea {
    max-width: 100%;
  }

  .reason-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-bottom: @marginBottom;
    gap: 0.5em;
  }

  .ui.primary.button {
    background-color: @grey !important;

    &:hover {
      background-color: #334555 !important;
    }
  }

  .ui.inverted.primary.button {
    background-color: #fff !important;
    box-shadow: 0px 0px 0px 2px @grey inset !important;
    color: @grey;

    &:hover {
      background-color: @grey !important;
      box-shadow: 0px 0px 0px 2px @grey inset !important;
      color: #fff;
    }
  }
}

.message-actions {
  margin: 0.8em 0;

  .ui.basic.button {
    padding: 6px 8px;
    margin-right: 0.2em;

    &:active,
    &:focus {
      box-shadow: none;
      outline: none;
    }

    svg {
      width: 15px;
      height: 15px;
      margin: 0 !important;
      stroke: #0a0a0a;
    }

    &:hover {
      border-radius: 3px;
      background-color: #f9f9f9 !important;
      box-shadow: none;
    }
  }
}

.ui.button.starter-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.7rem;
  border: 1px solid #e5e5e5;
  border-radius: @borderRadius;
  margin: 0;
  background-color: white;
  color: inherit;
  gap: 5px;
  line-height: normal;
  text-align: left;
  transition: background-color 0.3s ease;

  &:hover,
  &:active {
    background-color: #fbfbfb;
  }

  .starter-message-desc {
    color: #6b7280;
    font-size: 14px;
    font-weight: normal;
  }
}

.chat-citation {
  display: inline-block;
  width: 1.8em;
  height: 1.8em;
  border: 1px solid #dbd9d9;
  border-radius: 3em;
  background-color: @citationCircleColor;
  color: @grey;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  line-height: 1.8em;
  text-align: center;

  &:hover {
    border: 1px solid @citationCircleHoverColor;
    background-color: @citationCircleHoverColor;
    color: #ffffff;
  }
}

#chat-citation-popup {
  .ui.popup {
    padding: 0.8em;
    font-size: 13px;
  }

  .ui.popup > .header {
    font-size: 15px;
  }
}

.chat-form .ui.form {
  margin-top: 2em;

  .textarea-wrapper {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0.6em 0.8em;
    border: 1px solid #e5e5e5;
    border-radius: @borderRadius;
    background-color: #fbfbfb;

    textarea {
      max-width: none;
      min-height: auto !important;
      max-height: none !important;
      padding: 0;
      border: none !important;
      background: none !important;
      resize: none !important;
    }
  }

  .ui.button.submit-btn {
    padding: 0;
    margin: 0 0.5em 0 0.8em;
    background: none;

    &:hover {
      background: none;
    }

    svg {
      margin-top: 0.1em;
      color: @grey;
    }
  }
}

#fact-check-toggle[disabled] ~ label {
  opacity: 1;
}

.feedback-toast {
  position: fixed;
  z-index: 9999;
  bottom: -100px;
  left: 50%;
  display: flex;
  align-items: center;
  padding: 15px 25px;
  border-radius: 3px;
  font-size: 18px;
  opacity: 0;
  transform: translateX(-50%);
  transition:
    bottom 0.35s ease-in-out,
    opacity 0.35s ease-in-out;

  &.active {
    bottom: 20px;
    opacity: 1;
  }

  &.success {
    border: 1px solid #2c662d;
    background-color: #fcfff5;
    color: #2c662d;
  }

  &.error {
    border: 1px solid #db2828;
    background-color: #ffe8e6;
    color: #db2828;
  }
}

@keyframes dot-flashing {
  0% {
    background-color: @grey;
  }

  50%,
  100% {
    background-color: rgba(61, 82, 101, 0.2);
  }
}

@keyframes spin-rotate {
  0% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(180deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 22px;
  height: 22px;
  border: 6px solid @teal;
  border-radius: 50%;
  border-top: 6px solid @blue;
  animation: spin-rotate 1s infinite linear; // spin 2s linear infinite;
  animation-delay: 0.5s;
}

.halloumi-feedback-button {
  display: flex;
  align-items: center;
  gap: 0.5em;
}
