/* CS AI Chat widget — Bumu */
.bumu-cs {
  --cs-rose: #e11d48;
  --cs-rose-dark: #be123c;
  --cs-panel: #ffffff;
  --cs-bg: #fafaf9;
  --cs-text: #1c1917;
  --cs-muted: #78716c;
  --cs-border: #e7e5e4;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  z-index: 9990;
}
.bumu-cs *,
.bumu-cs *::before,
.bumu-cs *::after {
  box-sizing: border-box;
}

/* Launcher */
.bumu-cs__launcher {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  z-index: 9991;
}
.bumu-cs.is-hidden .bumu-cs__launcher,
.bumu-cs.is-hidden .bumu-cs__panel {
  display: none !important;
}

/* Tab tepi kanan (saat di-× / disembunyikan) */
.bumu-cs__restore {
  display: none;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9991;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--cs-border);
  border-right: 0;
  border-radius: 9999px 0 0 9999px;
  background: #fff;
  padding: 0.2rem;
  box-shadow: -4px 6px 18px -6px rgba(28, 25, 23, 0.22);
  cursor: pointer;
  font-family: inherit;
  transition: width 0.15s ease, box-shadow 0.15s ease;
}
.bumu-cs__restore img {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 9999px;
  object-fit: cover;
  background: #e11d48;
  display: block;
}
.bumu-cs__restore:hover {
  width: 3rem;
  box-shadow: -6px 8px 22px -4px rgba(225, 29, 72, 0.25);
}
.bumu-cs.is-hidden .bumu-cs__restore {
  display: inline-flex;
}

.bumu-cs__hi-wrap {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  animation: bumu-cs-pop 0.45s ease;
  max-width: min(260px, 78vw);
}
.bumu-cs__hi {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  color: var(--cs-text);
  border: 1px solid var(--cs-border);
  border-radius: 9999px;
  padding: 0.45rem 0.85rem 0.45rem 0.45rem;
  box-shadow: 0 10px 30px -8px rgba(28, 25, 23, 0.18);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  min-width: 0;
  flex: 1;
}
.bumu-cs__hi img {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  object-fit: cover;
  background: #e11d48;
  flex-shrink: 0;
}
.bumu-cs__hi span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bumu-cs__hi-x {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1px solid var(--cs-border);
  background: #fff;
  color: #78716c;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px -4px rgba(28, 25, 23, 0.15);
  font-family: inherit;
  padding: 0;
}
.bumu-cs__hi-x:hover {
  background: #f5f5f4;
  color: #e11d48;
}

.bumu-cs__fab {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 9999px;
  border: 3px solid #fff;
  background: linear-gradient(145deg, #e11d48, #be123c);
  box-shadow: 0 12px 28px -6px rgba(225, 29, 72, 0.55);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.bumu-cs__fab:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 32px -4px rgba(225, 29, 72, 0.6);
}
.bumu-cs__fab:active {
  transform: scale(0.97);
}
.bumu-cs__fab img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.bumu-cs__fab-close {
  display: none;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
}
.bumu-cs.is-open .bumu-cs__fab img {
  display: none;
}
.bumu-cs.is-open .bumu-cs__fab-close {
  display: block;
}
.bumu-cs.is-open .bumu-cs__hi-wrap {
  display: none;
}

@keyframes bumu-cs-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Panel */
.bumu-cs__panel {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.75rem);
  width: min(380px, calc(100vw - 1.5rem));
  height: min(560px, calc(100vh - 7rem));
  background: var(--cs-panel);
  border-radius: 1.25rem;
  border: 1px solid var(--cs-border);
  box-shadow: 0 25px 50px -12px rgba(28, 25, 23, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9992;
  animation: bumu-cs-pop 0.25s ease;
}
.bumu-cs.is-open .bumu-cs__panel {
  display: flex;
}

.bumu-cs__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #fff;
  flex-shrink: 0;
}
.bumu-cs__head-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  object-fit: cover;
  background: #9f1239;
  flex-shrink: 0;
}
.bumu-cs__head-text {
  min-width: 0;
  flex: 1;
}
.bumu-cs__head-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.2;
}
.bumu-cs__head-sub {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.bumu-cs__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 9999px;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
  flex-shrink: 0;
}
.bumu-cs__dot.is-offline {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4);
}
.bumu-cs.is-offline .bumu-cs__fab {
  filter: grayscale(0.25);
}
.bumu-cs__head-btn {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
  flex-shrink: 0;
}
.bumu-cs__head-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.bumu-cs__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  background: var(--cs-bg);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bumu-cs__msg {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.bumu-cs__msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--cs-border);
  color: var(--cs-text);
  border-bottom-left-radius: 0.35rem;
}
.bumu-cs__msg--user {
  align-self: flex-end;
  background: var(--cs-rose);
  color: #fff;
  border-bottom-right-radius: 0.35rem;
}
.bumu-cs__msg--err {
  align-self: flex-start;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  border-bottom-left-radius: 0.35rem;
}

