/* ===== RATU KARMEL CHATBOT — FLOATING FIX ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* FIX: Wrapper to escape overflow:hidden on body */
#rk-chat-root {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  z-index: 2147483647; /* max z-index possible */
  pointer-events: none;
}

#rk-launcher {
  pointer-events: all;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #1e5fa8, #2d8cff);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(30,95,168,0.55);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
}
#rk-launcher:hover { transform: scale(1.1); box-shadow: 0 10px 30px rgba(30,95,168,0.6); }
#rk-launcher svg { width: 28px; height: 28px; fill: white; }

#rk-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #ff4757;
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 19px; height: 19px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  animation: rk-pop 0.4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes rk-pop { from{transform:scale(0)} to{transform:scale(1)} }

#rk-window {
  pointer-events: all;
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 2147483646;
  width: 310px;
  height: 420px;
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  background: #f0f4f9;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 4px 20px rgba(0,0,0,0.1);
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(.4,0,.2,1), transform 0.3s cubic-bezier(.4,0,.2,1);
  /* Force stacking context */
  isolation: isolate;
  will-change: opacity, transform;
}
#rk-window.rk-hide {
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
}

/* HEADER */
#rk-header {
  background: linear-gradient(135deg, #1a4fa0 0%, #1e6fd4 60%, #2d8cff 100%);
  padding: 14px 14px 16px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
#rk-header::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,0.07);
}
.rk-hdr-top { display: flex; align-items: center; gap: 12px; position: relative; }
.rk-avatar-wrap { position: relative; }
.rk-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
}
.rk-avatar svg { width: 24px; height: 24px; fill: white; }
.rk-online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 11px; height: 11px; border-radius: 50%;
  background: #4ade80; border: 2px solid white;
  animation: rk-breathe 2.5s infinite;
}
@keyframes rk-breathe {
  0%,100%{box-shadow:0 0 0 0 rgba(74,222,128,0.5)}
  50%{box-shadow:0 0 0 5px rgba(74,222,128,0)}
}
.rk-hdr-info { flex: 1; }
.rk-hdr-name { font-size: 13.5px; font-weight: 700; color: white; letter-spacing: 0.2px; }
.rk-hdr-sub { font-size: 11px; color: rgba(255,255,255,0.8); margin-top: 2px; }
#rk-close {
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; transition: background 0.2s; flex-shrink: 0;
}
#rk-close:hover { background: rgba(255,255,255,0.3); }
.rk-hdr-tag {
  margin-top: 10px; position: relative;
  background: rgba(255,255,255,0.12); border-radius: 8px;
  padding: 7px 11px; font-size: 11.5px; color: rgba(255,255,255,0.92); line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.18);
}
.rk-hdr-tag strong { color: white; }

/* MESSAGES */
#rk-msgs {
  flex: 1; overflow-y: auto; padding: 12px 12px 6px;
  display: flex; flex-direction: column; gap: 8px; min-height: 0;
}
#rk-msgs::-webkit-scrollbar { width: 4px; }
#rk-msgs::-webkit-scrollbar-thumb { background: #c9d4e3; border-radius: 4px; }

.rk-msg { display: flex; gap: 8px; align-items: flex-end; animation: rk-slide-in 0.25s ease; }
.rk-msg.rk-u { flex-direction: row-reverse; }
@keyframes rk-slide-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.rk-av {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg,#1a4fa0,#2d8cff);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(30,95,168,0.3);
}
.rk-av svg { width: 15px; height: 15px; fill: white; }

