/* SiChatFish — UI chat (Phase 6). Satu gaya untuk halaman penuh, /embed, dan panel widget. */
:root {
  --sc-accent: #0b6e99;
  --sc-accent-ink: #ffffff;
  --sc-bg: #ffffff;
  --sc-bg-soft: #f3f6f8;
  --sc-ink: #1f2933;
  --sc-ink-soft: #52606d;
  --sc-line: #d9e2ec;
  --sc-user: #e6f2f8;
  --sc-notice: #fff8e1;
  --sc-notice-line: #f0d68a;
  --sc-error: #fdecec;
  --sc-error-line: #e8a0a0;
  --sc-radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sc-bg: #111820;
    --sc-bg-soft: #18222c;
    --sc-ink: #e4e9ee;
    --sc-ink-soft: #9aa5b1;
    --sc-line: #2a3642;
    --sc-user: #16303f;
    --sc-notice: #2b2716;
    --sc-notice-line: #6b5a1f;
    --sc-error: #3a1c1c;
    --sc-error-line: #7a3434;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sc-bg: #111820;
  --sc-bg-soft: #18222c;
  --sc-ink: #e4e9ee;
  --sc-ink-soft: #9aa5b1;
  --sc-line: #2a3642;
  --sc-user: #16303f;
  --sc-notice: #2b2716;
  --sc-notice-line: #6b5a1f;
  --sc-error: #3a1c1c;
  --sc-error-line: #7a3434;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--sc-ink);
  background: var(--sc-bg);
}
.sc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sc-app { display: flex; flex-direction: column; height: 100%; max-width: 860px; margin: 0 auto; }
html[data-mode="inline"] .sc-app, html[data-mode="floating"] .sc-app { max-width: none; }

.sc-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--sc-line); background: var(--sc-bg);
}
.sc-title { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.sc-title #sc-name, .sc-title span:last-child:not(.sc-beta) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Logo = kepala maskot SiChatFish (static/brand/). */
.sc-logo { width: 28px; height: 28px; flex: none; background: url("brand/ikon-96.png") center / contain no-repeat; }
.sc-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.sc-user { font-size: 13px; color: var(--sc-ink-soft); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sc-btn {
  font: inherit; font-size: 14px; border: 1px solid var(--sc-accent); background: var(--sc-accent); color: var(--sc-accent-ink);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.sc-btn:hover { filter: brightness(1.08); }
.sc-btn:focus-visible, .sc-cite:focus-visible, textarea:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 2px; }
.sc-btn:disabled { opacity: .5; cursor: not-allowed; }
.sc-btn-ghost { background: transparent; color: var(--sc-ink); border-color: var(--sc-line); }
.sc-close { font-size: 20px; line-height: 1; padding: 2px 10px; }

.sc-log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; background: var(--sc-bg-soft); }
.sc-msg { max-width: 92%; padding: 10px 14px; border-radius: var(--sc-radius); word-wrap: break-word; overflow-wrap: anywhere; }
.sc-msg-user { align-self: flex-end; background: var(--sc-user); white-space: pre-wrap; }
.sc-msg-bot { align-self: flex-start; background: var(--sc-bg); border: 1px solid var(--sc-line); }
.sc-msg-bot p { margin: 0 0 8px; }
.sc-msg-bot p:last-child { margin-bottom: 0; }
.sc-msg-bot ul, .sc-msg-bot ol { margin: 4px 0 8px; padding-left: 22px; }
.sc-msg-bot h4 { margin: 8px 0 4px; font-size: 15px; }
.sc-msg-bot code { background: var(--sc-bg-soft); padding: 0 4px; border-radius: 4px; }
.sc-streaming { white-space: pre-wrap; }
.sc-body:empty { display: none; }

.sc-cite {
  font-size: 12px; vertical-align: super; line-height: 0; color: var(--sc-accent); text-decoration: none;
  font-weight: 600; padding: 0 1px; border-radius: 3px;
}
.sc-cite:hover { text-decoration: underline; }
.sc-nosrc .sc-cite { display: none; }   /* penanda [n] tersembunyi; sumber tampil hanya bila diminta */
.sc-sources { margin-top: 10px; border-top: 1px dashed var(--sc-line); padding-top: 8px; font-size: 13px; }
.sc-sources summary { cursor: pointer; color: var(--sc-ink-soft); font-weight: 600; }
.sc-sources ol { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sc-sources li { padding: 6px 8px; border-radius: 8px; background: var(--sc-bg-soft); }
.sc-sources li.sc-flash { outline: 2px solid var(--sc-accent); }
.sc-src-ref { font-weight: 700; color: var(--sc-accent); margin-right: 4px; }
.sc-src-meta, .sc-src-loc, .sc-src-lic { display: block; color: var(--sc-ink-soft); font-size: 12px; }
.sc-sources a { color: var(--sc-accent); }

.sc-notice { margin-top: 8px; padding: 6px 10px; font-size: 12.5px; border-left: 3px solid var(--sc-notice-line); background: var(--sc-notice); border-radius: 6px; }
.sc-error { background: var(--sc-error); border-color: var(--sc-error-line); }
.sc-feedback { margin-top: 8px; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--sc-ink-soft); }
.sc-feedback button { font: inherit; font-size: 12px; background: transparent; border: 1px solid var(--sc-line); color: var(--sc-ink-soft); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.sc-feedback button[aria-pressed="true"] { border-color: var(--sc-accent); color: var(--sc-accent); }

.sc-suggest { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.sc-suggest button {
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; border-radius: 16px; padding: 5px 12px;
  background: var(--sc-bg); color: var(--sc-accent); border: 1px solid var(--sc-accent);
}
.sc-suggest button:hover { background: var(--sc-user); }
.sc-suggest button:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 2px; }
.sc-banner a.sc-btn { display: inline-block; margin-left: 8px; text-decoration: none; }
.sc-banner { padding: 8px 14px; font-size: 13px; background: var(--sc-notice); border-top: 1px solid var(--sc-notice-line); }
.sc-banner button { margin-left: 8px; }
.sc-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--sc-line); background: var(--sc-bg); }
.sc-form textarea {
  flex: 1; resize: none; font: inherit; color: var(--sc-ink); background: var(--sc-bg);
  border: 1px solid var(--sc-line); border-radius: 10px; padding: 8px 10px; max-height: 160px; min-height: 40px;
}
.sc-send { align-self: flex-end; }
.sc-foot { margin: 0; padding: 0 14px 8px; font-size: 11.5px; color: var(--sc-ink-soft); background: var(--sc-bg); }

