/* rail.css — status chat (markdown/thinking), toggle sidebar, dan panel kanan. */

/* ===== Markdown di bubble jawaban ===== */
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.bubble strong { color: var(--ink); font-weight: 700; }
.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
html[data-theme="light"] .bubble code { background: rgba(0,0,0,0.05); }
.bubble h3, .bubble h4 { margin: 4px 0 6px; font-size: 14.5px; }
.fb { gap: 8px; }
.fb button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.fb button:hover { background: var(--surface3); color: var(--ink); border-color: var(--line); }
.fb button:focus-visible { outline: none; box-shadow: var(--ring); }
.engine-note {
  padding: 0 24px 10px;
  font-size: 12px;
  color: var(--warn);
}
@media (max-width: 720px) { .engine-note { padding: 0 14px 8px; } }

/* ===== Indikator "thinking" ===== */
.msg.thinking .think-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
  padding: 11px 15px;
}
.think-dots { display: inline-flex; gap: 4px; align-items: center; }
.think-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: thinkPulse 1.25s infinite ease-in-out;
}
.think-dots i:nth-child(2) { animation-delay: 0.16s; }
.think-dots i:nth-child(3) { animation-delay: 0.32s; }
@keyframes thinkPulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0) scale(0.9); }
  40% { opacity: 1; transform: translateY(-2px) scale(1); }
}
.think-label {
  background: linear-gradient(90deg, var(--muted) 25%, var(--ink) 50%, var(--muted) 75%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: thinkShimmer 2.2s linear infinite;
}
@keyframes thinkShimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}
.think-elapsed {
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--faint);
  padding-left: 2px;
}
html[data-theme="light"] .think-label {
  background: linear-gradient(90deg, var(--muted) 25%, var(--ink) 50%, var(--muted) 75%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
}
@media (prefers-reduced-motion: reduce) {
  .think-dots i, .think-label { animation: none; }
  .think-label { color: var(--muted); -webkit-text-fill-color: var(--muted); }
}

/* tombol kirim saat memproses */

.cite .kv { color: var(--text-secondary); }


/* ===== Sidebar toggle (show/hide) ===== */
.side {
  transition: width 0.22s ease, flex-basis 0.22s ease, min-width 0.22s ease,
    padding 0.22s ease, border-color 0.22s ease;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 12px;
}
.side-head .brand { padding: 0; }
.side-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  opacity: 1;
  pointer-events: auto;
  transition: color 0.15s, background 0.15s;
}
.side-toggle:hover { color: var(--ink); background: var(--surface3); }
.side-toggle svg { transition: transform 0.22s ease; }
.app.sidebar-collapsed .side-toggle svg { transform: rotate(180deg); }

/* collapse -> rail ikon (logo header & ikon menu tetap tampil) */
.app.sidebar-collapsed .side {
  width: 64px;
  flex-basis: 64px;
  min-width: 64px;
  padding: 10px 8px 14px;
}
.app.sidebar-collapsed .side-head { position: relative; justify-content: center; padding-bottom: 12px; }
.app.sidebar-collapsed .side-toggle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  display: inline-flex;
  opacity: 0;
  pointer-events: none;
}
.app.sidebar-collapsed .side:hover .side-toggle { opacity: 1; pointer-events: auto; }
.app.sidebar-collapsed .side .brand { cursor: pointer; transition: opacity 0.15s; }
.app.sidebar-collapsed .side .brand .brandtext { display: none; }
.app.sidebar-collapsed .side .brand .mark { width: 26px; height: 26px; }
.app.sidebar-collapsed .side:hover .brand { opacity: 0; }
.app.sidebar-collapsed .side .theme-row { display: none; }
.app.sidebar-collapsed .menu-item { justify-content: center; padding: 10px; }
.app.sidebar-collapsed .menu-item span { display: none; }
.app.sidebar-collapsed .menu-label { display: none; }
.app.sidebar-collapsed .side-search { display: none; }
.app.sidebar-collapsed .user-chip { justify-content: center; padding-left: 0; padding-right: 0; }
.app.sidebar-collapsed .user-chip .uinfo,
.app.sidebar-collapsed .user-chip #logout { display: none; }
@media (max-width: 720px) {
  /* di mobile collapse dinetralkan agar strip menu tetap utuh */
  .app.sidebar-collapsed .side { width: 100%; flex-basis: auto; min-width: 0; padding: 8px 10px; }
  .app.sidebar-collapsed .side .brand { display: none; }
  .app.sidebar-collapsed .menu-item span { display: block; }
  .app.sidebar-collapsed .side-head { justify-content: flex-start; }
}