.rk-bub {
  padding: 9px 13px; border-radius: 18px;
  font-size: 13px; line-height: 1.55;
  max-width: 230px; word-break: break-word;
}
.rk-msg.rk-b .rk-bub {
  background: white; color: #1e2d40;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.rk-msg.rk-u .rk-bub {
  background: linear-gradient(135deg,#1a4fa0,#2d8cff);
  color: white; border-bottom-right-radius: 5px;
  box-shadow: 0 3px 10px rgba(30,95,168,0.35);
}
.rk-time { font-size: 10px; color: #94a3b8; margin-top: 3px; text-align: right; }

/* TYPING */
.rk-typing-wrap { display: flex; gap: 8px; align-items: flex-end; }
.rk-typing-bub {
  background: white; border-radius: 20px; border-bottom-left-radius: 5px;
  padding: 14px 18px; display: flex; gap: 5px; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.rk-typing-bub span {
  width: 7px; height: 7px; border-radius: 50%; background: #93c5fd;
  animation: rk-dot 1.4s infinite;
}
.rk-typing-bub span:nth-child(2) { animation-delay: 0.2s; }
.rk-typing-bub span:nth-child(3) { animation-delay: 0.4s; }
@keyframes rk-dot {
  0%,80%,100%{transform:translateY(0);background:#93c5fd}
  40%{transform:translateY(-6px);background:#2d8cff}
}

/* QUICK REPLIES */
.rk-quick-wrap { display: flex; flex-wrap: wrap; gap: 7px; padding: 4px 0 6px; }
.rk-quick {
  background: white; border: 1.5px solid #bfdbfe; color: #1a4fa0;
  border-radius: 20px; padding: 5px 11px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.2s; white-space: nowrap;
}
.rk-quick:hover { background: #eff6ff; border-color: #2d8cff; transform: translateY(-1px); }

/* ESCALATION */
.rk-esc-card {
  background: linear-gradient(135deg,#f0f7ff,#e8f3ff);
  border: 1.5px solid #bfdbfe; border-radius: 16px;
  padding: 14px; margin-top: 8px;
}
.rk-esc-title { font-size: 11.5px; font-weight: 700; color: #1a4fa0; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }
.rk-esc-btns { display: flex; flex-direction: column; gap: 8px; }
.rk-esc-btn {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-radius: 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all 0.2s;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.rk-esc-btn:hover { transform: translateY(-2px); }
.rk-esc-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.rk-wa-btn { background: #dcfce7; color: #15803d; }
.rk-wa-btn:hover { background: #bbf7d0; box-shadow: 0 4px 12px rgba(21,128,61,0.2); }
.rk-live-btn { background: #dbeafe; color: #1d4ed8; }
.rk-live-btn:hover { background: #bfdbfe; box-shadow: 0 4px 12px rgba(29,78,216,0.2); }

/* INPUT AREA */
#rk-input-area {
  padding: 12px 14px 14px; flex-shrink: 0;
  background: white; border-top: 1px solid #e8eef6;
}
.rk-input-wrap {
  display: flex; gap: 8px; align-items: flex-end;
  background: #f0f4f9; border-radius: 24px; padding: 6px 6px 6px 16px;
  border: 1.5px solid #e2eaf5; transition: border-color 0.2s;
}
.rk-input-wrap:focus-within { border-color: #2d8cff; background: white; }
#rk-inp {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 13.5px; font-family: 'Plus Jakarta Sans', sans-serif;
  color: #1e2d40; resize: none; max-height: 88px; line-height: 1.5; padding: 4px 0;
}
#rk-inp::placeholder { color: #94a3b8; }
#rk-send {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg,#1a4fa0,#2d8cff);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s; box-shadow: 0 2px 8px rgba(30,95,168,0.3);
}
#rk-send:hover { transform: scale(1.08); box-shadow: 0 4px 12px rgba(30,95,168,0.4); }
#rk-send:active { transform: scale(0.93); }
#rk-send svg { width: 16px; height: 16px; fill: white; margin-left: 2px; }
.rk-powered { text-align: center; font-size: 10.5px; color: #94a3b8; margin-top: 7px; }

/* MENU KATEGORI */
.rk-menu-wrap {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 0 6px;
}
.rk-menu-btn {
  background: white;
  border: 1.5px solid #bfdbfe;
  color: #1a4fa0;
  border-radius: 14px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.18s;
  text-align: left;
  width: 100%;
}
.rk-menu-btn:hover {
  background: #eff6ff;
  border-color: #2d8cff;
  transform: translateX(3px);
}

/* RESPONSIVE MOBILE — chatbot tidak nutupin navbar */
@media (max-width: 600px) {
  #rk-window {
    width: calc(100vw - 12px) !important;
    right: 6px !important;
    left: 6px !important;
    bottom: 76px !important;
    height: auto !important;
    max-height: calc(100svh - 130px) !important;
    border-radius: 18px !important;
  }
  #rk-launcher {
    right: 16px !important;
    bottom: 16px !important;
    width: 50px !important;
    height: 50px !important;
  }
  .rk-bub {
    max-width: calc(100% - 8px) !important;
    font-size: 13px !important;
  }
  #rk-msgs {
    padding: 10px 10px 6px !important;
  }
  .rk-menu-btn {
    font-size: 12.5px;
    padding: 8px 12px;
  }
}

/* TOMBOL KEMBALI KE MENU */
.rk-back-btn {
  background: transparent;
  border: 1.5px solid #bfdbfe;
  color: #1a4fa0;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rk-back-btn:hover {
  background: #eff6ff;
  border-color: #2d8cff;
  color: #1a4fa0;
}
