/* Chat Bantuan (widget dashboard + halaman /bantuan). Semua warna & spasi lewat tokens.css. */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); color: var(--color-ink); font: 400 var(--text-md, 0.9375rem)/1.45 var(--font-body); }
.chat [hidden] { display: none !important; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); border-bottom: 1px solid var(--color-rule); }
.chat-head-main { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; flex: 1; }
.chat-head-main > div { min-width: 0; }
.chat-title, .chat-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-avatar.is-agent { background: var(--color-accent); color: #fff; letter-spacing: 0; }
.chat-end { color: var(--color-muted); }
.chat-avatar { flex: none; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--color-ink); color: var(--color-ink-inverse); font: 650 1.0625rem/1 var(--font-display); letter-spacing: -0.04em; }
.chat-title { display: block; font-weight: 600; }
.chat-status { margin: 0; font-size: var(--text-sm); color: var(--color-muted); }
.chat-head-tools { display: flex; align-items: center; gap: var(--space-2xs); flex: none; }
.chat-handoff { height: 1.875rem; padding: 0 var(--space-sm); border: 1px solid var(--color-rule-strong); border-radius: 99px; background: transparent; color: var(--color-ink); font: 500 var(--text-sm)/1 var(--font-body); cursor: pointer; white-space: nowrap; }
.chat-handoff:hover { border-color: var(--color-ink); }

.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); background: var(--color-paper); }
.chat-log:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.chat-row { display: flex; }
.chat-row.is-mine { justify-content: flex-end; }
.chat-bubble { max-width: 85%; padding: var(--space-xs) var(--space-sm); border-radius: 1rem; border-bottom-left-radius: 0.3rem; background: var(--color-surface); border: 1px solid var(--color-rule); overflow-wrap: anywhere; }
.chat-bubble p { margin: 0; white-space: pre-wrap; }
.chat-bubble a { color: inherit; text-underline-offset: 3px; }
.chat-bubble.is-user { background: var(--color-ink); color: var(--color-ink-inverse); border-color: var(--color-ink); border-radius: 1rem; border-bottom-right-radius: 0.3rem; }
.chat-bubble.is-agent { background: var(--color-accent-soft); border-color: transparent; }
.chat-who { display: block; margin-bottom: 1px; font-size: var(--text-xs, 0.75rem); font-weight: 600; color: var(--color-muted); }
.chat-bubble.is-agent .chat-who { color: var(--color-accent); }
.chat-time { display: block; margin-top: 2px; font-size: var(--text-xs, 0.75rem); color: var(--color-muted); text-align: right; font-variant-numeric: tabular-nums; }
.chat-bubble.is-user .chat-time { color: inherit; opacity: 0.7; }
.chat-row.is-pending { opacity: 0.6; }
.chat-row.is-failed .chat-bubble { background: var(--color-critical-soft); color: var(--color-critical); border-color: transparent; }
.chat-row.is-failed .chat-time { color: inherit; opacity: 1; }
.chat-system, .chat-day { margin: var(--space-xs) 0; text-align: center; font-size: var(--text-xs, 0.75rem); color: var(--color-muted); }
.chat-typing { display: inline-flex; gap: 4px; padding: var(--space-sm); }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--color-muted); animation: chat-blink 1.2s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-typing i { animation: none; opacity: 0.6; } }

.chat-welcome { margin: auto 0; padding: var(--space-md) 0; display: flex; flex-direction: column; gap: var(--space-xs); }
.chat-welcome b { font: 600 var(--text-xl)/1.25 var(--font-display); letter-spacing: -0.02em; }
.chat-welcome p { margin: 0; color: var(--color-muted); }
.chat-chips { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-xs); }
.chat-chip { padding: var(--space-2xs) var(--space-sm); border: 1px solid var(--color-rule-strong); border-radius: 99px; background: var(--color-surface); color: var(--color-ink); font: 500 var(--text-sm)/1.4 var(--font-body); cursor: pointer; text-align: left; }
.chat-chip:hover { border-color: var(--color-ink); }

