@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Tokens ──────────────────────────────────────── */
:root {
  --bg-base:      #07071a;
  --bg-surface:   rgba(255,255,255,0.04);
  --bg-hover:     rgba(255,255,255,0.08);
  --border:       rgba(255,255,255,0.08);
  --border-focus: rgba(99,102,241,0.6);

  --primary:      #6366f1;
  --primary-dim:  rgba(99,102,241,0.15);
  --primary-hover:#7c7ff3;
  --accent:       #22d3ee;
  --accent-dim:   rgba(34,211,238,0.12);
  --success:      #10b981;
  --success-dim:  rgba(16,185,129,0.12);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245,158,11,0.12);
  --error:        #ef4444;
  --error-dim:    rgba(239,68,68,0.12);

  --text-1: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #475569;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-glow: 0 0 40px rgba(99,102,241,0.15);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);

  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-1);
  min-height: 100%;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ── Background mesh ─────────────────────────────── */
.bg-mesh {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
}
.bg-mesh::before {
  content: '';
  position: absolute;
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  top: -200px; left: -200px;
  animation: drift 20s ease-in-out infinite alternate;
}
.bg-mesh::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(34,211,238,0.08) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  animation: drift 25s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate(0,0); }
  to   { transform: translate(60px, 40px); }
}

/* ── Glass card ──────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 20px rgba(99,102,241,0.3);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 0 30px rgba(99,102,241,0.5); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-hover); color: var(--text-1); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-focus); background: var(--primary-dim); }
.btn-danger { background: var(--error-dim); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-full { width: 100%; justify-content: center; }

/* ── Inputs ──────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.input::placeholder { color: var(--text-3); }

/* ── Status badges ───────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-pending  { background: rgba(148,163,184,0.1); color: var(--text-2); }
.badge-processing { background: var(--warning-dim); color: var(--warning); }
.badge-completed  { background: var(--success-dim); color: var(--success); }
.badge-failed     { background: var(--error-dim);   color: var(--error); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-processing .badge-dot { animation: pulse-dot 1.2s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100%{ opacity:1; } 50%{ opacity:0.3; } }

/* ── Progress bar ────────────────────────────────── */
.progress-wrap { background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden; height: 6px; }
.progress-bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.5s ease;
  box-shadow: 0 0 10px var(--primary);
}

