/* ============================================================================
 * LIVE CHAT WIDGET — v4 (warna IKUT TEMA SITUS, dibuka dari tombol footer)
 * ----------------------------------------------------------------------------
 * - Semua warna pakai CSS var tema situs (--primary, --background, --base,
 *   --secondaryBackground, --separator, --caption) → otomatis ikut tema yang
 *   dipasang di Admin → Tema (gold-luxury = hitam + emas, midnight-blue, dll).
 * - Bubble mengambang DIHAPUS; widget dibuka lewat tombol "Live Chat" di
 *   footer (data-livechat="buka"). Panel tetap muncul dari kanan bawah.
 * ========================================================================== */

.lc-root,
.lc-root * {
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Paksa teks widget ikut warna sendiri — theme situs pakai `* { color: var(--base) }`
   yang bikin semua teks jadi cream/transparan. `color: inherit` menang lawan rule `*`
   karena specificity lebih tinggi (.lc-root * = 0,1,0 vs * = 0,0,0). */
.lc-root * {
  color: inherit;
}

.lc-root {
  /* ---- Warna ngikut tema situs (fallback = tema gold-luxury) ---- */
  --lc-primary: var(--primary, #eab308);
  --lc-primary-2: var(--emas-terang, #fde047);
  --lc-bg: var(--secondaryBackground, #1d1a10);
  --lc-bg-soft: var(--background, #12100a);
  --lc-teks: var(--base, #fefce8);
  --lc-teks-2: var(--caption, #b8a877);
  --lc-garis: var(--separator, #3d3520);
  --lc-masuk: var(--secondaryBackground, #1d1a10);
  --lc-masuk-teks: var(--base, #fefce8);
  --lc-keluar: var(--primary, #eab308);
  --lc-keluar-teks: var(--background, #12100a); /* teks gelap di atas warna primary */
  --lc-sistem: rgba(127, 127, 127, .16);
  --lc-sistem-teks: var(--caption, #b8a877);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-size: 14px;
  line-height: 1.45;
  color: var(--lc-teks);
}

/* ---------------- Bubble (tidak dipakai lagi — dibuka dari tombol footer) --- */
.lc-bubble { display: none !important; }

/* ---------------- Panel ---------------- */
.lc-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--lc-bg);
  border: 1px solid var(--lc-garis);
  border-radius: 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}
.lc-root.lc-buka .lc-panel { display: flex; animation: lc-muncul .22s ease; }
@keyframes lc-muncul {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Header ---------------- */
.lc-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-2));
  color: var(--lc-keluar-teks);
  flex-shrink: 0;
}
.lc-head-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.lc-head-avatar svg { width: 22px; height: 22px; }
.lc-head-avatar::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--lc-primary);
}
.lc-head-info { flex: 1; min-width: 0; }
.lc-head-judul { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-head-status { font-size: 12px; opacity: .92; display: flex; align-items: center; gap: 5px; margin-top: 1px; }
.lc-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; flex-shrink: 0; }
.lc-head-status.lc-off .lc-dot { background: #fbbf24; }
.lc-head-aksi { display: flex; gap: 4px; }
.lc-btn-ikon {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: rgba(0, 0, 0, .14);
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
  padding: 0;
}
.lc-btn-ikon:hover { background: rgba(0, 0, 0, .26); }
.lc-btn-ikon svg { width: 16px; height: 16px; }

/* ---------------- Body ---------------- */
.lc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--lc-bg-soft);
}

/* ---------------- Form pra-chat ---------------- */
.lc-pra {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: none;
  flex-direction: column;
}
.lc-pra-ikon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-2));
  color: var(--lc-keluar-teks);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 12px;
}
.lc-pra-ikon svg { width: 28px; height: 28px; }
.lc-pra-judul { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 6px; color: var(--lc-teks); }
.lc-pra-teks { font-size: 13px; color: var(--lc-teks-2); text-align: center; margin-bottom: 18px; }

.lc-pra-label { font-size: 12.5px; font-weight: 600; margin: 0 0 7px; display: block; color: var(--lc-teks); }
.lc-topik { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.lc-topik-item {
  border: 1.5px solid var(--lc-garis);
  background: var(--lc-bg);
  color: var(--lc-teks);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .14s ease;
  font-family: inherit;
}
.lc-topik-item:hover { border-color: var(--lc-primary); color: var(--lc-primary); }
.lc-topik-item.aktif { background: var(--lc-primary); border-color: var(--lc-primary); color: var(--lc-keluar-teks); }

.lc-pra-input {
  width: 100%;
  border: 1.5px solid var(--lc-garis);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  background: var(--lc-bg);
  color: var(--lc-teks);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  font-family: inherit;
}
.lc-pra-input:focus { border-color: var(--lc-primary); box-shadow: 0 0 0 3px rgba(127, 127, 127, .22); }
.lc-pra-input::placeholder { color: var(--lc-teks-2); }

.lc-pra-btn {
  width: 100%;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-2));
  color: var(--lc-keluar-teks);
  font-size: 14.5px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity .15s ease, transform .15s ease;
  font-family: inherit;
}
.lc-pra-btn:hover { opacity: .93; }
.lc-pra-btn:active { transform: scale(.985); }
.lc-pra-btn:disabled { opacity: .6; cursor: default; }
.lc-pra-err { color: #ef4444; font-size: 12.5px; margin-top: 9px; text-align: center; min-height: 16px; }
.lc-pra-kecil { font-size: 11px; color: var(--lc-teks-2); text-align: center; margin-top: 14px; }

/* ---------------- Area pesan ---------------- */
.lc-pesan {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.lc-pesan::-webkit-scrollbar { width: 5px; }
.lc-pesan::-webkit-scrollbar-thumb { background: var(--lc-garis); border-radius: 3px; }

.lc-baris { display: flex; }
.lc-baris.lc-masuk { justify-content: flex-start; }
.lc-baris.lc-keluar { justify-content: flex-end; }
.lc-baris.lc-sistem { justify-content: center; }

.lc-chip {
  background: var(--lc-sistem);
  color: var(--lc-sistem-teks);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 12px;
  text-align: center;
  max-width: 88%;
  line-height: 1.4;
}

.lc-balon {
  max-width: 78%;
  border-radius: 15px;
  padding: 9px 13px 7px;
  font-size: 14px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.lc-masuk .lc-balon { background: var(--lc-masuk); color: var(--lc-masuk-teks); border-bottom-left-radius: 5px; border: 1px solid var(--lc-garis); }
.lc-keluar .lc-balon { background: var(--lc-keluar); color: var(--lc-keluar-teks); border-bottom-right-radius: 5px; }

.lc-nama-agen { font-size: 11px; font-weight: 700; color: var(--lc-primary); margin-bottom: 2px; }
.lc-waktu { font-size: 10.5px; opacity: .62; margin-top: 3px; text-align: right; display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.lc-keluar .lc-waktu { color: rgba(0, 0, 0, .6); }
.lc-read { font-size: 11px; letter-spacing: -1px; }
.lc-read.lc-dibaca { color: #16a34a; }

.lc-gambar {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
  margin: 2px 0 3px;
  cursor: pointer;
  object-fit: cover;
}

.lc-baris.lc-kirim .lc-balon { opacity: .65; }
.lc-baris.lc-gagal .lc-balon { background: #fee2e2 !important; color: #991b1b !important; }

/* Indikator mengetik */
.lc-typing {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--lc-teks-2);
  padding: 2px 6px 8px;
}
.lc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lc-teks-2);
  animation: lc-ketik 1.2s infinite;
}
.lc-typing span:nth-child(2) { animation-delay: .18s; }
.lc-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes lc-ketik {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------- Rating ---------------- */
.lc-nilai {
  display: none;
  margin: 0 14px 12px;
  background: var(--lc-bg);
  border: 1px solid var(--lc-garis);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
.lc-nilai-judul { font-size: 13.5px; font-weight: 700; margin-bottom: 9px; color: var(--lc-teks); }
.lc-nilai-bintang { display: flex; justify-content: center; gap: 6px; }
.lc-nilai-bintang button {
  border: 0;
  background: transparent;
  font-size: 27px;
  color: var(--lc-garis);
  cursor: pointer;
  padding: 0 2px;
  transition: transform .12s ease, color .12s ease;
  font-family: inherit;
}
.lc-nilai-bintang button:hover { transform: scale(1.2); color: var(--lc-primary); }

/* ---------------- Notis (sesi ditutup) ---------------- */
.lc-notis {
  display: none;
  align-items: center;
  gap: 9px;
  margin: 0 14px 8px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(127, 127, 127, .16);
  color: var(--lc-primary);
  font-size: 12.5px;
  line-height: 1.35;
}
.lc-notis-btn {
  border: 0;
  background: var(--lc-primary);
  color: var(--lc-keluar-teks);
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
}

/* ---------------- Kaki / input ---------------- */
.lc-kaki { flex-shrink: 0; padding: 0 12px 10px; background: var(--lc-bg); border-top: 1px solid var(--lc-garis); }

.lc-prev {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 10px 2px 0;
  padding: 8px 10px;
  border: 1.5px solid var(--lc-garis);
  border-radius: 11px;
  background: var(--lc-bg-soft);
}
.lc-prev-img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }
.lc-prev-info { flex: 1; min-width: 0; }
.lc-prev-nama { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--lc-teks); }
.lc-prev-ukuran { font-size: 11px; color: var(--lc-teks-2); }
.lc-prev-x {
  border: 0;
  background: #ef4444;
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  font-family: inherit;
}

.lc-input-baris {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-top: 10px;
}
.lc-btn-upload {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1.5px solid var(--lc-garis);
  border-radius: 11px;
  background: var(--lc-bg);
  color: var(--lc-teks-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  padding: 0;
}
.lc-btn-upload:hover { border-color: var(--lc-primary); color: var(--lc-primary); }
.lc-btn-upload svg { width: 19px; height: 19px; }

.lc-input {
  flex: 1;
  border: 1.5px solid var(--lc-garis);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 14px;
  resize: none;
  max-height: 110px;
  outline: none;
  background: var(--lc-bg);
  color: var(--lc-teks);
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .15s ease;
}
.lc-input:focus { border-color: var(--lc-primary); }
.lc-input::placeholder { color: var(--lc-teks-2); }

.lc-btn-kirim {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-2));
  color: var(--lc-keluar-teks);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s ease, transform .12s ease;
  padding: 0;
}
.lc-btn-kirim:hover { opacity: .92; }
.lc-btn-kirim:active { transform: scale(.94); }
.lc-btn-kirim:disabled { opacity: .5; cursor: default; }
.lc-btn-kirim svg { width: 18px; height: 18px; }

.lc-akhiri {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--lc-teks-2);
  font-size: 12px;
  cursor: pointer;
  padding: 9px 0 2px;
  text-align: center;
  font-family: inherit;
  transition: color .15s ease;
}
.lc-akhiri:hover { color: #ef4444; text-decoration: underline; }

.lc-footer-teks {
  text-align: center;
  font-size: 10.5px;
  color: var(--lc-teks-2);
  padding: 5px 0 1px;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 480px) {
  .lc-root { right: 14px; bottom: 14px; }
  .lc-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }
}

/* ---------------- Layar pendek (viewport height kecil) ---------------- */
@media (max-height: 640px) {
  .lc-panel {
    bottom: 0;
    height: calc(100vh - 90px);
    max-height: calc(100vh - 90px);
  }
  .lc-pra { padding: 14px 16px; }
  .lc-pra-ikon { width: 42px; height: 42px; margin: 0 auto 8px; }
  .lc-pra-ikon svg { width: 22px; height: 22px; }
  .lc-pra-judul { font-size: 16px; margin-bottom: 4px; }
  .lc-pra-teks { font-size: 12px; margin-bottom: 12px; }
  .lc-topik { gap: 6px; margin-bottom: 12px; }
  .lc-topik-item { padding: 6px 11px; font-size: 12px; }
  .lc-pra-kecil { margin-top: 10px; }
}
