.dgcrm-site-chat {
  --dgcrm-chat-side-offset: 12px;
  --dgcrm-chat-bottom-offset: calc(var(--dgcrm-chat-side-offset) + env(safe-area-inset-bottom, 0px));
  --dgcrm-chat-shadow-soft: 0 14px 28px rgba(9, 14, 20, 0.2);
  --dgcrm-chat-shadow-window: 0 22px 44px rgba(0, 0, 0, 0.2);
  position: fixed;
  right: var(--dgcrm-chat-side-offset);
  bottom: var(--dgcrm-chat-bottom-offset);
  z-index: 10010;
  font-family: Inter, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.dgcrm-site-chat[hidden] {
  display: none !important;
}

.dgcrm-site-chat-toggle {
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #81d100 0%, #64b700 40%, #0f678b 100%);
  color: #fff;
  box-shadow: var(--dgcrm-chat-shadow-soft);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.18s ease;
}

.dgcrm-site-chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(9, 14, 20, 0.24);
}

.dgcrm-site-chat-toggle:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(129, 209, 0, 0.22),
    0 18px 34px rgba(9, 14, 20, 0.24);
}

.dgcrm-site-chat-toggle__eyebrow {
  display: none;
}

.dgcrm-site-chat-toggle__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0;
  border-radius: inherit;
}

.dgcrm-site-chat-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.dgcrm-site-chat-toggle__icon svg {
  display: block;
  width: 22px;
  height: 22px;
}

.dgcrm-site-chat-toggle__text {
  display: none;
  white-space: nowrap;
  color: #fff;
}

.dgcrm-site-chat-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(11, 16, 24, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    visibility 0s linear 0.18s;
}

.dgcrm-site-chat-window {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: min(82vh, 760px);
  height: min(82dvh, 760px);
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - 8px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 8px);
  background: #fff;
  border: 1px solid #e6ebf2;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--dgcrm-chat-shadow-window);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(18px);
  transition:
    opacity 0.22s ease,
    transform 0.24s ease,
    visibility 0s linear 0.24s;
}

.dgcrm-site-chat.is-open .dgcrm-site-chat-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.dgcrm-site-chat.is-open .dgcrm-site-chat-window {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity 0.22s ease,
    transform 0.24s ease,
    visibility 0s linear 0s;
}

.dgcrm-site-chat.is-open .dgcrm-site-chat-toggle {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
}

.dgcrm-site-chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #101418, #24303c);
  color: #fff;
}

.dgcrm-site-chat-title {
  font-size: 17px;
  font-weight: 700;
}

.dgcrm-site-chat-sub {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.78);
}

.dgcrm-site-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.dgcrm-site-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: #f5f8fb;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.dgcrm-site-chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.dgcrm-site-chat-message.is-visitor {
  align-self: flex-end;
  background: #101418;
  color: #fff;
  border-top-right-radius: 4px;
}

.dgcrm-site-chat-message.is-manager {
  align-self: flex-start;
  background: #fff;
  color: #111;
  border: 1px solid #e6ebf2;
  border-top-left-radius: 4px;
}

.dgcrm-site-chat-message.is-system {
  align-self: center;
  max-width: 94%;
  background: #e8eef5;
  color: #324050;
  border: 1px solid #d2dbe6;
  box-shadow: none;
}

.dgcrm-site-chat-message.is-gift {
  padding: 10px;
}

.dgcrm-site-chat-gift {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.dgcrm-site-chat-gift img {
  display: block;
  width: 100%;
  max-width: 190px;
  height: auto;
  border-radius: 12px;
}

.dgcrm-site-chat-gift__title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f2532;
}

.dgcrm-site-chat-gift__text {
  font-size: 12px;
  line-height: 1.4;
  color: #5f6773;
}

.dgcrm-site-chat-message.is-typing {
  opacity: 0.8;
  font-style: italic;
}

.dgcrm-site-chat-typing__body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dgcrm-site-chat-typing__dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 22px;
}

.dgcrm-site-chat-typing__dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: dgcrm-chat-typing-bounce 1.2s infinite ease-in-out;
}

.dgcrm-site-chat-typing__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.dgcrm-site-chat-typing__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.dgcrm-site-chat-message__meta {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.72;
}

.dgcrm-site-chat-identify {
  padding: 0 12px 10px;
  background: #fff;
}

.dgcrm-site-chat-identify details {
  border: 1px solid #e6ebf2;
  border-radius: 14px;
  padding: 10px 12px;
}

.dgcrm-site-chat-identify summary {
  cursor: pointer;
  font-weight: 600;
  color: #3c4655;
}

.dgcrm-site-chat-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.dgcrm-site-chat-note {
  font-size: 13px;
  line-height: 1.35;
  color: #5f6773;
}

.dgcrm-site-chat-contact-tabs {
  display: grid;
  gap: 8px;
}

.dgcrm-site-chat-contact-tabs__row {
  display: grid;
  gap: 8px;
}