.sc-message-page { max-width: 32rem; margin: 4rem auto; padding: 0 1rem; }

@media (max-width: 480px) {
  body { font-size: 15px; }
  .sc-msg { max-width: 100%; }
  .sc-user { display: none; }
}

/* ---- aplikasi mandiri di dalam kerangka sidebar (shell.css) ---- */
.sc-app-shell { max-width: none; width: 100%; margin: 0; height: 100%; flex: 1; min-height: 0; }
.sc-app-shell .sc-log { background: var(--sc-bg); padding: 20px max(14px, calc((100% - 820px) / 2)); }
.sc-app-shell .sc-form { border-top: 0; padding: 8px max(14px, calc((100% - 820px) / 2)) 6px; }
.sc-app-shell .sc-form textarea { border-radius: 14px; padding: 10px 14px; }
.sc-app-shell .sc-foot { padding: 0 max(14px, calc((100% - 820px) / 2)) 10px; text-align: center; }
.sc-app-shell .sc-msg-bot { background: var(--sc-bg-soft); }
.sc-welcome { margin: auto; text-align: center; padding: 24px 8px; }
.sc-welcome h2 { font-size: 28px; font-weight: 650; margin: 0 0 8px; line-height: 1.25; }
.sc-welcome p { font-size: 18px; color: var(--sc-ink-soft); margin: 0; }
@media (max-width: 480px) { .sc-welcome h2 { font-size: 23px; } .sc-welcome p { font-size: 16px; } }

/* ---- sambutan dengan maskot yang menyapa ---- */
.sc-mascot { position: relative; display: inline-block; margin: 0 auto 10px; }
.sc-mascot img { display: block; width: 136px; height: auto; transform-origin: 50% 88%;
  animation: sc-hello 2.6s cubic-bezier(.3, .7, .4, 1) both, sc-float 4.5s ease-in-out 2.6s infinite; }
