/* ============================================================================
   ScholarAI — Application page styles
   ============================================================================ */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Top bar */
.app-bar {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center;
  background: rgba(6,8,16,0.8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.app-bar .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 500;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-strong);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.status-pill.ok .dot { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-pill.bad .dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.status-pill .pulse { animation: pulse 2s infinite; }

/* Layout */
.app-main { flex: 1; padding: 28px 0 60px; }
.app-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; }

/* Sidebar tabs */
.side { position: sticky; top: 96px; height: max-content; }
.tabs { display: flex; flex-direction: column; gap: 6px; }
.tab {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border-radius: var(--radius-sm); text-align: left;
  color: var(--text-muted); font-weight: 500; font-size: 0.95rem;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.tab svg { width: 19px; height: 19px; flex-shrink: 0; }
.tab:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tab.active { background: var(--grad-brand); color: #fff; box-shadow: 0 8px 22px -10px rgba(99,102,241,0.8); }

.side-note { margin-top: 20px; padding: 14px; border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--text-dim); background: rgba(255,255,255,0.02); border: 1px solid var(--border); }

/* Panels */
.panel { display: none; animation: fadeInUp 0.4s var(--ease); }
.panel.active { display: block; }
.panel-head { margin-bottom: 20px; }
.panel-head h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.panel-head p { color: var(--text-muted); font-size: 0.95rem; margin-top: 4px; }

.card { padding: 22px; border-radius: var(--radius); }

/* Chat */
.chat-scope { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.chat-scope label { margin: 0; white-space: nowrap; }
.chat-scope select { flex: 1; max-width: 380px; padding: 9px 12px; }
.chat-window { min-height: 420px; max-height: 60vh; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 82%; padding: 13px 16px; border-radius: 15px; font-size: 0.94rem; line-height: 1.55; animation: fadeInUp 0.3s var(--ease); }
.msg.user { align-self: flex-end; background: var(--grad-brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; white-space: pre-wrap; }
.msg.bot .cites { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg.bot .cite {
  font-size: 0.76rem; padding: 7px 10px; border-radius: 8px;
  background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); color: var(--brand-2);
  font-family: var(--font-mono);
}
.msg .meta { margin-top: 8px; font-size: 0.72rem; color: var(--text-dim); }
.chat-empty { text-align: center; color: var(--text-dim); margin: auto; }
.chat-empty .big { font-size: 3rem; margin-bottom: 10px; opacity: 0.6; }

.chat-input-row { display: flex; gap: 10px; margin-top: 16px; }
.input {
  flex: 1; background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); padding: 13px 16px; border-radius: var(--radius-sm); font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,0.18); }
textarea.input { resize: vertical; min-height: 46px; }
select.input { cursor: pointer; }
label.field-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.field { margin-bottom: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  font-size: 0.8rem; padding: 7px 13px; border-radius: 999px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-strong); color: var(--text-muted);
  transition: all 0.2s;
}
.chip:hover { border-color: var(--brand); color: var(--text); transform: translateY(-1px); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 50px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: rgba(99,102,241,0.06); transform: scale(1.005); }
.dropzone .dz-ico { font-size: 2.6rem; margin-bottom: 14px; }
.dropzone h3 { font-size: 1.1rem; margin-bottom: 6px; }
.dropzone p { color: var(--text-dim); font-size: 0.88rem; }

.steps-progress { margin-top: 22px; display: none; }
.steps-progress.show { display: block; }
.pstep { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm); color: var(--text-dim); font-size: 0.9rem; transition: color 0.3s, background 0.3s; }
.pstep.active { color: var(--text); background: rgba(99,102,241,0.08); }
.pstep.done { color: var(--success); }
.pstep .pico { width: 22px; height: 22px; display: grid; place-items: center; }

/* Papers list */
.papers { display: grid; gap: 14px; }
.paper {
  padding: 18px 20px; border-radius: var(--radius); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  transition: transform 0.2s, border-color 0.2s;
}
.paper:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.paper .ptitle { font-weight: 600; margin-bottom: 6px; }
.paper .pid { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim); }
.paper .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 0.72rem; padding: 3px 9px; border-radius: 7px; background: rgba(99,102,241,0.1); color: var(--brand-2); border: 1px solid rgba(99,102,241,0.2); }
.tag.gray { background: rgba(148,163,184,0.08); color: var(--text-muted); border-color: var(--border); }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text-muted); transition: all 0.2s; }
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(248,113,113,0.1); }
.icon-btn svg { width: 17px; height: 17px; }

/* Result blocks */
.result { margin-top: 20px; }
.result h3 { font-size: 1.05rem; font-weight: 700; margin: 18px 0 8px; }
.result p, .result li { color: var(--text-muted); font-size: 0.94rem; }
.result ul { padding-left: 20px; list-style: disc; }
.result ul li { margin-bottom: 6px; }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
.loading-row { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.9rem; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 13px 18px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; animation: fadeInUp 0.3s var(--ease);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--brand); }

/* Empty / error states */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty-state .big { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

/* Settings modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: none; place-items: center; padding: 20px; }
.modal-backdrop.open { display: grid; }
.modal { width: 100%; max-width: 460px; padding: 28px; border-radius: var(--radius-lg); animation: fadeInUp 0.3s var(--ease); }
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.modal p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 18px; }

@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .tabs { flex-direction: row; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .side-note { display: none; }
}
