/* ==========================================================================
   WIDGET CHAT ASISTEN — PT Bentang Pilar Nusantara
   Dimuat di semua halaman bersama style.css, jadi variabel warna situs
   (--brand-2, --ink, --line, dst.) sudah tersedia.
   Semua aturan diberi awalan .bpn-chat / .bpn-chat- agar tidak bertabrakan
   dengan gaya halaman.
   ========================================================================== */

.bpn-chat-tombol {
  position: fixed;
  right: 22px;
  bottom: 84px;                 /* bertumpuk di atas tombol WhatsApp */
  z-index: 71;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border: 0;
  border-radius: var(--radius-pill, 50px);
  background: #fff;
  color: var(--brand-ink, #0b7a5f);
  font: inherit;
  font-weight: 700;
  font-size: .9rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-card, 0 14px 34px rgba(9, 74, 52, .10));
  border: 1px solid var(--line, #e2eae5);
  transition: transform .18s ease, box-shadow .18s ease;
}
.bpn-chat-tombol:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(9, 74, 52, .18); }
.bpn-chat-tombol:focus-visible { outline: 3px solid #bfe6d5; outline-offset: 2px; }
.bpn-chat-tombol svg { width: 20px; height: 20px; flex: 0 0 auto; }
.bpn-chat-tombol[hidden] { display: none; }

/* ------------------------------------------------------------------- panel */
.bpn-chat {
  position: fixed;
  right: 22px;
  bottom: 148px;
  z-index: 72;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: min(700px, calc(100vh - 158px));
  max-height: calc(100vh - 158px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line, #e2eae5);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(9, 74, 52, .22);
  overflow: hidden;
  font-family: inherit;
  color: var(--ink, #232b28);
}
.bpn-chat[hidden] { display: none; }
/* Elemen yang disembunyikan lewat atribut `hidden` harus benar-benar hilang,
   meski aturan kelas di bawah menetapkan display: flex. */
.bpn-chat [hidden],
.bpn-chat[hidden],
.bpn-chat-tombol[hidden] { display: none !important; }

.bpn-chat__kepala {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--grad-header, linear-gradient(359.96deg, #229b70 .02%, #0f7a56 101.18%));
  color: #fff;
}
.bpn-chat__kepala strong { display: block; font-size: .98rem; }
.bpn-chat__kepala span { display: block; font-size: .76rem; opacity: .88; }
.bpn-chat__lambang {
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
}
.bpn-chat__lambang svg { width: 18px; height: 18px; }
.bpn-chat__tutup {
  margin-left: auto;
  width: 32px; height: 32px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 1.1rem; line-height: 1;
  cursor: pointer;
}
.bpn-chat__tutup:hover { background: rgba(255, 255, 255, .28); }

/* -------------------------------------------------------------- isi bergulir */
.bpn-chat__badan {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--brand-tint, #f1faf5);
}

.bpn-chat__alur { display: flex; flex-direction: column; gap: 10px; }

.bpn-pesan {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: .875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bpn-pesan--asisten {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line, #e2eae5);
  border-bottom-left-radius: 4px;
}
.bpn-pesan--pengunjung {
  align-self: flex-end;
  background: var(--brand-2, #12855f);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bpn-pesan--sistem {
  align-self: center;
  max-width: 100%;
  background: #eef5f1;
  color: var(--muted, #5b6f66);
  font-size: .76rem;
  text-align: center;
  border: 1px dashed var(--line, #e2eae5);
}
.bpn-pesan--galat {
  align-self: center;
  max-width: 100%;
  background: #fdecea;
  border: 1px solid #f3c3bd;
  color: #7a1c14;
  font-size: .8rem;
  text-align: center;
}
.bpn-pesan__meta {
  display: block;
  margin-top: 6px;
  font-size: .7rem;
  opacity: .72;
}

/* penanda asisten sedang menyusun jawaban */
.bpn-menyusun { display: inline-flex; gap: 4px; align-items: center; }
.bpn-menyusun i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted, #5b6f66); opacity: .5;
  animation: bpn-kedip 1.1s infinite ease-in-out;
}
.bpn-menyusun i:nth-child(2) { animation-delay: .18s; }
.bpn-menyusun i:nth-child(3) { animation-delay: .36s; }
@keyframes bpn-kedip { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

/* ------------------------------------------------------------- formulir data */
/* formulir panjang pada layar pendek: tombol utama tetap terlihat */
.bpn-chat__badan > .bpn-chat__formulir .bpn-btn {
  position: sticky;
  bottom: 0;
  z-index: 3;
  box-shadow: 0 -8px 8px -6px rgba(0, 0, 0, .05), 0 0 0 6px #fff;
}
.bpn-chat__badan > .bpn-chat__formulir { padding: 2px 0 4px; }
.bpn-chat__formulir { padding: 16px; }
.bpn-chat__formulir p.bpn-ajak {
  margin: 0 0 14px;
  font-size: .85rem;
  color: var(--muted, #5b6f66);
  line-height: 1.55;
}
.bpn-medan { margin-bottom: 9px; }
.bpn-medan label {
  display: block;
  margin-bottom: 3px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink, #232b28);
}
.bpn-medan label span { font-weight: 400; color: var(--muted, #5b6f66); }
.bpn-medan input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #c9d9d1;
  border-radius: 8px;
  font: inherit;
  font-size: .875rem;
  color: var(--ink, #232b28);
  background: #fff;
}
.bpn-medan input:focus { outline: 2px solid #bfe6d5; border-color: var(--brand-ink, #0b7a5f); }
.bpn-jebakan { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.bpn-setuju {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 4px 0 14px;
  font-size: .76rem;
  color: var(--muted, #5b6f66);
  line-height: 1.5;
}
.bpn-setuju input { margin-top: 3px; flex: 0 0 auto; width: auto; height: auto; }
.bpn-setuju span { flex: 1 1 auto; min-width: 0; }
.bpn-setuju a { color: var(--brand-ink, #0b7a5f); }

.bpn-btn {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--brand-2, #12855f);
  border-radius: 9px;
  background: var(--brand-2, #12855f);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: .875rem;
  cursor: pointer;
}
.bpn-btn:hover { background: var(--brand-ink, #0b7a5f); border-color: var(--brand-ink, #0b7a5f); }
.bpn-btn[disabled] { opacity: .6; cursor: default; }
.bpn-btn--putih {
  background: #fff;
  color: var(--brand-ink, #0b7a5f);
  border-color: var(--line, #e2eae5);
}
.bpn-btn--putih:hover { background: var(--brand-tint, #f1faf5); color: var(--brand-ink, #0b7a5f); border-color: var(--brand-2, #12855f); }

/* ------------------------------------------------------------- kotak menulis */
.bpn-chat__kirim {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line, #e2eae5);
  background: #fff;
}
.bpn-chat__kirim textarea {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #c9d9d1;
  border-radius: 9px;
  font: inherit;
  font-size: .875rem;
  resize: none;
  color: var(--ink, #232b28);
}
.bpn-chat__kirim textarea:focus { outline: 2px solid #bfe6d5; border-color: var(--brand-ink, #0b7a5f); }
.bpn-chat__kirim button {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: 0; border-radius: 9px;
  background: var(--brand-2, #12855f);
  color: #fff;
  cursor: pointer;
  display: grid; place-items: center;
}
.bpn-chat__kirim button:hover { background: var(--brand-ink, #0b7a5f); }
.bpn-chat__kirim button[disabled] { opacity: .5; cursor: default; }
.bpn-chat__kirim button svg { width: 18px; height: 18px; }

/* --------------------------------------------------------------------- kaki */
.bpn-chat__kaki {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  padding: 9px 12px;
  border-top: 1px solid var(--line, #e2eae5);
  background: #fbfdfc;
  color: var(--muted, #5b6f66);
}
/* keterangan kecil: satu baris penuh di atas tombol, jadi tidak berdesakan */
.bpn-chat__catatan {
  flex: 1 1 100%;
  font-size: .68rem;
  line-height: 1.4;
  opacity: .8;
}
.bpn-chat__aksi {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.bpn-chat__aksi a,
.bpn-chat__aksi button {
  padding: 5px 10px;
  border: 1px solid var(--line, #e2eae5);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-ink, #0b7a5f);
  font: inherit;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.bpn-chat__aksi a:hover,
.bpn-chat__aksi button:hover { border-color: var(--brand-2, #12855f); }
.bpn-chat__aksi button[hidden] { display: none; }

/* --------------------------------------------------------------- telepon genggam */
@media (max-width: 700px) {
  .bpn-chat-tombol { right: 16px; bottom: 78px; padding: 14px; }
  .bpn-chat-tombol span { display: none; }
  .bpn-chat {
    right: 12px;
    left: 12px;
    bottom: 138px;
    width: auto;
    max-width: none;
    height: min(70vh, calc(100vh - 160px));
  }
}

@media print { .bpn-chat, .bpn-chat-tombol { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .bpn-chat-tombol { transition: none; }
  .bpn-menyusun i { animation: none; opacity: .6; }
}
