/* ============================================================
   Sicana RAG — Adhyaksa Edition
   Palet: Navy (institutional) + Gold (Adhyaksa wisdom)
   Inspired by Kejaksaan Agung visual identity
   ============================================================ */

:root[data-theme="dark"], :root {
  /* Surfaces — deep green-tinted dark (Kejaksaan green pelan, soothing untuk reading) */
  --bg: #0d1812;            /* very dark forest */
  --bg-sidebar: #0a130e;
  --bg-hover: #16241c;
  --bg-active: #1c2e23;
  --bg-input: #112019;
  --bg-bubble: #16241c;

  --border: #1f3328;
  --border-input: #2c4837;

  --text: #f1f5f0;
  --text-secondary: #c8d3c5;
  --text-muted: #8d9b8a;

  /* Brand accents — Gold (Adhyaksa wisdom) + Kejaksaan green */
  --accent: #f5c842;        /* Kejaksaan gold/yellow */
  --accent-strong: #d4a82f;
  --accent-soft: rgba(245, 200, 66, 0.15);
  --accent-green: #2d8d4a;  /* Kejaksaan green (wreath) */
  --accent-green-soft: rgba(45, 141, 74, 0.15);
  --accent-pink: #f5c842;   /* alias kompat */

  --send-bg: #f5c842;
  --send-fg: #0a130e;

  --user-bubble: #1c2e23;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 12px 36px rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  /* Light: crisp white institutional dengan green & gold accents */
  --bg: #ffffff;
  --bg-sidebar: #f5f7f3;
  --bg-hover: #e8ede4;
  --bg-active: #dbe3d4;
  --bg-input: #ffffff;
  --bg-bubble: #f0f3ec;

  --border: #dde4d6;
  --border-input: #c1cdb6;

  --text: #1a2e20;          /* deep green-black text */
  --text-secondary: #3d5544;
  --text-muted: #6e7d70;

  --accent: #b8902f;        /* darker gold untuk contrast on white */
  --accent-strong: #97751f;
  --accent-soft: rgba(184, 144, 47, 0.14);
  --accent-green: #1f6b34;
  --accent-green-soft: rgba(31, 107, 52, 0.12);
  --accent-pink: #b8902f;

  --send-bg: #1f6b34;       /* green send button */
  --send-fg: #f5c842;       /* gold icon */

  --user-bubble: #e8ede0;

  --shadow: 0 1px 4px rgba(26, 46, 32, 0.08);
  --shadow-strong: 0 12px 36px rgba(26, 46, 32, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  font-feature-settings: "ss01", "cv11";
}
/* Headings di chat respond pakai serif untuk formal touch */
.msg-content h2, .msg-content h3, .welcome-title {
  font-family: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}
/* Code wherever it appears */
.msg-content code, .msg-content pre, .code-block pre, .code-block-lang {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace !important;
  font-feature-settings: "calt" 1;
}

button, a { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; text-decoration: none; }
svg { display: block; }

/* ============================================================
   App layout
   ============================================================ */

.app { display: flex; height: 100vh; overflow: hidden; }

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.2s ease;
}
.sidebar.collapsed { margin-left: -260px; }

