/* Live chat: widget publik dan tampilan chat yang responsif (mobile first). */

.lcw { position: fixed; right: 16px; bottom: 16px; z-index: 60; font-size: 14px; color: var(--cnui-ink); }

.lcw-fab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--cnui-brand); color: #fff; font: inherit; font-weight: 600;
  box-shadow: 0 12px 30px -10px rgb(0 0 0 / .45); cursor: pointer;
}
.lcw-fab:focus-visible, .lcw-close:focus-visible, .lcw-btn:focus-visible, .lcw-send:focus-visible, .lcw-input:focus-visible {
  outline: 2px solid var(--cnui-brand); outline-offset: 2px;
}
.lcw-pulse { display: none; width: 8px; height: 8px; border-radius: 999px; background: #34d399; }
.lcw.lcw-has-admin .lcw-pulse { display: inline-block; box-shadow: 0 0 0 0 rgb(52 211 153 / .6); animation: lcw-ping 2s infinite; }
@keyframes lcw-ping { 70% { box-shadow: 0 0 0 8px rgb(52 211 153 / 0); } 100% { box-shadow: 0 0 0 0 rgb(52 211 153 / 0); } }
@media (prefers-reduced-motion: reduce) { .lcw.lcw-has-admin .lcw-pulse { animation: none; } }

.lcw-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
}
.lcw-badge[hidden] { display: none; }

.lcw-panel {
  position: absolute; right: 0; bottom: 60px;
  width: min(384px, calc(100vw - 32px)); height: min(580px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--cnui-line); border-radius: 16px; background: var(--cnui-panel); box-shadow: var(--cnui-shadow);
}
.lcw-panel[hidden] { display: none; }
.lcw-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--cnui-line); }
.lcw-title { margin: 0; font-weight: 600; font-size: 14px; }
.lcw-sub { margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: var(--cnui-muted); }
.lcw-close { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; }
.lcw-close:hover { background: rgb(127 127 127 / .12); }
.lcw-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lcw-body > [hidden] { display: none !important; }
.lcw-loading { margin: 0; padding: 24px; text-align: center; font-size: 13px; color: var(--cnui-muted); }
.lcw-gate { display: flex; flex-direction: column; gap: 8px; padding: 16px; overflow-y: auto; }
.lcw-gate-text { margin: 0 0 4px; font-size: 13px; line-height: 1.5; color: var(--cnui-muted); }
.lcw-label { font-size: 12px; font-weight: 600; margin-top: 4px; }
.lcw-muted { font-weight: 400; color: var(--cnui-muted); }
.lcw-input {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--cnui-line); border-radius: 10px;
  background: transparent; color: inherit; font: inherit; font-size: 16px; /* 16px mencegah zoom otomatis di iOS */
}
.lcw-textarea { resize: none; flex: 1; min-height: 42px; }
.lcw-btn {
  margin-top: 6px; height: 42px; border: 0; border-radius: 10px; background: var(--cnui-brand); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.lcw-btn:disabled { opacity: .6; cursor: progress; }
a.lcw-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.lcw-staff { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.lcw-link { margin-top: 4px; text-align: center; font-size: 12px; color: var(--cnui-brand); }
.lcw-error { margin: 0; font-size: 12px; color: var(--cnui-danger); }
.lcw-error[hidden] { display: none; }

.lcw-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lcw-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.lcw-empty { margin: auto; padding: 16px; text-align: center; font-size: 12px; color: var(--cnui-muted); }
.lcw-empty[hidden] { display: none; }
.lcw-row { display: flex; justify-content: flex-start; }
.lcw-row-mine { justify-content: flex-end; }
.lcw-bubble { max-width: 85%; padding: 8px 12px; border: 1px solid var(--cnui-line); border-radius: 16px; overflow-wrap: anywhere; }
.lcw-row-mine .lcw-bubble { background: var(--cnui-brand); color: #fff; border-color: transparent; }
.lcw-pending { opacity: .65; }
.lcw-failed .lcw-bubble { border-color: var(--cnui-danger); }
.lcw-who { margin: 0 0 2px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cnui-muted); }
.lcw-text { margin: 0; white-space: pre-line; line-height: 1.5; font-size: 13px; }
.lcw-time { margin: 4px 0 0; font-size: 10px; text-align: right; opacity: .7; }
.lcw-notice { margin: 0; padding: 6px 12px; font-size: 12px; color: var(--cnui-warning); }
.lcw-notice[hidden] { display: none; }
.lcw-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--cnui-line); }
.lcw-send {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 10px;
  background: var(--cnui-brand); color: #fff; cursor: pointer;
}

/* Mobile: panel menjadi lembar penuh di bagian bawah layar. */
@media (max-width: 639px) {
  .lcw { right: 12px; bottom: 12px; }
  .lcw-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(82dvh, 640px); border-radius: 18px; }
}

/* Panel chat dukungan (dashboard & admin): tinggi menyesuaikan layar, tidak dipotong di ponsel. */
.chat-panel-shell { height: min(72dvh, 40rem); min-height: 24rem; }
.chat-panel-shell > [data-chat-messages] { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat-input { font-size: 16px; }
@media (min-width: 640px) { .chat-input { font-size: 13px; } }
@media (min-width: 1024px) { .chat-panel-shell { height: calc(100vh - 16rem); min-height: 26rem; } }
