.hz-chat-widget {
  --hz-chat-main: var(--color-main, #b99dc9);
  --hz-chat-bg: #111217;
  --hz-chat-panel: #191a22;
  --hz-chat-border: #2f303b;
  --hz-chat-text: #f5f7fb;
  --hz-chat-muted: #9ca3af;
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 260;
  font-family: inherit;
}

html[dir="rtl"] .hz-chat-widget {
  right: auto;
  left: 22px;
}

.hz-chat-widget * {
  box-sizing: border-box;
}

.hz-chat-widget__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hz-chat-widget__button,
.hz-chat-widget__wechat,
.hz-chat-widget__whatsapp {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--hz-chat-main);
  color: #17171a;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  text-decoration: none;
}

.hz-chat-widget__whatsapp {
  background: #25d366;
  color: #fff;
}

.hz-chat-widget__wechat {
  background: #18a058;
  color: #fff;
}

.hz-chat-widget.is-open .hz-chat-widget__wechat,
.hz-chat-widget.is-open .hz-chat-widget__whatsapp {
  display: none;
}

.hz-chat-widget__button:hover,
.hz-chat-widget__wechat:hover,
.hz-chat-widget__whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .42);
}

.hz-chat-widget__button-icon {
  width: 28px;
  height: 28px;
  display: block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2Zm-3 10H7v-2h10v2Zm0-4H7V6h10v2Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2Zm-3 10H7v-2h10v2Zm0-4H7V6h10v2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hz-chat-widget__wechat-icon {
  width: 30px;
  height: 30px;
  display: block;
  background: currentColor;
  -webkit-mask-image: var(--svg-wechat);
  mask-image: var(--svg-wechat);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.hz-chat-widget__whatsapp-icon {
  width: 30px;
  height: 30px;
  display: block;
  background: currentColor;
  -webkit-mask-image: var(--svg-whatsapp);
  mask-image: var(--svg-whatsapp);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.hz-chat-widget__wechat-popover {
  position: absolute;
  right: 0;
  bottom: 136px;
  width: 218px;
  padding: 14px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .32);
  display: none;
  text-align: center;
}

html[dir="rtl"] .hz-chat-widget__wechat-popover {
  right: auto;
  left: 0;
}

.hz-chat-widget.is-wechat-open .hz-chat-widget__wechat-popover {
  display: block;
}

.hz-chat-widget__wechat-popover::after {
  content: '';
  position: absolute;
  right: 21px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
}

html[dir="rtl"] .hz-chat-widget__wechat-popover::after {
  right: auto;
  left: 21px;
}

.hz-chat-widget__wechat-title {
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

.hz-chat-widget__wechat-qrcode {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
}

.hz-chat-widget__wechat-id {
  margin-top: 10px;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-all;
}

.hz-chat-widget__panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(380px, calc(100vw - 32px));
  height: 560px;
  max-height: calc(100vh - 112px);
  background: var(--hz-chat-panel);
  border: 1px solid var(--hz-chat-border);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .48);
  overflow: hidden;
  display: none;
}

html[dir="rtl"] .hz-chat-widget__panel {
  right: auto;
  left: 0;
}

.hz-chat-widget.is-open .hz-chat-widget__panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.hz-chat-widget__header {
  height: 56px;
  padding: 0 14px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #12131a;
  border-bottom: 1px solid var(--hz-chat-border);
}

.hz-chat-widget__title {
  color: var(--hz-chat-text);
  font-size: 15px;
  font-weight: 600;
}

.hz-chat-widget__close {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: var(--hz-chat-muted);
  position: relative;
}

.hz-chat-widget__close::before,
.hz-chat-widget__close::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 16px;
  height: 2px;
  background: currentColor;
}

.hz-chat-widget__close::before {
  transform: rotate(45deg);
}

.hz-chat-widget__close::after {
  transform: rotate(-45deg);
}

.hz-chat-widget__status {
  min-height: 34px;
  padding: 8px 16px;
  color: var(--hz-chat-muted);
  font-size: 12px;
  line-height: 18px;
  background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.hz-chat-widget__status.is-error {
  color: #fca5a5;
}

.hz-chat-widget__messages {
  padding: 16px;
  overflow: auto;
  background: var(--hz-chat-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(156, 163, 175, .45) rgba(255, 255, 255, .04);
}

.hz-chat-widget__messages::-webkit-scrollbar {
  width: 6px;
}

.hz-chat-widget__messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, .04);
}