.sidebar-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16241c, #0a130e);
  flex-shrink: 0;
  border: 1px solid var(--accent-soft);
  box-shadow: inset 0 1px 0 rgba(245, 200, 66, 0.18), 0 2px 6px rgba(0, 0, 0, 0.25);
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
  color: var(--text);
}
.brand-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-nav {
  padding: 8px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-btn {
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
  width: 100%;
}
.nav-btn:hover { background: var(--bg-hover); }
.nav-btn.active { background: var(--bg-hover); }
.nav-btn svg { opacity: 0.85; flex-shrink: 0; }

.search-wrap {
  padding: 4px 8px 8px;
}
.search-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--text-muted); }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.sidebar-section { margin-bottom: 12px; }
.sidebar-section-title {
  padding: 8px 12px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-hint {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0.6;
  text-transform: uppercase;
}
.sidebar-item {
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.sidebar-item:hover { background: var(--bg-hover); }
.sidebar-item.active { background: var(--bg-active); font-weight: 500; }
.sidebar-item .emoji-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-active);
  border-radius: 6px;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-item svg { opacity: 0.7; flex-shrink: 0; }

/* Tool toggle items — clickable filter chips in sidebar */
.tool-item {
  position: relative;
  user-select: none;
}
.tool-item .tool-check {
  margin-left: auto;
  font-size: 8px;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.tool-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.tool-item.active .tool-check {
  opacity: 1;
  transform: scale(1);
}
.tool-item.active .emoji-icon {
  background: rgba(245, 200, 66, 0.25);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.conversation-list { display: flex; flex-direction: column; gap: 1px; }
.conv-item {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.conv-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.conv-delete {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s, color 0.1s, background 0.1s;
}
.conv-item:hover .conv-delete,
.conv-item.active .conv-delete { opacity: 1; }
.conv-delete:hover { color: #ef4444; background: var(--bg-hover); }
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }

.sidebar-bottom {
  padding: 8px;
  border-top: 1px solid var(--border);
}
.user-btn {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
}
.user-btn:hover { background: var(--bg-hover); }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c084fc, #8b5cf6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-info { flex: 1; text-align: left; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-plan { font-size: 11px; color: var(--text-muted); }
.theme-icon { font-size: 16px; }

/* ============================================================
   Right Content Panel (Claude-style)
   ============================================================ */

.content-panel {
  width: 400px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-right 0.2s ease;
}
.content-panel.hidden {
  display: none;
}

.content-panel-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.content-panel-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.content-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.content-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.content-empty svg { margin: 0 auto 12px; display: block; }
.content-empty p { font-size: 14px; margin-bottom: 4px; color: var(--text-secondary); }
.content-empty small { font-size: 12px; }

.content-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  position: relative;
}
.content-item:hover { background: var(--bg-hover); border-color: var(--border-input); }

.content-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.content-item-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-active);
  color: var(--text-secondary);
}
.content-item-type.doc { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.content-item-type.image { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.content-item-type.audio { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.content-item-type.source { background: var(--accent-soft); color: var(--accent); }
.content-item-type.url { background: rgba(99, 102, 241, 0.15); color: #818cf8; }

.content-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.content-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 80px;
  overflow: hidden;
  position: relative;
  margin-top: 6px;
}
.content-item-preview.fadeout::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.content-item-image-preview {
  width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.content-item-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.1s;
}
.content-item:hover .content-item-remove { opacity: 1; }
.content-item-remove:hover { color: #ef4444; background: var(--bg-hover); }

.content-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 4px 6px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.content-section-title:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* ============================================================
   Main
   ============================================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 52px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
}
.topbar-brand {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.4px;
  color: var(--text);
}
.topbar-brand::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 2px;
  box-shadow: 0 0 8px var(--accent-soft);
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.1s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.topbar-spacer { flex: 1; }
.sidebar-show { display: none; }
.sidebar.collapsed + .main .sidebar-show { display: flex; }

/* ============================================================
   Messages
   ============================================================ */

#messages-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#messages {
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 200px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Welcome (centered ChatGPT-style) */
.welcome-centered {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}
.welcome-centered.hidden { display: none; }

/* Subtle institutional pattern di background */
.welcome-centered::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 30%, var(--accent-soft) 0%, transparent 50%),
    repeating-linear-gradient(45deg, transparent 0, transparent 38px, rgba(212, 168, 67, 0.025) 38px, rgba(212, 168, 67, 0.025) 39px);
  pointer-events: none;
  z-index: 0;
}
.welcome-centered > * { position: relative; z-index: 1; }

.welcome-mark {
  width: 64px;
  height: 64px;
  margin-bottom: 22px;
  color: var(--accent);
  opacity: 0.85;
}
.welcome-mark svg { width: 100%; height: 100%; }
.welcome-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.welcome-title {
  font-size: 30px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
  color: var(--text);
  max-width: 600px;
  line-height: 1.25;
}
.welcome-sub {
  font-size: 14.5px;
  color: var(--text-secondary);
  text-align: center;
  max-width: 540px;
  margin-bottom: 18px;
  line-height: 1.55;
}
/* Motto "Satya Adhi Wicaksana" — formal display di bawah welcome */
.welcome-motto {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 28px;
  opacity: 0.85;
}
.welcome-motto span {
  display: inline-block;
  font-weight: 600;
}
/* Update welcome mark sizing (logo lebih komplek sekarang) */
.welcome-mark {
  width: 80px !important;
  height: 80px !important;
  opacity: 1 !important;
}

/* Action chips below welcome input */
.action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
  max-width: 700px;
}
.action-chip {
  padding: 8px 14px;
  border: 1px solid var(--border-input);
  border-radius: 22px;
  font-size: 13px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.action-chip:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text);
}
.action-chip svg { opacity: 0.7; }

