:root {
  --rg-primary:       var(--color-primary);
  --rg-primary-light: var(--color-primary-25);
  --rg-primary-glow:  rgba(124, 58, 237, 0.28);
  --rg-surface:       #ffffff;
  --rg-surface-2:     var(--color-secondary);
  --rg-border:        rgba(124, 58, 237, 0.15);
  --rg-text:          var(--bs-body-color);
  --rg-muted:         var(--color-secondary-700);
  --rg-bubble-user:   linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  --rg-bubble-bot:    var(--color-secondary);
  --rg-radius:        20px;
  --rg-shadow:        0 24px 64px rgba(124, 58, 237, 0.22), 0 4px 16px rgba(38, 0, 72, 0.12);
  --rg-btn-size:      58px;
}

/* ── widget wrapper ── */
.rg-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: "Poppins", sans-serif;
}

/* ── FAB button ── */
.rg-fab {
  width: var(--rg-btn-size);
  height: var(--rg-btn-size);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--rg-bubble-user);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px var(--rg-primary-glow), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
              box-shadow 0.25s ease;
  position: relative;
  overflow: hidden;
}
.rg-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 16px 48px var(--rg-primary-glow), 0 4px 12px rgba(0,0,0,0.15);
}
.rg-fab:active { transform: scale(0.96); }

/* pulse ring */
.rg-fab::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--rg-primary-light);
  animation: rg-pulse 2.4s ease-out infinite;
  opacity: 0;
}
@keyframes rg-pulse {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.55); }
}

/* fab icon transition */
.rg-fab-icon {
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.rg-fab-icon.exit { transform: rotate(90deg) scale(0.4); opacity: 0; position: absolute; }
.rg-fab-icon.enter { transform: rotate(0deg) scale(1); opacity: 1; }

/* ── chat panel ── */
.rg-panel {
  position: absolute;
  bottom: calc(var(--rg-btn-size) + 14px);
  right: 0;
  width: 370px;
  max-width: 92vw;
  background: var(--rg-surface);
  border-radius: var(--rg-radius);
  border: 1px solid var(--rg-border);
  box-shadow: var(--rg-shadow);
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
  transition:
    transform 0.42s cubic-bezier(.34,1.56,.64,1),
    opacity   0.28s ease;
}
.rg-panel.hidden {
  transform: scale(0.72) translateY(20px);
  opacity: 0;
  pointer-events: none;
}

/* ── header ── */
.rg-header {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #a78bfa 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.rg-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.12) 50%, transparent 60%);
  animation: rg-shimmer 3.5s ease-in-out infinite;
}
@keyframes rg-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

.rg-avatar {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.35);
  flex-shrink: 0;
  position: relative; z-index: 1;
}

.rg-header-info { flex: 1; position: relative; z-index: 1; }
.rg-header-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  line-height: 1.2;
}
.rg-header-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: rgba(255,255,255,0.8); margin-top: 2px;
}
.rg-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #a3e635;
  box-shadow: 0 0 0 2px rgba(163, 230, 53, 0.35);
  animation: rg-blink 2s ease-in-out infinite;
}
@keyframes rg-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.rg-close-btn {
  width: 30px; height: 30px; border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
  flex-shrink: 0; position: relative; z-index: 1;
  line-height: 1;
}
.rg-close-btn:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }

/* ── messages ── */
.rg-messages {
  height: min(420px, 60vh);
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(124, 58, 237, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(38, 0, 72, 0.08) 0%, transparent 60%),
    var(--rg-surface);
}
.rg-messages::-webkit-scrollbar { width: 4px; }
.rg-messages::-webkit-scrollbar-track { background: transparent; }
.rg-messages::-webkit-scrollbar-thumb { background: var(--rg-border); border-radius: 4px; }

/* ── message bubbles ── */
.rg-row { display: flex; animation: rg-pop-in 0.32s cubic-bezier(.34,1.56,.64,1) both; }
.rg-row.user { justify-content: flex-end; }
.rg-row.bot  { justify-content: flex-start; align-items: flex-end; gap: 8px; }

@keyframes rg-pop-in {
  from { transform: translateY(10px) scale(0.92); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.rg-bot-mini-avatar {
  width: 26px; height: 26px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 10px; color: #fff;
}

.rg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 16px;
}
.rg-bubble.user {
  background: var(--rg-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px var(--rg-primary-glow);
}
.rg-bubble.bot {
  background: var(--rg-bubble-bot);
  color: var(--rg-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--rg-border);
}

/* typing dots */
.rg-typing { display: flex; gap: 4px; align-items: center; padding: 4px 2px; }
.rg-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rg-primary-light);
  animation: rg-bounce 1.2s ease-in-out infinite;
}
.rg-typing span:nth-child(2) { animation-delay: 0.18s; }
.rg-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes rg-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* ── input bar ── */
.rg-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--rg-border);
  display: flex;
  gap: 9px;
  align-items: center;
  background: var(--rg-surface);
}

.rg-input {
  flex: 1;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--rg-border);
  background: var(--rg-surface-2);
  padding: 0 14px;
 
  font-size: 13.5px;
  color: var(--rg-text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.rg-input::placeholder { color: var(--rg-muted); }
.rg-input:focus {
  border-color: var(--rg-primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}
.rg-input:disabled { opacity: 0.55; cursor: not-allowed; }

.rg-send-btn {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  border: none; cursor: pointer;
  background: var(--rg-bubble-user);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px var(--rg-primary-glow);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s, opacity 0.2s;
}
.rg-send-btn:hover:not(:disabled) {
  transform: scale(1.1) translateY(-1px);
  box-shadow: 0 8px 20px var(--rg-primary-glow);
}
.rg-send-btn:active:not(:disabled) { transform: scale(0.94); }
.rg-send-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* powered-by footer */
.rg-powered {
  text-align: center;
  font-size: 10.5px;
  color: var(--rg-muted);
  padding: 6px 0 10px;
  letter-spacing: 0.02em;
}
.rg-powered strong { color: var(--rg-primary); font-weight: 500; }