/* ===== Tooltip menu saat sidebar di-collapse =====
   Pill charcoal dengan teks terang, muncul di kanan ikon. Elemen tunggal
   (#sideTip) diposisikan oleh js/shell/side-tooltip.js; bukan ::after per item
   supaya bisa keluar dari `overflow-x: hidden` sidebar.
   `pointer-events: none` wajib: tooltip tidak boleh memicu pointerout yang
   membuatnya berkedip. */
.side-tip {
  position: fixed;
  z-index: 120;
  left: 0;
  top: 0;
  max-width: 260px;
  padding: 6px 11px;
  border-radius: 8px;
  background: #101113;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #F2F3F5;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.side-tip[hidden] { display: none; }
.side-tip.in { opacity: 1; transform: translateX(0); }
html[data-theme="light"] .side-tip {
  background: #1B1C1F;
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 6px 18px rgba(20, 22, 26, 0.24);
}
@media (prefers-reduced-motion: reduce) {
  .side-tip { transition: none; transform: none; }
}

/* Notifikasi: mengambang di pojok kanan atas (tanpa navbar, tanpa border) */
.top-right { position: fixed; top: 12px; right: 16px; z-index: 70; }
.top-right .notif-wrap { padding: 0; }
.notif-btn { background: transparent; border: 0; box-shadow: none; color: var(--muted); width: 34px; height: 34px; }
.notif-btn:hover { color: var(--ink); border-color: transparent; }

/* ===== Panel kanan (toggle di pojok kanan atas) ===== */
.rail-right {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--side);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: flex-basis 0.22s ease, width 0.22s ease;
}
/* Bar tab: strip tab yang bisa digeser + tombol + yang selalu terlihat.
   Tombol + berada di luar area scroll agar tidak pernah menutupi tab. */
.rail-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  /* Ruang untuk notifikasi + toggle panel kanan (fixed di pojok atas). */
  padding-right: 100px;
  border-bottom: 1px solid var(--line);
  flex: none;
  min-width: 0;
}
.rail-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Menyusut sesuai isi: tombol + menempel tepat setelah tab terakhir
     (seperti referensi), dan tetap di tepi kanan saat tab meluap. */
  flex: 0 1 auto;
  min-width: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}
.rail-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-width: 96px;
  padding: 5px 7px;
  border: 0;
  background: var(--rail-tab);
  border-radius: 8px;
  color: var(--rail-tab-ink);
  font-size: 12.5px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.rail-tab:hover { background: var(--rail-tab-hover); color: var(--rail-tab-ink-strong); }
.rail-tab.active { background: var(--rail-tab-active); color: var(--rail-tab-ink-strong); }
.rail-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.rail-tab-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  border: 0;
  background: var(--rail-tab-box);
  color: var(--rail-tab-ink);
  font-size: 13px;
  line-height: 1;
}
.rail-tab-title { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  color: var(--rail-tab-close);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.rail-tab-close:hover { color: var(--rail-tab-ink-strong); background: var(--rail-tab-box-hover); }

.rail-tab-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 6px;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  /* Tanpa background (sesuai referensi); tombol berada di luar strip yang
     di-scroll sehingga selalu terlihat walau tab banyak. */
  background: transparent;
  transition: color 0.15s, background 0.15s;
}
.rail-tab-add:hover { color: var(--ink); background: var(--surface-hover); }
/* Tab yang sedang aktif selalu digeser ke area pandang saat dibuka dari menu. */
.rail-tab.active { scroll-margin-inline: 12px; }
.rail-tab-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rail-body { flex: 1; min-height: 0; overflow-y: auto; }
.rail-pane { display: none; height: 100%; }
.rail-pane.active { display: block; }
.app.rail-open #view { flex: 1 1 50%; }
.app.rail-open .rail-right { flex: 1 1 50%; width: auto; }
.rail-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 24px;
  text-align: center;
}
.rail-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface2);
  color: var(--muted);
}
.rail-empty-icon svg { width: 20px; height: 20px; }
.rail-empty-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.rail-empty-desc { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--faint); max-width: 32ch; }
.rail-empty-hint { margin: 14px 0 0; font-size: 12px; color: var(--faint); }
.rail-empty-hint kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface2);
  color: var(--muted);
}
.top-right { display: flex; align-items: center; gap: 6px; }
.rail-toggle {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  order: 2;
  transition: color 0.15s, background 0.15s;
}
.rail-toggle:hover { color: var(--ink); background: var(--surface3); }
.top-right .notif-wrap { order: 1; }

