/* ═══════════════════════════════════════
   RINGRISE AI CHAT WIDGET
═══════════════════════════════════════ */

#rr-chat-widget {
  position: fixed;
  bottom: 32px;
  right: 28px;
  z-index: 850;
  font-family: 'Barlow', -apple-system, sans-serif;
}

/* ── Toggle button ── */
#rrcw-toggle {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--orange, #ED6F02);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(237,111,2,0.45);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  opacity: 0;
  animation: rrcwFadeIn 0.5s ease 2.6s forwards;
  position: relative;
}
@keyframes rrcwFadeIn { to { opacity: 1; } }

#rrcw-toggle:hover {
  background: #F9840B;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(237,111,2,0.55);
}
#rrcw-toggle svg {
  width: 22px; height: 22px; stroke: #fff;
  transition: opacity 0.15s, transform 0.15s;
  position: absolute;
}
.rrcw-icon-chat  { opacity: 1;  transform: scale(1); }
.rrcw-icon-close { opacity: 0;  transform: scale(0.7); }
#rrcw-toggle.rrcw-active .rrcw-icon-chat  { opacity: 0;  transform: scale(0.7); }
#rrcw-toggle.rrcw-active .rrcw-icon-close { opacity: 1;  transform: scale(1); }

/* ── Panel ── */
#rrcw-panel {
  position: absolute;
  bottom: 64px; right: 0;
  width: 340px;
  background: #111;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(.16,1,.3,1), transform 0.22s cubic-bezier(.16,1,.3,1);
  transform-origin: bottom right;
}
#rrcw-panel.rrcw-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
#rrcw-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: #0A0A0A;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.rrcw-header-info { display: flex; align-items: center; gap: 10px; }
.rrcw-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--orange, #ED6F02);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900; font-style: italic; font-size: 0.72rem;
  color: #000; flex-shrink: 0; letter-spacing: 0.04em;
}
.rrcw-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700; font-size: 0.9rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: #fff; line-height: 1.2;
}
.rrcw-status { display: flex; align-items: center; gap: 5px; font-size: 0.68rem; color: rgba(255,255,255,0.38); margin-top: 1px; }
.rrcw-dot { width: 6px; height: 6px; background: #4ade80; border-radius: 50%; flex-shrink: 0; }
#rrcw-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.28); padding: 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: color 0.2s;
}
#rrcw-close:hover { color: #fff; }
#rrcw-close svg { width: 15px; height: 15px; }

/* ── Messages ── */
#rrcw-messages {
  flex: 1; overflow-y: auto;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 280px; max-height: 340px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.rrcw-msg {
  max-width: 86%; padding: 10px 13px; border-radius: 10px;
  font-size: 0.875rem; line-height: 1.55; word-wrap: break-word;
  animation: rrcwMsgIn 0.18s ease;
}
@keyframes rrcwMsgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rrcw-msg-user {
  background: var(--orange, #ED6F02); color: #000;
  align-self: flex-end; border-bottom-right-radius: 3px; font-weight: 500;
}
.rrcw-msg-assistant {
  background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.88);
  align-self: flex-start; border-bottom-left-radius: 3px;
}

/* Typing indicator */
.rrcw-typing {
  display: flex !important; align-items: center;
  gap: 5px; padding: 12px 14px;
}
.rrcw-typing span {
  width: 6px; height: 6px;
  background: rgba(255,255,255,0.3); border-radius: 50%;
  animation: rrcwBounce 1.1s ease infinite;
}
.rrcw-typing span:nth-child(2) { animation-delay: 0.15s; }
.rrcw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rrcwBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ── */
#rrcw-input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: #0A0A0A; flex-shrink: 0;
}
#rrcw-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; padding: 9px 12px;
  color: #fff; font-family: 'Barlow', sans-serif; font-size: 0.875rem;
  outline: none; transition: border-color 0.2s;
}
#rrcw-input::placeholder { color: rgba(255,255,255,0.26); }
#rrcw-input:focus { border-color: rgba(237,111,2,0.55); }

#rrcw-send {
  width: 36px; height: 36px;
  background: var(--orange, #ED6F02);
  border: none; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.2s, transform 0.15s;
}
#rrcw-send:hover { background: #F9840B; transform: scale(1.05); }
#rrcw-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
#rrcw-send svg { width: 14px; height: 14px; stroke: #000; }

#rrcw-mic {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
#rrcw-mic:hover { background: rgba(255,255,255,0.13); transform: scale(1.05); }
#rrcw-mic svg { width: 14px; height: 14px; stroke: rgba(255,255,255,0.6); transition: stroke 0.2s; }
#rrcw-mic.rrcw-listening {
  background: rgba(237,111,2,0.18);
  border-color: rgba(237,111,2,0.6);
  animation: rrcwPulse 1s ease infinite;
}
#rrcw-mic.rrcw-listening svg { stroke: #ED6F02; }
@keyframes rrcwPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(237,111,2,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(237,111,2,0); }
}