.dgcrm-site-chat-contact-tabs__row:first-child {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dgcrm-site-chat-contact-tabs__row:last-child {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dgcrm-site-chat-contact-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #d7dfeb;
  border-radius: 999px;
  background: #fff;
  color: #39414d;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.dgcrm-site-chat-contact-tab span {
  white-space: nowrap;
}

.dgcrm-site-chat-contact-tab img {
  width: 20px;
  height: 20px;
  display: block;
}

.dgcrm-site-chat-contact-tab .fa {
  font-size: 18px;
}

.dgcrm-site-chat-contact-tab--icon-only {
  padding: 8px;
}

.dgcrm-site-chat-contact-tab.is-active {
  background: linear-gradient(135deg, #81d100, #5ca800);
  border-color: #6eb200;
  color: #fff;
  box-shadow: 0 10px 24px rgba(92, 168, 0, 0.2);
}

.dgcrm-site-chat-contact-tab.is-active img {
  filter: brightness(0) invert(1);
}

.dgcrm-site-chat-input,
.dgcrm-site-chat-textarea {
  width: 100%;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  box-sizing: border-box;
}

.dgcrm-site-chat-textarea {
  min-height: 80px;
  resize: vertical;
}

.dgcrm-site-chat-save {
  border: none;
  border-radius: 12px;
  background: #81d100;
  color: #fff;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(92, 168, 0, 0.18);
}

.dgcrm-site-chat-save[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.dgcrm-site-chat-compose {
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff;
}

.dgcrm-site-chat-policy {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #e5ebf3;
  border-radius: 12px;
  background: #fafcff;
}

.dgcrm-site-chat-policy__note {
  font-size: 10px;
  line-height: 1.45;
  color: #8893a3;
}

.dgcrm-site-chat-policy__note a {
  color: #6f94d6;
  text-decoration: none;
}

.dgcrm-site-chat-policy__note a:hover {
  text-decoration: underline;
}

.dgcrm-site-chat-policy__check {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.45;
  color: #8893a3;
  cursor: pointer;
}

.dgcrm-site-chat-policy__check input {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  margin: 0;
}

.dgcrm-site-chat-policy__check span {
  display: inline;
}

.dgcrm-site-chat-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.dgcrm-site-chat-status {
  font-size: 12px;
  line-height: 1.3;
  color: #5c6675;
}

.dgcrm-site-chat-send {
  border: none;
  border-radius: 12px;
  background: #24303c;
  color: #fff;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.dgcrm-site-chat-send[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

@keyframes dgcrm-chat-typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }

  40% {
    transform: translateY(-3px);
    opacity: 0.85;
  }
}

/* Tablet: compact pill trigger, regular floating chat window. */
@media (min-width: 768px) {
  .dgcrm-site-chat {
    --dgcrm-chat-side-offset: 14px;
    --dgcrm-chat-shadow-soft: 0 16px 30px rgba(9, 14, 20, 0.22);
  }

  .dgcrm-site-chat-toggle {
    width: auto;
    height: auto;
    padding: 10px;
    border-radius: 20px;
    background: linear-gradient(155deg, rgba(14, 19, 26, 0.96) 0%, rgba(33, 47, 62, 0.96) 100%);
    box-shadow:
      0 18px 36px rgba(9, 14, 20, 0.24),
      0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  }

  .dgcrm-site-chat-toggle__cta {
    justify-content: flex-start;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #81d100 0%, #64b700 38%, #0f678b 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 10px 22px rgba(50, 115, 17, 0.24);
  }

  .dgcrm-site-chat-toggle__icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .dgcrm-site-chat-toggle__icon svg {
    width: 20px;
    height: 20px;
  }

  .dgcrm-site-chat-toggle__text--short {
    display: inline;
    font-size: 16px;
    line-height: 1.1;
    font-weight: 600;
  }

  .dgcrm-site-chat-backdrop {
    display: none;
  }

  .dgcrm-site-chat-window {
    position: absolute;
    left: auto;
    right: 0;
    bottom: 0;
    width: min(392px, calc(100vw - 28px));
    height: auto;
    max-height: min(78vh, 720px);
    max-height: min(78dvh, 720px);
    border-radius: 20px;
    transform: translateY(14px) scale(0.97);
    transform-origin: right bottom;
  }

  .dgcrm-site-chat-messages {
    max-height: 320px;
  }

  .dgcrm-site-chat-compose {
    padding-bottom: 14px;
  }
}

/* Desktop: keep the richer expanded trigger that already exists on the site. */
@media (min-width: 1024px) {
  .dgcrm-site-chat {
    --dgcrm-chat-side-offset: 18px;
  }

  .dgcrm-site-chat-toggle {
    align-items: center;
    gap: 8px;
    width: min(250px, calc(100vw - 24px));
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
  }

  .dgcrm-site-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow:
      0 24px 54px rgba(9, 14, 20, 0.38),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  }

  .dgcrm-site-chat-toggle:focus-visible {
    transform: translateY(-2px);
    box-shadow:
      0 0 0 3px rgba(129, 209, 0, 0.24),
      0 24px 54px rgba(9, 14, 20, 0.38);
  }

  .dgcrm-site-chat-toggle__eyebrow {
    display: flex;
    align-items: center;
    font-size: 13px;
    line-height: 1.2;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.82);
  }

  .dgcrm-site-chat-toggle__cta {
    min-height: 56px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .dgcrm-site-chat-toggle__icon {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }

  .dgcrm-site-chat-toggle__icon svg {
    width: 22px;
    height: 22px;
  }

  .dgcrm-site-chat-toggle__text--short {
    display: none;
  }

  .dgcrm-site-chat-toggle__text--full {
    display: inline;
    font-size: 17px;
    line-height: 1.1;
    font-weight: 500;
    letter-spacing: 0.01em;
  }

  .dgcrm-site-chat-window {
    width: min(392px, calc(100vw - 24px));
  }
}

@media (max-width: 360px) {
  .dgcrm-site-chat {
    --dgcrm-chat-side-offset: 10px;
  }

  .dgcrm-site-chat-toggle {
    width: 50px;
    height: 50px;
  }

  .dgcrm-site-chat-window {
    left: 6px;
    right: 6px;
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - 6px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 6px);
  }

  .dgcrm-site-chat-head,
  .dgcrm-site-chat-identify,
  .dgcrm-site-chat-compose,
  .dgcrm-site-chat-messages {
    padding-left: 10px;
    padding-right: 10px;
  }
}
