/* =========================
   RK FLOATING CHAT (UI ONLY)
   Bottom-right + no overlap with scroll-top
========================= */

/* Ensure scroll-top stays at the bottom */
#scroll-top {
  right: 18px;
  bottom: 18px;
  z-index: 9998;
  /* below chat */
}

/* Floating Chat Button (bottom-right, raised above scroll-top) */
.rk-chat-fab {
  position: fixed;
  right: 18px;
  bottom: 90px;
  /* raised to avoid overlap */
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  z-index: 9999;
  background: rgba(13, 110, 253, 0.95);
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;

  /* Important for ::before/::after positioning */
  position: fixed;
}

.rk-chat-fab:hover {
  background: rgba(13, 110, 253, 1);
}

.rk-chat-fab:active {
  transform: translateY(1px);
}

/* Backdrop */
.rk-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9997;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.rk-chat-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Chat Panel (opens above the buttons) */
.rk-chat-panel {
  position: fixed;
  right: 18px;
  bottom: 90px;
  /* align with chat button */
  width: 380px;
  max-width: calc(100vw - 36px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  z-index: 9998;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);

  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  display: flex;
  flex-direction: column;
}

.rk-chat-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.rk-chat-topbar {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rk-chat-sub {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

.rk-chat-actions {
  display: flex;
  gap: 6px;
}

.rk-chat-iconbtn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rk-chat-iconbtn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.rk-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rk-msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.rk-msg.user {
  align-self: flex-end;
  background: rgba(13, 110, 253, 0.12);
  border: 1px solid rgba(13, 110, 253, 0.18);
}

.rk-msg.bot {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.rk-chat-footer {
  padding: 10px;
  display: flex;
  gap: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.rk-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
}

.rk-chat-input:focus {
  border-color: rgba(13, 110, 253, 0.4);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.rk-chat-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: rgba(13, 110, 253, 0.95);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rk-chat-send:hover {
  background: rgba(13, 110, 253, 1);
}

.rk-chat-hint {
  padding: 8px 12px 12px 12px;
  font-size: 12px;
  opacity: 0.7;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
}

/* Base mobile layout */
@media (max-width: 480px) {
  .rk-chat-fab {
    right: 14px;
    bottom: 95px;
  }

  #scroll-top {
    right: 14px;
    bottom: 18px;
  }

  .rk-chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    height: 70vh;
    max-height: 70vh;
    border-radius: 16px;
    bottom: 95px;
  }
}

/* Hide the floating FAB when chat is open to avoid overlap */
body.rk-chat-open .rk-chat-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

/* =========================
   vRK Attention Booster (FAB Animation + Label)
   NOTE: Works on desktop AND mobile (lighter on mobile)
========================= */

#rkChatFab {
  /* Anchor pseudo-elements correctly */
  position: fixed;
  /* keep it fixed */
  overflow: visible;
  animation: rk-fab-float 2.6s ease-in-out infinite;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  backface-visibility: hidden;
}

#rkChatFab::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.25);
  z-index: -1;
  animation: rk-fab-ping 1.8s ease-out infinite;
  pointer-events: none;
}

#rkChatFab::after {
  content: "Ask Autumn ✨";
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  padding: 9px 12px;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  background: linear-gradient(110deg,
      rgba(13, 110, 253, 0.95),
      rgba(0, 180, 255, 0.90),
      rgba(13, 110, 253, 0.95));
  background-size: 200% 100%;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.20), 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
  white-space: nowrap;
  pointer-events: none;
  animation: rk-fab-shimmer 2.2s linear infinite;
}

/* Mobile: keep animation but reduce intensity + move label above */
@media (max-width: 480px) {
  #rkChatFab {
    animation: rk-fab-float 3.2s ease-in-out infinite;
  }

  #rkChatFab::before {
    inset: -8px;
    animation: rk-fab-ping 2.4s ease-out infinite;
  }

  #rkChatFab::after {
    display: block;
    right: 50%;
    top: -12px;
    transform: translate(50%, -100%);
    font-size: 12px;
    padding: 7px 10px;
    animation: rk-fab-shimmer 2.8s linear infinite;
  }
}

/* Respect accessibility: if user prefers reduced motion, stop animation */
@media (prefers-reduced-motion: reduce) {

  #rkChatFab,
  #rkChatFab::before,
  #rkChatFab::after {
    animation: none !important;
  }
}

@keyframes rk-fab-ping {
  0% {
    transform: scale(0.80);
    opacity: 0.0;
  }

  20% {
    opacity: 0.55;
  }

  100% {
    transform: scale(1.35);
    opacity: 0.0;
  }
}

@keyframes rk-fab-shimmer {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 200% 50%;
  }
}

@keyframes rk-fab-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}