.hz-chat-widget__messages::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, .42);
  border-radius: 999px;
}

.hz-chat-widget__messages::-webkit-scrollbar-thumb:hover {
  background: rgba(185, 157, 201, .72);
}

.hz-chat-widget__empty {
  color: var(--hz-chat-muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
  padding: 46px 20px;
}

.hz-chat-message {
  display: flex;
  margin-bottom: 12px;
}

.hz-chat-message.is-user,
.hz-chat-message.is-visitor {
  justify-content: flex-end;
}

.hz-chat-message.is-system {
  justify-content: center;
}

.hz-chat-message__bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #272933;
  color: var(--hz-chat-text);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.hz-chat-message.is-user .hz-chat-message__bubble,
.hz-chat-message.is-visitor .hz-chat-message__bubble {
  background: var(--hz-chat-main);
  color: #17171a;
}

.hz-chat-message.is-system .hz-chat-message__bubble {
  max-width: 92%;
  background: transparent;
  border: 1px solid var(--hz-chat-border);
  color: var(--hz-chat-muted);
}

.hz-chat-image {
  display: block;
  max-width: 220px;
}

.hz-chat-image img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 6px;
}

.hz-chat-order-card {
  min-width: 240px;
  color: var(--hz-chat-text);
}

.hz-chat-order-card__title {
  font-weight: 700;
  margin-bottom: 8px;
}

.hz-chat-order-card__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.hz-chat-order-card__label {
  color: var(--hz-chat-muted);
  flex: 0 0 auto;
}

.hz-chat-order-card__value {
  text-align: right;
  min-width: 0;
}

html[dir="rtl"] .hz-chat-order-card__value {
  text-align: left;
}

.hz-chat-widget__composer {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  padding: 12px;
  background: #12131a;
  border-top: 1px solid var(--hz-chat-border);
}

.hz-chat-widget__file {
  display: none;
}

.hz-chat-widget__input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--hz-chat-border);
  border-radius: 6px;
  background: #20212a;
  color: var(--hz-chat-text);
  font: inherit;
}

.hz-chat-widget__image {
  width: 42px;
  height: 42px;
  border: 1px solid var(--hz-chat-border);
  border-radius: 6px;
  background: #20212a;
  color: var(--hz-chat-muted);
  cursor: pointer;
  position: relative;
}

.hz-chat-widget__image::before {
  content: '';
  position: absolute;
  inset: 10px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 19V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2ZM8.5 11.5l2.5 3.01L14.5 10l4.5 6H5l3.5-4.5ZM8 8a2 2 0 1 1 4 0 2 2 0 0 1-4 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 19V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2ZM8.5 11.5l2.5 3.01L14.5 10l4.5 6H5l3.5-4.5ZM8 8a2 2 0 1 1 4 0 2 2 0 0 1-4 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hz-chat-widget__send {
  min-width: 72px;
  height: 42px;
  border-radius: 6px;
  border: 0;
  background: var(--hz-chat-main);
  color: #17171a;
  font-weight: 700;
  cursor: pointer;
}

.hz-chat-widget__send:disabled,
.hz-chat-widget__input:disabled,
.hz-chat-widget__image:disabled {
  cursor: not-allowed;
  opacity: .55;
}

@media (max-width: 1024px) {
  .hz-chat-widget {
    right: 16px;
    bottom: 88px;
  }

  html[dir="rtl"] .hz-chat-widget {
    right: auto;
    left: 16px;
  }

  .hz-chat-widget__panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 88px;
    width: auto;
    height: calc(100dvh - 112px);
    max-height: none;
  }
}

@media (max-width: 480px) {
  .hz-chat-widget {
    right: 12px;
  }

  html[dir="rtl"] .hz-chat-widget {
    right: auto;
    left: 12px;
  }

  .hz-chat-widget__button,
  .hz-chat-widget__wechat,
  .hz-chat-widget__whatsapp {
    width: 54px;
    height: 54px;
  }

  .hz-chat-widget__wechat-popover {
    bottom: 128px;
    width: min(218px, calc(100vw - 24px));
  }

  .hz-chat-widget__messages {
    padding: 12px;
  }

  .hz-chat-message__bubble {
    max-width: 86%;
  }

  .hz-chat-widget__composer {
    grid-template-columns: 42px minmax(0, 1fr) auto;
  }

  .hz-chat-image {
    max-width: min(220px, 68vw);
  }
}
