/* ============================================
   路桥智图 - 工程图纸智能识别平台
   样式系统 V1.0
   ============================================ */

/* CSS 变量 */
:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --bg3: #1a2332;
  --surface: #1e293b;
  --surface-hover: #243244;
  --ink: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --border: #1e293b;
  --border-light: #334155;
  --accent: #0ea5e9;
  --accent-light: #38bdf8;
  --accent-dark: #0284c7;
  --success: #10b981;
  --success-light: #34d399;
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --danger: #ef4444;
  --danger-light: #f87171;
  --purple: #8b5cf6;
  --purple-light: #a78bfa;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --transition: all 0.2s ease;
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Layout */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidebar-header .logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--success));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}
.sidebar-header .brand { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.sidebar-header .brand-sub { font-size: 0.7rem; color: var(--muted); }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.sidebar-nav .nav-section { margin-bottom: 1.5rem; }
.sidebar-nav .nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  padding: 0 0.75rem;
  margin-bottom: 0.4rem;
}
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  font-size: 0.88rem;
}
.sidebar-nav .nav-item:hover { background: var(--surface); color: var(--ink); }
.sidebar-nav .nav-item.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(16, 185, 129, 0.1));
  color: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
}
.sidebar-nav .nav-item .icon { font-size: 1.1rem; width: 24px; text-align: center; }
.sidebar-nav .nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.sidebar-footer .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: white;
}
.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-name { font-size: 0.82rem; font-weight: 600; }
.sidebar-footer .user-role { font-size: 0.7rem; color: var(--muted); }

/* Main Content */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .menu-toggle { display: none; font-size: 1.3rem; }
.topbar .breadcrumb { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.topbar .breadcrumb span { color: var(--ink); }
.topbar .topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.topbar .search-box {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 240px;
}
.topbar .search-box input {
  background: none;
  border: none;
  color: var(--ink);
  outline: none;
  flex: 1;
  font-size: 0.82rem;
}
.topbar .search-box input::placeholder { color: var(--muted); }
.topbar .icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: var(--transition);
  font-size: 1.1rem;
}
.topbar .icon-btn:hover { background: var(--surface); color: var(--ink); }

/* Content Area */
.content { flex: 1; padding: 1.5rem; }

/* Views */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Page Header */
.page-header { margin-bottom: 1.5rem; display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.2rem; }
.page-header .subtitle { font-size: 0.85rem; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
}
.btn-primary:hover { box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2); transform: translateY(-1px); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-light); }
.btn-outline { border: 1px solid var(--border-light); color: var(--ink-secondary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 0.95rem; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.5rem; }

/* Stat Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}
.stat-card.green::before { background: var(--success); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.purple::before { background: var(--purple); }
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.8; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.stat-card .stat-trend { font-size: 0.72rem; margin-top: 0.4rem; display: flex; align-items: center; gap: 0.2rem; }
.stat-card .stat-trend.up { color: var(--success-light); }
.stat-card .stat-trend.down { color: var(--danger-light); }

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-wrap .table-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-wrap .table-header h3 { font-size: 0.95rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
thead th {
  background: var(--bg3);
  color: var(--muted-light);
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 1rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
tbody td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success-light); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning-light); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger-light); }
.badge-info { background: rgba(14, 165, 233, 0.15); color: var(--accent-light); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple-light); }
.badge-muted { background: var(--bg3); color: var(--muted); }

/* Progress */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-bar .fill.warning { background: linear-gradient(90deg, var(--warning), var(--danger)); }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.05);
}
.upload-zone .upload-icon { font-size: 3rem; margin-bottom: 1rem; }
.upload-zone .upload-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.3rem; }
.upload-zone .upload-hint { font-size: 0.82rem; color: var(--muted); }

