/* ==========================================================================
   FRUITCITY AI Chat Widget
   Namespace: .fcai-*  (tidak bentrok dengan widget lama .fc-chatbot)
   ========================================================================== */

.fcai-root {
  --fcai-accent: #0071e3;
  --fcai-accent-dark: #0060c0;
  --fcai-ink: #1d1d1f;
  --fcai-muted: #6e6e73;
  --fcai-surface: #ffffff;
  --fcai-surface-alt: #f5f5f7;
  --fcai-border: #d2d2d7;
  --fcai-radius: 20px;
  --fcai-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2147482000;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fcai-ink);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.fcai-root *,
.fcai-root *::before,
.fcai-root *::after {
  box-sizing: border-box;
}

/* ---------- Launcher ---------- */

.fcai-launcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fcai-launcher {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--fcai-accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(0, 113, 227, 0.4);
  transition: transform 0.2s ease, background-color 0.2s ease;
  flex-shrink: 0;
}

/* Denyut lembut + goyangan ikon sesekali saat panel tertutup, supaya tombol
   chatbot mudah dinotice pengunjung tanpa mengganggu. */
.fcai-root:not(.fcai-root-open) .fcai-launcher {
  animation: fcai-pulse 2.8s ease-out infinite;
}

.fcai-root:not(.fcai-root-open) .fcai-launcher svg {
  animation: fcai-wiggle 7s ease-in-out 2s infinite;
}

@keyframes fcai-pulse {
  0% {
    box-shadow: 0 10px 28px rgba(0, 113, 227, 0.4), 0 0 0 0 rgba(0, 113, 227, 0.45);
  }
  60% {
    box-shadow: 0 10px 28px rgba(0, 113, 227, 0.4), 0 0 0 14px rgba(0, 113, 227, 0);
  }
  100% {
    box-shadow: 0 10px 28px rgba(0, 113, 227, 0.4), 0 0 0 0 rgba(0, 113, 227, 0);
  }
}

@keyframes fcai-wiggle {
  0%,
  86%,
  100% {
    transform: rotate(0deg);
  }
  88% {
    transform: rotate(-12deg);
  }
  91% {
    transform: rotate(10deg);
  }
  94% {
    transform: rotate(-6deg);
  }
  97% {
    transform: rotate(0deg);
  }
}

/* Gelembung ajakan di samping launcher */
.fcai-hint {
  border: 1px solid var(--fcai-border);
  background: var(--fcai-surface);
  border-radius: 16px;
  padding: 10px 14px;
  max-width: min(240px, calc(100vw - 130px));
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  animation: fcai-hint-in 0.4s ease 1s backwards;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fcai-hint:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.fcai-hint-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--fcai-ink);
}

.fcai-hint-text {
  font-size: 12px;
  color: var(--fcai-muted);
  line-height: 1.4;
}

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

/* Hint hilang saat panel terbuka, dan tidak muncul lagi setelah pengunjung
   pernah membuka chat di halaman ini. */
.fcai-root-open .fcai-hint,
.fcai-hint-done .fcai-hint {
  display: none;
}

.fcai-launcher:hover {
  background: var(--fcai-accent-dark);
  transform: scale(1.06);
}

.fcai-launcher:focus-visible {
  outline: 3px solid rgba(0, 113, 227, 0.45);
  outline-offset: 3px;
}

/* ---------- Panel ---------- */

/* Atribut hidden harus menang atas display:flex di bawah — ini yang membuat
   tombol close berfungsi. */
.fcai-panel[hidden] {
  display: none !important;
}

.fcai-panel {
  width: min(380px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 120px));
  background: var(--fcai-surface);
  border-radius: var(--fcai-radius);
  box-shadow: var(--fcai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fcai-pop 0.22s ease;
}

@keyframes fcai-pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Header ---------- */

.fcai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: var(--fcai-accent);
  color: #ffffff;
}

.fcai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fcai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.fcai-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fcai-subtitle {
  font-size: 12px;
  opacity: 0.85;
}