/* Link di balasan bot — merah & hidup */
.bumu-cs__msg a.bumu-cs__link,
.bumu-cs__msg--bot a,
.bumu-cs__msg--err a {
  color: #e11d48;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.bumu-cs__msg a.bumu-cs__link:hover,
.bumu-cs__msg--bot a:hover,
.bumu-cs__msg--err a:hover {
  color: #be123c;
}
.bumu-cs__typing {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--cs-muted);
  padding: 0.25rem 0.5rem;
}

/* Gate name form */
.bumu-cs__gate {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem 0.15rem 0.5rem;
}
.bumu-cs__gate p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--cs-muted);
  line-height: 1.5;
}
.bumu-cs__gate label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cs-muted);
}
.bumu-cs__gate input {
  width: 100%;
  height: 2.75rem;
  border: 1px solid var(--cs-border);
  border-radius: 0.85rem;
  padding: 0 0.9rem;
  font-size: 0.875rem;
  outline: none;
  background: #fff;
}
.bumu-cs__gate input:focus {
  border-color: var(--cs-rose);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}
.bumu-cs__gate-btn {
  height: 2.75rem;
  border: 0;
  border-radius: 0.85rem;
  background: var(--cs-rose);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
}
.bumu-cs__gate-btn:hover {
  background: var(--cs-rose-dark);
}
.bumu-cs__gate-err {
  font-size: 0.75rem;
  color: #e11d48;
  min-height: 1rem;
}

.bumu-cs__foot {
  flex-shrink: 0;
  border-top: 1px solid var(--cs-border);
  padding: 0.65rem 0.75rem;
  background: #fff;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.bumu-cs__foot textarea {
  flex: 1;
  min-height: 2.5rem;
  max-height: 5.5rem;
  resize: none;
  border: 1px solid var(--cs-border);
  border-radius: 0.85rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  line-height: 1.4;
}
.bumu-cs__foot textarea:focus {
  border-color: var(--cs-rose);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.1);
}
.bumu-cs__foot textarea:disabled {
  background: #f5f5f4;
  color: #a8a29e;
}
.bumu-cs__send {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 0.85rem;
  background: var(--cs-rose);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.bumu-cs__send:hover {
  background: var(--cs-rose-dark);
}
.bumu-cs__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.bumu-cs__powered {
  text-align: center;
  font-size: 0.625rem;
  color: #a8a29e;
  padding: 0 0.75rem 0.45rem;
  background: #fff;
}

/*
 * Mobile: angkat di atas bottom nav
 * - Landing index.php: .bottom-nav (md:hidden → <768px)
 * - Client shell: bottom dock
 */
@media (max-width: 767px) {
  .bumu-cs__launcher {
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0px) + 5rem));
  }
  .bumu-cs__panel {
    bottom: max(10.25rem, calc(env(safe-area-inset-bottom, 0px) + 9.75rem));
    height: min(460px, calc(100vh - 12.5rem - env(safe-area-inset-bottom, 0px)));
    max-height: calc(100vh - 12.5rem - env(safe-area-inset-bottom, 0px));
    right: max(0.75rem, env(safe-area-inset-right));
    width: min(380px, calc(100vw - 1.25rem));
  }
  .bumu-cs__restore {
    top: auto;
    bottom: max(5.75rem, calc(env(safe-area-inset-bottom, 0px) + 5.25rem));
    transform: none;
  }
}

/* Client dashboard (lg bottom dock) — tetap angkat s/d 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
  body.client-shell .bumu-cs__launcher,
  .bumu-cs--client .bumu-cs__launcher {
    bottom: max(4.75rem, calc(env(safe-area-inset-bottom, 0px) + 4.25rem));
  }
  body.client-shell .bumu-cs__panel,
  .bumu-cs--client .bumu-cs__panel {
    bottom: max(9.5rem, calc(env(safe-area-inset-bottom, 0px) + 9rem));
    height: min(480px, calc(100vh - 11rem));
  }
  body.client-shell .bumu-cs__restore,
  .bumu-cs--client .bumu-cs__restore {
    top: auto;
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 0px) + 5rem));
    transform: none;
  }
}
