/* ═══════════════════════════════════════════════════════════
   Reypub Digital — Live Chat Widget
   Self-contained styles (scoped under #rd-chat-root)
   ═══════════════════════════════════════════════════════════ */
#rd-chat-root, #rd-chat-root * { box-sizing: border-box; }
#rd-chat-root {
  --rd-primary: #4f46e5;
  --rd-primary-2: #7c3aed;
  --rd-accent: #06b6d4;
  --rd-ink: #0f172a;
  --rd-muted: #64748b;
  --rd-line: #e2e8f0;
  --rd-bg: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: fixed; z-index: 2147483000;
  left: 20px; bottom: 20px;
  color: var(--rd-ink);
}

/* ─── Launcher bubble ─── */
#rd-chat-launcher {
  position: relative;
  width: 68px; height: 68px; border-radius: 50%;
  border: none; cursor: pointer; padding: 0; overflow: visible;
  background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2));
  color: #fff; box-shadow: 0 12px 30px rgba(79,70,229,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
#rd-chat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 16px 40px rgba(79,70,229,.55); }
/* Branded support-agent avatar image fills the bubble */
#rd-chat-launcher .rd-launcher-avatar {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  display: block; border: 3px solid #fff;
}
#rd-chat-launcher i { font-size: 26px; }
/* The close (X) icon overlays the avatar only when the panel is open */
#rd-chat-launcher .rd-close-ic {
  display: none; position: absolute; inset: 0; border-radius: 50%;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2));
  color: #fff; border: 3px solid #fff;
}
#rd-chat-root.rd-open #rd-chat-launcher .rd-launcher-avatar { display: none; }
#rd-chat-root.rd-open #rd-chat-launcher .rd-close-ic { display: flex; }
#rd-launcher-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
#rd-launcher-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--rd-primary); opacity: .5; z-index: -1;
  animation: rd-pulse 2s infinite;
}
@keyframes rd-pulse { 0%{transform:scale(1);opacity:.5} 70%{transform:scale(1.7);opacity:0} 100%{opacity:0} }

/* Online status dot on the launcher avatar */
#rd-launcher-online {
  position: absolute; bottom: 3px; right: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #22c55e; border: 3px solid #fff; z-index: 1;
}
#rd-chat-root.rd-open #rd-launcher-online { display: none; }

/* Greeting tooltip beside the launcher */
#rd-launcher-tip {
  position: absolute; bottom: 14px; left: 82px; white-space: nowrap;
  background: #fff; color: var(--rd-ink); font-size: 13px; font-weight: 600;
  padding: 10px 34px 10px 14px; border-radius: 12px;
  box-shadow: 0 10px 26px rgba(15,23,42,.18); border: 1px solid var(--rd-line);
  animation: rd-tip-in .4s ease .6s both;
}
#rd-launcher-tip::after {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%) rotate(45deg);
  width: 12px; height: 12px; background: #fff; border-left: 1px solid var(--rd-line); border-bottom: 1px solid var(--rd-line);
}
#rd-launcher-tip #rd-tip-x {
  position: absolute; top: 4px; right: 6px; border: none; background: none;
  color: var(--rd-muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 2px;
}
#rd-launcher-tip.rd-tip-hide { opacity: 0; transform: translateX(-10px); pointer-events: none; transition: opacity .4s ease, transform .4s ease; }
@keyframes rd-tip-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
#rd-chat-root.rd-open #rd-launcher-tip { display: none !important; }
@media (max-width: 460px) { #rd-launcher-tip { display: none !important; } }

/* ─── Panel ─── */
#rd-chat-panel {
  position: absolute; left: 0; bottom: 78px;
  width: 380px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 110px);
  background: var(--rd-bg); border-radius: 20px;
  box-shadow: 0 30px 70px rgba(15,23,42,.28);
  display: none; flex-direction: column; overflow: hidden;
  transform: translateY(16px) scale(.98); opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
  border: 1px solid var(--rd-line);
}
#rd-chat-root.rd-open #rd-chat-panel { display: flex; transform: translateY(0) scale(1); opacity: 1; }

