.kreechat-widget {
  --background-color: linear-gradient(
    45deg,
    hsla(235, 100%, 78%, 1) 0%,
    hsla(222, 77%, 33%, 1) 76%
  );
  --text-color: #fff;
  --header-text-color: #fff;
  --button-text-color: #fff;
  --border-color: rgba(35, 121, 147, 0.6);
  --def-box-shadow: rgba(0, 0, 0, 0.23) 0px 3px 6px;
  --hover-scale: 1.2;
  --active-scale: 0.95;

  position: fixed;
  bottom: 1.5%;
  right: 1.5%;
  width: clamp(280px, 90%, 370px);
  height: 560px;
  border-radius: 12px;
  z-index: 9999;
  box-shadow: var(--def-box-shadow);
  background: var(--background-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: sans-serif;
  font-size: clamp(0.8rem, 1vw, 1rem);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.kreechat-widget *,
.kreechat-widget *::before,
.kreechat-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Light & dark themes */
.kreechat-widget-light {
  --background-color: #fff;
  --text-color: #000;
  --header-bg-color: #fff;
  --header-text-color: #000;
  --border-color: #aba4a4;
  --input-font-color: black;
}

.kreechat-widget-dark {
  --background-color: linear-gradient(
    45deg,
    hsla(211, 100%, 28%, 1) 0%,
    hsla(236, 100%, 8%, 1) 70%
  );
  --text-color: #fff;
  --header-bg-color: transparent;
  --header-text-color: #fff;
  --border-color: rgba(35, 121, 147, 0.6);
  --input-font-color: white;
}

.kreechat-widget.kreechat-widget--minimized {
  width: clamp(70px, 12vw, 60px);
  height: clamp(70px, 12vw, 60px);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
}

.kreechat-widget.kreechat-widget--minimized .widget-circle-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
}

.kreechat-widget.kreechat-widget--minimized > :not(.widget-circle-indicator) {
  display: none;
}

.kreechat-widget:not(.kreechat-widget--minimized) .minimized-message {
  display: none;
}

.kreechat-widget.kreechat-widget--minimized .minimized-message {
  display: block;
  font-weight: bold;
  text-align: center;
}

.kreechat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg-color, #111d61);
  color: var(--header-text-color);
  padding: 0.5em 0.8em;
  font-weight: bold;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.kreechat-welcome-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5em;
  overflow-y: auto;
}

.kreechat-welcome-body.hidden {
  display: none;
}

.widget_welcome_message,
.widget_welcome_message_client {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5em;
  width: 100%;
  padding: 15px;
  gap: 10px;
}

.image-input {
  display: none;
}

.button-attach {
  width: 1.5em;
  height: 1.5em;
  cursor: pointer;
  transition: transform 0.2s;
}

.button-attach:hover {
  transform: scale(var(--hover-scale));
}
.button-attach:active {
  transform: scale(var(--active-scale));
}

.widget_welcome_message h3,
.widget_welcome_message_client h3 {
  font-weight: bold;
  font-size: 1.1rem;
}
.widget_welcome_message p,
.widget_welcome_message_client p {
  font-size: 0.85rem;
  line-height: 1.3;
}

.email-input-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  width: 100%;
  color: white;
  background-color: transparent;
  margin-top: 2em;
}

.email-input-field.hidden {
  display: none;
}

.client_submit_email_form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 1em;
}

.input_wrapper {
  width: 100%;
  position: relative;
}

.input_wrapper input {
  width: 100%;
  height: 2.5em;
  border-radius: 6px;
  border: 1px solid #36586f;
  padding: 0 0.5em;
  font-size: 0.85rem;
  outline: none;
  color: var(--input-font-color);
  background-color: transparent;
}

.input_wrapper label {
  position: absolute;
  left: 0.5em;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  padding: 0 0.2em;
  transition: all 0.2s ease;
  pointer-events: none;
  font-size: 0.85rem;
}
.input_wrapper input:focus + label,
.input_wrapper input:valid + label {
  top: -0.6em;
  font-size: 0.75rem;
  color: #5cf6fc;
}

.loading-chat-message.hidden {
  display: none;
}

.widget_service_name {
  color: var(--header-color);
}

.customers_create_ticket_button,
.admin_create_ticket_button,
.submit_client_email_button {
  background-color: #3a6fd8;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5em 1em;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.3s,
    transform 0.2s;
  min-width: 60%;
}

