/* RicherBetter concierge widget — matches richerbetter.com tokens */
.rbchat-root {
  --rb-navy: #0A1D37;
  --rb-navy-soft: #3A4A63;
  --rb-white: #FFFFFF;
  --rb-off: #F6F4EC;
  --rb-line: #E2DFD2;
  --rb-gold: #D4AF37;
  --rb-gold-soft: #E3C669;
  --rb-charcoal: #2E2E2E;
  --rb-display: "Fraunces", "Noto Serif Thai", serif;
  --rb-body: "Inter", "Noto Sans Thai", sans-serif;
  --rb-mono: "IBM Plex Mono", monospace;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  font-family: var(--rb-body);
  color: var(--rb-navy);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.rbchat-root * { box-sizing: border-box; }

.rbchat-toggle {
  width: auto;
  height: 60px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--rb-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
  transition: transform .2s ease;
}
.rbchat-toggle:hover { background: transparent; transform: translateY(-1px); }
.rbchat-toggle:focus-visible { outline: 2px solid var(--rb-gold); outline-offset: 3px; }
.rbchat-toggle[aria-expanded="true"] { background: transparent; color: inherit; }

.rbchat-ask {
  display: inline-flex;
  align-items: center;
  background: var(--rb-navy);
  color: var(--rb-white);
  border: 1px solid rgba(212, 175, 55, 0.9);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--rb-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(10, 29, 55, 0.22);
}
.rbchat-toggle:hover .rbchat-ask { color: var(--rb-gold); }
.rbchat-root.is-open .rbchat-ask { display: none; }
.rbchat-root.is-open .rbchat-toggle { gap: 0; }

.rbchat-avatar-wrap {
  width: 60px;
  height: 60px;
  position: relative;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 10px 28px rgba(10, 29, 55, 0.28);
}
.rbchat-toggle-avatar,
.rbchat-header-avatar,
.rbchat-msg-avatar {
  display: block;
  border-radius: 50%;
  object-fit: cover;
  background: var(--rb-navy);
}
.rbchat-toggle-avatar {
  width: 60px;
  height: 60px;
}

.rbchat-toggle-close {
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--rb-gold);
  color: var(--rb-navy);
  font-size: 15px;
  line-height: 19px;
  text-align: center;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(10, 29, 55, 0.28);
}
.rbchat-root.is-open .rbchat-toggle-close { display: block; }

.rbchat-badge {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rb-gold);
  border: 2px solid var(--rb-off);
  display: none;
}
.rbchat-badge.is-on { display: block; }
.rbchat-root.is-open .rbchat-badge { display: none; }

.rbchat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(392px, calc(100vw - 28px));
  height: min(580px, calc(100vh - 110px));
  background: var(--rb-off);
  border: 1px solid var(--rb-line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(10, 29, 55, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.rbchat-panel.is-open { display: flex; }

.rbchat-header {
  background: var(--rb-navy);
  color: var(--rb-white);
  padding: 14px 16px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.rbchat-header h2 {
  font-family: var(--rb-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--rb-white);
}
.rbchat-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--rb-gold-soft);
}
.rbchat-header-text { flex: 1; min-width: 0; }
.rbchat-header-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px var(--rb-gold);
}

.rbchat-lang {
  display: flex;
  gap: 6px;
  font-family: var(--rb-mono);
  font-size: 11px;
  color: rgba(255,255,255,.55);
  align-items: center;
}
.rbchat-lang button {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
  font-size: inherit;
}
.rbchat-lang button.is-active { color: var(--rb-gold); font-weight: 500; }

.rbchat-close {
  background: none;
  border: 0;
  color: var(--rb-white);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  opacity: .8;
}
.rbchat-close:hover { opacity: 1; background: rgba(255,255,255,.08); }

.rbchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rbchat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
  align-self: flex-start;
}
.rbchat-msg-avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.rbchat-row .rbchat-bubble {
  max-width: 100%;
}

.rbchat-bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.rbchat-bubble a { color: inherit; text-decoration: underline; }
.rbchat-bubble.is-bot {
  align-self: flex-start;
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  color: var(--rb-navy);
  border-bottom-left-radius: 4px;
}
.rbchat-bubble.is-user {
  align-self: flex-end;
  background: var(--rb-navy);
  color: var(--rb-white);
  border-bottom-right-radius: 4px;
}
.rbchat-bubble.is-system {
  align-self: center;
  max-width: 94%;
  background: transparent;
  color: var(--rb-navy-soft);
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
}

.rbchat-typing {
  align-self: flex-start;
  display: none;
  gap: 4px;
  padding: 12px 14px;
  background: var(--rb-white);
  border: 1px solid var(--rb-line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.rbchat-typing.is-on { display: inline-flex; }
.rbchat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rb-gold);
  animation: rbchat-dot 1s infinite ease-in-out;
}
.rbchat-typing span:nth-child(2) { animation-delay: .15s; }
.rbchat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes rbchat-dot {
  0%, 80%, 100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.rbchat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
  flex-shrink: 0;
}
.rbchat-quick button {
  border: 1px solid var(--rb-line);
  background: var(--rb-white);
  color: var(--rb-navy);
  font-family: var(--rb-body);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.rbchat-quick button:hover {
  border-color: var(--rb-gold);
  color: var(--rb-navy);
}

.rbchat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--rb-line);
  background: var(--rb-white);
  flex-shrink: 0;
}
.rbchat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--rb-line);
  border-radius: 12px;
  padding: 9px 11px;
  font-family: var(--rb-body);
  font-size: 14px;
  color: var(--rb-navy);
  max-height: 110px;
  min-height: 42px;
  background: var(--rb-off);
}
.rbchat-form textarea:focus {
  outline: 2px solid var(--rb-gold);
  outline-offset: 0;
  background: var(--rb-white);
}
.rbchat-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--rb-gold);
  color: var(--rb-navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rbchat-send:hover { background: var(--rb-navy); color: var(--rb-white); }
.rbchat-send:disabled { opacity: .5; cursor: default; }
.rbchat-send svg { width: 18px; height: 18px; }

.rbchat-foot {
  font-size: 10.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-family: var(--rb-mono);
  color: var(--rb-navy-soft);
  text-align: center;
  padding: 0 12px 10px;
  background: var(--rb-white);
}

@media (max-width: 520px) {
  .rbchat-root { right: 12px; bottom: 12px; }
  .rbchat-ask {
    font-size: 12.5px;
    padding: 6px 11px;
  }
  .rbchat-toggle { height: 56px; gap: 8px; }
  .rbchat-avatar-wrap,
  .rbchat-toggle-avatar {
    width: 56px;
    height: 56px;
  }
  .rbchat-panel {
    position: fixed;
    right: 8px;
    left: 8px;
    bottom: 80px;
    width: auto;
    height: min(70vh, 620px);
  }
}
