/* ============================================================
   Rizve Growth OS — Chat Widget v2
   Themes: light (default) | dark | chatgpt
   ============================================================ */

/* ── CSS variables — light theme (default) ──────────────────── */
#rgo-win {
  --rgo-bg:           #ffffff;
  --rgo-bg-msgs:      #f3f4f6;
  --rgo-bg-bot-msg:   #ffffff;
  --rgo-bg-user-msg:  var(--rgo-brand, #2563eb);
  --rgo-ink:          #111827;
  --rgo-ink-light:    #6b7280;
  --rgo-border:       #e5e7eb;
  --rgo-input-bg:     #ffffff;
  --rgo-header-bg:    var(--rgo-brand, #2563eb);
  --rgo-header-ink:   #ffffff;
  --rgo-shadow:       0 12px 40px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
  --rgo-radius:       16px;
  --rgo-radius-msg:   14px;
  --rgo-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── dark theme ─────────────────────────────────────────────── */
#rgo-win.rgo-theme-dark {
  --rgo-bg:           #1e1e2e;
  --rgo-bg-msgs:      #181825;
  --rgo-bg-bot-msg:   #2a2a3c;
  --rgo-bg-user-msg:  var(--rgo-brand, #2563eb);
  --rgo-ink:          #cdd6f4;
  --rgo-ink-light:    #6c7086;
  --rgo-border:       #313244;
  --rgo-input-bg:     #2a2a3c;
  --rgo-header-bg:    #11111b;
  --rgo-header-ink:   #cdd6f4;
  --rgo-shadow:       0 12px 40px rgba(0,0,0,0.5);
}

/* ── chatgpt theme ──────────────────────────────────────────── */
#rgo-win.rgo-theme-chatgpt {
  --rgo-bg:           #212121;
  --rgo-bg-msgs:      #212121;
  --rgo-bg-bot-msg:   transparent;
  --rgo-bg-user-msg:  #2f2f2f;
  --rgo-ink:          #ececec;
  --rgo-ink-light:    #8e8ea0;
  --rgo-border:       #383838;
  --rgo-input-bg:     #2f2f2f;
  --rgo-header-bg:    #212121;
  --rgo-header-ink:   #ececec;
  --rgo-shadow:       0 12px 40px rgba(0,0,0,0.6);
}

/* ── Bubble ─────────────────────────────────────────────────── */
#rgo-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483640;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--rgo-brand, #2563eb);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(var(--rgo-brand-rgb, 37,99,235), 0.45);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
  animation: rgo-pop-in 0.4s cubic-bezier(.34,1.56,.64,1) both;
}
#rgo-bubble:hover  { transform: scale(1.1); box-shadow: 0 6px 24px rgba(var(--rgo-brand-rgb, 37,99,235), 0.55); }
#rgo-bubble:active { transform: scale(0.96); }
#rgo-bubble.rgo-left { right: auto; left: 24px; }
#rgo-bubble.rgo-bubble-hidden { display: none; }
#rgo-bubble.rgo-open { background: rgba(0,0,0,0.55); box-shadow: 0 4px 20px rgba(0,0,0,0.35); }

/* Unread badge */
.rgo-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  animation: rgo-pop-in 0.3s cubic-bezier(.34,1.56,.64,1) both;
}
.rgo-badge-hidden { display: none; }

/* ── Chat window ────────────────────────────────────────────── */
#rgo-win {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 2147483641;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--rgo-bg);
  border-radius: var(--rgo-radius);
  box-shadow: var(--rgo-shadow);
  font-family: var(--rgo-font);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rgo-border);
  transform-origin: bottom right;
}
#rgo-win.rgo-left { right: auto; left: 24px; transform-origin: bottom left; }
#rgo-win.rgo-open {
  display: flex;
  animation: rgo-slide-up 0.28s cubic-bezier(.34,1.12,.64,1) both;
}

/* ── Header ─────────────────────────────────────────────────── */
.rgo-header {
  background: var(--rgo-header-bg);
  color: var(--rgo-header-ink);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}
