/* ========================================
   豆苗AI PDF智能工具箱 — 全局样式
   品牌：豆苗AI — 一家做教育的AI
   ======================================== */

/* === Theme Variables === */
:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --gradient: linear-gradient(135deg, var(--green), var(--blue));
  --gradient-subtle: linear-gradient(135deg, rgba(34,197,94,0.05), rgba(59,130,246,0.05));

  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 300ms ease;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #111111;
  --bg-card: #1a1a1a;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #2a2a2a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.5);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea { font-family: inherit; }

/* === Utility === */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* === Theme Toggle === */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-alt); border: 1px solid var(--border);
  color: var(--text); font-size: 18px;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--border); }

/* === Navbar === */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
[data-theme="dark"] .navbar { background: rgba(10,10,10,0.85); }

.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}

.navbar-brand {
  display: flex; align-items: center; gap: 12px;
}

.navbar-logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.navbar-logo img { width: 100%; height: 100%; object-fit: contain; }

.navbar-title {
  font-size: 18px; font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-subtitle {
  font-size: 11px; color: var(--text-muted);
  display: none;
}
@media (min-width: 640px) { .navbar-subtitle { display: block; } }

/* === Hero Section === */
.hero {
  position: relative; overflow: hidden;
  background: var(--gradient-subtle);
  padding: 48px 0 40px;
  text-align: center;
}

.hero-logo {
  width: 80px; height: 80px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.hero-logo img { width: 100%; height: 100%; object-fit: contain; }

.hero h1 {
  margin-top: 20px;
  font-size: 32px; font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  margin-top: 8px; font-size: 16px; color: var(--text-secondary);
  margin-left: auto; margin-right: auto;
}

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

@media (min-width: 640px) {
  .hero { padding: 64px 0 48px; }
  .hero h1 { font-size: 40px; }
  .hero p { font-size: 18px; }
}

/* === Section === */
.section { padding: 32px 0; }

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 20px;
}
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

/* === Tool Card === */
.tool-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--green);
}

.tool-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(34,197,94,0.1), rgba(59,130,246,0.1));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  transition: all var(--transition);
}

.tool-card:hover .tool-card-icon {
  background: linear-gradient(135deg, rgba(34,197,94,0.2), rgba(59,130,246,0.2));
}

.tool-card h3 {
  margin-top: 16px; font-size: 17px; font-weight: 600;
}

.tool-card p {
  margin-top: 6px; font-size: 13px; color: var(--text-secondary);
  line-height: 1.5; flex: 1;
}

.tool-card .tag {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 14px; font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 100px;
  align-self: flex-start;
}

.tag-new { background: rgba(34,197,94,0.1); color: var(--green-dark); }
.tag-hot { background: rgba(59,130,246,0.1); color: var(--blue-dark); }
.tag-core { background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(59,130,246,0.15));
  background-clip: padding-box;
  -webkit-background-clip: padding-box;
  color: var(--green-dark); font-weight: 600; }

/* === View Container (operation panel) === */
.view-container {
  display: none;
  animation: fadeInUp 0.35s ease;
}
.view-container.active { display: block; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Panel === */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.panel-header h2 { font-size: 20px; font-weight: 600; }
.panel-header .back-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text-secondary);
  padding: 8px 16px; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.panel-header .back-btn:hover { background: var(--bg-alt); color: var(--text); }

/* === Upload Zone === */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.upload-zone:hover,
.upload-zone.dragover { border-color: var(--green); background: rgba(34,197,94,0.03); }

.upload-zone-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.upload-zone p { font-size: 13px; color: var(--text-muted); }

.upload-zone input[type="file"] { display: none; }

