/**
 * Whatsapp Plugin Marketing — tampilan widget.
 * Warna diambil dari variabel --wpm-bg / --wpm-teks yang disuntik dari pengaturan.
 * Semua kelas diawali .wpm supaya tidak bentrok dengan tema.
 */

.wpm {
  position: fixed;
  z-index: 99999;
  bottom: var(--wpm-y, 12px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
.wpm--kanan { right: var(--wpm-x, 12px); }
.wpm--kiri  { left:  var(--wpm-x, 12px); }

/* ---------- tombol mengambang ---------- */
.wpm__tombol {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  padding: 11px 19px;
  border: 0;
  border-radius: 999px;
  background: var(--wpm-bg, #22c15e);
  color: var(--wpm-teks, #fff);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  transition: transform .18s ease, box-shadow .18s ease;
}
.wpm--kiri .wpm__tombol { margin-left: 0; margin-right: auto; }
.wpm__tombol:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .22); }
.wpm__tombol:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.wpm__tombol svg { width: 21px; height: 21px; flex: none; }

/* ---------- panel ---------- */
.wpm__panel {
  width: 330px;
  max-width: calc(100vw - 24px);
  margin-bottom: 12px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.wpm--kiri .wpm__panel { transform-origin: bottom left; }
.wpm.is-buka .wpm__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.wpm__head {
  position: relative;
  padding: 18px 44px 18px 18px;
  background: var(--wpm-bg, #22c15e);
  color: var(--wpm-teks, #fff);
}
.wpm__sambutan { font-size: 15px; font-weight: 600; }
.wpm__tutup {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.wpm__tutup:hover { background: rgba(255, 255, 255, .35); }

.wpm__body { padding: 14px; }
.wpm__tentang {
  margin: 0 0 12px;
  color: #5b6b7a;
  font-size: 13px;
}

/* Atribut hidden harus menang atas display di bawah.
   .wpm__agen-list punya display:flex, dan itu mengalahkan display:none bawaan
   [hidden] dari stylesheet browser — tanpa baris ini daftar agen dan form
   tampil bersamaan walau JS sudah menyetel .hidden = true. */
.wpm [hidden] { display: none !important; }

/* ---------- daftar agen ---------- */
.wpm__agen-list { display: flex; flex-direction: column; gap: 8px; }
.wpm__agen {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px;
  border: 1px solid #e8edf2;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.wpm__agen:hover { border-color: var(--wpm-bg, #22c15e); background: #f7fbf9; }
.wpm__agen:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 1px; }

.wpm__ava { position: relative; flex: none; }
.wpm__ava img,
.wpm__ava-huruf {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: #e9f7ef;
  color: #15803d;
  font-size: 19px;
  font-weight: 700;
  text-transform: uppercase;
}
.wpm__titik {
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
}
.wpm__titik.is-on  { background: #22c15e; }
.wpm__titik.is-off { background: #b4bcc4; }

.wpm__agen-info { display: flex; flex-direction: column; min-width: 0; }
.wpm__agen-jabatan { color: #8794a1; font-size: 11px; }
.wpm__agen-nama { color: #16202a; font-size: 14px; font-weight: 600; }
.wpm__agen-status { font-size: 11px; }
.wpm__agen-status.is-on  { color: #16a34a; }
.wpm__agen-status.is-off { color: #94a3b0; }

/* ---------- form ---------- */
.wpm__kembali {
  margin-bottom: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: #5b6b7a;
  font-size: 12px;
  cursor: pointer;
}
.wpm__kembali:hover { color: #16202a; }

.wpm__form-agen {
  margin-bottom: 10px;
  color: #16202a;
  font-size: 13px;
  font-weight: 600;
}

.wpm__input {
  display: block;
  width: 100%;
  margin-bottom: 9px;
  padding: 10px 12px;
  border: 1px solid #dde4ea;
  border-radius: 10px;
  background: #fff;
  color: #16202a;
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.wpm__input:focus {
  border-color: var(--wpm-bg, #22c15e);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(34, 193, 94, .18);
}
.wpm__textarea { resize: vertical; min-height: 68px; }
.wpm__input.is-galat { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .14); }

.wpm__galat { margin: 0 0 9px; color: #dc2626; font-size: 12px; }

.wpm__kirim {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--wpm-bg, #22c15e);
  color: var(--wpm-teks, #fff);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.wpm__kirim:hover { filter: brightness(1.06); }
.wpm__kirim svg { width: 17px; height: 17px; }

@media (max-width: 480px) {
  .wpm__panel { width: calc(100vw - 24px); }
  .wpm__tombol-teks { display: none; }
  .wpm__tombol { padding: 14px; }
  .wpm__tombol svg { width: 24px; height: 24px; }
}

/* Hormati preferensi pengguna yang mematikan animasi. */
@media (prefers-reduced-motion: reduce) {
  .wpm__panel, .wpm__tombol { transition: none; }
}
