#chat-button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  position: absolute;
  bottom: 20px;
  right: 20px;
  background-color: #f1980f;
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 24px;
  text-align: center;
  line-height: 60px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2 ease;
}

#chat-speechbubble {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  
  user-select: none;

  position: absolute;
  bottom: 80px;
  right: 80px;
  background: #ffffff;

  min-width: 60px;
  max-width: 300px;
  padding: 15px;

  text-align: justify;

  border: #bebebe solid;
  border-radius: 25px 25px 0px 25px;
}

.fadeout {
  animation: fadeOut 1s ease forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#chat-button:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#chat-window {
  position: absolute;
  bottom: 90px;
  right: 20px;
  width: 400px;
  max-height: 80%;
  max-width: 80%;
  min-height: 32.5%;
  min-width: 350px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  box-sizing: border-box;

  /*resize: both;*/
}

.smooth-transition {
  transition: all 0.3s ease;  
}

.hidden {
  display: none !important;
}

.chat-header {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  background: #f1980f;
  color: black;
  padding: 10px;
  letter-spacing: 1px;
  font-style: italic;
  font-weight: bold;

  min-height: 28px;

  display: flex;
  flex-direction: row;

  justify-content: space-between;
}

/* Body */
.chat-body {
  flex: 1 1 auto;
  padding: 8px;
  overflow-y: auto;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
  /*flex-shrink: 0;*/
  flex-grow: 1;
  gap: 4px;

  /*max-height: 620px;*/  
  min-height: 0;
}

.message {
  /*margin-bottom: 10px;*/
  display: inline-block;
  position: relative;
  /*padding: 8px 12px;*/
  padding: 8px 20px 20px 12px;
  border-radius: 10px;
  max-width: 80%; /* 80 */
  min-height: max-content;
  text-align: justify;
  /*white-space: pre-wrap*/;
  word-wrap: break-word;
  overflow: visible;
  word-break: break-word;
  line-height: 1.4;
}

.bot {
  background: #e0e0e0;
  align-self: flex-start;
  border-top-left-radius: 0;
  margin-right: auto;

  padding-bottom: 5px;
}

.message ul, ol {
  margin: 0;
  padding-left: 1.2em;
  line-height: 0.3;
}

.message li {
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

.message p {
  margin: 0;
  margin-top: 10px;
  padding: 0;
}



.user {
  background: #d1f0d1;
  justify-self: right;
  align-self: flex-end;
  border-top-right-radius: 0;
  margin-left: auto;

  display: flex;
  flex-direction: row;

}

.chat-footer {
  display: flex;
  padding: 10px;
  border-top: 1px solid #ddd;
  background: white;
  max-height: 58px;
  min-height: 36px;
}

#chat-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 20px;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;  
}

#chat-name {
  margin: 0;
  align-content: center;
}

#send-button {
  background: #f1980f;
  color: white;
  border: none;
  padding: 8px 12px;
  margin-left: 5px;
  border-radius: 20px;
  cursor: pointer;
}

#send-button:hover {
  transform: scale(1.08);
}

#send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: scale(0.9);
}

#send-button.enabled-anim {
  animation: enableAnim 0.35s ease;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #555;
  border-radius: 50%;
  display: inline-block;
  animation: typing 1.2s infinite;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

.msg-time {
  bottom: 4px;
  right: 8px;
  font-size: 0.68em;
  color: #666;
  opacity: 0.75;
  white-space: nowrap;
  line-height: 1;
}

.msg-text {
  padding: 0;
}

.user .msg-time {
  position: absolute;
  right: 8px;
  user-select: none;
}

.bot .msg-time {
  left: 8px;
  user-select: none;

  margin-top: 10px;
  margin-bottom: 0;
}

.cnotice {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  user-select: none;

  color: #666;
  align-self: center;
  /*font-style: italic;*/
  font-style: oblique;
  margin: 0px 20px 10px 20px;
  font-size: small;
  min-height: fit-content;
}

.rest-chat {
  border: none;
  background-color: transparent;
  font-size: large;
  height: 1.5em;
  width: 1.5em;
  border-radius: 50px;
}

.rest-chat:hover {
  background: #88530428 
}

#chat-select {
  padding-right: 5px;
  width: 70%;
  height: 1.5rem;
  border: #88530428 2px solid;
  border-radius: 4px;  
  align-self: center;
  text-align: center;
  background: #f1980f;
}


.msg-footer {
  bottom: 4px;
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-content: center;
}

.msg-footer button {
  font-size: 0.68em;
  width: auto;
  height: auto;
  padding: 2px 5px 2px 5px;

  border: none;
  border-radius: 25px;

  background: #7e7e7e11;
}

.msg-footer button:hover {
  background: #00000011;
}

.msg-footer button.selected {
  background: #00000050;
}

#chat-speechbubble p {
  margin: 0;
}


@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes enableAnim {
  0% {
    opacity: 0.5;
    transform: translateY(4px) scale(0.95);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes botWiggle {
  0% {
    transform: rotate(0deg);
  }
  15% {
    transform: rotate(-10deg);
  }
  30% {
    transform: rotate(10deg);
  }
  45% {
    transform: rotate(-6deg) translateY(2px);
  }
  60% {
    transform: rotate(6deg);
  }
  75% {
    transform: rotate(-3deg);
  }
  100% {
    transform: rotate(0deg) translateY(0);
  }
}

#chat-button.wiggle-once {
  animation: botWiggle 600ms ease;
}

@media (prefers-reduced-motion: reduce) {
  #chat-button.wiggle-once {
    animation: none;
  }
}
