/* ============================================================
   RosmonPro · RosmonAI Business Copilot Widget
   Bottom-LEFT anchor — keeps right-side registration form clear
   Full text-visibility audit: every element has explicit colour
   ============================================================ */

/* ---------- Widget Shell ---------- */
.rp-chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a; /* base text — never transparent */
  pointer-events: none;
}
.rp-chat-widget > * {
  pointer-events: auto;
}

/* ---------- Trigger Button ---------- */
.rp-chat-trigger {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;          /* icon always white */
  border: none;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.rp-chat-trigger:hover {
  transform: scale(1.08);
  background: #1d4ed8;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.55);
}

/* Pulsing notification badge — appears when a message is waiting */
.rp-chat-trigger.rp-has-message {
  animation: rp-trigger-pulse 2.4s ease-in-out infinite;
}
.rp-chat-trigger.rp-has-message::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #ef4444;
  border: 2.5px solid #fff;
  border-radius: 50%;
  animation: rp-badge-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes rp-trigger-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(37,99,235,0.45); }
  50%       { box-shadow: 0 8px 32px rgba(37,99,235,0.75), 0 0 0 9px rgba(37,99,235,0.12); }
}
@keyframes rp-badge-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Chat Window ---------- */
.rp-chat-window {
  position: fixed;
  bottom: 90px;
  left: 24px;
  width: 390px;
  max-width: min(390px, calc(100vw - 48px));
  height: min(560px, calc(100vh - 110px));
  background: #ffffff;
  border-radius: 18px;
  box-shadow:
    0 4px 6px  rgba(15,23,42,0.05),
    0 20px 60px rgba(15,23,42,0.20),
    0 0 0 1px  rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom left;
}
.rp-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile — full width */
@media (max-width: 480px) {
  .rp-chat-widget  { left: 12px; }
  .rp-chat-window  { left: 12px; right: 12px; width: auto; max-width: none; border-radius: 14px; }
}

/* ---------- Header (dark navy) ---------- */
.rp-chat-header {
  background: #0f172a;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}

/* Avatar glow wrapper */
.rp-avatar-glow {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #38bdf8;          /* sky-400 — vivid on dark */
  flex-shrink: 0;
}

/* Title row */
.rp-chat-header .title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;          /* pure white — max contrast on #0f172a */
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.rp-chat-header .title .badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  background: #10b981 !important;
  color: #ffffff !important;
  letter-spacing: 0.3px;
}

/* Status line */
.rp-chat-header .status {
  font-size: 11.5px;
  font-weight: 500;
  color: #94a3b8;          /* slate-400 — readable on dark without being too bright */
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.rp-chat-header .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.25);
}