/* ── Toast ───────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  animation: toast-in 0.3s ease;
  max-width: 360px;
}
.toast-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.toast-error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.toast-info    { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: #a5b4fc; }
@keyframes toast-in { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #0f0f2e;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%; max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), var(--shadow-glow);
  animation: modal-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modal-in { from { opacity:0; transform: scale(0.92); } to { opacity:1; transform: scale(1); } }
@keyframes fade-in  { from { opacity:0; } to { opacity:1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-title  { font-size: 18px; font-weight: 700; }

/* ── Login page ──────────────────────────────────── */
.auth-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px;
  padding: 40px;
}
.auth-logo {
  text-align: center; margin-bottom: 32px;
}
.auth-logo .logo-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  box-shadow: 0 8px 32px rgba(99,102,241,0.4);
}
.auth-logo h1 { font-size: 24px; font-weight: 700; }
.auth-logo p  { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-error {
  background: var(--error-dim); border: 1px solid rgba(239,68,68,0.2);
  color: var(--error); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  display: none;
}
.auth-error.show { display: block; }

/* ── App layout ──────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(7,7,26,0.8);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 100;
}
.nav-logo { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
.nav-logo .logo-icon-sm {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user  { font-size: 13px; color: var(--text-2); }
.nav-user span { color: var(--text-1); font-weight: 500; }

.main-content { padding: 32px 24px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ── Upload zone ─────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-dim);
  box-shadow: var(--shadow-glow);
}
.upload-zone.drag-over { transform: scale(1.01); }
.upload-icon { font-size: 48px; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-8px); } }
.upload-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.upload-sub   { font-size: 14px; color: var(--text-2); }
.upload-sub strong { color: var(--primary); }
#file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── File list ───────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  animation: slide-in 0.2s ease;
}
@keyframes slide-in { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: translateY(0); } }
.file-icon { font-size: 18px; flex-shrink: 0; }
.file-name { flex: 1; color: var(--text-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-3); flex-shrink: 0; }
.file-remove { color: var(--error); background: none; border: none; font-size: 16px; padding: 2px 6px; border-radius: 4px; transition: background var(--transition); }
.file-remove:hover { background: var(--error-dim); }

/* ── Job cards ───────────────────────────────────── */
.jobs-grid { display: flex; flex-direction: column; gap: 12px; }
.job-card {
  padding: 20px 24px; cursor: default;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: slide-in 0.25s ease;
}
.job-card:hover { border-color: rgba(99,102,241,0.3); box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.job-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.job-card-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.job-id   { font-size: 13px; color: var(--text-2); font-family: monospace; }
.job-time { font-size: 12px; color: var(--text-3); }
.job-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.job-files-summary { font-size: 13px; color: var(--text-2); }

/* ── Live progress ───────────────────────────────── */
.live-job {
  padding: 24px;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.live-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.live-title  { font-size: 16px; font-weight: 600; }
.live-files  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.live-file-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 8px 12px;
  background: rgba(255,255,255,0.03); border-radius: var(--radius-sm);
}
.live-file-item .status-icon { font-size: 16px; width: 20px; text-align: center; }
.live-file-name { flex: 1; color: var(--text-2); }
.live-file-name.done { color: var(--text-1); }
.live-overall { display: flex; align-items: center; gap: 16px; }
.live-overall-label { font-size: 13px; color: var(--text-2); min-width: 80px; }
.live-count { font-size: 13px; color: var(--text-2); min-width: 40px; text-align: right; }

/* ── Markdown viewer ─────────────────────────────── */
.md-viewer {
  padding: 32px;
  max-width: 800px; margin: 0 auto;
}
.md-viewer h1 { font-size: 26px; margin-bottom: 16px; }
.md-viewer h2 { font-size: 20px; margin: 24px 0 12px; color: var(--text-1); }
.md-viewer h3 { font-size: 16px; margin: 18px 0 8px; color: var(--text-2); }
.md-viewer p  { margin-bottom: 14px; color: var(--text-2); line-height: 1.8; }
.md-viewer pre {
  background: rgba(0,0,0,0.4); border-radius: var(--radius-sm);
  padding: 16px; overflow-x: auto; margin-bottom: 16px; font-size: 13px;
  border: 1px solid var(--border);
}
.md-viewer code { font-family: monospace; font-size: 13px; background: rgba(99,102,241,0.1); padding: 2px 6px; border-radius: 4px; }
.md-viewer pre code { background: none; padding: 0; }
.md-viewer img { max-width: 100%; border-radius: var(--radius-sm); margin: 16px 0; }
.md-viewer blockquote { border-left: 3px solid var(--primary); padding-left: 16px; color: var(--text-2); margin: 16px 0; }
.md-viewer table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.md-viewer th, .md-viewer td { border: 1px solid var(--border); padding: 8px 12px; }
.md-viewer th { background: var(--bg-hover); }
.md-viewer ul, .md-viewer ol { padding-left: 24px; margin-bottom: 14px; color: var(--text-2); }
.md-viewer li { margin-bottom: 4px; }

/* ── Section titles ──────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title  { font-size: 18px; font-weight: 700; }
.section-sub    { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  background: none; border: none; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text-1); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Empty state ─────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ─────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .main-content { padding: 20px 16px; }
  .auth-card { padding: 28px 20px; }
  .modal { padding: 24px 20px; }
  .navbar { padding: 0 16px; }
  .job-card { padding: 16px; }
  .job-card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}