/* ─── Full screen mode ─── */
#rd-chat-root.rd-full { right: 0; bottom: 0; left: 0; top: 0; }
#rd-chat-root.rd-full #rd-chat-panel {
  position: fixed; right: 0; bottom: 0; left: 0; top: 0;
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  border-radius: 0; border: none;
}
#rd-chat-root.rd-full .rd-body { max-width: 760px; margin: 0 auto; width: 100%; }
#rd-chat-root.rd-full .rd-head,
#rd-chat-root.rd-full .rd-composer,
#rd-chat-root.rd-full .rd-foot { }
#rd-chat-root.rd-full .rd-composer { max-width: 760px; margin: 0 auto; width: 100%; }
#rd-chat-root.rd-full #rd-chat-launcher { display: none; }

/* ─── Header ─── */
.rd-head {
  background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2));
  color: #fff; padding: 16px 18px 14px; flex-shrink: 0;
}
.rd-head-top { display: flex; align-items: center; justify-content: space-between; }
.rd-head-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.rd-head-title .rd-logo { height: 22px; border-radius: 5px; background:#fff; padding:2px 4px; }
.rd-head-sub { font-size: 12.5px; opacity: .92; margin-top: 3px; }
.rd-head-actions { display: flex; align-items: center; gap: 6px; }
.rd-head-btn { background: rgba(255,255,255,.16); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: background .15s ease; }
.rd-head-btn:hover { background: rgba(255,255,255,.28); }
.rd-head-btn.rd-head-close:hover { background: #ef4444; }

/* Live members row */
.rd-members { display: flex; align-items: center; margin-top: 12px; gap: 10px; }
.rd-avatars { display: flex; }
.rd-avatars img, .rd-avatars .rd-av-fallback {
  width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid #fff;
  margin-left: -9px; object-fit: cover; background: #c7d2fe;
}
.rd-avatars img:first-child, .rd-avatars .rd-av-fallback:first-child { margin-left: 0; }
.rd-online-txt { font-size: 12px; opacity: .95; line-height: 1.3; }
.rd-online-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:#22c55e; margin-right:5px; box-shadow:0 0 0 3px rgba(34,197,94,.3); vertical-align: middle; }

/* ─── Body ─── */
.rd-body { flex: 1; overflow-y: auto; padding: 16px; background: #f8fafc; }
.rd-body::-webkit-scrollbar { width: 6px; }
.rd-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.rd-step { animation: rd-fade .25s ease; }
@keyframes rd-fade { from{opacity:0; transform: translateY(8px);} to{opacity:1; transform:none;} }

.rd-welcome-card { background:#fff; border:1px solid var(--rd-line); border-radius:14px; padding:18px; text-align:center; }
.rd-welcome-card h3 { margin: 6px 0 4px; font-size:17px; }
.rd-welcome-card p { margin:0; color: var(--rd-muted); font-size:13px; line-height:1.5; }
.rd-welcome-ic { width:52px; height:52px; border-radius:14px; margin:0 auto 6px; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,var(--rd-primary),var(--rd-primary-2)); color:#fff; font-size:22px; }

.rd-choices { display: grid; gap: 10px; margin-top: 14px; }
.rd-choice-btn {
  display:flex; align-items:center; gap:12px; width:100%;
  background:#fff; border:1.5px solid var(--rd-line); border-radius:12px;
  padding:13px 14px; cursor:pointer; text-align:left; transition:.15s; font-size:14px; color:var(--rd-ink);
}
.rd-choice-btn:hover { border-color: var(--rd-primary); box-shadow:0 4px 14px rgba(79,70,229,.14); transform: translateY(-1px); }
.rd-choice-ic { width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center; color:#fff; font-size:16px; flex-shrink:0; }
.rd-choice-btn b { display:block; font-size:14px; }
.rd-choice-btn small { color: var(--rd-muted); font-size:12px; }

/* Forms */
.rd-field { margin-bottom: 12px; }
.rd-field label { display:block; font-size:12.5px; font-weight:600; margin-bottom:5px; color:#334155; }
.rd-field label .rd-req { color:#ef4444; }
.rd-field input, .rd-field textarea, .rd-field select {
  width:100%; border:1.5px solid var(--rd-line); border-radius:10px; padding:11px 12px;
  font-size:14px; font-family:inherit; outline:none; transition:.15s; background:#fff; color:var(--rd-ink);
}
.rd-field input:focus, .rd-field textarea:focus, .rd-field select:focus { border-color: var(--rd-primary); box-shadow:0 0 0 3px rgba(79,70,229,.12); }
.rd-field textarea { resize: vertical; min-height: 92px; }
.rd-err { color:#ef4444; font-size:12px; margin-top:-6px; margin-bottom:10px; display:none; }

.rd-btn { width:100%; border:none; border-radius:11px; padding:13px; font-size:14.5px; font-weight:700; cursor:pointer; font-family:inherit; transition:.15s; display:flex; align-items:center; justify-content:center; gap:8px; }
.rd-btn-primary { background:linear-gradient(135deg,var(--rd-primary),var(--rd-primary-2)); color:#fff; }
.rd-btn-primary:hover { filter:brightness(1.06); box-shadow:0 8px 22px rgba(79,70,229,.35); }
.rd-btn-ghost { background:#fff; color:var(--rd-primary); border:1.5px solid var(--rd-line); }
.rd-btn-ghost:hover { border-color:var(--rd-primary); }
.rd-btn:disabled { opacity:.6; cursor:not-allowed; }
.rd-btn-row { display:flex; gap:10px; margin-top:6px; }
.rd-btn-row .rd-btn { flex:1; }

.rd-section-title { font-size:14px; font-weight:700; margin:2px 0 4px; }
.rd-section-desc { font-size:12.5px; color:var(--rd-muted); margin:0 0 12px; }

/* ─── Conversation view ─── */
.rd-conv-head { display:flex; align-items:center; gap:8px; background:#eef2ff; border:1px solid #e0e7ff; color:#3730a3; padding:8px 11px; border-radius:10px; margin-bottom:12px; font-size:12.5px; }
.rd-conv-head b { font-family: ui-monospace, monospace; }
.rd-copy-btn { margin-left:auto; background:none; border:none; color:#4f46e5; cursor:pointer; font-size:12px; }
.rd-msgs { display:flex; flex-direction:column; gap:10px; }
.rd-msg { max-width:82%; padding:10px 13px; border-radius:14px; font-size:13.5px; line-height:1.5; word-wrap:break-word; position:relative; }
.rd-msg .rd-msg-name { font-size:11px; font-weight:700; opacity:.8; margin-bottom:2px; }
.rd-msg .rd-msg-time { font-size:10px; opacity:.6; margin-top:4px; }
.rd-msg-visitor { align-self:flex-end; background:linear-gradient(135deg,var(--rd-primary),var(--rd-primary-2)); color:#fff; border-bottom-right-radius:4px; }
.rd-msg-agent { align-self:flex-start; background:#fff; border:1px solid var(--rd-line); border-bottom-left-radius:4px; }
.rd-msg-system { align-self:center; background:#fef3c7; border:1px solid #fde68a; color:#92400e; font-size:12.5px; text-align:center; max-width:94%; border-radius:12px; }
.rd-msg-att { display:flex; align-items:center; gap:8px; margin-top:6px; padding:7px 9px; border-radius:9px; background:rgba(0,0,0,.06); font-size:12px; }
.rd-msg-visitor .rd-msg-att { background:rgba(255,255,255,.2); }
.rd-msg-att a { color:inherit; text-decoration:underline; }

/* Connecting / status banners */
.rd-status { background:#fff; border:1px solid var(--rd-line); border-radius:14px; padding:16px 14px; text-align:center; margin-bottom:12px; }
.rd-status .rd-spin { color:var(--rd-primary); font-size:22px; }
.rd-status h4 { margin:8px 0 3px; font-size:14.5px; }
.rd-status p { margin:0; font-size:12.5px; color:var(--rd-muted); }
.rd-eta { font-weight:700; color:var(--rd-primary); }
.rd-status-ic { display:flex; align-items:center; justify-content:center; margin-bottom:4px; }
.rd-status-callback .rd-status-ic { color:#22c55e; font-size:32px; }
.rd-status-connecting .rd-status-ic .rd-typing span { width:9px; height:9px; }

/* Big, prominent 5-minute countdown */
.rd-countdown {
  display:flex; align-items:center; justify-content:center; gap:8px;
  margin:12px auto 4px; padding:12px 16px; max-width:240px;
  background:linear-gradient(135deg, rgba(79,70,229,.08), rgba(124,58,237,.08));
  border:1.5px solid rgba(79,70,229,.25); border-radius:14px;
}
.rd-countdown i { color:var(--rd-primary); font-size:16px; }
.rd-countdown .rd-countdown-label { font-size:12px; color:var(--rd-muted); font-weight:600; }
.rd-countdown .rd-countdown-time {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size:24px; font-weight:800; color:var(--rd-primary);
  min-width:64px; letter-spacing:1px; font-variant-numeric: tabular-nums;
}
.rd-countdown-note { margin:12px 0 8px !important; font-size:12px; }

/* Call back / Email me back option buttons */
.rd-callback-opts { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.rd-cb-btn {
  flex:1 1 auto; min-width:120px; display:inline-flex; align-items:center; justify-content:center; gap:7px;
  background:#fff; border:1.5px solid var(--rd-line); border-radius:10px;
  padding:10px 12px; font-size:12.5px; font-weight:700; color:var(--rd-ink);
  cursor:pointer; font-family:inherit; transition:.15s;
}
.rd-cb-btn i { color:var(--rd-primary); }
.rd-cb-btn:hover { border-color:var(--rd-primary); box-shadow:0 4px 12px rgba(79,70,229,.14); transform:translateY(-1px); }
.rd-cb-btn.rd-cb-both { flex-basis:100%; background:linear-gradient(135deg,var(--rd-primary),var(--rd-primary-2)); color:#fff; border-color:transparent; }
.rd-cb-btn.rd-cb-both i { color:#fff; }
.rd-cb-btn.rd-cb-both:hover { filter:brightness(1.06); }
.rd-cb-sending { font-size:12.5px; color:var(--rd-muted); padding:8px; }

/* Attachment prompt */
.rd-att-prompt { text-align:center; }
.rd-att-drop { border:2px dashed var(--rd-line); border-radius:12px; padding:18px; text-align:center; cursor:pointer; color:var(--rd-muted); font-size:13px; margin-bottom:12px; transition:.15s; }
.rd-att-drop:hover { border-color:var(--rd-primary); color:var(--rd-primary); }
.rd-att-chip { display:flex; align-items:center; gap:8px; background:#eef2ff; border:1px solid #e0e7ff; border-radius:9px; padding:8px 11px; font-size:12.5px; margin-bottom:12px; }
.rd-att-chip .rd-att-x { margin-left:auto; cursor:pointer; color:#ef4444; border:none; background:none; }

/* Composer */
.rd-composer { border-top:1px solid var(--rd-line); padding:10px; background:#fff; display:flex; align-items:flex-end; gap:8px; flex-shrink:0; }
.rd-composer textarea { flex:1; border:1.5px solid var(--rd-line); border-radius:12px; padding:10px 12px; font-size:14px; font-family:inherit; resize:none; max-height:110px; outline:none; }
.rd-composer textarea:focus { border-color:var(--rd-primary); }
.rd-icon-btn { width:40px; height:40px; border-radius:11px; border:none; cursor:pointer; flex-shrink:0; font-size:16px; display:flex; align-items:center; justify-content:center; }
.rd-icon-btn.rd-attach { background:#f1f5f9; color:#475569; }
.rd-icon-btn.rd-attach:hover { background:#e2e8f0; }
.rd-icon-btn.rd-send { background:linear-gradient(135deg,var(--rd-primary),var(--rd-primary-2)); color:#fff; }
.rd-icon-btn.rd-send:hover { filter:brightness(1.06); }

/* Footer watermark */
.rd-foot { text-align:center; padding:7px; font-size:11px; color:var(--rd-muted); background:#fff; border-top:1px solid var(--rd-line); flex-shrink:0; }
.rd-foot a { color:var(--rd-primary); text-decoration:none; font-weight:600; }
.rd-foot i { color: var(--rd-primary-2); }

.rd-typing { display:inline-flex; gap:3px; }
.rd-typing span { width:6px; height:6px; border-radius:50%; background:#94a3b8; animation:rd-blink 1.2s infinite; }
.rd-typing span:nth-child(2){animation-delay:.2s}
.rd-typing span:nth-child(3){animation-delay:.4s}
@keyframes rd-blink{0%,60%,100%{opacity:.3}30%{opacity:1}}

@media (max-width: 460px) {
  #rd-chat-root { left: 12px; bottom: 12px; }
  #rd-chat-panel { width: calc(100vw - 24px); height: calc(100vh - 92px); bottom: 74px; }
}