/* === Uploaded File List === */
.uploaded-files { margin-top: 16px; }
.file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 14px;
}
.file-item .file-icon { font-size: 20px; }
.file-item .file-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-size { color: var(--text-muted); font-size: 12px; }
.file-item .file-remove {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #ef4444; transition: all var(--transition);
  flex-shrink: 0;
}
.file-item .file-remove:hover { background: rgba(239,68,68,0.1); }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: all var(--transition);
  border: none; cursor: pointer;
}
.btn-primary {
  background: var(--gradient);
  color: white;
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(34,197,94,0.35); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  color: var(--text-secondary); padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-group { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* === Progress === */
.progress-bar {
  width: 100%; height: 6px; background: var(--bg-alt);
  border-radius: 100px; overflow: hidden; margin-top: 16px;
  display: none;
}
.progress-bar.active { display: block; }
.progress-bar-fill {
  height: 100%; background: var(--gradient);
  border-radius: 100px; width: 0%;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 13px; color: var(--text-muted);
  margin-top: 8px; text-align: center;
  display: none;
}
.progress-text.active { display: block; }

/* === Result Preview === */
.result-preview {
  margin-top: 20px;
}

.result-tabs {
  display: flex; gap: 2px;
  background: var(--bg-alt);
  padding: 3px; border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.result-tab {
  flex: 1; padding: 8px 16px; text-align: center;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  border-radius: 6px; transition: all var(--transition);
}
.result-tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.result-content {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px; overflow-y: auto;
  font-size: 13px; line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* === Split View (original vs cleaned) === */
.split-view {
  display: grid; grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) { .split-view { grid-template-columns: 1fr 1fr; } }

.split-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.split-pane-header {
  padding: 8px 12px; font-size: 12px; font-weight: 600;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.split-pane-content {
  padding: 12px; font-size: 13px; line-height: 1.8;
  max-height: 400px; overflow-y: auto;
  white-space: pre-wrap;
}

/* === Options / Forms === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.form-select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-size: 14px; font-family: inherit;
}
.form-select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,0.1); }

/* === Loading Spinner === */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Image Sort (for merge) === */
.image-sort {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px;
}
.image-sort-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: grab;
}
.image-sort-item:active { cursor: grabbing; }
.image-sort-preview {
  width: 60px; height: 45px; object-fit: cover; border-radius: 4px;
}
.image-sort-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-sort-handle { color: var(--text-muted); font-size: 18px; cursor: grab; }

/* === AI Changes Log === */
.changes-list {
  margin-top: 12px;
}
.change-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}
.change-item .change-icon { flex-shrink: 0; width: 20px; text-align: center; }
.change-item .change-desc { flex: 1; }
.change-delete { background: rgba(239,68,68,0.06); }
.change-merge { background: rgba(59,130,246,0.06); }
.change-clean { background: rgba(34,197,94,0.06); }

/* === Footer === */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.footer-brand {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 600;
}

/* === Toolbar in view === */
.toolbar { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* Mode switch (auto / interactive) */
.mode-switch {
  display: flex; gap: 2px;
  background: var(--bg-alt);
  padding: 3px; border-radius: var(--radius-sm);
}
.mode-btn {
  padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text-secondary);
  border-radius: 6px; transition: all var(--transition);
}
.mode-btn.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.mode-btn:hover:not(.active) { color: var(--text); }

/* === Toast === */
.toast-container {
  position: fixed; top: 80px; right: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-hover);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { background: var(--green); color: white; }
.toast-error { background: #ef4444; color: white; }
.toast-info { background: var(--blue); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === Split Editor (清理结果左右对照) === */
.split-editor {
  display: flex; gap: 12px; min-height: 360px;
}
.split-editor-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.split-editor-header {
  font-size: 13px; font-weight: 600; padding: 8px 12px;
  border-radius: 8px 8px 0 0; border: 1px solid var(--border);
  border-bottom: none; background: var(--bg-alt);
}
.split-editor-header-orig { color: #ef4444; border-color: rgba(239,68,68,0.3); }
.split-editor-header-clean { color: #22c55e; border-color: rgba(34,197,94,0.3); }
.split-editor-body {
  flex: 1; padding: 12px; font-size: 13px; line-height: 1.7;
  border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  overflow-y: auto; min-height: 300px;
}
.split-editor-body-ro {
  background: var(--bg-alt); color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word;
}
.split-editor-body-edit {
  font-family: 'PingFang SC', 'Microsoft YaHei', monospace;
  background: var(--bg-card); color: var(--text);
  resize: vertical; outline: none; width: 100%;
}
.split-editor-body-edit:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