.sc-mascot:hover img { animation: sc-wave 1.3s ease-in-out both; }
.sc-bubble { position: absolute; top: 6px; left: calc(100% - 22px); white-space: nowrap; padding: 7px 14px;
  border-radius: 16px 16px 16px 4px; background: var(--sc-accent); color: var(--sc-accent-ink); font-weight: 700;
  font-size: 16px; box-shadow: 0 6px 18px rgba(11, 110, 153, .25); transform-origin: 0 100%;
  animation: sc-bubble 2.6s ease-out .5s both; }
.sc-bubble::after { content: ""; position: absolute; left: -6px; bottom: 0; border: 7px solid transparent;
  border-right-color: var(--sc-accent); border-bottom-color: var(--sc-accent); border-left: 0; }
.sc-welcome h2 { animation: sc-rise .7s ease-out .35s both; }
.sc-welcome p { animation: sc-rise .7s ease-out .55s both; }

/* Muncul memantul lalu bergoyang kiri-kanan seperti melambai "halo". */
@keyframes sc-hello {
  0%   { opacity: 0; transform: translateY(26px) scale(.82) rotate(0); }
  18%  { opacity: 1; transform: translateY(-8px) scale(1.04) rotate(0); }
  28%  { transform: translateY(0) scale(1) rotate(-9deg); }
  40%  { transform: rotate(9deg); }
  52%  { transform: rotate(-7deg); }
  64%  { transform: rotate(6deg); }
  76%  { transform: rotate(-3deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}
@keyframes sc-wave {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-9deg); } 40% { transform: rotate(9deg); }
  60% { transform: rotate(-6deg); } 80% { transform: rotate(4deg); }
}
@keyframes sc-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes sc-bubble {
  0%   { opacity: 0; transform: scale(.3) rotate(-10deg); }
  15%  { opacity: 1; transform: scale(1.12) rotate(3deg); }
  25%  { transform: scale(1) rotate(0); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes sc-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .sc-mascot img { width: 132px; } .sc-bubble { font-size: 14px; } }
@media (prefers-reduced-motion: reduce) {
  .sc-mascot img, .sc-mascot:hover img, .sc-bubble, .sc-welcome h2, .sc-welcome p { animation: none; }
}

/* ---- cincin berputar dengan titik bercahaya mengelilingi logo (permintaan pengguna) ---- */
.sc-ring {
  --ring-size: 150px; --ring-w: 3px; --ring-dot: 16px; --ring-color: #fff000; --ring-base: #3c3c3c;
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: var(--ring-size); height: var(--ring-size); box-sizing: border-box;
  border: var(--ring-w) solid var(--ring-base); border-radius: 50%; box-shadow: 0 0 20px rgba(0, 0, 0, .5);
}
.sc-ring::before {
  content: ""; position: absolute; inset: calc(-1 * var(--ring-w)); box-sizing: border-box;
  border: var(--ring-w) solid transparent; border-top-color: var(--ring-color); border-right-color: var(--ring-color);
  border-radius: 50%; animation: rotate-arc 2s linear infinite; pointer-events: none;
}
.sc-ring > span {
  display: block; position: absolute; top: 50%; left: 50%; width: calc(50% + var(--ring-w) / 2); height: 0;
  transform-origin: left center; animation: rotate-comet 2s linear infinite; pointer-events: none; z-index: 2;
}
.sc-ring > span::before {
  content: ""; position: absolute; top: calc(var(--ring-dot) / -2); right: calc(var(--ring-dot) / -2);
  width: var(--ring-dot); height: var(--ring-dot); border-radius: 50%;
  background: var(--ring-color); box-shadow: 0 0 20px var(--ring-color);
}
/* Logo tetap di tengah cincin. */
.sc-ring > img, .sc-ring > .sc-logo { position: relative; z-index: 1; }
.sc-ring-lg { --ring-size: 190px; margin: 0 auto; background: radial-gradient(circle, #ffffff 0 62%, #eef4f8 100%); }
.sc-ring-sm { --ring-size: 46px; --ring-w: 2px; --ring-dot: 7px; box-shadow: 0 0 8px rgba(0, 0, 0, .35);
  background: #fff; }
.sc-ring-sm > .sc-logo { width: 34px; height: 34px; }
.sc-ring-sm > span::before { box-shadow: 0 0 8px var(--ring-color); }
@keyframes rotate-arc { to { transform: rotate(360deg); } }
@keyframes rotate-comet { from { transform: rotate(45deg); } to { transform: rotate(405deg); } }
@media (max-width: 480px) { .sc-ring-lg { --ring-size: 160px; } .sc-mascot img { width: 112px; } }
@media (prefers-reduced-motion: reduce) {
  /* Animasi berhenti; cincin dan logo tetap terlihat. */
  .sc-ring::before, .sc-ring > span { animation: none; }
}

/* ---- sambutan maskot di widget/iframe (panel sempit): ukuran diperkecil ---- */
html[data-mode="floating"] .sc-welcome, html[data-mode="inline"] .sc-welcome { padding: 12px 4px; }
html[data-mode="floating"] .sc-ring-lg, html[data-mode="inline"] .sc-ring-lg { --ring-size: 150px; }
html[data-mode="floating"] .sc-mascot img, html[data-mode="inline"] .sc-mascot img { width: 106px; }
html[data-mode="floating"] .sc-bubble, html[data-mode="inline"] .sc-bubble { font-size: 14px; padding: 6px 12px; }
html[data-mode="floating"] .sc-welcome h2, html[data-mode="inline"] .sc-welcome h2 { font-size: 21px; }
html[data-mode="floating"] .sc-welcome p, html[data-mode="inline"] .sc-welcome p { font-size: 15px; }
/* Logo header widget/iframe: cincin berputar seperti halaman mandiri, ukuran disesuaikan tinggi header. */
html[data-mode="floating"] .sc-header .sc-ring-sm, html[data-mode="inline"] .sc-header .sc-ring-sm {
  --ring-size: 32px; --ring-dot: 5px; }
html[data-mode="floating"] .sc-header .sc-ring-sm > .sc-logo,
html[data-mode="inline"] .sc-header .sc-ring-sm > .sc-logo { width: 24px; height: 24px; }
.sc-quota-login { margin-top: 8px; display: block; }

/* Label tahap rilis (APP_RELEASE_STAGE, mis. BETA) di samping nama SiChatFish */
.sc-beta { display: inline-block; vertical-align: middle; margin-left: 4px; padding: 2px 6px; border-radius: 999px;
  background: #f5b82e; color: #3a2a00; font-size: 10px; font-weight: 800; letter-spacing: .06em; line-height: 1.2;
  flex: 0 0 auto; white-space: nowrap; }
.sc-ring .sc-beta { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); z-index: 2; margin: 0;
  font-size: 8px; padding: 1px 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }

/* ---- Memori pengguna ---- */
.sc-app { position: relative; }
.sc-memrow { padding: 0 14px 8px; background: var(--sc-bg); text-align: right; }
.sc-linkbtn { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 12px; color: var(--sc-accent); cursor: pointer; text-decoration: underline; }
.sc-memp { position: absolute; inset: 0; z-index: 20; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-end; justify-content: center; }
.sc-memp[hidden] { display: none; }
.sc-memp-box { background: var(--sc-bg); color: var(--sc-ink); width: 100%; max-width: 560px; max-height: 88%; overflow: auto; border-radius: var(--sc-radius) var(--sc-radius) 0 0; padding: 14px; box-sizing: border-box; }
@media (min-width: 640px) { .sc-memp { align-items: center; } .sc-memp-box { border-radius: var(--sc-radius); } }
.sc-memp-head { display: flex; align-items: center; justify-content: space-between; }
.sc-memp-head h2 { margin: 0; font-size: 16px; }
.sc-memp-notice { margin: 10px 0; padding: 10px; font-size: 13px; background: var(--sc-notice); border: 1px solid var(--sc-notice-line); border-radius: 8px; }
.sc-memp-notice .sc-btn { display: block; margin-top: 8px; }
.sc-memp-switch { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 14px; }
.sc-memp-box .sc-foot { padding: 0 0 8px; }
.sc-memp-list { list-style: none; margin: 0; padding: 0; }
.sc-memp-list li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--sc-line); font-size: 13px; }
.sc-memp-txt { flex: 1; overflow-wrap: anywhere; }
.sc-memp-foot { margin-top: 10px; text-align: right; }