.fcai-close {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.fcai-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.fcai-close:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* ---------- Messages ---------- */

.fcai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--fcai-surface-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.fcai-msg {
  display: flex;
}

.fcai-msg-user {
  justify-content: flex-end;
}

.fcai-msg-bot {
  justify-content: flex-start;
}

.fcai-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Jawaban bot berisi daftar butuh ruang lebih lebar agar mudah dibaca. */
.fcai-msg-bot .fcai-bubble {
  max-width: 92%;
  padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fcai-msg-user .fcai-bubble {
  background: var(--fcai-accent);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.fcai-msg-bot .fcai-bubble {
  background: var(--fcai-surface);
  color: var(--fcai-ink);
  border: 1px solid var(--fcai-border);
  border-bottom-left-radius: 6px;
}

.fcai-bubble a {
  color: var(--fcai-accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(0, 113, 227, 0.35);
  text-underline-offset: 2px;
  /* Patah di spasi dulu ("Chat WhatsApp" tidak terpotong jadi "Chat Wha-
     tsApp"); URL mentah yang panjang tetap boleh dipatah paksa. */
  word-break: normal;
  overflow-wrap: anywhere;
}

.fcai-bubble a:hover {
  text-decoration-color: var(--fcai-accent);
}

.fcai-msg-user .fcai-bubble a {
  color: #ffffff;
}

/* ---------- Typing indicator ---------- */

.fcai-typing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-height: 20px;
}

.fcai-typing-text {
  font-size: 13.5px;
  color: var(--fcai-muted);
  line-height: 1.4;
}

.fcai-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fcai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fcai-muted);
  animation: fcai-bounce 1.2s infinite ease-in-out;
}

.fcai-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.fcai-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes fcai-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---------- WhatsApp hint ---------- */

.fcai-wa-hint {
  display: flex;
  justify-content: flex-start;
}

.fcai-wa-button {
  display: inline-block;
  background: #25d366;
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 980px;
  text-decoration: none;
  transition: filter 0.15s ease;
}

.fcai-wa-button:hover {
  filter: brightness(0.94);
}

/* ---------- Smart action buttons (di bawah jawaban bot) ---------- */

.fcai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -2px 0 2px 2px;
}

.fcai-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 980px;
  text-decoration: none;
  border: 1px solid var(--fcai-border);
  background: var(--fcai-surface);
  color: var(--fcai-ink);
  transition: filter 0.15s ease, background-color 0.15s ease;
}

.fcai-action:hover {
  filter: brightness(0.96);
}

.fcai-action-wa {
  background: #25d366;
  border-color: #25d366;
  color: #ffffff;
}

.fcai-action-tiket {
  background: var(--fcai-accent);
  border-color: var(--fcai-accent);
  color: #ffffff;
}

.fcai-action-maps {
  color: var(--fcai-accent);
  border-color: var(--fcai-accent);
}

.fcai-action-page {
  color: var(--fcai-accent);
}

/* ---------- Quick replies ---------- */

.fcai-quick {
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--fcai-surface);
  touch-action: pan-x;
  cursor: grab;
}

.fcai-quick:active {
  cursor: grabbing;
}

.fcai-quick::-webkit-scrollbar {
  display: none;
}

.fcai-chip {
  flex-shrink: 0;
  border: 1px solid var(--fcai-border);
  background: var(--fcai-surface);
  color: var(--fcai-accent);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 980px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.fcai-chip:hover {
  background: rgba(0, 113, 227, 0.08);
  border-color: var(--fcai-accent);
}

.fcai-chip:focus-visible {
  outline: 2px solid var(--fcai-accent);
  outline-offset: 2px;
}

/* ---------- Input ---------- */

.fcai-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--fcai-surface);
}

.fcai-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--fcai-border);
  border-radius: 18px;
  padding: 10px 14px;
  font: inherit;
  /* 16px minimum: font lebih kecil membuat iOS Safari auto-zoom saat input
     difokus, yang memicu overflow horizontal di HP. */
  font-size: 16px;
  color: var(--fcai-ink);
  background: var(--fcai-surface-alt);
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
}

