.bags-chat-fab {
  position: fixed;
  left: calc(100vw - 80px);
  top: calc(100vh - 80px);
  z-index: 99990;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2c1810, #4a2f1f);
  color: #f5e6c8;
  font-size: 1.45rem;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  box-shadow: 0 6px 28px rgba(44, 24, 16, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.bags-chat-fab:hover:not(.dragging) {
  transform: scale(1.06);
  box-shadow: 0 8px 32px rgba(201, 169, 98, 0.35);
}
.bags-chat-fab.dragging {
  cursor: grabbing;
  touch-action: none;
  transform: none;
  transition: none;
}

body.bags-chat-fab-dragging {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

.bags-chat-fab-hint {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(44, 24, 16, 0.92);
  color: #f5e6c8;
  font-size: 0.72rem;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
  box-shadow: 0 4px 14px rgba(44, 24, 16, 0.25);
}
.bags-chat-fab-hint.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.bags-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 22px;
  z-index: 99991;
  width: min(390px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 120px));
  background: #fff;
  border: 1px solid #e8dfd0;
  border-radius: 18px;
  box-shadow: 0 18px 52px rgba(44, 24, 16, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  direction: ltr;
}
.bags-chat-panel.open {
  display: flex;
}

.bags-chat-panel-head {
  padding: 14px 16px;
  background: linear-gradient(135deg, #2c1810, #3d2618);
  color: #f5e6c8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.bags-chat-panel-head strong {
  font-size: 0.94rem;
  display: block;
}
.bags-chat-panel-head span {
  font-size: 0.72rem;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}
.bags-chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #f5e6c8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.bags-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf8f5;
}
.bags-chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.bags-chat-msg.user {
  align-self: flex-end;
  background: #2c1810;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bags-chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e8dfd0;
  color: #2c1810;
  border-bottom-left-radius: 4px;
}
.bags-chat-msg.typing {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.bags-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

.bags-chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a8894a;
  opacity: 0.35;
  animation: bags-chat-typing-bounce 1.2s infinite ease-in-out;
}

.bags-chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.bags-chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bags-chat-typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.bags-chat-msg.bot .bags-chat-link {
  color: #a8894a;
  text-decoration: underline;
  font-weight: 600;
}
.bags-chat-msg.bot .bags-chat-link:hover {
  color: #8a7038;
}

.bags-chat-msg.bot .bags-chat-wa-cta {
  display: inline-block;
  margin-top: 6px;
  padding: 8px 14px;
  background: #25d366;
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.82rem;
}
.bags-chat-msg.bot .bags-chat-wa-cta:hover {
  background: #1ebe57;
  color: #fff !important;
}

.bags-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e8dfd0;
  background: #fff;
}
.bags-chat-input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid #e8dfd0;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.86rem;
  min-height: 44px;
  max-height: 110px;
  direction: ltr;
}
.bags-chat-send {
  align-self: flex-end;
  padding: 10px 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #c9a962, #a8894a);
  color: #2c1810;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}
.bags-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .bags-chat-panel {
    right: 12px;
    bottom: 82px;
    width: calc(100vw - 24px);
  }
  .bags-chat-fab-hint {
    right: auto;
    left: 50%;
    top: auto;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px);
  }
  .bags-chat-fab-hint.visible {
    transform: translateX(-50%) translateY(0);
  }
}