.chat-extra:empty { display: none; }
.chat-extra { padding: var(--space-sm) var(--space-md) 0; background: var(--color-paper); }
.chat-card { display: flex; flex-direction: column; gap: var(--space-2xs); padding: var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-card); background: var(--color-surface); font-size: var(--text-sm); }
.chat-card p { margin: 0; color: var(--color-muted); }
.chat-card-row { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-2xs); }
.chat-card-row input { flex: 1 1 8rem; min-width: 0; height: 2.25rem; padding: 0 var(--space-xs); border: 1px solid var(--color-rule-strong); border-radius: var(--radius-input); background: var(--color-surface); color: var(--color-ink); font: inherit; }
.chat-card-btn { height: 2.25rem; padding: 0 var(--space-sm); border: 1px solid var(--color-ink); border-radius: var(--radius-input); background: var(--color-ink); color: var(--color-ink-inverse); font: 500 var(--text-sm)/1 var(--font-body); cursor: pointer; }
.chat-card-contact { position: relative; padding-right: 2rem; }
.chat-card-contact b { color: var(--color-ink); }
.chat-card-x { position: absolute; top: 0.125rem; right: 0.25rem; width: 1.75rem; height: 1.75rem; border: 0; background: none; color: var(--color-muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.chat-card .chat-card-btn { align-self: flex-start; margin-top: var(--space-2xs); }
.chat-card-row .chat-card-btn { margin-top: 0; }
.chat-card-error { color: var(--color-critical); }
.chat-link { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--color-muted); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.chat-thanks { margin: 0; padding-bottom: var(--space-2xs); font-size: var(--text-sm); color: var(--color-muted); text-align: center; }

.chat-image { display: block; margin: 2px 0 4px; border-radius: 0.6rem; overflow: hidden; background: var(--color-paper-2); }
.chat-image img { display: block; max-width: 100%; max-height: 15rem; min-width: 6rem; min-height: 4rem; object-fit: cover; }
.chat-file { display: flex; align-items: center; gap: var(--space-xs); margin: 2px 0 4px; padding: var(--space-2xs) var(--space-xs); border: 1px solid var(--color-rule); border-radius: 0.6rem; background: var(--color-surface); color: var(--color-ink); text-decoration: none; }
.chat-file svg { flex: none; width: 1.5rem; height: 1.5rem; color: var(--color-muted); }
.chat-file-text { display: flex; flex-direction: column; min-width: 0; font-size: var(--text-sm); }
.chat-file-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 13rem; }
.chat-file-text span { color: var(--color-muted); font-size: var(--text-xs); }
.chat-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chat-attach { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; background: transparent; color: var(--color-muted); cursor: pointer; }
.chat-attach:hover { color: var(--color-ink); background: var(--color-paper-2); }
.chat-attach svg { width: 1.375rem; height: 1.375rem; }
.chat-attach:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chat-form { position: relative; display: flex; align-items: flex-end; gap: var(--space-2xs); padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-xs); background: var(--color-paper); }
.chat-input { flex: 1; min-width: 0; min-height: 2.5rem; max-height: 7.5rem; padding: 0.5625rem var(--space-sm); border: 1px solid var(--color-rule-strong); border-radius: 1.25rem; background: var(--color-surface); color: var(--color-ink); font: inherit; font-size: 1rem; line-height: 1.35; resize: none; }
.chat-input:focus-visible, .chat-card-row input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.chat-send { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; background: var(--color-ink); color: var(--color-ink-inverse); cursor: pointer; }
.chat-send svg { width: 1.125rem; height: 1.125rem; fill: currentColor; }
.chat-send:focus-visible, .chat-chip:focus-visible, .chat-handoff:focus-visible, .chat-card-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chat-note { margin: 0; padding: 0 var(--space-md) var(--space-sm); background: var(--color-paper); font-size: var(--text-xs, 0.75rem); color: var(--color-muted); }

/* layar sentuh kecil: sasaran sentuh 44px (harus di akhir berkas supaya menang atas aturan dasar) */
@media (max-width: 760px) {
  .chat-handoff { height: 2.25rem; }
  .chat-attach, .chat-send { width: 2.75rem; height: 2.75rem; }
  .chat-input { min-height: 2.75rem; padding-top: 0.6875rem; padding-bottom: 0.6875rem; }
  .chat-bubble { max-width: 88%; }
}
