/* ============================================================
   unified - 娄教授AI工作室 shared design system
   ============================================================ */

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --ink: #1a1a1a;
  --ink-2: #555;
  --ink-3: #888;
  --surface: #fff;
  --bg: #f3f3f0;
  --border: #e2e2e2;
  --border-focus: #0c7d6e;
  --accent: #0c7d6e;
  --accent-hover: #0a6b5e;
  --accent-light: rgba(12,125,110,.06);
  --error: #c53030;
  --success: #15803d;
  --radius: 10px;
  --radius-sm: 8px;
  --transition: 180ms cubic-bezier(.22,1,.36,1);
}

/* ── Base ─────────────────────────────────────────────────── */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 48px; font-size: 13px;
}
.topbar .left { display: flex; align-items: center; gap: 12px; }
.topbar .back {
  color: var(--ink-3); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color var(--transition);
}
.topbar .back:hover { color: var(--accent); }
.topbar .back svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.topbar .credits { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; }
.topbar .credits .badge {
  background: var(--accent-light); color: var(--accent);
  padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.topbar .logout {
  color: var(--ink-3); text-decoration: none; font-size: 12px;
  transition: color var(--transition);
}
.topbar .logout:hover { color: var(--error); }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 720px; margin: 0 auto; padding: 24px 20px 48px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); margin-bottom: 4px; }
.page-header p { font-size: 14px; color: var(--ink-3); }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; margin-bottom: 16px;
  transition: border-color var(--transition);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 16px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: 42px; padding: 0 20px;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition); font-family: inherit; text-decoration: none;
}
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: scale(.985); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); background: var(--accent-light); }
.btn-danger { background: rgba(197,48,48,.06); color: var(--error); border: 1px solid rgba(197,48,48,.15); }
.btn-danger:hover { background: rgba(197,48,48,.1); border-color: rgba(197,48,48,.25); }

/* ── Spinner ──────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .65s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
.btn .spinner { border-color: rgba(255,255,255,.3); border-top-color: #fff; }

/* ── Forms ────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.field .required { color: var(--error); }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.field input, .field textarea, textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--surface); outline: none; resize: vertical; line-height: 1.6;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:hover, .field textarea:hover, textarea:hover { border-color: #ccc; }
.field input:focus, .field textarea:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(12,125,110,.1);
}
::placeholder { color: #b0b0b0; }

/* ── Progress ─────────────────────────────────────────────── */
.progress-bar-bg { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.progress-status { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

/* ── Status badges ────────────────────────────────────────── */
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.status-running  { background: rgba(12,125,110,.08); color: var(--accent); }
.status-done     { background: rgba(21,128,61,.08);  color: var(--success); }
.status-failed   { background: rgba(197,48,48,.08);  color: var(--error); }
.status-pending  { background: rgba(12,125,110,.06); color: var(--accent); }

/* ── Task list (history pages) ────────────────────────────── */
.task-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer;
  transition: border-color var(--transition);
}
.task-item:hover { border-color: var(--accent); }
.task-item .info { flex: 1; min-width: 0; }
.task-item .name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-item .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty p { font-size: 14px; }
.empty .spinner { width: 20px; height: 20px; border-width: 2.5px; }

/* ── Footer ───────────────────────────────────────────────── */
.footer { text-align: center; padding: 16px 0; font-size: .72rem; color: var(--ink-3); }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 16px 14px 32px; }
  .topbar { padding: 0 14px; font-size: 12px; }
  .card { border-radius: 12px; padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
