/* Panel chat Asisten AI — gaya kaca, mengikuti mode terang (rose) / gelap (emas). */
.chat {
  position: fixed; z-index: 60; inset-inline-end: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(410px, calc(100vw - 32px)); height: min(680px, calc(100dvh - 32px));
  display: flex; flex-direction: column; border-radius: 30px; overflow: hidden;
  background: var(--glass-strong); animation: chat-in .28s cubic-bezier(.2, .8, .2, 1);
}
.chat[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.chat__head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--line); }
.chat__head .fab-ai__mark { width: 40px; height: 40px; flex-shrink: 0; }
.chat__who { flex: 1; min-width: 0; line-height: 1.2; }
.chat__who b { display: block; font-size: 1rem; }
.chat__who small { color: var(--muted); font-size: .78rem; }
.chat__icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 1px solid var(--glass-edge); background: var(--glass); color: var(--ink); }
.chat__icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Ringkasan rencana (detail calon klien) */
.chat__sum { margin: 10px 12px 0; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-edge); }
.chat__sum summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 14px; font-weight: 700; font-size: .88rem; }
.chat__sum summary::-webkit-details-marker { display: none; }
.chat__sum summary::after { content: "▾"; grid-column: 2; grid-row: 1; justify-self: end; color: var(--muted); transition: transform .2s; display: none; }
.chat__count { color: var(--muted); font-weight: 600; font-size: .78rem; }
.chat__bar { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.chat__bar i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: inherit; transition: width .5s ease; }
.chat__sum.is-ready summary .chat__sumT::after { content: " ✓"; color: #34c759; }
.chat__sumBody { padding: 0 14px 14px; }
.chat__sum dl { margin: 0 0 10px; display: grid; gap: 4px; font-size: .84rem; }
.chat__sum dl div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.chat__sum dt { color: var(--muted); }
.chat__sum dd { margin: 0; font-weight: 600; text-align: end; }
.chat__empty { font-size: .82rem; color: var(--muted); margin: 0 0 10px; }
.chat__wa { --btn-bg: #25d366; --btn-ink: #fff; --btn-ledge: #128c45; font-size: .9rem; padding: .75em 1em; }

/* Percakapan */
.chat__log { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 20px; font-size: .93rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0 0 .5em; } .msg p:last-child { margin: 0; }
.msg ul { margin: .2em 0 .5em; padding-inline-start: 1.1em; } .msg li { margin: .15em 0; }
.msg a { color: var(--accent); font-weight: 600; }
.msg--ai { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-edge); border-end-start-radius: 6px; }
.msg--user { align-self: flex-end; background: var(--btn-bg); color: var(--btn-ink); border-end-end-radius: 6px; }
.msg.is-error { border-color: #ff3b30; }
.dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.chat__chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 8px; }
.chat__chips:empty { display: none; }
.chat__chips button {
  border: 1px solid var(--glass-edge); background: var(--glass); color: var(--accent); cursor: pointer;
  padding: .5em .85em; border-radius: 999px; font: 600 .82rem var(--sans); box-shadow: 0 2px 0 var(--glass-ledge);
}
html[lang="ar"] .chat__chips button { font-family: inherit; }

.chat__form { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px 4px; border-top: 1px solid var(--line); }
.chat__form textarea {
  flex: 1; resize: none; border-radius: 20px; padding: .7em 1em; max-height: 140px;
  font: 400 16px/1.4 inherit; font-family: inherit; color: var(--ink);
  background: var(--glass); border: 1px solid var(--glass-edge); outline: none;
}
.chat__form textarea:focus { border-color: var(--accent-2); }
.chat__send { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex-shrink: 0; }
.chat__send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .chat__send svg { transform: scaleX(-1); }
.chat__send:disabled { opacity: .5; cursor: wait; }
.chat__note { margin: 0; padding: 4px 16px 12px; font-size: .7rem; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .chat { inset: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  body.chat-open { overflow: hidden; }
}