@media (max-width: 720px) {
  /* Panel kanan jadi drawer overlay di layar kecil (tidak disembunyikan). */
  .rail-right {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(92vw, 420px);
    min-width: 0;
    z-index: 60;
    transform: translateX(102%);
    transition: transform 0.22s ease;
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
  }
  .app.rail-open .rail-right {
    flex: none;
    width: min(92vw, 420px);
    transform: translateX(0);
  }
  .app.rail-open #view { flex: 1 1 auto; }
  .rail-toggle { display: inline-flex; }
  .app.rail-open .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 55;
  }
}

.rail-backdrop { display: none; }
/* Footer sidebar: toggle tema dekat profil */
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.theme-row { display: flex; justify-content: flex-end; padding-right: 4px; }
.side-foot .user-chip { margin-top: 4px; }

/* === Ukuran sidebar terkunci (spek pengguna) === */
.side .brand .mark { width: 29px; height: 29px; }
.side .brand .brandtext span { font-size: 11px; margin-left: 0; letter-spacing: 0; }
.side-head { height: 49px; margin-left: -8px; margin-right: -8px; padding: 0 8px; }
.side .menu-item { height: 37px; padding: 8px 12px 8px 8px; }
.side .menu-item svg { width: 19px; height: 19px; }
.side .user-chip { height: 49px; margin-left: -8px; margin-right: -8px; padding-left: 8px; padding-right: 8px; }

/* === Tinggi layar pendek: rapatkan menu supaya sidebar tetap tanpa scroll.
   Ditaruh paling akhir agar menang atas spek tinggi 37px di atas. === */
@media (min-width: 721px) and (max-height: 880px) {
  .menu-label { font-size: 10.5px; padding: 3px 8px 1px; }
  .menu-group { margin-bottom: 2px; }
  .side .menu-item { height: 34px; }
  .menu-more-pop .menu-item { height: 34px; }
}
@media (min-width: 721px) and (max-height: 800px) {
  .side .menu-item { height: 32px; }
  .menu-more-pop .menu-item { height: 32px; }
  .menu-label { padding: 2px 8px 0; }
  .menu-group { margin-bottom: 1px; }
}
@media (min-width: 721px) and (max-height: 720px) {
  .side .menu-item { height: 30px; padding-top: 5px; padding-bottom: 5px; }
  .menu-more-pop .menu-item { height: 30px; }
  .menu-label { font-size: 10px; padding: 1px 8px 0; line-height: 1.2; }
  .menu-group { margin-bottom: 0; }
}
@media (min-width: 721px) and (max-height: 710px) {
  .side .menu-item { height: 28px; padding-top: 4px; padding-bottom: 4px; }
  .menu-more-pop .menu-item { height: 30px; }
  .menu-label { font-size: 9.5px; letter-spacing: 0.05em; }
}
@media (min-width: 721px) and (max-height: 660px) {
  .side .menu-item { height: 26px; }
  .menu-more-pop .menu-item { height: 30px; }
  .menu-label { display: none; }
}
/* Layar sangat pendek (<=600px): rapatkan lagi supaya tetap tanpa scroll. */
@media (min-width: 721px) and (max-height: 600px) {
  .side .menu-item { height: 24px; padding-top: 3px; padding-bottom: 3px; }
  .menu-group { margin-bottom: 0; }
  .side-head { padding-bottom: 8px; }
}
@media (min-width: 721px) and (max-height: 560px) {
  .side .menu-item { height: 22px; padding-top: 2px; padding-bottom: 2px; }
  .side .menu-item svg { width: 17px; height: 17px; }
  .side-head { padding-bottom: 6px; }
}
@media (min-width: 721px) and (max-height: 520px) {
  .side .menu-item { height: 20px; padding-top: 1px; padding-bottom: 1px; }
  .side { padding-top: 6px; }
}
/* Ekstrem (<=490px): sisakan scroll tipis saja — bukan layout rusak. */
@media (min-width: 721px) and (max-height: 490px) {
  .side .menu-item { height: 19px; }
  .side { padding-bottom: 6px; }
  .side-head { padding-bottom: 4px; }
}
