/* SuperByte — bubble error turn V2 (PRD#turn-error-accuracy P7 · ui-detail; turn-error.js).
   SATU berkas gaya untuk pip.html/widget.html (pip.js), group.html (pip/group.js) dan halaman Chat in-page
   (apps/dashboard/index.html → js/chat-group.js). Disajikan web lewat /chat-widget/pip/turn-error.css (peta
   widget-shared.js). Kerangka bubble (latar merah muda, border) tetap milik renderer: pip `.bubble.error`,
   grup `.sb-grp-bub.err`; berkas ini hanya isi `.sb-te` + status retry `.sb-te-cont`.
   Surface extension/bubble = tema terang saja (ui-design-system §1, surface 6) — warna = mockup yang disetujui. */
.sb-te { white-space: normal; min-width: 0; }
.sb-te p { margin: 0; }
.sb-te-ic { width: 15px; height: 15px; flex: none; }
.sb-te-ic-sm { width: 13px; height: 13px; }
.sb-te-main { font-size: 13.5px; line-height: 1.5; color: #991b1b; font-weight: 500; overflow-wrap: anywhere; }
.sb-te-main strong { font-weight: 700; color: #991b1b; }
.sb-te-hint { margin-top: 5px !important; font-size: 12.5px; line-height: 1.45; color: #7f5252; }
.sb-te-note { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px !important; font-size: 12px; line-height: 1.45; color: #7f5252; }
/* PRD#byok-auto-fallback §3.11 R2 — rantai koneksi turn (dicoba + dilewati). */
.sb-te-chain { margin-top: 6px; font-size: 12px; line-height: 1.45; color: #7f5252; }
.sb-te-chain ol { margin: 2px 0 0 18px !important; padding: 0 !important; list-style: decimal; }
.sb-te-note .sb-te-ic { margin-top: 2px; }
.sb-te-note.sb-te-neutral { color: #6b7280; }

/* Baris aksi — tautan (biru) = navigasi ke halaman, tombol (merah) = kirim ulang. */
.sb-te-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sb-te-act { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 11px; border-radius: 7px;
  border: 1px solid #fecaca; background: #fff; color: #b91c1c; font: inherit; font-size: 12px; font-weight: 600;
  line-height: 1.2; cursor: pointer; text-decoration: none; box-sizing: border-box; }
.sb-te-act:hover:not(:disabled) { background: #fef2f2; border-color: #fca5a5; }
.sb-te-act:disabled { opacity: .55; cursor: default; }
/* Spesifisitas dinaikkan: pip.css `.message.assistant .bubble a` menggarisbawahi semua tautan di bubble. */
.sb-te a.sb-te-act.sb-te-link, .sb-te a.sb-te-act.sb-te-link:visited { border-color: #bfdbfe; color: #1d4ed8; text-decoration: none; opacity: 1; overflow-wrap: normal; }
.sb-te a.sb-te-act.sb-te-link:hover { background: #eff6ff; border-color: #93c5fd; opacity: 1; }
.sb-te-act.sb-te-ghost { border-color: #d1d5db; color: #374151; }
.sb-te-act.sb-te-ghost:hover:not(:disabled) { background: #f9fafb; border-color: #d1d5db; }
.sb-te-act:focus-visible, .sb-te-det summary:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

/* "Lihat detail" — <details> bawaan tertutup. */
.sb-te-det { margin-top: 10px; border-top: 1px dashed #fecaca; padding-top: 6px; }
.sb-te-det summary { display: inline-flex; align-items: center; gap: 4px; list-style: none; cursor: pointer; font-size: 12px;
  font-weight: 600; color: #7f5252; padding: 3px 2px; border-radius: 5px; user-select: none; -webkit-user-select: none; }
.sb-te-det summary::-webkit-details-marker { display: none; }
.sb-te-det summary::marker { content: ''; }
.sb-te-det summary:hover { color: #991b1b; }
.sb-te-chev { display: flex; transition: transform .15s; }
.sb-te-det[open] .sb-te-chev { transform: rotate(180deg); }
.sb-te-lbl-open { display: none; }
.sb-te-det[open] .sb-te-lbl-open { display: inline; }
.sb-te-det[open] .sb-te-lbl-closed { display: none; }
.sb-te-det-body { margin-top: 8px; background: #fff; border: 1px solid #fecaca; border-radius: 9px; padding: 10px 12px; color: #374151; }
.sb-te-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: 12px; line-height: 1.5; }
.sb-te-kv dt { color: #6b7280; }
.sb-te-kv dd { margin: 0; color: #111827; min-width: 0; overflow-wrap: anywhere; }
.sb-te-kv code, .sb-te-main code { font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: #f3f4f6; color: #374151; border-radius: 4px; padding: 0 4px; }
.sb-te-raw-h { margin: 10px 0 4px; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .04em;
  display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.sb-te-redact-note { font-weight: 500; text-transform: none; letter-spacing: 0; color: #9ca3af; }
.sb-te-raw { margin: 0; background: #111827; color: #e5e7eb; border-radius: 8px; padding: 9px 11px;
  font: 11.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.sb-te-rd { background: #4338ca; color: #e0e7ff; border-radius: 3px; padding: 0 4px; }
.sb-te-foot { margin-top: 9px; }

/* Retry otomatis Q3 berjalan (frame continuing) — status netral indigo, bukan bubble error. */
.sb-te-cont { white-space: normal; background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.5; }
.sb-te-cont p { margin: 0; }
.sb-te-cont-who { display: block; font-size: 11px; font-weight: 600; color: #4f46e5; margin-bottom: 2px; }
.sb-te-cont-line { display: flex; align-items: center; gap: 8px; }
.sb-te-cont-main { font-weight: 500; }
.sb-te-cont-hint { margin-top: 3px !important; font-size: 12.5px; color: #4f46e5; }
.sb-te-spin { width: 14px; height: 14px; border: 2px solid #c7d2fe; border-top-color: #4f46e5; border-radius: 50%; animation: sbTeSpin .8s linear infinite; flex: none; box-sizing: border-box; }
@keyframes sbTeSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sb-te-spin { animation: none; } .sb-te-chev { transition: none; } }

/* Lebar HP (≥360 px): target sentuh 44 px, ringkasan satu kolom. */
@media (max-width: 640px) {
  .sb-te-act { min-height: 44px; padding: 8px 14px; font-size: 13px; }
  .sb-te-det summary { min-height: 44px; }
  .sb-te-kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sb-te-kv dt { margin-top: 5px; }
}

/* Bubble Sistem grup (pip/group.js + dashboard js/chat-group.js): "Sistem · untuk <agent>", avatar merah, lebih lebar
   dari bubble chat biasa supaya ringkasan "Lihat detail" muat (mockup). */
.sb-grp-bub.sb-grp-te { max-width: 88%; white-space: normal; border: 1px solid #fecaca; color: #991b1b; }
.sb-grp-bub.sb-grp-te .who { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; color: #b91c1c; }
.sb-grp-bub.sb-grp-te .who-for { font-weight: 500; color: #b45353; }
.sb-grp-ava.sb-grp-ava-sys { background: #dc2626; }
.sb-grp-row > .sb-te-cont { max-width: 88%; }
@media (max-width: 640px) { .sb-grp-bub.sb-grp-te, .sb-grp-row > .sb-te-cont { max-width: 90%; } }
