.web-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
}

html.web-chat-no-scroll,
body.web-chat-no-scroll {
  overflow: hidden;
  touch-action: none;
}

body.web-chat-no-scroll {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
}
.web-chat-launch {
  position: relative;
  border: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  padding: 0;
  background: linear-gradient(135deg, #e47418, #ff7300);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(148, 163, 184, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.web-chat-launch:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(148, 163, 184, 0.45);
}

.web-chat-launch:active {
  transform: scale(0.95);
}

.web-chat-launch-icon,
.web-chat-launch-close {
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
}

.web-chat-launch-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.web-chat-widget.open .web-chat-launch-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.web-chat-widget.open .web-chat-launch-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* ── Unread badge ── */
.web-chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  line-height: 1;
  pointer-events: none;
}

.web-chat-panel {
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 110px);
  border-radius: 18px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 20px 38px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.web-chat-widget.open .web-chat-panel {
  display: flex;
}

.web-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, rgba(255, 225, 201, 0.8), #fff);
}

.web-chat-header strong {
  display: block;
  font-size: 0.95rem;
}

.web-chat-header p {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: #64748b;
}

.web-chat-close {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.web-chat-close:hover {
  background: #f8fafc;
}

.web-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
}

.web-chat-message {
  max-width: 88%;
  padding: 9px 11px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.web-chat-message.incoming {
  align-self: flex-start;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #0f172a;
}

.web-chat-message.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, #e47418, #ff7300);
  color: #fff;
}

.web-chat-meta {
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.72;
}

/* ── Quick-reply chips ── */
.web-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.web-chat-chips:empty,
.web-chat-chips[hidden] {
  display: none;
}

.web-chat-chip {
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: #0f172a;
  background: #f8fafc;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.web-chat-chip:hover {
  background: #e47418;
  border-color: #e47418;
  color: #fff;
}

.web-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  background: #fff;
}

.web-chat-form textarea {
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.35;
  min-height: 42px;
  max-height: 120px;
}

.web-chat-form textarea:focus-visible {
  outline: 2px solid rgba(228, 116, 24, 0.4);
  border-color: #e47418;
}

.web-chat-form button {
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: #0f172a;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.web-chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.web-chat-status {
  padding: 8px 10px;
  font-size: 0.78rem;
  color: #64748b;
  text-align: center;
}

/* ── Typing indicator ── */
.web-chat-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  max-width: 88%;
}

.web-chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.web-chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: web-chat-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes web-chat-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.web-chat-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

@media (max-width: 640px) {
  .web-chat-widget {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    left: auto;
  }

  .web-chat-widget.open {
    position: fixed;
    inset: 0;
    z-index: 9999;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: rgba(2, 6, 23, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: stretch;
  }

  .web-chat-widget.open .web-chat-launch {
    display: none;
  }

  .web-chat-panel {
    width: 100%;
    max-width: 100%;
    margin-top: 0;
    border-radius: 16px 16px 0 0;
    height: calc(100dvh - env(safe-area-inset-top));
    max-height: calc(100dvh - env(safe-area-inset-top));
  }

  .web-chat-form {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .web-chat-form textarea {
    font-size: 16px;
    min-height: 44px;
  }
}
