/* SuperByte — gaya keluaran renderer markdown tunggal (md-render.js).
   PRD#chat-reading-quality R1. Dimuat di widget.html, pip.html, dan index.html
   (grup) supaya blok kode, kutipan, daftar, dan tabel tampak IDENTIK di semua
   surface. Selector generik (.sb-md) + selector bubble lama supaya CSS lama
   tidak perlu diubah. */

.sb-md pre.sb-code, .bubble pre.sb-code, .sb-grp-bub .md pre.sb-code {
  margin: 8px 0; padding: 0; border-radius: 8px; overflow: hidden;
  background: #111827; color: #e5e7eb; border: 1px solid #1f2937;
  font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55;
}
.sb-code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px 4px 10px; background: #1f2937; color: #9ca3af; font-size: 11px;
  font-family: Inter, -apple-system, system-ui, sans-serif;
}
.sb-code-lang { text-transform: lowercase; letter-spacing: .02em; }
.sb-code-copy {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  border: 1px solid #374151; background: transparent; color: #d1d5db; font: inherit; font-size: 11px; cursor: pointer;
}
.sb-code-copy:hover { background: #374151; color: #fff; }
pre.sb-code > code {
  display: block; padding: 10px 12px; overflow-x: auto; white-space: pre; background: transparent !important;
  color: inherit !important; font-size: inherit !important; border-radius: 0 !important;
}
.bubble blockquote, .sb-grp-bub .md blockquote {
  margin: 6px 0; padding: 4px 12px; border-left: 3px solid #c7d2fe; background: #eef2ff; color: #374151; border-radius: 6px;
}
.bubble ol, .sb-grp-bub .md ol { padding-left: 22px; margin: 6px 0; }
.bubble ul, .sb-grp-bub .md ul { padding-left: 20px; margin: 6px 0; }
.bubble li + li, .sb-grp-bub .md li + li { margin-top: 2px; }
.bubble p, .sb-grp-bub .md p { margin: 0 0 8px; }
.bubble p:last-child, .sb-grp-bub .md p:last-child { margin-bottom: 0; }
.bubble hr, .sb-grp-bub .md hr { border: 0; border-top: 1px solid #e5e7eb; margin: 10px 0; }
.bubble table.md-table, .sb-grp-bub .md table.md-table {
  border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12.5px; display: block; overflow-x: auto;
}
.md-table th, .md-table td { border: 1px solid #e5e7eb; padding: 5px 8px; text-align: left; vertical-align: top; }
.md-table th { background: #f3f4f6; font-weight: 600; }
/* PRD#chat-attachments-paste P5 — tabel pipa di bubble USER (biru/ungu): pembungkus .sb-ub-table dari
 * SBChatAttach.userBubbleHtml. white-space:normal menetralkan pre-wrap bubble (kalau tidak, newline di antara
 * <tr> menjadi celah); scroll horizontal di pembungkus supaya tabel lebar tak meluber (layar 360 px). */
.sb-ub-table { white-space: normal; max-width: 100%; overflow-x: auto; margin: 6px 0; text-align: left; -webkit-overflow-scrolling: touch; }
.bubble .sb-ub-table table.md-table, .sb-grp-bub .sb-ub-table table.md-table {
  display: table; width: auto; margin: 0; border-collapse: collapse; font-size: 12.5px; overflow: visible; color: #fff;
}
.sb-ub-table .md-table th, .sb-ub-table .md-table td { border: 1px solid rgba(255, 255, 255, 0.55); color: #fff; }
.sb-ub-table .md-table th { background: rgba(255, 255, 255, 0.2); }
.sb-ub-table .md-table td { background: rgba(255, 255, 255, 0.06); }
/* zebra pip.css (#fafafa) tak berlaku di bubble berwarna; kata tak dipecah di tengah (tabel melebar + scroll) */
.sb-ub-table .md-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.06); }
.sb-ub-table .md-table th, .sb-ub-table .md-table td { overflow-wrap: normal; word-break: normal; }
/* Gambar sbfile: placeholder bertinggi supaya hydrate tidak menggeser posisi baca (R3) */
img.sb-media-img { max-width: 100%; border-radius: 8px; display: block; margin: 6px 0; }
img.sb-media-img:not([src]) { min-height: 96px; min-width: 120px; background: #f3f4f6; border: 1px dashed #d1d5db; }
a.sb-file-card {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; margin: 4px 0; border-radius: 8px;
  border: 1px solid #e5e7eb; background: #f9fafb; color: #1f2937; text-decoration: none; font-size: 12.5px;
}
/* PRD#chat-attachments-paste P2 — lampiran di gelembung user (pip + Multiagent): gambar = thumbnail,
   berkas lain = kartu yang bisa dibuka. Gelembung user berlatar indigo → kartu transparan putih. */
.sb-grp-bub .bubble-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.bubble-attachments img.sb-attach-thumb { max-width: 100%; max-height: 240px; width: auto; object-fit: contain; margin: 0; cursor: zoom-in; border-radius: 8px; background: rgba(255,255,255,.12); }
.bubble-attachments img.sb-attach-thumb:not([src]) { width: 160px; height: 120px; min-width: 0; min-height: 0; border: 1px dashed rgba(255,255,255,.5); background: rgba(255,255,255,.12); }
.bubble-attachments a.sb-attach-file { margin: 0; max-width: 100%; cursor: pointer; color: inherit; background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.35); }
.bubble-attachments a.sb-attach-file:hover, .bubble-attachments a.sb-attach-file:focus-visible { background: rgba(255,255,255,.26); outline: none; }
.bubble-attachments a.sb-attach-file svg { flex: none; }
.bubble-attachments a.sb-attach-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bubble-attachments .bubble-attach-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 8px; border-radius: 10px; font-size: 11px; background: rgba(255,255,255,.16); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Pill "Pesan baru" (R3): sticky di dasar area scroll */
.sb-newmsg-pill {
  position: sticky; bottom: 8px; display: none; margin: 0 auto; width: max-content; z-index: 5;
  padding: 6px 12px; border-radius: 999px; background: #4f46e5; color: #fff; font-size: 12px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(79,70,229,.35); cursor: pointer; align-items: center; gap: 6px; border: 0;
}
.sb-newmsg-pill.show { display: inline-flex; }
@media (prefers-reduced-motion: no-preference) { .sb-newmsg-pill.show { animation: sbPillIn .18s ease-out; } }
@keyframes sbPillIn { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
/* Ikon berputar (chip konfirmasi "Memproses…", chip lampiran "mengunggah") */
.sb-spin { animation: sbSpin 1s linear infinite; }
@keyframes sbSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sb-spin { animation: none; } }
/* Separator tanggal + jam pada bubble Multiagent (R5 paritas pip) */
.sb-grp-date { text-align: center; font-size: 11px; color: #9ca3af; margin: 8px 0 4px; }
.sb-grp-time { display: block; text-align: right; font-size: 10.5px; color: #9ca3af; margin-top: 4px; }
.sb-grp-row.user .sb-grp-time { color: rgba(255,255,255,.75); }
/* PRD#chat-history-durability H2/H4 — riwayat: sentinel muat-sebelumnya, divider reset,
   tautan "Lihat riwayat" di hero, sorotan hasil pencarian */
.history-sentinel { display: flex; justify-content: center; padding: 10px 0 6px; min-height: 28px; }
.history-sentinel-dots { display: inline-flex; gap: 4px; }
.history-sentinel-dots span { width: 6px; height: 6px; border-radius: 50%; background: #c7d2fe; animation: sbDots 1s infinite ease-in-out; }
.history-sentinel-dots span:nth-child(2) { animation-delay: .15s; } .history-sentinel-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes sbDots { 0%, 80%, 100% { opacity: .35; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .history-sentinel-dots span { animation: none; } }
.reset-divider { text-align: center; margin: 14px 0; position: relative; }
.reset-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed #d1d5db; }
.reset-divider span { position: relative; display: inline-block; padding: 3px 10px; background: #fff; color: #6b7280; font-size: 11px; border-radius: 10px; }
.hero-history { display: block; margin: 12px auto 0; padding: 6px 14px; border-radius: 999px; border: 1px solid #c7d2fe; background: #fff; color: #4f46e5; font: inherit; font-size: 13px; cursor: pointer; }
.hero-history:hover { background: #eef2ff; }
.msg-highlight > .bubble, .sb-grp-row.msg-highlight .sb-grp-bub { outline: 2px solid #a5b4fc; outline-offset: 2px; transition: outline-color 1.5s ease; }
/* Pencarian riwayat (host halaman Chat). Jarak antar tombol = `gap` milik .sbc-top (index.html);
   tanpa margin di sini — dulu margin-right 8px + gap 8px = 16px, bar atas tampak tak simetris. */
.sbc-search-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; border: 1px solid #e5e7eb; background: #fff; color: #6b7280; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.06); vertical-align: middle; }
.sbc-search-btn:hover { background: #f9fafb; color: #111827; }
.sbc-search { position: fixed; top: 54px; right: 18px; z-index: 61; width: 380px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 10px; }
.sbc-search[hidden] { display: none; }
.sbc-search input { width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; font-size: 13px; }
.sbc-search-res { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.sbc-search-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.sbc-search-item:hover, .sbc-search-item:focus { background: #f3f4f6; outline: none; }
.sbc-search-meta { display: flex; gap: 8px; font-size: 11px; color: #6b7280; margin-bottom: 2px; }
.sbc-search-snip { font-size: 12.5px; color: #111827; line-height: 1.4; }
.sbc-search-empty { padding: 10px 8px; font-size: 12.5px; color: #9ca3af; }
@media (max-width: 768px) { .sbc-search { top: 108px; right: 12px; } }
