/* Embeddable customer chat widget — self-contained styles, scoped under
   #hub-chat-root so they never leak into (or get clobbered by) the host
   page's CSS. */

#hub-chat-root,
#hub-chat-root * {
  box-sizing: border-box;
}

#hub-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2f6b3a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 999999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#hub-chat-bubble svg {
  width: 26px;
  height: 26px;
}

#hub-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  display: none;
}

#hub-chat-badge.show {
  display: block;
}

#hub-chat-window {
  position: fixed;
  right: 20px;
  bottom: 156px;
  width: 340px;
  height: 460px;
  max-height: 70vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#hub-chat-window.open {
  display: flex;
}

#hub-chat-header {
  background: #2f6b3a;
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#hub-chat-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

#hub-chat-header-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  background: #fff;
  border-radius: 50%;
  padding: 3px;
}

#hub-chat-close {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s ease;
}

#hub-chat-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

#hub-chat-close svg {
  width: 13px;
  height: 13px;
}

#hub-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f6f8f2;
}

.hub-chat-row {
  display: flex;
}

.hub-chat-row.customer {
  justify-content: flex-end;
}

.hub-chat-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.hub-chat-row.customer .hub-chat-msg {
  background: #2f6b3a;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.hub-chat-row.staff .hub-chat-msg,
.hub-chat-row.ai .hub-chat-msg {
  background: #e7efdd;
  color: #234d2a;
  border-bottom-left-radius: 4px;
}

.hub-chat-row.customer .hub-chat-msg.hub-chat-msg-enter {
  animation:
    hub-chat-msg-in 0.35s ease,
    hub-chat-msg-flash-customer 1.1s ease;
}

.hub-chat-row.staff .hub-chat-msg.hub-chat-msg-enter,
.hub-chat-row.ai .hub-chat-msg.hub-chat-msg-enter {
  animation:
    hub-chat-msg-in 0.35s ease,
    hub-chat-msg-flash-ai 1.1s ease;
}

@keyframes hub-chat-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hub-chat-msg-flash-customer {
  0% {
    box-shadow: 0 0 0 2px #2f6b3a;
  }
  100% {
    box-shadow: 0 0 0 2px transparent;
  }
}

@keyframes hub-chat-msg-flash-ai {
  0% {
    box-shadow: 0 0 0 2px #97c459;
  }
  100% {
    box-shadow: 0 0 0 2px transparent;
  }
}

.hub-chat-typing .hub-chat-msg {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 10px 14px;
}

.hub-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8aa97e;
  animation: hub-chat-blink 1.2s infinite ease-in-out;
}

.hub-chat-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.hub-chat-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes hub-chat-blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

#hub-chat-input-row {
  display: flex;
  align-items: center;
  border-top: 1px solid #dde3d4;
  padding: 8px;
  gap: 6px;
}

#hub-chat-input {
  flex: 1;
  border: 1px solid #d7ded0;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

#hub-chat-send {
  border: none;
  background: #2f6b3a;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

#hub-chat-send:hover:not(:disabled) {
  background: #265a30;
}

#hub-chat-send svg {
  width: 18px;
  height: 18px;
}

#hub-chat-send:disabled {
  opacity: 0.6;
  cursor: default;
}
