/* ── Chat Widget ──────────────────────────────────────────────────────────── */

#ms-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Bubble */
#ms-chat-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a3a2a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
  font-size: 15px;
  font-weight: 600;
  user-select: none;
}
#ms-chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
#ms-chat-bubble .bubble-icon { font-size: 18px; }

/* Panel */
#ms-chat-panel {
  display: none;
  flex-direction: column;
  width: 340px;
  height: 500px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  border: 1px solid #e0d8cc;
}
#ms-chat-panel.open { display: flex; }

/* Header */
#ms-chat-header {
  background: #1a3a2a;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ms-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ms-chat-info { flex: 1; min-width: 0; }
.ms-chat-info strong { color: #fff; font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-chat-info small { color: #a8c5b0; font-size: 12px; }
#ms-chat-close {
  background: none;
  border: none;
  color: #a8c5b0;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
#ms-chat-close:hover { color: #fff; }

/* Messages */
#ms-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #faf8f4;
}

.ms-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
}
.ms-msg--bot {
  background: #fff;
  color: #2a2a2a;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #e0d8cc;
}
.ms-msg--user {
  background: #1a3a2a;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ms-typing {
  background: #fff;
  border: 1px solid #e0d8cc;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
}
.ms-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ms-typing-dots span {
  width: 6px;
  height: 6px;
  background: #a8c5b0;
  border-radius: 50%;
  animation: ms-bounce 1.2s infinite;
}
.ms-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ms-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ms-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Lead captured confirmation */
.ms-lead-confirmed {
  background: #f0f7f4;
  border: 1px solid #a8c5b0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: #1a3a2a;
  align-self: stretch;
  text-align: center;
}

/* Input row */
#ms-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e0d8cc;
  background: #fff;
  flex-shrink: 0;
}
#ms-chat-input-row input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid #d5cdc3;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  color: #2a2a2a;
  outline: none;
  transition: border-color 0.15s;
}
#ms-chat-input-row input:focus { border-color: #1a3a2a; }
#ms-send-btn {
  width: 36px;
  height: 36px;
  background: #1a3a2a;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ms-send-btn:hover { background: #2d5c47; }
#ms-send-btn:disabled { background: #a8c5b0; cursor: not-allowed; }

/* Footer */
#ms-chat-footer {
  padding: 6px 12px 8px;
  text-align: center;
  font-size: 11px;
  color: #bbb;
  background: #fff;
  border-top: 1px solid #f0ebe3;
  flex-shrink: 0;
}
#ms-chat-footer a { color: #999; }

/* Mobile */
@media (max-width: 480px) {
  #ms-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
  }
  #ms-chat-bubble {
    border-radius: 0;
    width: 100%;
    justify-content: center;
  }
  #ms-chat-panel {
    width: 100%;
    height: 70vh;
    border-radius: 16px 16px 0 0;
  }
}
