.ladica-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ladica-widget.has-preview::before {
  content: var(--ladica-preview-text);
  position: absolute;
  right: 86px;
  bottom: 12px;
  width: 230px;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
}

.ladica-widget.has-preview::after {
  content: "";
  position: absolute;
  right: 78px;
  bottom: 35px;
  border-width: 8px 0 8px 8px;
  border-style: solid;
  border-color: transparent transparent transparent #fff;
}

.ladica-widget__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  height: 72px !important;
  min-height: 72px !important;
  max-height: 72px !important;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 50% !important;
  background: #25d366;
  color: #fff;
  box-shadow: 0 14px 34px rgba(37, 211, 102, 0.34);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  appearance: none;
  -webkit-appearance: none;
  overflow: visible;
}

.ladica-widget__toggle:hover,
.ladica-widget__toggle:focus-visible {
  background: #1ebe5d;
  box-shadow: 0 16px 38px rgba(37, 211, 102, 0.44);
  transform: translateY(-2px);
}

.ladica-widget__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 30px;
  border-radius: 18px;
  background: #fff;
}

.ladica-widget__icon::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.ladica-widget__icon span {
  position: relative;
  z-index: 1;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #25d366;
  animation: ladicaDot 1.1s infinite ease-in-out;
}

.ladica-widget__icon span:nth-child(2) {
  animation-delay: 0.16s;
}

.ladica-widget__icon span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes ladicaDot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.ladica-chat {
  position: absolute;
  right: 0;
  bottom: 86px;
  display: none;
  width: min(360px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid #d8e2ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
}

.ladica-widget.is-open .ladica-chat {
  display: block;
}

.ladica-chat__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #16877f;
  color: #fff;
}

.ladica-chat__avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

.ladica-chat__header div {
  min-width: 0;
  flex: 1;
}

.ladica-chat__header strong,
.ladica-chat__header span {
  display: block;
}

.ladica-chat__header span {
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.86;
}

.ladica-chat__close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.ladica-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 260px;
  padding: 16px;
  overflow-y: auto;
  background: #f4f7fb;
}

.ladica-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 86%;
}

.ladica-message--visitor {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ladica-message--admin,
.ladica-message--ai,
.ladica-message--system {
  align-self: flex-start;
  align-items: flex-start;
}

.ladica-message--intro {
  max-width: 94%;
  margin-bottom: 4px;
}

.ladica-message--intro .ladica-message__bubble {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.ladica-message__avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.ladica-message__content {
  display: flex;
  flex-direction: column;
}

.ladica-message__bubble {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  line-height: 1.4;
  word-break: break-word;
}

.ladica-message--visitor .ladica-message__bubble {
  background: #1777f2;
  color: #fff;
}

.ladica-message span {
  margin-top: 4px;
  color: #6b7280;
  font-size: 11px;
}

.ladica-chat__form {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #fff;
}

.ladica-contact-card {
  display: grid;
  gap: 10px;
  margin: -8px 8px 8px;
  padding: 18px;
  border: 1px solid #18c540;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.ladica-contact-card[hidden] {
  display: none;
}

.ladica-contact-card p {
  margin: 0 0 4px;
  color: #64748b;
  text-align: center;
  font-size: 16px;
}

.ladica-chat input,
.ladica-chat textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px;
  font: inherit;
}

.ladica-contact-card input {
  border-width: 0 0 1px;
  border-radius: 0;
  padding: 10px 2px;
}

.ladica-chat textarea {
  resize: vertical;
}

.ladica-consent {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #64748b;
  font-size: 13px;
  line-height: 1.3;
}

.ladica-consent input {
  width: 20px;
  height: 20px;
  margin: 0;
}

.ladica-consent a {
  color: #15803d;
}

.ladica-contact-card__submit {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: #18c540;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.ladica-message-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
}

.ladica-message-box textarea {
  min-height: 44px;
  max-height: 92px;
}

.ladica-message-box button {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 50%;
  background: #18c540;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 480px) {
  .ladica-widget {
    right: 16px;
    bottom: 16px;
  }

  .ladica-chat {
    position: fixed;
    right: 16px;
    bottom: 78px;
  }

  .ladica-widget.has-preview::before {
    right: 0;
    bottom: 86px;
    width: min(280px, calc(100vw - 32px));
  }

  .ladica-widget.has-preview::after {
    right: 28px;
    bottom: 75px;
    border-width: 8px 8px 0 8px;
    border-color: #fff transparent transparent transparent;
  }
}