/* File List */
.file-list { margin-top: 1rem; }
.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: var(--transition);
}
.file-item:hover { border-color: var(--border-light); }
.file-item .file-icon { font-size: 1.5rem; }
.file-item .file-info { flex: 1; }
.file-item .file-name { font-size: 0.85rem; font-weight: 500; }
.file-item .file-meta { font-size: 0.72rem; color: var(--muted); }
.file-item .file-actions { display: flex; gap: 0.3rem; }

/* Recognition Steps */
.recognition-steps { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.recognition-step {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  position: relative;
}
.recognition-step .step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin: 0 auto 0.5rem;
}
.recognition-step.active .step-num { background: var(--accent); color: white; }
.recognition-step.done .step-num { background: var(--success); color: white; }
.recognition-step .step-title { font-size: 0.82rem; font-weight: 600; }
.recognition-step .step-desc { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
.recognition-step .step-status { font-size: 0.7rem; margin-top: 0.4rem; }

/* Engine Status */
.engine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.engine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.engine-card .engine-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.engine-card .engine-icon { font-size: 1.5rem; }
.engine-card .engine-name { font-size: 0.95rem; font-weight: 600; }
.engine-card .engine-status { margin-left: auto; }
.engine-card .engine-detail { font-size: 0.78rem; color: var(--muted); line-height: 1.8; }
.engine-card .engine-detail span { color: var(--ink-secondary); }

/* JSON Viewer */
.json-viewer {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}
.json-key { color: var(--accent-light); }
.json-string { color: var(--success-light); }
.json-number { color: var(--warning-light); }
.json-boolean { color: var(--purple-light); }
.json-null { color: var(--muted); }
.json-bracket { color: var(--muted-light); }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.tab {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Hero (Landing) */
.hero {
  background: linear-gradient(135deg, #0a0e1a 0%, #0c4a6e 50%, #064e3b 100%);
  padding: 4rem 2rem;
  text-align: center;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, transparent 50%);
  animation: pulse 8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.8rem;
  position: relative;
  background: linear-gradient(135deg, var(--accent-light), var(--success-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero .hero-sub { font-size: 1.1rem; color: var(--ink-secondary); margin-bottom: 1.5rem; position: relative; }
.hero .hero-actions { display: flex; gap: 0.75rem; justify-content: center; position: relative; }

/* Feature Grid */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
}
.feature-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.feature-card .feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.82rem; color: var(--muted); line-height: 1.7; }

/* Workflow Steps */
.workflow { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.workflow-step {
  flex: 1;
  min-width: 150px;
  text-align: center;
  position: relative;
}
.workflow-step .step-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin: 0 auto 0.5rem;
}
.workflow-step .step-text { font-size: 0.82rem; font-weight: 600; }
.workflow-step .step-sub { font-size: 0.7rem; color: var(--muted); }
.workflow-step::after {
  content: '→';
  position: absolute;
  top: 14px;
  right: -0.75rem;
  color: var(--border-light);
  font-size: 1.2rem;
}
.workflow-step:last-child::after { display: none; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Form */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--ink-secondary); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--ink);
  outline: none;
  transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Toast */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty State */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state .empty-text { font-size: 0.95rem; color: var(--muted); }
.empty-state .empty-hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

/* Diff View */
.diff-row { display: flex; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.diff-row .diff-label { width: 200px; color: var(--muted); flex-shrink: 0; }
.diff-row .diff-old { color: var(--danger-light); text-decoration: line-through; }
.diff-row .diff-new { color: var(--success-light); font-weight: 600; }
.diff-row .diff-arrow { color: var(--muted); }

/* Page List */
.page-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.page-card:hover { border-color: var(--accent); }
.page-card .page-num { font-size: 0.85rem; font-weight: 700; color: var(--accent-light); }
.page-card .page-type { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }
.page-card .page-status { margin-top: 0.4rem; }

/* Responsive */
@media (max-width: 1024px) {
  .engine-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: block; }
  .topbar .search-box { display: none; }
  .hero h1 { font-size: 1.6rem; }
  .hero { padding: 2rem 1rem; }
  .workflow-step::after { display: none; }
  .recognition-steps { flex-direction: column; }
}
