/* ═══════════════════════════════════════════════════════════════
   ANAKKU GROUP — AI ASSISTANT "ANA"
   Floating chat widget: pojok kanan bawah
   ═══════════════════════════════════════════════════════════════ */

/* ── Container ────────────────────────────────────────────────── */
#ai-assistant {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  font-family: "Plus Jakarta Sans", "Avenir Next", -apple-system, sans-serif;
  font-size: 14px;
}

/* ── Floating Button ──────────────────────────────────────────── */
#ai-fab {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1b6546 0%, #2d9b6e 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(27, 101, 70, 0.55), 0 2px 8px rgba(0,0,0,0.18);
  animation: ai-float 3.2s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  margin-left: auto;
}

#ai-fab:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 14px 36px rgba(27, 101, 70, 0.65), 0 4px 12px rgba(0,0,0,0.2);
}

#ai-fab:active { transform: scale(0.96); }

/* Animasi float naik-turun */
@keyframes ai-float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* Badge notifikasi */
#ai-fab .ai-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid white;
  animation: ai-pulse 1.8s ease-in-out infinite;
}

@keyframes ai-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(1.3); opacity: 0.7; }
}

/* SVG karakter di dalam FAB */
#ai-fab svg.ai-char {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

/* ── Chat Window ──────────────────────────────────────────────── */
#ai-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(14, 46, 32, 0.18), 0 4px 16px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.2,0.8,0.2,1), opacity 0.25s ease;
}

#ai-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.ai-header {
  background: linear-gradient(135deg, #1b6546 0%, #2a8a60 100%);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ai-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-header-avatar svg { width: 28px; height: 28px; }

.ai-header-info { flex: 1; min-width: 0; }
.ai-header-info strong { display: block; font-size: 15px; font-weight: 700; }
.ai-header-info span { font-size: 11px; opacity: 0.82; }

.ai-online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6effa8;
  box-shadow: 0 0 6px #6effa8;
  flex-shrink: 0;
}

.ai-close-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  color: white;
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}
.ai-close-btn:hover { background: rgba(255,255,255,0.3); }

/* Messages area */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: #dfe7df; border-radius: 4px; }

/* Bubble messages */
.ai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
  animation: ai-msg-in 0.22s cubic-bezier(0.2,0.8,0.2,1);
}

@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg.bot  { align-self: flex-start; }

.ai-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg,#1b6546,#2d9b6e);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ai-msg-avatar svg { width: 18px; height: 18px; }

.ai-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}

.ai-msg.bot .ai-bubble {
  background: #f0f6ed;
  color: #183b2e;
  border-radius: 4px 16px 16px 16px;
}

.ai-msg.user .ai-bubble {
  background: linear-gradient(135deg,#1b6546,#2d9b6e);
  color: white;
  border-radius: 16px 4px 16px 16px;
}

/* Quick replies */
.ai-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.ai-qr {
  background: #edf5ed;
  border: 1px solid #b8d8c2;
  color: #1b6546;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.ai-qr:hover {
  background: #1b6546;
  color: white;
  border-color: #1b6546;
  transform: translateY(-1px);
}

/* Typing indicator */
.ai-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: #f0f6ed;
  border-radius: 4px 16px 16px 16px;
}

.ai-typing span {
  width: 7px; height: 7px;
  background: #5a9e78;
  border-radius: 50%;
  animation: ai-bounce 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-6px); }
}

/* Action link dalam bubble */
.ai-action-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  background: #1b6546;
  color: white;
  font-size: 12px;
  font-weight: 650;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s;
}
.ai-action-link:hover { background: #143f30; }

/* Input area */
.ai-input-area {
  padding: 12px 14px;
  border-top: 1px solid #edf5ed;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  background: #fdfdf9;
}

#ai-input {
  flex: 1;
  border: 1px solid #dfe7df;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: white;
  color: #183b2e;
  transition: border-color 0.15s;
  resize: none;
  min-width: 0;
}

#ai-input:focus { border-color: #1b6546; }
#ai-input::placeholder { color: #a0b5a5; }

#ai-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg,#1b6546,#2d9b6e);
  border: none;
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}
#ai-send:hover { transform: scale(1.08); background: #143f30; }
#ai-send svg { width: 18px; height: 18px; }

/* Mobile responsive */
@media (max-width: 480px) {
  #ai-assistant { bottom: 18px; right: 14px; }
  #ai-fab { width: 56px; height: 56px; }
  #ai-window { width: calc(100vw - 28px); right: 0; bottom: 68px; max-height: 430px; }
}
