/* =========================================================
   ASISTEN AI (chat konsultasi) — memakai variabel warna dari style.css
   ========================================================= */
.ai-launcher {
  position: fixed; right: 20px; bottom: 84px; z-index: 95;
  display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  padding: 12px 18px 12px 14px; border-radius: 99px;
  font-family: inherit; font-weight: 700; font-size: 14px; line-height: 1;
  color: #fff; background: linear-gradient(135deg, #2a77ff, #7c3aed);
  box-shadow: 0 10px 26px rgba(76, 81, 255, .4); transition: transform .2s, opacity .2s;
}
.ai-launcher:hover { transform: translateY(-3px); }
.ai-launcher__icon svg { width: 22px; height: 22px; fill: #fff; }
.ai-launcher::after {
  content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid rgba(124, 58, 237, .5);
  animation: aiPulse 2.4s ease-out infinite; pointer-events: none;
}
@keyframes aiPulse { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.25); } }
body.ai-chat-open .ai-launcher, body.ai-chat-open .wa-float { opacity: 0; visibility: hidden; }

.ai-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  width: 390px; height: min(620px, calc(100vh - 40px)); display: flex; flex-direction: column;
  background: #fff; border-radius: 20px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(15, 40, 100, .25);
  opacity: 0; transform: translateY(16px) scale(.98); transform-origin: bottom right; transition: opacity .25s, transform .25s;
}
.ai-chat.is-open .ai-panel { opacity: 1; transform: none; }
.ai-panel[hidden] { display: none; }

.ai-panel__head {
  display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 16px; color: #fff;
  background: linear-gradient(135deg, #1463ff, #6d3df2);
}
.ai-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.2); flex: none; }
.ai-avatar svg { width: 22px; height: 22px; fill: #fff; }
.ai-panel__title { flex: 1; min-width: 0; line-height: 1.3; }
.ai-panel__title b { display: block; font-size: 15px; }
.ai-panel__title small { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .3); }
.ai-icon-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.ai-icon-btn:hover { background: rgba(255,255,255,.15); }
.ai-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ai-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f5f8ff; overscroll-behavior: contain; }
.ai-msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; animation: aiIn .25s ease; }
@keyframes aiIn { from { opacity: 0; transform: translateY(6px); } }
.ai-msg p { margin: 0; }
.ai-msg p + p, .ai-msg ul + p, .ai-msg p + ul { margin-top: 8px; }
.ai-msg ul { margin: 0; padding-left: 18px; list-style: disc; }
.ai-msg li + li { margin-top: 3px; }
.ai-msg--bot { align-self: flex-start; background: #fff; color: #1e293b; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-msg--bot b { color: var(--blue-600); }
.ai-msg--user { align-self: flex-end; background: linear-gradient(135deg, #2a77ff, var(--blue-600)); color: #fff; border-bottom-right-radius: 4px; }
.ai-notice { align-self: stretch; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.5; color: #92400e; background: #fffbeb; border: 1px dashed #f59e0b; }
.ai-notice code { background: #fef3c7; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.ai-typing { display: flex; gap: 5px; padding: 14px 16px; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: aiDot 1.2s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.ai-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 12px; background: #f5f8ff; }
.ai-suggest[hidden] { display: none; }
.ai-suggest button {
  border: 1px solid var(--blue-100); background: #fff; color: var(--blue-600);
  padding: 8px 12px; border-radius: 99px; font-family: inherit; font-weight: 600; font-size: 12.5px; line-height: 1.2; cursor: pointer;
}
.ai-suggest button:hover { background: var(--blue-50); }

.ai-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.ai-input {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; max-height: 120px;
  font-family: inherit; font-size: 14.5px; line-height: 1.4; color: var(--ink); background: #f8faff; outline: none;
}
.ai-input:focus { border-color: var(--blue); background: #fff; }
.ai-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2a77ff, var(--blue-600)); }
.ai-send:disabled { opacity: .5; cursor: wait; }
.ai-send svg { width: 20px; height: 20px; fill: currentColor; }
.ai-wa { display: block; text-align: center; font-size: 12.5px; padding: 0 12px 12px; color: var(--text); background: #fff; }
.ai-wa b { color: #16a34a; }
.ai-wa:hover b { text-decoration: underline; }

/* Ajakan tanya AI di dalam halaman */
.ai-cta {
  display: flex; align-items: center; gap: 14px; margin-top: 28px; padding: 16px 18px; border-radius: 16px; width: 100%;
  background: linear-gradient(135deg, #eef4ff, #f3edff); border: 1px solid #dcd3ff; color: var(--ink); cursor: pointer; text-align: left;
  font-family: inherit; transition: transform .2s, box-shadow .2s;
}
.ai-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ai-cta .ai-avatar { background: linear-gradient(135deg, #2a77ff, #7c3aed); }
.ai-cta b { display: block; font-size: 14.5px; }
.ai-cta small { display: block; color: var(--text); font-size: 13px; }
.ai-cta .arrow { margin-left: auto; color: var(--blue); font-weight: 700; }

@media (max-width: 640px) {
  .ai-launcher { right: 14px; bottom: 76px; padding: 12px 16px 12px 12px; font-size: 13.5px; }
  .ai-panel { inset: 0; width: auto; height: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .ai-msg { max-width: 90%; }
  .ai-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .ai-launcher::after { animation: none; } }
