/* ── RankMesh Chatbot ─────────────────────────────────────────────────── */

#rm-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: var(--font-body, "Inter", sans-serif);
}

#rm-chat-trigger {
  position: relative;
  display: flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 22px;
  cursor: pointer;
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,0.32), transparent 32%),
    linear-gradient(135deg, #0a0a0a 0%, #09332a 52%, #00c97a 135%);
  box-shadow:
    0 20px 45px rgba(4, 13, 10, 0.22),
    0 0 0 1px rgba(255,255,255,0.14) inset;
  transition: transform 180ms ease, box-shadow 180ms ease;
  isolation: isolate;
}

#rm-chat-trigger::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  opacity: 0.8;
}

#rm-chat-trigger:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 26px 56px rgba(4, 13, 10, 0.28),
    0 0 0 1px rgba(255,255,255,0.16) inset;
}

#rm-chat-trigger::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 28px;
  background: radial-gradient(circle, rgba(0, 201, 122, 0.22), transparent 62%);
  z-index: -1;
  opacity: 0.7;
  animation: rm-trigger-pulse 2.8s ease-in-out infinite;
}

@keyframes rm-trigger-pulse {
  0%, 100% { transform: scale(0.92); opacity: 0.35; }
  50% { transform: scale(1.06); opacity: 0.8; }
}

#rm-chat-trigger svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
}

.rm-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: none;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.rm-unread-badge.visible {
  display: flex;
}

#rm-chat-window {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: 410px;
  max-width: calc(100vw - 28px);
  height: 600px;
  max-height: calc(100vh - 118px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(10, 10, 10, 0.08);
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(0,201,122,0.08), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  box-shadow: 0 34px 90px rgba(10, 20, 16, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(16px);
  overflow: hidden;
}

#rm-chat-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.22), transparent 20%),
    linear-gradient(180deg, transparent, rgba(0, 201, 122, 0.02));
  pointer-events: none;
}

#rm-chat-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.rm-chat-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  color: #fff;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.18), transparent 26%),
    linear-gradient(135deg, #07100d 0%, #0a241d 48%, #0eb67d 128%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.rm-chat-avatar {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.rm-chat-avatar::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(255,255,255,0.14), transparent 54%);
}

.rm-chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.rm-chat-header-info {
  min-width: 0;
  flex: 1;
}

.rm-chat-header-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rm-chat-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255,255,255,0.78);
}

.rm-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #7bf1b8;
  box-shadow: 0 0 0 6px rgba(123,241,184,0.14);
  display: inline-block;
}

.rm-chat-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: rgba(255,255,255,0.82);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.rm-chat-close:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.rm-chat-close svg {
  width: 18px;
  height: 18px;
}

.rm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at top left, rgba(0,201,122,0.05), transparent 24%),
    linear-gradient(180deg, #f8faf9, #f3f6f5);
  scroll-behavior: smooth;
}

.rm-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.rm-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.rm-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.16);
  border-radius: 999px;
}

.rm-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.rm-msg--new {
  animation: rm-slide-in 220ms cubic-bezier(.22,1,.36,1);
}

@keyframes rm-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.rm-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.rm-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.rm-bubble {
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.rm-msg.user .rm-bubble {
  color: #fff;
  background: linear-gradient(135deg, #0a0a0a 0%, #0f3c31 100%);
  border-bottom-right-radius: 6px;
  box-shadow: 0 10px 26px rgba(10, 20, 16, 0.16);
}

.rm-msg.assistant .rm-bubble {
  color: #111827;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-bottom-left-radius: 6px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.rm-msg.assistant .rm-bubble.rm-streaming-live {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(244,252,248,0.98));
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.06),
    0 0 0 1px rgba(0, 201, 122, 0.05) inset;
}

.rm-bubble-meta {
  margin-top: 5px;
  padding: 0 2px;
  font-size: 10px;
  color: #94a3b8;
}

.rm-streaming::after {
  content: "▋";
  display: inline-block;
  color: #00c97a;
  margin-left: 2px;
  font-size: 0.95em;
  vertical-align: text-bottom;
  animation: rm-cursor 0.7s step-end infinite;
  text-shadow: 0 0 10px rgba(0, 201, 122, 0.32);
}

@keyframes rm-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.rm-source-tag {
  margin-top: 7px;
  padding: 5px 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(0,201,122,0.18);
  border-radius: 999px;
  background: rgba(0,201,122,0.08);
  color: #0b8e58;
  font-size: 11px;
  box-shadow: 0 8px 20px rgba(0, 201, 122, 0.08);
}

.rm-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  width: fit-content;
  padding: 11px 14px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.rm-typing span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #00c97a;
  animation: rm-bounce 1.2s ease infinite;
}

.rm-typing span:nth-child(2) { animation-delay: 0.18s; }
.rm-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes rm-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

.rm-welcome {
  padding: 8px 2px 4px;
  text-align: left;
}

.rm-welcome-card {
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 24px;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(0,201,122,0.09), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.98));
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
  position: relative;
  overflow: hidden;
}

.rm-welcome-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0, 201, 122, 0.16), transparent 68%);
  pointer-events: none;
}

.rm-welcome-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #0b8e58;
}

.rm-welcome h3 {
  margin: 10px 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
}

.rm-welcome p {
  font-size: 13px;
  line-height: 1.6;
  color: #64748b;
}

.rm-suggestion-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.rm-suggestion-btn {
  padding: 8px 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  color: #1f2937;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.rm-suggestion-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(0,201,122,0.28);
  box-shadow: 0 10px 20px rgba(0,201,122,0.08);
}

.rm-suggestion-btn:active {
  transform: translateY(0);
}

.rm-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 13px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(251,253,252,0.98));
  flex-shrink: 0;
}

#rm-chat-input {
  flex: 1;
  resize: none;
  max-height: 110px;
  overflow-y: auto;
  padding: 11px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  outline: none;
  background: #f8faf9;
  color: #111827;
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

#rm-chat-input::placeholder {
  color: #94a3b8;
}

#rm-chat-input:focus {
  background: #fff;
  border-color: rgba(0,201,122,0.34);
  box-shadow: 0 0 0 4px rgba(0,201,122,0.08);
}

#rm-chat-send {
  display: flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #0a0a0a 0%, #0f3c31 100%);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  box-shadow: 0 10px 24px rgba(10, 20, 16, 0.14);
}

#rm-chat-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(10, 20, 16, 0.2);
}

#rm-chat-send:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

#rm-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

@media (max-width: 480px) {
  #rm-chat-widget {
    right: 16px;
    bottom: 16px;
  }

  #rm-chat-window {
    right: -6px;
    bottom: 74px;
    width: calc(100vw - 16px);
    height: calc(100vh - 86px);
    max-height: unset;
    border-radius: 24px 24px 0 0;
  }

  #rm-chat-trigger {
    width: 60px;
    height: 60px;
  }
}