.rgo-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.rgo-ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
}
.rgo-ai-avatar-default {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rgo-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rgo-header-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rgo-header-status {
  font-size: 11.5px;
  opacity: 0.8;
}
.rgo-online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 4px;
  position: relative;
  top: 1px;
}
.rgo-online-dot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid #4ade80;
  animation: rgo-pulse 2s infinite;
}
.rgo-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.rgo-icon-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--rgo-header-ink);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s;
}
.rgo-icon-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Messages area ──────────────────────────────────────────── */
.rgo-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--rgo-bg-msgs);
  scroll-behavior: smooth;
}
.rgo-msgs::-webkit-scrollbar { width: 5px; }
.rgo-msgs::-webkit-scrollbar-track { background: transparent; }
.rgo-msgs::-webkit-scrollbar-thumb { background: var(--rgo-border); border-radius: 4px; }

/* Message wrap (bot row = avatar + bubble) */
.rgo-msg-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.rgo-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--rgo-brand, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}
.rgo-msg-avatar-img { width: 100%; height: 100%; object-fit: cover; }

/* Base message bubble */
.rgo-msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--rgo-radius-msg);
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
}

/* User bubble */
.rgo-msg-user {
  align-self: flex-end;
  background: var(--rgo-bg-user-msg);
  color: #fff;
  border-bottom-right-radius: 4px;
  margin-left: auto;
  animation: rgo-msg-user-in 0.2s ease both;
}

/* Bot bubble */
.rgo-msg-bot {
  background: var(--rgo-bg-bot-msg);
  color: var(--rgo-ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  animation: rgo-msg-bot-in 0.22s ease both;
}
.rgo-theme-chatgpt .rgo-msg-bot {
  box-shadow: none;
  padding-left: 2px;
}

/* Streaming cursor */
.rgo-streaming::after {
  content: '▋';
  font-size: 13px;
  animation: rgo-blink 0.85s step-end infinite;
  color: var(--rgo-brand, #2563eb);
}

/* Copy button */
.rgo-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--rgo-bg-msgs);
  border: 1px solid var(--rgo-border);
  border-radius: 6px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--rgo-ink-light);
  transition: background 0.15s, color 0.15s;
}
.rgo-msg-wrap:hover .rgo-copy-btn { display: flex; }
.rgo-copy-btn:hover { background: var(--rgo-border); color: var(--rgo-ink); }

/* Citations */
.rgo-citations {
  font-size: 11.5px;
  color: var(--rgo-ink-light);
  margin-top: 4px;
  padding: 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.rgo-cite-label { font-weight: 600; }
.rgo-cite {
  background: rgba(var(--rgo-brand-rgb, 37,99,235), 0.1);
  color: var(--rgo-brand, #2563eb);
  border-radius: 20px;
  padding: 2px 8px;
  text-decoration: none;
  transition: background 0.15s;
}
.rgo-cite:hover { background: rgba(var(--rgo-brand-rgb, 37,99,235), 0.2); text-decoration: underline; }

/* Action bar (WhatsApp / Book) */
.rgo-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0 4px;
}
.rgo-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--rgo-bg-bot-msg);
  border: 1px solid var(--rgo-border);
  color: var(--rgo-ink);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.rgo-action-btn:hover { background: var(--rgo-border); }

/* ── Typing indicator ───────────────────────────────────────── */
.rgo-typing {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--rgo-bg-bot-msg);
  border-radius: var(--rgo-radius-msg);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  width: fit-content;
  animation: rgo-msg-bot-in 0.22s ease both;
}
.rgo-theme-chatgpt .rgo-typing { background: transparent; box-shadow: none; }
.rgo-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rgo-ink-light);
  animation: rgo-bounce 1.4s infinite both;
}
.rgo-typing span:nth-child(2) { animation-delay: 0.18s; }
.rgo-typing span:nth-child(3) { animation-delay: 0.36s; }

