/* ============ PaddleOCR Console — Design Tokens (Linear recipe) ============ */
:root {
  --ground: #08090A;
  --surface-1: #16171C;
  --surface-2: #1E1F25;
  --surface-3: #26272E;
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #F7F8F8;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --accent: #5E6AD2;
  --accent-dim: rgba(94, 106, 210, 0.16);
  --ok: #34D399;
  --danger: #EF4444;
  --danger-dim: rgba(239, 68, 68, 0.08);
  --font-display: -apple-system, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: -apple-system, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-raised: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--ground);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============ Login view ============ */
.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* 顶部极淡紫色环境光 — 唯一允许的 mesh，<8% 透明度 */
.view-login::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 55%;
  background:
    radial-gradient(60% 100% at 50% 0%, rgba(94, 106, 210, 0.10), transparent 70%),
    radial-gradient(35% 70% at 15% 10%, rgba(94, 106, 210, 0.05), transparent 60%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 380px;
  padding: 40px 32px 32px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(94, 106, 210, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.login-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.login-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.field-label {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}

.input-token {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--ground);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.input-token:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-token::placeholder {
  color: var(--text-muted);
}

.btn {
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}

.btn-primary {
  width: 100%;
  margin-top: 24px;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: #6B77E0; }
.btn-primary:active { background: #525DC0; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  display: none;
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--danger-dim);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: #FCA5A5;
  font-size: 13px;
}

/* ============ Main view ============ */
/* 初始隐藏由 .hidden class 控制；.view-main 本身必须可显示，
   否则 JS 移除 hidden 后仍被 display:none 卡死（黑屏 bug） */
.view-main { display: block; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(8, 9, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.status-dot.offline { background: var(--danger); }

.btn-ghost {
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 150ms ease-out, color 150ms ease-out;
}

.btn-ghost:hover {
  border-color: var(--hairline-strong);
  color: var(--text-primary);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.panel-hint {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.panel-body { padding: 16px; }

/* ---- 上传区 ---- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 160px;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-md);
  background: var(--ground);
  cursor: pointer;
  transition: border-color 200ms ease-out, background 200ms ease-out;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropzone-icon {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  opacity: 0.7;
}

.dropzone-text { color: var(--text-secondary); font-size: 13px; }
.dropzone-sub { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }

.file-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}

.file-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
}

.btn-ocr {
  height: 34px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out;
  flex-shrink: 0;
}

.btn-ocr:hover { background: #6B77E0; }
.btn-ocr:active { background: #525DC0; }
.btn-ocr:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- 识别加载态 ---- */
.ocr-loading {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.loading-timer {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}

/* ---- 结果区 ---- */
.result-grid {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.result-pane {
  background: var(--surface-1);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.result-pane-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.canvas-wrap {
  position: relative;
  padding: 12px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  background: #000;
}

/* ---- 文本表格 ---- */
.table-wrap { flex: 1; overflow-y: auto; max-height: 420px; }

table.ocr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ocr-table th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  text-align: left;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
}

.ocr-table td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

.ocr-table tr:last-child td { border-bottom: none; }

.ocr-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease-out;
}

.ocr-table tbody tr:hover { background: var(--surface-2); }
.ocr-table tbody tr.active { background: var(--accent-dim); }

.cell-text { word-break: break-all; }

.cell-conf {
  font-family: var(--font-mono);
  font-size: 12px;
}

.conf-pill {
  display: inline-block;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

.conf-pill.high { color: var(--ok); }
.conf-pill.mid { color: var(--text-secondary); }
.conf-pill.low { color: #F59E0B; }

.cell-box { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* ---- 空态 ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ---- curl 样例 ---- */
.curl-panel { margin-top: 16px; }

.curl-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--ground);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}

.curl-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #A78BFA;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  user-select: text;
}

.btn-copy {
  height: 30px;
  padding: 0 12px;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 150ms ease-out;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-copy:hover {
  color: var(--text-primary);
  border-color: var(--hairline-strong);
}

.btn-copy.copied {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.3);
}

/* ---- 错误提示条 ---- */
.error-banner {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--danger-dim);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  color: #FCA5A5;
  font-size: 13px;
}

@media (max-width: 900px) {
  .result-grid { grid-template-columns: 1fr; }
  .layout { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
