.chat-popup {
  box-sizing: border-box;
  max-width: 400px;
  width: calc(100vw - 1rem);
  position: fixed;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 1em;
  background-color: white;
  box-shadow: 0 0 30px -10px rgba(0, 0, 0, 0.2);
  border: 1px solid rgb(234, 234, 234);
  border-radius: 1rem;
  z-index: 9999;

  color: #43454b;
  font-family: "Source Sans Pro", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  line-height: 1.618;
  text-rendering: optimizeLegibility;
  font-weight: 400;
}

@media (max-width: 600px) {
  .chat-popup {
    font-size: 0.95em;
    padding: 0.7em;
  }

  .chat-popup:has(.chat-popup-body.hidden) {

    /* border-radius: 10rem; */
    width: min-content;
  }

  .chat-popup:has(.chat-popup-body.hidden) .chat-popup-header-title {
    width: max-content;
    background-color: white;
    padding: 0.1em 0.5em;
    font-size: 0.9em;
    border-bottom-left-radius: 1em;
    border-top-left-radius: 1em;
  }
}

.chat-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-popup:has(.chat-popup-body.hidden) .chat-popup-header {
  /* margin-left: 0.6rem; */
}

.chat-popup-header:hover {
  cursor: pointer;
}

.chat-popup-header-title {
  font-size: 1.2em;
}

.chat-popup-body {
  padding-top: 1em;
  margin-top: 1em;
  border-top: 1px solid rgb(234, 234, 234);
}

.chat-popup-body.hidden {
  display: none;
}

.chat-message-area {
  max-height: 40vh;
  overflow-y: auto;
}

.chat-message {
  position: relative;
  padding: 1em;
  margin-bottom: 1em;
  margin-top: 2em;
  border-radius: 1rem;
  background-color: #f1f1f1;
  overflow: visible;
}

.chat-message.model {
  margin-right: 3em;
  text-align: left;
  /* background-color: #37338d;
  color: white; */
}

.chat-message.user {
  margin-left: 3em;
  margin-right: 0.5em;
  text-align: right;
  /* background-color: #397f39;
  color: white; */
}

.chat-message.model::before,
.chat-message.user::before {
  position: absolute;
  top: -1.3rem;
  font-size: small;
}

.chat-message.model::before {
  content: 'Asiakaspalvelu';
  left: 1rem;
  /* color: #37338d; */
}

.chat-message.user::before {
  content: 'Sinä';
  right: 1rem;
  /* color: #397f39; */
}

form#chat-message-form {
  margin: 0;
}

.chat-message-input {
  margin-bottom: 1em;
  border-radius: 0.5em;
  resize: none;
  width: 100%;
  padding: .6180469716em;
  background-color: #f2f2f2;
  color: #43454b;
  border: 0;
  -webkit-appearance: none;
  box-sizing: border-box;
  font-size: 1em;
  line-height: 1.5;
  font-weight: 400;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .125);
  font-family: "Source Sans Pro", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}

.chat-message-input:focus {
  outline: 1px solid #545454 !important;
}

.chat-message-submit,
.chat-popup-close {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: auto;
  padding: 0.5em;
  border: none;
  border-radius: 10em;
  cursor: pointer;
}

.chat-popup-close {
  background-color: #fff;
  color: white;
  transition-duration: 0s !important;
}

.chat-popup:has(.chat-popup-body.hidden) .chat-popup-close,
.chat-message-submit {
  background-color: #d091cf;
  color: white;
}

.chat-popup:has(.chat-popup-body.hidden) .chat-popup-header:hover .chat-popup-close,
.chat-message-submit:hover {
  background-color: #b06abf;
}

.chat-popup-close:hover,
.chat-popup-header:hover .chat-popup-close {
  background-color: #f1f1f1;
}

.chat-popup svg.open-popup {
  display: none;
}

.chat-popup svg.close-popup {
  display: block;
}

.chat-popup:has(.chat-popup-body.hidden) svg.open-popup {
  display: block;
}

.chat-popup:has(.chat-popup-body.hidden) svg.close-popup {
  display: none;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-footer-text {
  display: flex;
  flex-direction: column;
}

.form-footer .credits {
  font-size: 0.8em;
  color: #b0b0b0;
}

.form-footer .terms a {
  text-decoration: none;
}

/* Loader */

.lds-ellipsis,
.lds-ellipsis div {
  box-sizing: border-box;
}

.lds-ellipsis {
  display: block;
  position: relative;
  width: 40px;
  height: 40px;
  margin-left: auto;
  margin-right: auto;
  visibility: hidden;
}

.lds-ellipsis div {
  position: absolute;
  top: 13.33333px;
  width: 5.33333px;
  height: 5.33333px;
  border-radius: 50%;
  background: #d091cf;
  animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.lds-ellipsis div:nth-child(1) {
  left: 4px;
  animation: lds-ellipsis1 0.6s infinite;
}

.lds-ellipsis div:nth-child(2) {
  left: 4px;
  animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(3) {
  left: 16px;
  animation: lds-ellipsis2 0.6s infinite;
}

.lds-ellipsis div:nth-child(4) {
  left: 28px;
  animation: lds-ellipsis3 0.6s infinite;
}

@keyframes lds-ellipsis1 {
  0% {
    transform: scale(0);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes lds-ellipsis3 {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(0);
  }
}

@keyframes lds-ellipsis2 {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(12px, 0);
  }
}

/* Scrollbar */

.chat-popup ::-webkit-scrollbar {
  width: 8px;
}

/* Track */
.chat-popup ::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* Handle */
.chat-popup ::-webkit-scrollbar-thumb {
  background: #9d9d9d;
  border-radius: 5px;
}

/* Handle on hover */
.chat-popup ::-webkit-scrollbar-thumb:hover {
  background: #686868;
}