/* ── Suggestions chips ──────────────────────────────────────── */
.rgo-suggestions {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 4px;
  background: var(--rgo-bg);
  border-top: 1px solid var(--rgo-border);
}
.rgo-suggestions-visible { display: flex; }
.rgo-chip {
  background: rgba(var(--rgo-brand-rgb, 37,99,235), 0.08);
  color: var(--rgo-brand, #2563eb);
  border: 1px solid rgba(var(--rgo-brand-rgb, 37,99,235), 0.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  white-space: nowrap;
  font-family: var(--rgo-font);
}
.rgo-chip:hover { background: rgba(var(--rgo-brand-rgb, 37,99,235), 0.16); transform: translateY(-1px); }
.rgo-chip:active { transform: translateY(0); }

/* ── Lead form ──────────────────────────────────────────────── */
.rgo-lead-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--rgo-bg);
  border-top: 1px solid var(--rgo-border);
  animation: rgo-slide-down 0.22s ease both;
}
.rgo-lead-wrap.rgo-lead-open { display: flex; }
.rgo-lead-prompt {
  font-size: 12.5px;
  color: var(--rgo-ink-light);
  font-weight: 500;
}
.rgo-lead-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rgo-input-sm {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--rgo-border);
  border-radius: 10px;
  font-size: 13px;
  background: var(--rgo-input-bg);
  color: var(--rgo-ink);
  font-family: var(--rgo-font);
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.rgo-input-sm:focus { outline: none; border-color: var(--rgo-brand, #2563eb); box-shadow: 0 0 0 3px rgba(var(--rgo-brand-rgb,37,99,235),0.15); }
.rgo-lead-btns {
  display: flex;
  gap: 8px;
}
.rgo-btn-primary {
  flex: 1;
  padding: 9px 14px;
  background: var(--rgo-brand, #2563eb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
  font-family: var(--rgo-font);
}
.rgo-btn-primary:hover  { opacity: 0.9; }
.rgo-btn-primary:active { transform: scale(0.98); }
.rgo-btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.rgo-btn-ghost {
  padding: 9px 14px;
  background: transparent;
  color: var(--rgo-ink-light);
  border: 1px solid var(--rgo-border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--rgo-font);
}
.rgo-btn-ghost:hover { background: var(--rgo-border); }
.rgo-lead-msg {
  font-size: 12.5px;
  border-radius: 8px;
  padding: 6px 10px;
  display: none;
}
.rgo-lead-ok  { display: block; background: rgba(74,222,128,0.12); color: #16a34a; border: 1px solid rgba(74,222,128,0.3); }
.rgo-lead-err { display: block; background: rgba(239,68,68,0.1);  color: #dc2626; border: 1px solid rgba(239,68,68,0.25); }

/* ── Footer / input ─────────────────────────────────────────── */
.rgo-footer {
  padding: 10px 14px 12px;
  background: var(--rgo-bg);
  border-top: 1px solid var(--rgo-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rgo-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.rgo-text-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--rgo-border);
  border-radius: 22px;
  font-size: 13.5px;
  background: var(--rgo-input-bg);
  color: var(--rgo-ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--rgo-font);
}
.rgo-text-input:focus { border-color: var(--rgo-brand, #2563eb); box-shadow: 0 0 0 3px rgba(var(--rgo-brand-rgb,37,99,235),0.15); }
.rgo-text-input::placeholder { color: var(--rgo-ink-light); opacity: 0.7; }
.rgo-text-input:disabled { opacity: 0.5; }
.rgo-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--rgo-brand, #2563eb);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.rgo-send-btn:hover  { transform: scale(1.08); }
.rgo-send-btn:active { transform: scale(0.94); }
.rgo-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.rgo-booking-btn {
  display: block;
  text-align: center;
  padding: 7px 14px;
  background: rgba(var(--rgo-brand-rgb,37,99,235),0.07);
  color: var(--rgo-brand, #2563eb);
  border: 1px solid rgba(var(--rgo-brand-rgb,37,99,235),0.22);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.rgo-booking-btn:hover { background: rgba(var(--rgo-brand-rgb,37,99,235),0.14); }

/* ── Shake animation (rate limit / validation) ───────────────── */
.rgo-shake {
  animation: rgo-shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #rgo-win {
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100%;
    bottom: 0;
    right: 0 !important;
    left: 0 !important;
    border-radius: 0;
    transform-origin: bottom center;
  }
  #rgo-bubble { bottom: 16px; right: 16px; }
  #rgo-bubble.rgo-left { right: auto; left: 16px; }
}

/* ── Keyframes ──────────────────────────────────────────────── */
@keyframes rgo-pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes rgo-slide-up {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}
@keyframes rgo-slide-down {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes rgo-msg-bot-in {
  from { transform: translateX(-8px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes rgo-msg-user-in {
  from { transform: translateX(8px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}
@keyframes rgo-bounce {
  0%, 80%, 100% { transform: scale(0.35); opacity: 0.5; }
  40%           { transform: scale(1);    opacity: 1; }
}
@keyframes rgo-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}
@keyframes rgo-pulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes rgo-shake {
  10%, 90%  { transform: translateX(-2px); }
  20%, 80%  { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60%  { transform: translateX(5px); }
}