.customers_create_ticket_button:hover,
.admin_create_ticket_button:hover,
.submit_client_email_button:hover {
  background-color: #1a91da;
}

.customers_create_ticket_button:active,
.admin_create_ticket_button:active,
.submit_client_email_button:active {
  transform: scale(var(--active-scale));
}

.customers_create_ticket_button.hidden {
  display: none;
}

.kreechat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
}
.kreechat-body.hidden {
  display: none;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.5em;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}
.messages-container::-webkit-scrollbar {
  width: 6px;
}
.messages-container::-webkit-scrollbar-track {
  background-color: #111d61;
}
.messages-container::-webkit-scrollbar-thumb {
  background-color: rgba(145, 138, 217, 0.3);
  border-radius: 3px;
}

.client-message,
.agent-message {
  padding: 0.4em 0.6em;
  border-radius: 6px;
  max-width: 90%;
  word-break: break-word;
  font-size: 0.85rem;
}

.client-message {
  align-self: flex-end;
  background: rgb(41, 174, 240);
  color: #fff;
}

.agent-message {
  align-self: flex-start;
  background: #e5e5ea;
  color: #000;
}

.closing-message {
  align-self: center;
  justify-content: center;
  text-align: center;
  background-color: none;
}

.msg-timestamp {
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 2px;
  align-self: flex-end;
}

.msg-timestamp-closed {
  font-size: 0.7rem;
  color: black;
  margin-top: 2px;
}

.video-message {
  max-width: 100%;
  border-radius: 8px;
  outline: none;
  background: #000;
  display: block;
}
.client-message .video-message {
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.agent-message .video-message {
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.video-message::-webkit-media-controls {
  background: rgba(0, 0, 0, 0.2);
}

.textarea-container {
  display: flex;
  gap: 0.3em;
  padding: 0.3em;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.textarea {
  flex: 1;
  resize: none;
  padding: 0.3em 0.5em;
  font-size: 0.85rem;
  background: transparent;
  color: var(--text-color);
  border: none;
  outline: none;
  min-width: 0;
  max-height: 5em;
}

.textarea:focus {
  background-color: var(--bg-color, transparent);
  color: var(--text-color);
}

.send-button {
  width: 1.5em;
  height: 1.5em;
  cursor: pointer;
  transition: transform 0.2s;
}

.send-button:hover {
  transform: scale(var(--hover-scale));
}
.send-button:active {
  transform: scale(var(--active-scale));
}

.emoji-button-container {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: max-height 0.3s ease;
  max-height: 48px;
}

.emoji-button-container.open {
  max-height: 35vh;
}

.emoji-button {
  user-select: none;
  cursor: pointer;
  font-size: 1.8rem;
  transition: transform 0.2s ease-in-out;
}

.emoji-button:hover {
  transform: scale(var(--hover-scale));
}

.emoji-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 0.3em;
  padding: 0.3em;
  overflow-y: auto;
  max-height: 120px;
}

.emoji-item {
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s;
}
.emoji-item:hover {
  transform: scale(var(--hover-scale));
}

.emoji-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  height: 50px;
}

.logo-container {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  padding: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  text-decoration: none;
  align-self: flex-end;
}

.logo-container-outside {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  padding: 3px;
  font-size: 0.7rem;
  cursor: pointer;
  text-decoration: none;
  align-self: flex-end;
}

#minimize-button {
  background: none;
  cursor: pointer;
  border: none;
}

#minimize-button:active {
  transform: scale(var(--active-scale));
}

.logo-image {
  width: 20px;
  height: 20px;
}

.logo {
  text-decoration: none;
  user-select: none;
}

.image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

.doc-info-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-arrow {
  width: 20px;
  height: 20px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.download-arrow:hover {
  transform: scale(1.2);
}

.closing_message {
  border: 1px solid red;
}

@media (max-width: 480px) {
  .kreechat-widget:not(.kreechat-widget--minimized) {
    width: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    max-height: none !important;
    height: 100%;
  }

  .kreechat-header {
    font-size: 1rem;
    padding: 0.7em 1em;
  }

  .textarea,
  .client-message,
  .agent-message {
    font-size: 0.8rem;
  }

  .emoji-list {
    grid-template-columns: repeat(5, 1fr);
  }
}