/* Voice toggle button */
.rp-chat-voice-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 17px;
  cursor: pointer;
  padding: 5px 7px;
  line-height: 1;
  border-radius: 7px;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rp-chat-voice-btn:hover    { color: #ffffff; background: rgba(255,255,255,0.12); }
.rp-chat-voice-btn.active   { color: #38bdf8; }
.rp-chat-voice-btn.muted    { color: #f87171; }
.rp-chat-voice-btn.speaking { color: #4ade80; animation: rpPulse 1.2s infinite ease-in-out; }

/* Close button */
.rp-chat-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 17px;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
  border-radius: 7px;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rp-chat-close:hover { color: #ffffff; background: rgba(255,255,255,0.12); }

/* ---------- Session separator badge ---------- */
.rp-chat-date-sep {
  padding: 4px 0 2px;
}
.rp-chat-date-sep .badge {
  font-size: 0.7rem !important;
  font-weight: 600;
  color: #e2e8f0 !important;          /* light text — readable on dark badge */
  background: #1e293b !important;
  border: 1px solid rgba(148,163,184,0.2) !important;
  padding: 4px 10px;
  letter-spacing: 0.2px;
}

/* ---------- Messages Body ---------- */
.rp-chat-body {
  flex: 1;
  padding: 14px 14px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f1f5f9;     /* slate-100 — clean light background */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.rp-chat-body::-webkit-scrollbar       { width: 5px; }
.rp-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ---------- Message Bubbles ---------- */
.rp-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  word-break: break-word;
}
.rp-msg-bot  { align-self: flex-start; }
.rp-msg-user { align-self: flex-end; }

/* Bot bubble */
.rp-bubble-bot {
  background: #ffffff;
  color: #0f172a;          /* slate-900 — near-black, maximum readability */
  border: 1px solid #e2e8f0;
  border-radius: 14px 14px 14px 3px;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: 0 1px 4px rgba(15,23,42,0.07);
}

/* User bubble */
.rp-bubble-user {
  background: #2563eb;
  color: #ffffff;          /* white on blue — WCAG AA */
  border-radius: 14px 14px 3px 14px;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

/* Legacy class aliases — keep for backward compat with history replay */
.rp-msg.bot,
.rp-msg-bot > .rp-bubble-bot {
  color: #0f172a;
}
.rp-msg.user,
.rp-msg-user > .rp-bubble-user {
  color: #ffffff;
}

/* ---------- Typing Indicator ---------- */
.rp-typing {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
/* Both old `.rp-typing span` and new `.rp-typing-dot` class */
.rp-typing span,
.rp-typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #64748b;     /* slate-500 — clearly visible on white */
  border-radius: 50%;
  animation: rp-bounce 1.4s infinite ease-in-out both;
}
.rp-typing span:nth-child(1),
.rp-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.rp-typing span:nth-child(2),
.rp-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.rp-typing .text-secondary {
  font-size: 0.78rem;
  color: #475569 !important;  /* slate-600 — not invisible */
  margin-left: 4px;
}
@keyframes rp-bounce {
  0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ---------- Read-Instruction (Replay) Button ---------- */
.rp-msg-actions {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.rp-replay-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;          /* slate-700 — clearly readable */
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.rp-replay-btn:hover   { color: #1d4ed8; background: #eff6ff; border-color: #93c5fd; }
.rp-replay-btn.speaking { color: #15803d; background: #f0fdf4; border-color: #86efac; }

/* ---------- Chat Input Footer ---------- */
.rp-chat-footer {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.rp-chat-footer input {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 22px;
  padding: 8px 15px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;          /* typed text — dark and clear */
  background: #f8fafc;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.rp-chat-footer input::placeholder {
  color: #94a3b8;          /* slate-400 — visible but clearly a placeholder */
}
.rp-chat-footer input:focus {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.rp-chat-footer button {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s, transform 0.15s;
}
.rp-chat-footer button:hover { background: #1d4ed8; transform: scale(1.06); }

/* ---------- Welcome-Back Card ---------- */
.rp-welcome-back-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 4px 0;
  box-shadow: 0 4px 12px rgba(16,185,129,0.08);
  animation: rpFadeSlideIn 0.3s ease-out;
}
.rp-welcome-back-card.active-step {
  border-color: #93c5fd;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}
@keyframes rpFadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Welcome-back heading */
.rp-welcome-back-card .fw-bold {
  color: #0f172a;          /* slate-900 — always dark */
  font-size: 0.92rem;
}
/* Welcome-back sub-text */
.rp-welcome-back-card .text-secondary {
  color: #475569 !important; /* slate-600 — not a faded ghost */
  font-size: 0.82rem;
}

.rp-resume-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: #10b981;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Step preview box */
.rp-step-preview {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(203,213,225,0.8);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: #1e293b;          /* slate-800 — high contrast on white box */
  margin: 8px 0;
  line-height: 1.45;
}
.rp-step-preview strong {
  color: #0f172a;
}

/* Step counter text */
.rp-welcome-back-card .text-muted {
  color: #64748b !important; /* slate-500 — not invisible */
  font-size: 0.72rem;
}

/* Resume action buttons */
.rp-resume-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 9px;
}
.rp-btn-continue {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.rp-btn-continue:hover { background: #1d4ed8; transform: translateY(-1px); }
.rp-btn-restart {
  background: transparent;
  color: #334155;          /* slate-700 — clearly readable */
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.rp-btn-restart:hover { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

/* ---------- Lead Gate Overlay ---------- */
.rp-lead-gate {
  position: absolute;
  inset: 0;
  background: #ffffff;
  z-index: 10;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.rp-lead-gate h4 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}
.rp-lead-gate p {
  font-size: 13px;
  color: #475569;          /* slate-600 — readable */
  margin-bottom: 18px;
  line-height: 1.5;
}
.rp-lead-gate label {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;          /* slate-800 — clearly visible */
  margin-bottom: 4px;
  display: block;
}
.rp-lead-gate input {
  width: 100%;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #0f172a;
  background: #f8fafc;
}
.rp-lead-gate input::placeholder { color: #94a3b8; }
.rp-lead-gate input:focus { border-color: #2563eb; outline: none; background: #fff; }
.rp-lead-gate .form-group { margin-bottom: 12px; }
.rp-lead-gate button {
  margin-top: 8px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.rp-lead-gate button:hover { background: #1d4ed8; }

/* ---------- Shared Animations ---------- */
@keyframes rpPulse {
  0%   { transform: scale(1);    filter: drop-shadow(0 0 0   rgba(74,222,128,0.4)); }
  50%  { transform: scale(1.15); filter: drop-shadow(0 0 6px rgba(74,222,128,0.8)); }
  100% { transform: scale(1);    filter: drop-shadow(0 0 0   rgba(74,222,128,0.4)); }
}