/* Light mode mic */
html[data-theme="light"] #rrcw-mic { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12); }
html[data-theme="light"] #rrcw-mic:hover { background: rgba(0,0,0,0.09); }
html[data-theme="light"] #rrcw-mic svg { stroke: rgba(0,0,0,0.45); }

/* ── Call button in header ── */
#rrcw-call-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.28); padding: 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: color 0.2s;
}
#rrcw-call-btn:hover { color: #ED6F02; }
html[data-theme="light"] #rrcw-call-btn { color: rgba(0,0,0,0.28); }
html[data-theme="light"] #rrcw-call-btn:hover { color: #ED6F02; }

/* ── Call overlay ── */
#rrcw-call-overlay {
  position: absolute;
  inset: 0;
  background: #0A0A0A;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 12px;
}
.rrcw-call-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--orange, #ED6F02);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900; font-style: italic; font-size: 1.4rem;
  color: #000; letter-spacing: 0.04em;
  box-shadow: 0 0 0 0 rgba(237,111,2,0.5);
  animation: rrcwCallPulse 2s ease infinite;
}
@keyframes rrcwCallPulse {
  0%   { box-shadow: 0 0 0 0 rgba(237,111,2,0.5); }
  70%  { box-shadow: 0 0 0 18px rgba(237,111,2,0); }
  100% { box-shadow: 0 0 0 0 rgba(237,111,2,0); }
}
.rrcw-call-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700; font-size: 1rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff;
}
.rrcw-call-status {
  font-size: 0.78rem; color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
}
.rrcw-call-waves {
  display: flex; align-items: center; gap: 4px;
  height: 24px; margin: 4px 0;
}
.rrcw-call-waves span {
  width: 3px; border-radius: 3px;
  background: rgba(237,111,2,0.7);
  animation: rrcwWave 1.1s ease infinite;
}
.rrcw-call-waves span:nth-child(1) { animation-delay: 0s;    height: 8px; }
.rrcw-call-waves span:nth-child(2) { animation-delay: 0.15s; height: 16px; }
.rrcw-call-waves span:nth-child(3) { animation-delay: 0.3s;  height: 22px; }
.rrcw-call-waves span:nth-child(4) { animation-delay: 0.15s; height: 16px; }
.rrcw-call-waves span:nth-child(5) { animation-delay: 0s;    height: 8px; }
@keyframes rrcwWave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50%       { transform: scaleY(1);   opacity: 1; }
}
#rrcw-call-end {
  margin-top: 8px;
  display: flex; align-items: center; gap: 8px;
  background: #c0392b; color: #fff;
  border: none; border-radius: 24px; cursor: pointer;
  padding: 10px 22px; font-family: 'Barlow', sans-serif;
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.04em;
  transition: background 0.2s, transform 0.15s;
}
#rrcw-call-end:hover { background: #e74c3c; transform: scale(1.04); }
#rrcw-call-end svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Move scroll-to-top above chat button */
#scrollTop { bottom: 94px !important; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #rr-chat-widget { bottom: 20px; right: 16px; }
  #rrcw-panel { width: calc(100vw - 32px); right: 0; bottom: 62px; }
  #rrcw-messages { min-height: 220px; max-height: 260px; }
  #scrollTop { bottom: 84px !important; }
}

/* ── Light mode ── */
html[data-theme="light"] #rrcw-panel { background: #fff; border-color: rgba(0,0,0,0.09); box-shadow: 0 20px 60px rgba(0,0,0,0.12); }
html[data-theme="light"] #rrcw-header { background: #F5F4F2; border-color: rgba(0,0,0,0.08); }
html[data-theme="light"] .rrcw-name { color: #111; }
html[data-theme="light"] .rrcw-status { color: rgba(0,0,0,0.38); }
html[data-theme="light"] #rrcw-close { color: rgba(0,0,0,0.28); }
html[data-theme="light"] #rrcw-close:hover { color: #111; }
html[data-theme="light"] .rrcw-msg-assistant { background: #EEECE9; color: rgba(0,0,0,0.82); }
html[data-theme="light"] .rrcw-typing span { background: rgba(0,0,0,0.2); }
html[data-theme="light"] #rrcw-input-area { background: #F5F4F2; border-color: rgba(0,0,0,0.08); }
html[data-theme="light"] #rrcw-input { background: #fff; border-color: rgba(0,0,0,0.12); color: #111; }
html[data-theme="light"] #rrcw-input::placeholder { color: rgba(0,0,0,0.28); }
html[data-theme="light"] #rrcw-messages { scrollbar-color: rgba(0,0,0,0.08) transparent; }
