/* ==========================================================================
   Live Chat AI - PT Riau Petroleum Mahato
   Mengikuti sistem warna beranda: navy / gold / emerald.
   Semua kelas berawalan .rpm-chat supaya tidak bentrok dengan Bootstrap.
   ========================================================================== */

.rpm-chat {
  --chat-navy:        #0a1a2f;
  --chat-navy-terang: #12304f;
  --chat-gold:        #c9a227;
  --chat-emerald:     #0f6b4f;
  --chat-kertas:      #f7f8fa;
  --chat-garis:       rgba(201, 162, 39, .28);
  --chat-teks:        #16232f;
  --chat-redup:       #6b7785;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1080;
  font-family: inherit;
}

/* --- Tombol pemicu ------------------------------------------------------- */

.rpm-chat__tombol {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-navy);
  box-shadow: 0 10px 28px rgba(10, 26, 47, .34);
  color: var(--chat-gold);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}

.rpm-chat__tombol:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(10, 26, 47, .42); }
.rpm-chat__tombol:focus-visible { outline: 3px solid var(--chat-gold); outline-offset: 3px; }

/* Garis emas tipis mengelilingi tombol: penanda identitas, bukan hiasan acak. */
.rpm-chat__tombol::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--chat-garis);
  border-radius: 50%;
  pointer-events: none;
}

.rpm-chat__ikon { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rpm-chat__ikon--tutup { display: none; }
.rpm-chat.is-buka .rpm-chat__ikon--buka  { display: none; }
.rpm-chat.is-buka .rpm-chat__ikon--tutup { display: block; }

/* --- Panel --------------------------------------------------------------- */

.rpm-chat__panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 366px;
  max-height: min(560px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  background: var(--chat-kertas);
  border: 1px solid var(--chat-garis);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(10, 26, 47, .3);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .22s ease, transform .22s ease;
}

.rpm-chat__panel[hidden] { display: none; }
.rpm-chat.is-buka .rpm-chat__panel { opacity: 1; transform: none; }

/* --- Kepala -------------------------------------------------------------- */

.rpm-chat__kepala {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--chat-navy) 0%, var(--chat-navy-terang) 100%);
  border-bottom: 1px solid var(--chat-gold);
}

.rpm-chat__eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--chat-gold);
}

.rpm-chat__judul { margin: 0; font-size: 15px; font-weight: 600; color: #fff; line-height: 1.25; }

.rpm-chat__tutup {
  width: 30px; height: 30px;
  border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.rpm-chat__tutup svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.rpm-chat__tutup:hover { background: rgba(255, 255, 255, .2); }
.rpm-chat__tutup:focus-visible { outline: 2px solid var(--chat-gold); outline-offset: 2px; }

/* --- Isi percakapan ------------------------------------------------------ */

.rpm-chat__isi {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.rpm-chat__gelembung {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: 12px;
  word-wrap: break-word;
}

.rpm-chat__gelembung--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--chat-teks);
  border: 1px solid rgba(10, 26, 47, .1);
  border-left: 2px solid var(--chat-gold);
}

.rpm-chat__gelembung--saya {
  align-self: flex-end;
  background: var(--chat-navy);
  color: #fff;
}

.rpm-chat__gelembung a { color: var(--chat-emerald); font-weight: 600; }
.rpm-chat__gelembung--saya a { color: var(--chat-gold); }

/* --- Kartu alih ke manusia ----------------------------------------------- */

.rpm-chat__alih {
  align-self: flex-start;
  max-width: 84%;
  padding: 12px 13px;
  border: 1px solid var(--chat-garis);
  border-radius: 12px;
  background: rgba(15, 107, 79, .06);
  font-size: 13px;
  line-height: 1.5;
  color: var(--chat-teks);
}

.rpm-chat__alih a {
  display: inline-block;
  margin-top: 8px;
  padding: 7px 14px;
  background: var(--chat-emerald);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.rpm-chat__alih a:hover { background: #0c5940; color: #fff; }

/* --- Pintasan ------------------------------------------------------------ */

.rpm-chat__pintasan { display: flex; flex-wrap: wrap; gap: 7px; }

.rpm-chat__cip {
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--chat-navy);
  background: #fff;
  border: 1px solid var(--chat-garis);
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.rpm-chat__cip:hover { background: var(--chat-navy); color: var(--chat-gold); }
.rpm-chat__cip:focus-visible { outline: 2px solid var(--chat-gold); outline-offset: 2px; }

/* --- Penanda mengetik ---------------------------------------------------- */

.rpm-chat__mengetik { display: flex; gap: 4px; align-self: flex-start; padding: 12px 14px; }
.rpm-chat__mengetik span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--chat-redup);
  animation: rpmChatDenyut 1.2s infinite ease-in-out;
}
.rpm-chat__mengetik span:nth-child(2) { animation-delay: .18s; }
.rpm-chat__mengetik span:nth-child(3) { animation-delay: .36s; }

@keyframes rpmChatDenyut {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* --- Kaki ---------------------------------------------------------------- */

.rpm-chat__kaki { padding: 12px 14px 14px; background: #fff; border-top: 1px solid rgba(10, 26, 47, .08); }

.rpm-chat__label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rpm-chat__baris { display: flex; align-items: flex-end; gap: 8px; }

.rpm-chat__input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  color: var(--chat-teks);
  background: var(--chat-kertas);
  border: 1px solid rgba(10, 26, 47, .14);
  border-radius: 10px;
}
.rpm-chat__input:focus { outline: none; border-color: var(--chat-gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, .16); }

.rpm-chat__kirim {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border: 0; border-radius: 10px;
  background: var(--chat-emerald);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.rpm-chat__kirim svg { width: 18px; height: 18px; fill: currentColor; }
.rpm-chat__kirim:disabled { background: #b9c2cc; cursor: not-allowed; }
.rpm-chat__kirim:focus-visible { outline: 2px solid var(--chat-navy); outline-offset: 2px; }

.rpm-chat__nota { margin: 9px 0 0; font-size: 11px; line-height: 1.4; color: var(--chat-redup); }

/* --- Layar kecil --------------------------------------------------------- */

@media (max-width: 480px) {
  .rpm-chat { right: 14px; bottom: 14px; }
  .rpm-chat__panel {
    position: fixed;
    right: 10px; left: 10px;
    bottom: 84px;
    width: auto;
    max-height: calc(100vh - 150px);
  }
}

/* --- Hormati preferensi kurangi gerak ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .rpm-chat__panel,
  .rpm-chat__tombol,
  .rpm-chat__cip { transition: none; }
  .rpm-chat__mengetik span { animation: none; opacity: .5; }
}

/* --- Beri ruang untuk tombol back-to-top -------------------------------- */

#backToTop {
  bottom: 92px !important;
  right: 22px !important;
  z-index: 1070;
}

@media (max-width: 480px) {
  #backToTop {
    bottom: 84px !important;
    right: 16px !important;
  }
}