.fcai-input:focus {
  border-color: var(--fcai-accent);
}

.fcai-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--fcai-accent);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.fcai-send:hover {
  background: var(--fcai-accent-dark);
}

.fcai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.fcai-send:focus-visible {
  outline: 2px solid var(--fcai-accent);
  outline-offset: 2px;
}

/* ---------- Disclaimer ---------- */

.fcai-disclaimer {
  padding: 0 14px 10px;
  font-size: 11px;
  color: var(--fcai-muted);
  text-align: center;
  background: var(--fcai-surface);
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
  .fcai-root {
    bottom: 16px;
    right: 16px;
  }

  /* Fullscreen dengan top/height eksplisit supaya JS bisa menyamakan tinggi
     panel dengan area yang terlihat saat keyboard HP muncul (visualViewport)
     — header tetap kelihatan dan tidak ada gap di tengah. */
  .fcai-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  /* Saat panel fullscreen, tombol launcher tidak boleh menumpuk di atas
     area ketik — tutup lewat tombol X di header. */
  .fcai-root-open .fcai-launcher-row {
    display: none;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .fcai-panel {
    animation: none;
  }

  .fcai-dot {
    animation: none;
    opacity: 0.7;
  }

  .fcai-launcher {
    transition: none;
  }

  .fcai-launcher:hover {
    transform: none;
  }

  .fcai-root:not(.fcai-root-open) .fcai-launcher,
  .fcai-root:not(.fcai-root-open) .fcai-launcher svg,
  .fcai-hint {
    animation: none;
  }
}

/* ---------- SVG Click Targeting Fix ---------- */
.fcai-launcher svg,
.fcai-close svg,
.fcai-send svg {
  pointer-events: none;
}

/* ---------- Structured Reply Formatting ---------- */
.fcai-p {
  margin: 0 0 8px 0;
}
.fcai-p:last-child {
  margin-bottom: 0;
}

/* Daftar premium: tiap item jadi baris kartu lembut dengan penanda warna,
   agar informasi panjang (wahana, cabang, jadwal) gampang dipindai. */
.fcai-list {
  list-style: none;
  margin: 6px 0 10px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fcai-list:last-child {
  margin-bottom: 0;
}
.fcai-list-item {
  position: relative;
  margin: 0;
  padding: 8px 12px 8px 30px;
  background: var(--fcai-surface-alt);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  line-height: 1.45;
  font-size: 14px;
}
.fcai-list-item::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fcai-accent), #34c759);
}
.fcai-item-label {
  font-weight: 700;
  color: var(--fcai-ink);
}
.fcai-item-note {
  color: var(--fcai-muted);
  font-size: 0.93em;
}

/* Logo partner di dalam jawaban bot: kotak seragam agar semua logo tampil
   sama besar walau rasio file aslinya berbeda. */
.fcai-inline-img {
  display: inline-block;
  height: 44px;
  width: 92px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--fcai-border);
  border-radius: 10px;
  padding: 6px 10px;
  margin: 4px 6px 2px 0;
  vertical-align: middle;
}

/* Foto orang (mis. /img/foto-ikbal.png): thumbnail kecil kotak yang pas di
   dalam bubble chat, bukan kotak logo yang melebar. */
.fcai-inline-photo {
  display: block;
  width: 96px;
  height: 96px;
  max-width: 100%;
  object-fit: cover;
  border-radius: 12px;
  margin: 6px 0 2px 0;
}

/* ---------- Disabled State for Quick Replies ---------- */
.fcai-quick-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Badge / Chip Styling ---------- */
.fcai-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 1px 3px;
  white-space: nowrap;
}
.fcai-badge-email {
  background-color: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #bbdefb;
}
.fcai-badge-price {
  background-color: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}
.fcai-badge-phone {
  background-color: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}