/* Message bubbles */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeIn 0.15s ease;
}
/* User: bubble di kanan, avatar di pojok kanan */
.msg.user { flex-direction: row-reverse; }
/* Assistant: tetap kiri (default flow) */
@keyframes fadeIn { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;        /* squircle — bukan circle generic */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
  box-shadow: 0 2px 6px rgba(10, 16, 36, 0.35);
  margin-top: 2px;
  position: relative;
}
.msg-avatar::after {
  /* Subtle gold rim untuk premium feel */
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 10px;
  border: 1px solid var(--accent-soft);
  pointer-events: none;
}
.msg.user .msg-avatar { background: linear-gradient(135deg, #d4a843, #b8902f); color: #0a1024; }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #1a2547, #0a1024); border: 1px solid var(--accent); }
.msg.assistant .msg-avatar svg { color: #fff; }
.msg.system .msg-avatar { background: var(--text-muted); opacity: 0.6; }

.msg-content {
  min-width: 0;
  line-height: 1.65;
  color: var(--text);
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user .msg-content {
  background: var(--user-bubble);
  padding: 11px 16px;
  /* Asymmetric corners — sudut kanan-atas flat menempel ke avatar (formal speech bubble) */
  border-radius: 18px 6px 18px 18px;
  max-width: 100%;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}
/* Assistant: tanpa bubble, tapi pakai thin gold left-accent untuk distinctive marker */
.msg.assistant .msg-content {
  border-left: 2px solid var(--accent-soft);
  padding-left: 14px;
  margin-left: -2px;
  transition: border-color 0.3s;
}
.msg.assistant:hover .msg-content {
  border-left-color: var(--accent);
}
.msg.system .msg-content { font-size: 13px; color: var(--text-muted); font-style: italic; }

.msg-content p { margin: 0 0 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h2, .msg-content h3 { margin: 16px 0 8px; font-weight: 600; }
.msg-content h2 { font-size: 20px; }
.msg-content h3 { font-size: 17px; }
.msg-content ul, .msg-content ol { margin: 8px 0 8px 22px; }
.msg-content li { margin: 4px 0; }
.msg-content strong { font-weight: 600; }
.msg-content code {
  background: var(--bg-bubble);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
.msg-content pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  padding: 14px;
  margin: 0;
  overflow-x: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.msg-content pre code { background: none; padding: 0; }

/* Code block wrapper (lang label + copy button) */
.code-block {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.code-block pre { border: none; border-radius: 0; margin: 0; }
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  font-size: 11.5px;
  color: var(--text-muted);
}
.code-block-lang {
  text-transform: lowercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}
.code-block-copy {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}
.code-block-copy:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.code-block-copy.copied { color: var(--accent); }

/* Inline citation badges [1] [2] */
.citation-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin: 0 2px;
  border-radius: 10px;
  background: var(--bg-bubble);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none !important;
  vertical-align: 1px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.citation-badge:hover {
  background: var(--accent);
  color: #fff;
}

/* Highlight flash on content panel item when its citation is clicked */
.content-item.flash {
  animation: citeFlash 1.4s ease-out;
}
@keyframes citeFlash {
  0%   { background: rgba(212, 168, 67, 0.25); border-color: var(--accent); }
  100% { background: var(--bg); border-color: var(--border); }
}
.msg-content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 10px 0;
  border: 1px solid var(--border);
}
.msg-content a { color: var(--accent); }
.msg-content a:hover { text-decoration: underline; }

/* Tables (GFM) */
.msg-content table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.msg-content th, .msg-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.msg-content thead th {
  background: var(--bg-bubble);
  font-weight: 600;
  color: var(--text);
}
.msg-content tbody tr:nth-child(even) {
  background: var(--bg-hover);
}

/* Numbered lists & nested lists */
.msg-content ol { list-style: decimal; }
.msg-content ul ul, .msg-content ol ol, .msg-content ul ol, .msg-content ol ul {
  margin: 4px 0 4px 18px;
}

/* Blockquote (e.g. citations from RAG) */
.msg-content blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-style: italic;
  border-radius: 0 6px 6px 0;
}
.msg-content blockquote p { margin-bottom: 4px; }
.msg-content blockquote p:last-child { margin-bottom: 0; }

/* Horizontal rule */
.msg-content hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Strikethrough */
.msg-content del { color: var(--text-muted); }

.sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}
.sources a { color: var(--text-secondary); }

/* Body wrapper holds bubble + action toolbar stacked vertically */
.msg-body-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
/* User: limit bubble width so long messages don't fill the whole row */
.msg.user .msg-body-wrap {
  align-items: flex-end;
  max-width: 75%;
  margin-left: auto;
}

/* Message action toolbar (Claude-style — copy / retry / like, etc.) */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.msg:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
}
.msg-actions-user {
  justify-content: flex-end;
}
.msg-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 6px;
  letter-spacing: 0.2px;
}
.msg-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.msg-action-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Loading state untuk voice button (saat transcribe via server) */
.voice-btn.loading {
  color: var(--accent);
  animation: voice-spin 1s linear infinite;
}
@keyframes voice-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Voice settings form */
.form-group { margin-bottom: 16px; }
.form-group > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.radio-row { display: flex; gap: 8px; }
.radio-col { display: flex; flex-direction: column; gap: 6px; }
.radio-option, .radio-option-full {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex: 1;
  transition: background 0.1s, border-color 0.1s;
  font-size: 14px;
}
.radio-option-full { align-items: flex-start; }
.radio-option:hover, .radio-option-full:hover { background: var(--bg-hover); }
.radio-option input, .radio-option-full input { margin: 0; }
.radio-option input:checked + span,
.radio-option-full input:checked ~ div { color: var(--text); }
.radio-option-full:has(input:checked),
.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio-option-full div { display: flex; flex-direction: column; flex: 1; }
.radio-option-full strong { font-weight: 500; }
.radio-option-full small { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.toggle-row input { margin-top: 4px; }
.toggle-row span { display: flex; flex-direction: column; flex: 1; }
.toggle-row strong { font-weight: 500; font-size: 14px; }
.toggle-row small { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.cursor-blink {
  display: inline-block;
  width: 10px;
  height: 18px;
  background: var(--text);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
  margin-left: 2px;
  border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   Input area
   ============================================================ */

.input-area {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px 16px;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
  pointer-events: none;
}
.input-area.hidden { display: none; }
.input-area > * { pointer-events: auto; }

.attachments-bar {
  max-width: 768px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attached-chip {
  background: var(--bg-bubble);
  border: 1px solid var(--border-input);
  padding: 6px 10px 6px 12px;
  border-radius: 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.attached-chip .x { color: var(--text-muted); cursor: pointer; font-size: 14px; }
.attached-chip .x:hover { color: var(--text); }
.web-mode-pill { background: rgba(16, 163, 127, 0.1); border-color: var(--accent); color: var(--accent); }

.input-wrap {
  max-width: 768px;
  margin: 0 auto;
}
.input-wrap.centered { max-width: 720px; width: 100%; }

.input-box {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 26px;
  padding: 6px 6px 6px 10px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-box:focus-within {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-strong);
}

.input-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 0.1s, color 0.1s;
}
.input-icon:hover { background: var(--bg-hover); color: var(--text); }

.input-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  max-height: 220px;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.input-textarea::placeholder { color: var(--text-muted); }

.extended-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.extended-badge .dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.voice-lang-btn {
  height: 28px;
  min-width: 32px;
  padding: 0 8px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.voice-lang-btn:hover { background: var(--border); color: var(--text); }

.voice-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.voice-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Recording state — red pulse */
.voice-btn.recording {
  background: #ef4444;
  color: white;
  animation: voice-pulse 1.4s ease-in-out infinite;
}
.voice-btn.recording:hover {
  background: #dc2626;
  color: white;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.voice-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-pink);
  color: white;
  transition: opacity 0.1s;
}
.voice-circle:hover { opacity: 0.9; }

.send-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--send-bg);
  color: var(--send-fg);
  transition: opacity 0.1s;
}
.send-icon:hover:not(:disabled) { opacity: 0.85; }
.send-icon:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
}
.send-icon.stopping {
  background: #ef4444;
  color: #fff;
  animation: pulseStop 1.4s ease-in-out infinite;
}
.send-icon.stopping:hover { background: #dc2626; opacity: 1; }
@keyframes pulseStop {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.input-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0 0;
}

/* ============================================================
   Model picker
   ============================================================ */

.model-picker-wrap { position: relative; flex-shrink: 0; }
.model-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.model-pill:hover { background: var(--bg-hover); color: var(--text); }
.model-pill svg { opacity: 0.6; }

.badge-pill {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.model-menu {
  position: absolute;
  bottom: 44px;
  right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  min-width: 320px;
  max-height: 420px;
  overflow-y: auto;
  box-shadow: var(--shadow-strong);
  z-index: 100;
}
.model-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s;
}
.model-option:hover { background: var(--bg-hover); }
.model-option.selected { background: var(--bg-hover); }

.model-option-info { flex: 1; min-width: 0; }
.model-option-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}
.model-option-title .badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.model-option-title .badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-active);
  color: var(--text-muted);
  font-weight: 500;
}
.model-option-title .badge.default { background: var(--accent); color: white; }
.model-option-title .badge.fast { background: #f59e0b; color: white; }
.model-option-title .badge.powerful { background: #6366f1; color: white; }
.model-option-title .badge.code { background: #8b5cf6; color: white; }

.model-option-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.model-option-check { color: var(--accent); opacity: 0; flex-shrink: 0; margin-top: 2px; }
.model-option.selected .model-option-check { opacity: 1; }

/* ============================================================
   Attach menu
   ============================================================ */

.attach-menu {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 280px;
  box-shadow: var(--shadow-strong);
  z-index: 100;
}
.attach-menu button {
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  transition: background 0.1s;
  width: 100%;
}
.attach-menu button:hover { background: var(--bg-hover); }
.attach-menu button svg { color: var(--text-secondary); flex-shrink: 0; }
.attach-menu button div { display: flex; flex-direction: column; flex: 1; }
.attach-menu button strong { font-weight: 500; }
.attach-menu button small { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ============================================================
   Modal
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 560px;
  max-width: 90vw;
  box-shadow: var(--shadow-strong);
}
.modal h3 { margin-bottom: 6px; font-size: 18px; font-weight: 600; }
.modal p { color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }
#context-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  resize: vertical;
  outline: none;
}
#context-input:focus { border-color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-primary, .btn-ghost, .btn-danger {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.1s, opacity 0.1s;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* Confirm modal */
.confirm-modal-content {
  width: 420px;
  text-align: center;
  padding: 28px 24px 22px;
}
.confirm-modal-content h3 { margin-bottom: 8px; }
.confirm-modal-content p { margin-bottom: 20px; }
.confirm-modal-content .modal-actions { justify-content: center; gap: 10px; }
.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.12);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

/* Modal enter animation */
.modal:not(.hidden) .modal-content {
  animation: modalPop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Utilities
   ============================================================ */

.hidden { display: none !important; }

/* Drag & drop overlay */
#drop-overlay {
  position: fixed;
  inset: 0;
  background: var(--accent-soft);
  backdrop-filter: blur(4px);
  border: 3px dashed var(--accent);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
#drop-overlay.visible { opacity: 1; }
#drop-overlay .drop-inner {
  text-align: center;
  color: var(--accent);
  padding: 32px;
  border-radius: 16px;
}
#drop-overlay .drop-inner svg { margin: 0 auto 12px; }
#drop-overlay .drop-inner p { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
#drop-overlay .drop-inner small { font-size: 13px; opacity: 0.8; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { position: absolute; height: 100%; z-index: 50; }
  #messages { padding: 16px 12px 200px; }
  .input-area { padding: 12px 12px 16px; }
  .welcome-title { font-size: 24px; }
}
