/* ============================================================
   BlueBot Chatbot — Modern UI v2.0
   Dream Blue Library
   ============================================================ */

/* --- Floating Button --- */
.chatbot-toggler {
  position: relative;
  outline: none;
  border: none;
  height: 72px;
  width: 72px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}
.chatbot-toggler:hover {
  transform: scale(1.12);
}
.chatbot-toggler * {
  pointer-events: none;
}
.chatbot-toggler i {
  font-size: 1.4rem;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

/* --- Tooltip --- */
.chatbot-tooltip {
  position: absolute;
  bottom: 82px;
  right: 8px;
  background: #fff;
  padding: 9px 14px;
  border-radius: 16px 16px 0 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  font-size: 0.83rem;
  font-weight: 600;
  color: #1e3a8a;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  z-index: 100;
  border: 1px solid #e2e8f0;
}
.chatbot-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.chatbot-tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 14px;
  width: 9px;
  height: 9px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  transform: rotate(45deg);
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 24px;
  right: 108px;
  width: 370px;
  max-height: 600px;          /* ← KUNCI: window tidak pernah melebihi ini */
  background: #f1f5f9;
  border-radius: 24px;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.14),
    0 0 0 1px rgba(203, 213, 225, 0.5);
  overflow: hidden;            /* ← clip konten di luar batas */
  transform: scale(0.4) translateY(60px);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: all 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  display: flex;
  flex-direction: column;      /* ← header/chatbox/input susun vertikal */
}
.chatbot-window.active {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* --- Header --- */
.chatbot-header {
  background: linear-gradient(135deg, var(--clr-blue-2, #1e285d) 0%, var(--clr-blue-1, #273374) 100%);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.chatbot-header::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}
.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chatbot-header-avatar {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
  overflow: hidden;
}
.chatbot-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.chatbot-header-text h3 {
  margin: 0 0 3px 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.chatbot-header-text .bot-status {
  font-size: 0.72rem;
  color: #bae6fd;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.bot-status::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}
.close-btn {
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  font-size: 1rem;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.close-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: rotate(90deg);
}

/* --- Chatbox --- */
.chatbox {
  padding: 20px 16px;
  overflow-y: auto;            /* ← HANYA chatbox yang scroll */
  min-height: 0;               /* ← PENTING: izinkan flex child menyusut */
  flex: 1;                     /* ← ambil sisa ruang, tidak lebih */
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f1f5f9;
}
.chatbox::-webkit-scrollbar {
  width: 4px;
}
.chatbox::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* --- Messages --- */
.chat-msg {
  display: flex;
  gap: 9px;
  max-width: 90%;
  align-items: flex-end;
  animation: msg-in 0.3s ease both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.bot {
  align-self: flex-start;
}
.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg-time {
  font-size: 0.62rem;
  color: #94a3b8;
  padding: 0 4px;
  font-weight: 500;
}
.chat-msg.bot .msg-time { align-self: flex-start; }
.chat-msg.user .msg-time { align-self: flex-end; }
.msg-avatar {
  width: 30px;
  height: 30px;
  background: #e0f2fe;
  color: #1e3a8a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-msg.user .msg-avatar {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
}
.msg-text {
  background: #fff;
  padding: 12px 16px;
  border-radius: 4px 18px 18px 18px;
  font-size: 0.9rem;
  color: #1e293b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  line-height: 1.55;
}
.msg-text a {
  color: #2563eb;
  font-weight: 600;
}
.chat-msg.user .msg-text {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3);
}
.chat-msg.user .msg-text a { color: #bfdbfe; }

/* AI badge */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: #7c3aed;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 20px;
  padding: 2px 8px;
  margin-top: 4px;
  font-weight: 600;
}

/* --- Typing Indicator --- */
.typing-bg {
  background: #e8ecf0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 14px 18px !important;
  border-radius: 4px 18px 18px 18px !important;
}
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 12px;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bounce 1.3s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0) scale(0.8); }
  40%            { transform: translateY(-6px) scale(1); }
}

/* --- Quick Replies --- */
.quick-replies-container {
  background: #fff;
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.quick-replies-label {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.quick-replies {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.quick-replies::-webkit-scrollbar { display: none; }
.quick-reply-btn {
  background: rgba(39, 51, 116, 0.06);
  color: var(--clr-blue-1, #273374);
  border: 1.5px solid rgba(39, 51, 116, 0.15);
  padding: 7px 13px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.quick-reply-btn:hover {
  background: var(--clr-yellow-1, #e9be2b);
  color: var(--clr-blue-1, #273374);
  border-color: var(--clr-yellow-2, #cfa823);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(233, 190, 43, 0.25);
}

/* --- Input Area --- */
.chat-input {
  display: flex;
  align-items: center;
  padding: 12px 16px 16px;
  background: #fff;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  padding: 11px 16px;
  border-radius: 22px;
  outline: none;
  font-size: 0.9rem;
  color: #1e293b;
  transition: all 0.25s;
  font-family: inherit;
}
.chat-input input::placeholder { color: #94a3b8; }
.chat-input input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.chat-input button {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.3);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}
.chat-input button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.4);
}
.chat-input button:active {
  transform: scale(0.95);
}

/* AI thinking state */
.chat-input button.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 500px) {
  .chatbot-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 88px;
    border-radius: 20px;
  }
}
